当前位置: 首页 > 编程日记 > 正文

如何有效使用每一点脑力总结_如何更有效地节省脑力和编码

如何有效使用每一点脑力总结

如果您知道这些工具的存在,那么您现在可能会使用它们。 (If you knew these tools existed, you'd probably be using them by now.)

This article isn’t going to tell you about saving your neck with a Roost stand, or your wrists with a split keyboard - I’ve already done that. This article is about saving your brain – let's call it technical ergonomics.

本文不会告诉您有关使用Roost支架节省脖子或使用拆分式键盘节省手腕的知识- 我已经做到了 。 本文旨在节省您的大脑–我们称之为技术人体工程学。

When I first began to program full time, I found myself constantly tired from the mental exertion. Programming is hard! Thankfully, you can take some solace in knowing it gets easier with practice, and with a great supporting cast.

当我第一次开始全职编程时,我发现自己经常因精神消耗而感到疲倦。 编程很难! 值得庆幸的是,您可以放心,因为它知道实践变得更容易,并且有很好的辅助演员。

Some very nice folks who preceded us came up with tools to make the difficult bits of communicating with computers much easier on our poor human meat-brains.

在我们之前的一些非常出色的人想出了一些工具,可以使我们在人类可怜的肉类大脑上与计算机进行通信的困难变得更加容易。

I invite you to explore these super helpful technical tools. They’ll improve your development set up and alleviate much of the mental stress of programming. You soon won’t believe you could have done without them.

我邀请您探索这些超级有用的技术工具。 它们将改善您的开发设置,并减轻编程的大部分精神压力。 您很快将不相信没有它们,您将无法完成。

不是您的平均语法突出显示 (Not your average syntax highlighting)

If you’re still working with syntax highlighting that just picks out variable and class names for you, that’s cute. Time to turn it up a notch.

如果您仍在使用语法突出显示功能,只是为您挑选变量和类名,那就太好了。 是时候提高它了。

In all seriousness, syntax highlighting can make it much easier to find what you’re looking for on your screen: the current line, where your current code block starts and ends, or the absolute game-changing which-bracket-set-am-I-in highlight.

严格来说,语法高亮显示可以使您在屏幕上查找所需内容变得更加容易:当前行,当前代码块的开始和结束位置,或者改变游戏规则的绝对方法,我在突出显示。

I primarily use Visual Studio Code, but similar extensions can be found for the major text editors.

我主要使用Visual Studio Code,但是可以在主要的文本编辑器中找到类似的扩展名。

Here are my favorites:

这是我的最爱:

  • Bracket Pair Colorizer highlights sequential bracket pairs in different matching colors, making the pain of picking through nested brackets and parentheses a  thing of the past.

    括号对着色器以不同的匹配颜色突出显示顺序的括号对,从而消除了通过嵌套括号和括号进行选择的痛苦。

  • TODO Highlight effectively removes any excuse you may have had for unintentionally committing TODO and FIXME comments by making them really easy to see. You can even add your own custom keywords to be highlighted (I suggest wtf, but you didn’t hear it from me.)

    TODO Highlight通过使它们真正易于查看,有效地消除了您可能无意间提交TODOFIXME注释的任何借口。 您甚至可以添加自己的自定义关键字以突出显示(我建议使用wtf ,但您没有收到我的wtf 。)

  • Indented Block Highlighting puts an easy-to-distinguish but unobtrusive highlight behind your current indented code block, so you can see just where that if ends and why that last else isn’t doing anything at all.

    缩进块突出显示在当前缩进代码块的后面放置了易于区分但不引人注意的突出显示,因此您可以看到if结束的地方以及为什么最后else根本没有做任何事情。

  • Highlight Line puts a (slightly too) bright line where you last left your cursor. You can customize the line’s appearance - I set the borderWidth of mine to 1px.

    高亮线在您最后一次离开光标的位置放置了一条(也略微)亮线。 您可以自定义线条的外观-我将我的borderWidth设置为1px

The theme pictured in Visual Studio Code above is Kabukichō. I made it.

上面的Visual Studio Code中描绘的主题是Kabukichō 。 我做到了。

使用Git挂钩 (Use Git hooks)

I previously brought you an interactive pre-commit checklist in the style of infomercials that’s both fun and useful for reinforcing the quality of your commits. But that’s not all!

之前,我以信息商业的方式为您带来了一个交互式的提交前检查清单,该清单既有趣又对增强提交质量很有帮助。 但这还不是全部!

Git hooks are scripts that run automatically at pre-determined points in your workflow. Use them well, and you can save a ton of brainpower.

Git挂钩是在工作流中的预定位置自动运行的脚本。 很好地使用它们,您可以节省大量的脑力。

A  pre-commit hook remembers to do things like lint and format code, and even runs local tests for you before you indelibly push something embarrassing.

pre-commit钩子会记住执行诸如lint和format代码之类的操作,甚至会在您无情地推送令人尴尬的内容之前为您运行本地测试。

Hooks can be a little annoying to share (the .git/hooks directory isn’t tracked and thus omitted when you clone or fork a  repository) but there’s a framework for that: the confusingly-named pre-commit framework, which allows you to create a shareable configuration file of Git hook plugins, not just for pre-commit.

钩子共享可能会有些烦人(不会跟踪.git/hooks目录,因此在克隆或分叉存储库时会省略.git/hooks ),但是有一个框架:易混淆的预提交框架 ,允许您创建一个可共享的Git钩子插件配置文件,而不仅仅是用于pre-commit

I spend a majority of my time these days coding in Python, so here is my current favorite .pre-commit-config.yaml:

这些天,我大部分时间都用Python编码,所以这是我目前最喜欢的.pre-commit-config.yaml

fail_fast: true
repos:- repo: https://github.com/pre-commit/pre-commit-hooksrev: v3.1.0 # Use the ref you want to point athooks:- id: detect-aws-credentials- id: end-of-file-fixer- id: trailing-whitespace- repo: https://github.com/psf/blackrev: 19.3b0hooks:- id: black- repo: https://github.com/asottile/blacken-docsrev: v1.7.0hooks:- id: blacken-docsadditional_dependencies: [black==19.3b0]- repo: https://github.com/pre-commit/mirrors-mypyrev: v0.780hooks:- id: mypy- repo: localhooks:- id: isortname: isortstages: [commit]language: systementry: isorttypes: [python]- id: blackname: blackstages: [commit]language: systementry: blacktypes: [python]

There are tons of supported hooks to explore.

有大量受支持的钩子可供探索。

使用文字系统 (Use a type system)

If you write in languages like Python and JavaScript, get yourself an early birthday present and start using a static type system. Not only will this help improve the way you think about code, it can help make type errors clear before running a single line.

如果您使用Python和JavaScript之类的语言编写代码,请给自己一个生日礼物,并开始使用静态类型系统。 这不仅有助于改善您对代码的思考方式,而且还可以帮助在运行单行之前清除类型错误。

For Python, I like using mypy for static type checking. You can set it up as a pre-commit hook (see above) and it’s supported in Visual Studio Code too.

对于Python,我喜欢使用mypy进行静态类型检查。 您可以将其设置为pre-commit挂钩(参见上文),并且在Visual Studio Code中也受支持 。

TypeScript is my preferred way to write JavaScript. You can run the compiler on the command line using Node.js (see instructions in the repo), it works pretty well with Visual Studio Code out of the box, and of course there are multiple options for extension integrations.

TypeScript是我编写JavaScript的首选方式。 您可以使用Node.js在命令行上运行编译器(请参见repo中的说明 ),它与开箱即用的Visual Studio Code一起使用时效果很好,当然, 扩展集成有多个选项。

退出不必要地殴打你的肉脑 (Quit unnecessarily beating up your meat-brain)

I mean, you wouldn’t stand on your head all day to do your work. It would be rather inconvenient to read things upside down all the time (at least until your brain adjusted), and in any case you’d likely get uncomfortably congested in short order.

我的意思是,您不会整日站着工作。 一直在颠倒阅读东西(至少直到您的大脑调整了 )会很不方便,而且在任何情况下,您短期内都可能会感到不适。

Working without taking advantage of the technical ergonomic tools I’ve given you today is a little like unnecessary inversion - why would you, if you don’t have to?

在不利用我今天提供给您的技术人体工程学工具的情况下工作有点像不必要的倒置-如果不需要,为什么要这么做?

翻译自: https://www.freecodecamp.org/news/how-to-save-your-brainpower-and-code-more-efficiently/

如何有效使用每一点脑力总结

相关文章:

C语言程序设计50例(一)(经典收藏)

【程序1】题目:有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?1.程序分析:可填在百位、十位、个位的数字都是1、2、3、4。组成所有的排列后再去      掉不满足条件的排列。 1 #include…

python多线程执行类中的静态方法

在python 中如果通过多线程的方式执行某个方法很简单,只需要把同步函数的第一个参数为该函数对象即可。但是如果函数对象是某个类的静态方法,这时候如果直接使用类的该函数对象会报错。此时需要构造一个代理的方法来实现。 如:上一个博文中的…

检测缓存文件是否超时

(BOOL)isTimeOutWithFile:(NSString *)filePath timeOut:(double)timeOut {//获取文件的属性NSDictionary *fileDict [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil];//获取文件的上次的修改时间NSDate *lastModfyDate fileDict.fileModificat…

JavaScript创建对象–如何在JS中定义对象

Objects are the main unit of encapsulation in Object-Oriented Programming. In this article, I will describe several ways to build objects in JavaScript. They are:对象是面向对象编程中封装的主要单元。 在本文中,我将介绍几种使用JavaScript构建对象的方…

MyBatis中#{}和${}的区别

------------------------siwuxie095 MyBatis 中 #{} 和 ${} 的区别 1、在 MyBatis 的映射配置文件中,动态传递参数有两种方式: (1)#{} 占位符 (2)${} 拼接符 2、#{} 和 ${} 的区别 (1&#xff…

十进制字符串转十六进制字符串

NSString *colorStr[self.model.sclass_color substringFromIndex:1]; unsigned long cor strtoul([colorStr UTF8String],0,16);

gi克隆github文件_如何构建GitHub文件搜索功能的克隆

gi克隆github文件In this article, we will build a project that mimics the lesser known but awesome file search functionality provided by GitHub.在本文中,我们将构建一个项目,该项目模仿GitHub提供的鲜为人知但功能强大的文件搜索功能。 To se…

ipython --pandas

d定义: pandas是一个强大的Python数据分析的工具包。 pandas是基于NumPy构建的。 安装方法: pip install pandas import pandas as pd pandas的主要功能 具备对其功能的数据结构DataFrame、Series 集成时间序列功能 提供丰富的数学运算和操作 灵活处理缺失数据 Series 定义:Ser…

玩转Android之二维码生成与识别

二维码,我们也称作QRCode,QR表示quick response即快速响应,在很多App中我们都能见到二维码的身影,最常见的莫过于微信了。那么今天我们就来看看怎么样在我们自己的App中集成二维码的扫描与生成功能。OK,废话不多说&…

属性字符串(富文本)的使用

改变字符串中某些字符串字体的颜色 NSMutableAttributedString *attrStr[[NSMutableAttributedString alloc] initWithString:str]; [attrStr addAttribute:NSForegroundColorAttributeName value:kUIColorFromRGB(0xb2151c) range:[str rangeOfString:[NSString stringWith…

如何使用create-react-app在本地设置HTTPS

Running HTTPS in development is helpful when you need to consume an API that is also serving requests via HTTPS. 当您需要使用同时通过HTTPS服务请求的API时,在开发中运行HTTPS会很有帮助。 In this article, we will be setting up HTTPS in development …

Swift强制解析

IDE:Xcode Version7.3.1 Swift中"数据类型?"表示这是可选类型,即 某个常量或者变量可能是一个类型,也可能什么都没有,不确定它是否有值,也许会是nil。 比如: let num1 “123” let num2 Int(number1) pri…

rfc6455 WebSockets

https://tools.ietf.org/html/rfc6455 转载于:https://www.cnblogs.com/cheungxiongwei/p/8385719.html

2020-mb面试指南_2020年最佳代码面试准备平台

2020-mb面试指南Software developer interviews are rapidly evolving. Years ago, mastering data structures and common algorithms was enough to ace an interview and get a job. Today though, employers want candidates with real-world experience and skills. 软件开…

设计模式学习笔记(一)之工厂模式、单例模式

一、工厂模式 (1)简单工厂模式: 1 public interface IProduct { 2 3 public void saleProduct(); 4 5 } 创建一个产品接口,有一个卖产品的方法。 1 public class ProductA implements IProduct{ 2 3 public void saleProduct(){ 4 Sy…

iOS使用支付宝支付步骤

开发平台 (http://open.alipay.com/index.htm(这个里面找不到sdk) 需要进入下面的链接) 使用支付宝进行一个完整的支付功能,大致有以下步骤: 1>先与支付宝签约,获得商户ID(partner)和账号ID&#xff08…

heroku_了解如何使用Heroku部署全栈Web应用程序

herokuBuilding a full stack web app is no mean feat. Learning to deploy one to production so that you can share it with the world can add an additional layer of complexity.构建全栈式Web应用程序绝非易事。 学习将其部署到生产环境中,以便您可以与世界…

SpringMVC学习手册(三)------EL和JSTL(上)

1.含义 EL: Expression Language , 表达式语言JSTL: Java Server Pages Standard Tag Library, JSP标准标签库 2.测试项目构建 2.1 复制JSTL的标准实现 复制Tomcat中webapps\examples\WEB-INF\lib下的两个jar包到新建项目目录的WEB-INF\lib下2.2 在JSP文件中使用tagli…

OpenStack Heat模板详解

Heat模板全称为heat orchestration template,简称为HOT。 1 典型Heat模板结构 heat_template_version: 2015-04-30 description:# a description of the template parameter_groups:# a declaration of input parameter groups and order parameters:# declaration …

如何从头开始构建自己的Linux Dotfiles Manager

As a new linux 🐧 user, you might realize that there are a bunch of configuration files present in your system. These special files are called "dotfiles". 作为新的Linux用户,您可能会意识到系统中存在大量配置文件。 这些特殊文件…

D3.js、HTML5、canvas 开发专题

https://www.smartdraw.com/genogram/ http://www.mamicode.com/info-detail-1163777.html D3折线图 https://www.cnblogs.com/hwaggLee/p/5073885.html js-d3画图插件 http://www.xiaomlove.com/2014/06/29/d3-js简单画图-箭头连接随机圆圈/ 连线 http://www.decemberc…

单向链表JAVA代码

//单向链表类publicclassLinkList{ //结点类 publicclassNode{ publicObject data; publicNode next; publicNode(Object obj,Node next){ this.data obj; this.next next; } } Node head; //记录…

forkjoin rxjs_如何通过吃披萨来理解RxJS运算符:zip,forkJoin和Combine

forkjoin rxjs什么是RxJS? (What is RxJS?) Reactive programming is an asynchronous programming paradigm concerned with data streams and the propagation of change - Wikipedia响应式编程是一种与数据流和变更传播有关的异步编程范式 -Wikipedia RxJS is a…

SQLserver数据库操作帮助类SqlHelper

1 SqlHelper源码 using System; using System.Data; using System.Xml; using System.Data.SqlClient; using System.Collections; namespace SQL.Access {/// <summary>/// SqlServer数据访问帮助类/// </summary>public sealed class SqlHelper{#region 私有构造…

python框架之Flask基础篇(一)

一.第一个hello world程序 # codingutf-8 from flask import Flaskapp Flask(__name__)app.route(/) def hello_world():return Hello World!if __name__ __main__:app.run(debugTrue) 1.app参数的设置&#xff1a; 以下几种方式全部拿debug模式举例&#xff1a; .方式一&…

flask部署机器学习_如何开发端到端机器学习项目并使用Flask将其部署到Heroku

flask部署机器学习Theres one question I always get asked regarding Data Science:关于数据科学&#xff0c;我经常被问到一个问题&#xff1a; What is the best way to master Data Science? What will get me hired?掌握数据科学的最佳方法是什么&#xff1f; 什么会雇…

UVALive2678:Subsequence

UVALive2678:Subsequence 题目大意 给定一个数组A和一个整数S。求数组A中&#xff0c;连续且之和不小于S的连续子序列长度最小值。 要求复杂度:Ο(n) Solution 用变量L表示所选区间最左端下标&#xff0c;用变量R表示所选区间最右端下标&#xff0c;用变量sum表示所选区间的和。…

【BZOJ-3712】Fiolki LCA + 倍增 (idea题)

3712: [PA2014]Fiolki Time Limit: 30 Sec Memory Limit: 128 MBSubmit: 303 Solved: 67[Submit][Status][Discuss]Description 化学家吉丽想要配置一种神奇的药水来拯救世界。吉丽有n种不同的液体物质&#xff0c;和n个药瓶&#xff08;均从1到n编号&#xff09;。初始时&am…

访问系统相册或调用摄像头

头文件&#xff1a;#import <MobileCoreServices/MobileCoreServices.h> 协议&#xff1a;<UINavigationControllerDelegate, UIImagePickerControllerDelegate> // 调用系统相册获取图片 - (IBAction)getImageFromAlbum:(id)sender {// 判断系统相册是否可用&…

unity镜像_通过镜像学习Unity Multiplayer Basics

unity镜像Unity is one of the most well-known and established engines for game development, and Mirror is a third-party, open source networking solution that allows you to add multiplayer to your games.Unity是最著名的游戏开发引擎之一&#xff0c;而Mirror是第…