自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

K.Sun

用最简单的文字解释问题,用最少的步骤解决问题!

  • 博客(377)
  • 资源 (8)
  • 收藏
  • 关注

原创 让git在Mac上有提示

git作为一个跨平台的工具,对于大部分码农来讲,基本是日常工作绕不过的工具。Windows和Linux平台还好,只要你安装好了,tab键一摁,提示就跟着出来了,比如后面可以用啥参数,你要切到哪个分支等等。但是水果的macOS有点不友好,你要是在你mac上只是刚刚装好了git,在terminal中只能给你提示git命令,git后面具体是啥,它就提示不了了,这着实让被那些提示功能宠坏的农农们不爽……没有提示就不能解决了吗,只能一个字符一个字符地往终端里敲么,答案肯定是no来来来,下面就是解决问题的步骤:

2020-12-26 23:13:23 2120

原创 [JS] 计算数组中最大的N个元素

const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n);测试:maxN([1, 2, 3]); // [3]maxN([1, 2, 3], 2); // [3,2]注意,如果直接是arr.sort()的话,arr本身就会被排序,所以用[...arr].sort,相当于做了一次复制。...

2019-12-24 13:06:59 3376

原创 [C++ STL] list::resize()

list::resize(),看下例子就理解了,重新设置容器尺寸,如果想要的长度比原长度小,那么截处后面的元素,如果要比原尺寸大,那就后面补默认值。string的话就是空字符串,bool的话就是false:#include<iostream>#include<list>int main(){ // Creating a list std::list...

2019-12-24 11:54:16 2040

原创 [C++ STL] list::swap()

list::swap() 交换两个容器中的元素,前提是元素类型相同:#include <iostream>#include <list>int main(){ // list container declaration std::list<int> mylist1{1, 2, 3, 4, 5, 6}; std::list<...

2019-12-23 20:15:01 3913

原创 [C++ STL] list::back()

list::back(),输出容器中最后一个元素:#include<iostream>#include<list>int main(){ // Initialization of list std::list<int> _list; // Adding elements to the list _list.push_bac...

2019-12-23 20:05:31 1569

原创 [JS] Flatten array

拍平数组,这个在lodash里也是很常见的方法,那自己实现一个看看:const flatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? v : [v])));测试Flatten([1, [2], [[3], 4], 5]); // [1, 2, [3], 4, 5]逻辑很简单,如果元素是数组的话,那就直接...

2019-12-23 19:50:20 381

原创 [JS] 寻找Object中满足条件的最后一个key

const findLastKey = (obj, fn) => Object.keys(obj).reverse() .find(key => fn(obj[key], key, obj));测试:findLastKey( { barney: { age: 36, active: true }, fred: { age: 40, active: false ...

2019-12-23 19:30:29 2050

原创 [C++ STL] list::merge()

#include<iostream>#include<list>int main(){ // declaring the lists // initially sorted, use sort() if unsorted std::list<int> list1 = { 10, 20, 30 }; std::list<...

2019-12-23 19:19:54 1184

原创 [JS] 检查一个对象是否可迭代

检查一个对象是否可迭代,也就是说这个对象是否可用迭代器遍历,比如字符串,数组……怎么检查,很简单,只要看看对象下面Symbol.iterator是不是function就行了:const isIterable = obj => obj != null && typeof obj[Symbol.iterator] === 'function';测试:isArrayLik...

2019-12-23 19:11:54 6770

原创 [JS] 变量提升

猜猜下面的代码会输出什么东东?var foo = 1;var foobar = function() { console.log(foo); var foo = 2;};foobar();如果你知道局部变量这个概念的话,你可能会觉得这个输出是foo is not defined。如果你还知道JS里有变量提升这个概念的话,你可能觉得这个输出会是2。如果你还知道JS里的变量...

2019-12-23 19:05:09 133

原创 [JS] 格式化时间长度(formatDuration)

一般来讲我们拿到的时间长度是以毫秒(millisecond)为单位的,例如34325055574,那么问题来了,一眼看去不知道这到底是多长时间,只是隐隐感觉比较长,那么我们需要转换一下:const formatDuration = ms => { if (ms < 0) ms = -ms; const time = { day: Math.floor(ms / 864...

2019-12-23 18:33:18 3891

原创 npm生成的package.json文件中依赖项版本号前的波浪号(~)和插入符号(^)是啥意思?

package.json一般也就长这么模样:{ "name": "", "description": "", "version": "4.17.1", "author": "", "contributors": [], "license": "MIT", "repository": "", "homepage": "", "keywords": [], "...

2019-07-04 15:37:52 5397

原创 推荐几个关于学习编程的GitHub仓库

GitHub全球最大的源码版本控制及托管站点,在这个站点上托管代码当时是第一位,但是对于学习资源的托管,GitHub也是相当优秀的,以下是强烈推荐每个开发者的5个GitHub仓库:1. Free Learning Resources这是一个汇集了来自世界各地的各种语言的免费学习资料。它包括书籍,网站,播客等等。大家可以试试遵循这个仓库。2. Papers With Code如果你正在学习机...

2019-06-25 19:20:47 1280

翻译 开发人员必备的13项技能

原文地址:13 Technical Skills You Should Have As A Developer如果你是计算机科学专业的学生或正在修读软件工程师或软件开发人员的课程,那么你需要掌握一些技术技能才能成为优秀的程序员。技术面广,市场上出现了很多工具,平台和语言。你是一位经验丰富的程序员还是新手菜鸟这并不重要,作为一名现代开发人员,你应该知道如何将现代技术和其他技术内容集成到你的工作中以...

2019-06-25 13:10:27 8730 1

原创 Git:重新提交没有更新的commit

应用场景一般来讲,我们push一个commit的流程是这样的:$ git add <file>$ git commit -m "commit message"$ git push origin branch-name 这时候一般Jenkins会在后台开始build项目,那么如果Build环境不太稳定的话(不是更改代码导致的),那么这次commit很可能就会build失败,那...

2019-03-27 10:58:52 10067 1

原创 JavaScript中Number类下几个常见的方法

toPrecision()很简单,toPrecision( )方法用于对数字格式化到指定精度。看例子:const num = 213.45689;console.log(num.toPrecision());console.log(num.toPrecision(4));console.log(num.toPrecision(12));console.log(num.toPrecis...

2019-03-25 15:31:41 3015 3

原创 JavaScript中Object的create和assign方法

Object.assign()这个方法是用于拷贝JSON对象的,复制对象的可枚举属性。Object.assign(target, ...sources)target是目标对象,source是原对象,返回目标对象。看例子:let returnedValue = Object.assign({ a: 1, b: 2 }, { c: 4, d: 5 });console.log(retur...

2019-03-01 22:02:43 556

原创 JavaScript中Object.getOwnPropertyNames()与Object.keys(obj)的区别

大部分情况下Object.getOwnPropertyNames()与Object.keys(obj)的功能是一样的,我们一般也是用来获取一个JSON对象中所有属性,例如const obj = { property1: 1, property2: 2,};console.log(Object.keys(obj));console.log(Object.getOwnProp...

2019-03-01 18:01:14 10913 4

转载 《原则》之生活原则——[美] 瑞·达利欧——刘波 等译——中信出版社

一、拥抱现实,应对现实1.1 做一个超级现实的人 - 梦想+现实+决心=成功的生活。1.2 真相(或者更精确地说,对现实的精确理解)是任何良好结果的根本依据。1.3 做到头脑极度开放,极度透明 - 对于快速学习和有效改变而言,头脑极度开放、极度透明是价值无限的。 - 不要担心其他人的看法,使之成为你的障碍。 - 拥抱极度求真和极度透明将带来更有意义的工作和更有意义的人际关系。1...

2018-12-23 21:31:49 1022

原创 Git: 恢复被删除的分支(Restore the deleted branch)

一般来讲,当我们的分支已经合并到了master,那么我们会删除本地和远程的分支,用下面的命令:git branch -d &lt;your-branch&gt;或者git branch -D &lt;your-branch&gt;下面这个-D表示强制删除。那么有时候就会手贱,甩开膀子写了一大堆代码,一不小心,你把分支给干掉了,更可气的是你用的-D强制删除,这咋办,别着急,想办法恢复。...

2018-10-29 21:46:55 9586 4

原创 如何设计RESTful API

每次开工前,设计API也是十分重要的一个环节,现在RESTful API大行其道,那么如何才能设计出好的RESTful API呢,也就是说我们在设计RESTful API需要遵循哪些原则呢?1、使用名词,别使用动词我们知道RESTful API是一种面向资源(resource)设计的API,那么既然是面向资源,那自然用名词更合适,这个比较好理解吧。/computers #推荐/run...

2018-06-22 17:19:23 2143 2

原创 Git: remote: Invalid username or password

$ git pullremote: Invalid username or password.fatal: Authentication failed for 'https://github.com/project/project.git/'执行git pull的时候,会出现用户名或者密码错误的提示,解决办法,执行:git push这时候会弹出一个对话框,然后输入正确的用户名和密码...

2018-06-19 11:51:52 20000 3

翻译 微服务生态系统及生产可用概要

微服务生态系统第一层:微服务硬件生态系统物理服务器(公司自有的或者从云供应商租的)数据库(专用的或者共享的)操作系统资源的隔离和抽取配置管理主机级的监控主机级的日志第二层:微服务通信生态系统网络DNS远程过程调用端点消息服务发现服务注册负载均第三层:应用平台自服务内部的开发工具开发环境测试,打包,构建,发布工具部署流程微服...

2018-06-11 22:20:59 577

原创 ES6的几个新特征

废话少说,还是直接上代码吧。1、参数默认值以前是这么写的:var link = function (height, color, url) { var height = height || 50 var color = color || 'red' var url = url || 'http://azat.co' ...}很显然以前的写法有点技巧...

2018-06-06 22:46:01 961

原创 Git撤销本地commit

本人总是干这种挫事情:一顿操作猛如虎,各种git add,各种git commit,最后一看,我擦,还特么在master上,太吓人了,这咋办?——撤销commit:$ git commit -m "commit on master"$ git reset HEAD~ 这样撤销了上面的commit。 后续该回滚回滚,该新建分支新建分支。最后切记,时刻查看当前branch是个好...

2018-04-18 19:45:50 90773 9

原创 git: error: cannot lock ref, error: cannot lock ref

在执行git pull的时候会出现这样的错误:$ git pullerror: cannot lock ref 'refs/remotes/origin/branch': 'refs/remotes/origin/branch/repair' exists; cannot create 'refs/remotes/origin/branch'From git.microsoft.com:o...

2018-04-16 13:48:55 5694 1

原创 https git clone与ssh git clone之间的区别

首先看一下两种使用方法的面相:https git clone是长这样的:git clone https://github.com/project/repo.gitssh git clone是长这样的:git clone [email protected]:project/repo.git区别就是所用的协议不同:https用443端口,可以对repo根据权限进行读写,只要有账号密...

2018-04-10 18:10:08 38615 2

原创 Git: There is no tracking information for the current branch.

在执行git pull的时候,提示当前branch没有跟踪信息:git pullThere is no tracking information for the current branch.Please specify which branch you want to merge with.对于这种情况有两种解决办法,就比如说要操作master吧,一种是直接指定远程master:...

2018-03-29 10:29:22 92175 13

原创 Git: This branch is out-of-date with the base branch

有时候在你提交自己的branch后,会出现这样的情况: 如果是这样的话,那就说明该branch已经过时了,并且即使通过了所有的检测,也不能合并该branch到master,那该怎么办呢?首先要切回到mastergit checkout master切到master以后,更新master到最新:git pull这时候再切回到自己的branch:git check...

2018-03-28 10:56:13 2603

原创 Rails db rake命令

db:create 在当前的RAILS_ENV环境创建数据库,如果这个环境变量没有设好,那就默认创建开发和测试数据库。db:create:all 为所有的环境创建数据库,比如开发,测试,生产环境等。db:drop 删掉指定环境的库,如果没有指定的话,就删掉开发测试的数据库,与第一条一个意思。db:drop:all 干掉所有环境的数据库。db:migrate 跑一下当前环境的migrati...

2018-03-07 17:11:39 2940

原创 在Mac上安装consolas字体

Mac上一般不会预装consolas字体,但是作为一枚码农,没有consolas字体,无论是敲代码还是敲命令,总感觉不得劲儿,就像菜里没放盐一样,所以想想还得把这个字体装上。本文参考了http://ikato.com/blog/how-to-install-consolas-font-on-mac-os-x.html$ brew install cabextract$ cd ~/Down...

2018-03-06 15:56:54 10398

原创 双重哈希

双重哈希属于开放地址哈希中的一种解决冲突方案,也就是说如果一次哈希不能解决问题的时候,要再次哈希,与再哈希方法不同的是,第二次使用的哈希函数与第一次是不同的:(hash1(key) + i * hash2(key)) % TABLE_SIZE一般来讲,hash1(key) = key % TABLE_SIZEhash2(key) = PRIME – (key % PRIME)...

2018-02-24 22:19:54 11340 1

原创 error: cannot lock ref 'a/b/c/d' exists; cannot create 'a/b/c/d'

在使用git pull的时候出现这样的错误。解决办法: 首先要删除引用,有多少删除多少:git update-ref -d a/b/c/d然后在使用:git pull实在不行就使用:git pull origin master

2018-02-06 13:59:23 2958

原创 Binary Tree Inorder Traversal

题目地址:https://leetcode.com/problems/binary-tree-inorder-traversal/description/Given a binary tree, return the inorder traversal of its nodes’ values.For example: Given binary tree [1,null,2,3],

2018-01-21 12:53:44 296

原创 Daily Temperatures

题目地址:https://leetcode.com/problems/daily-temperatures/description/Given a list of daily temperatures, produce a list that, for each day in the input, tells you how many days you would have to wait u

2018-01-20 23:08:20 280

原创 Unique Paths

题目地址:https://leetcode.com/problems/unique-paths/description/A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or r

2018-01-20 17:36:21 186

原创 Merge Intervals

题目地址:https://leetcode.com/problems/merge-intervals/description/Given a collection of intervals, merge all overlapping intervals.For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10]

2018-01-20 16:37:20 257

原创 Partition List

题目地址:https://leetcode.com/problems/partition-list/description/Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You shoul

2018-01-20 12:51:54 191

原创 Search a 2D Matrix

题目地址:https://leetcode.com/problems/search-a-2d-matrix/description/Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in e

2018-01-14 17:53:40 146

原创 Simplify Path

题目地址:https://leetcode.com/problems/simplify-path/description/Given an absolute path for a file (Unix-style), simplify it.For example, path = "/home/", => "/home" path = "/a/./b/../../c/", => "/c

2018-01-13 21:06:47 164

Spring Data

As a developer of Java enterprise applications, you can choose among several data access frameworks when working with relational databases. But what do you turn to when working with newer technologies such as NoSQL databases and Hadoop? This book shows you how Spring's data access framework can help you connect to either non-relational or relational databases, or a combination of the two. You'll learn how Spring Data's familiar and consistent programming model greatly reduces the learning curve for creating applications with newer data access technologies. And you'll discover how to use Spring Data's improved JPA and JDBC support to increase your productivity when writing RDBMS-based data access layers. Relational database technologies continue to be predominant in the enterprise, but they're no longer considered a 'one size fits all' solution. This book shows you how to increase your options.

2017-10-05

OSGi in Action

HIGHLIGHT OSGi in Action is the definitive guide to OSGi, the hottest technology available for creating modular enterprise Java applications. DESCRIPTION What is OSGi? Simply put, OSGi is a standardized technology that allows developers to create the highly modular Java applications that are required for enterprise development. OSGi lets you install, start, stop, update, or uninstall components without taking down your entire system. The interest in OSGibased applications has exploded since major vendors like Sun, Spring, Oracle, BEA, and IBM have gotten behind the standard. OSGi in Action is a comprehensive guide to OSGi with two primary goals. First, it provides a clear introduction to OSGi concepts with examples that are relevant both for architects and developers. Then, it explores numerous practical scenarios and techniques, answering questions like: How much of OSGi do you actually need? How do you embed OSGi inside other containers? What are the best practices for moving legacy systems to OSGi? KEY POINTS Highly-visible authors and reviewers are core members of OSGI community. This book is based on hands-on experience with OSGI. Authors have contributed to high-profile OSGi implementations, including Apache Felix.

2017-10-05

C++编程思想 两卷合订本

(美)Bruce Eckel 著 刘宗田 袁兆山 潘秋菱 等译

2017-10-01

iOS编程 第四版

作者[美] Christian Keur / [美] Aaron Hillegass / [美] Joe Conway

2017-10-01

apt-mirror-api-0.1.jar

Files contained in apt-mirror-api-0.1.jar: META-INF/MANIFEST.MF META-INF/maven/com.moparisthebest.aptIn16/apt-mirror-api/pom.properties META-INF/maven/com.moparisthebest.aptIn16/apt-mirror-api/pom.xml com.sun.mirror.apt.AnnotationProcessor.class com.sun.mirror.apt.AnnotationProcessorEnvironment.class com.sun.mirror.apt.AnnotationProcessorFactory.class com.sun.mirror.apt.AnnotationProcessorListener.class com.sun.mirror.apt.AnnotationProcessors.class com.sun.mirror.apt.Filer.class com.sun.mirror.apt.Messager.class com.sun.mirror.apt.RoundCompleteEvent.class com.sun.mirror.apt.RoundCompleteListener.class com.sun.mirror.apt.RoundState.class com.sun.mirror.declaration.AnnotationMirror.class com.sun.mirror.declaration.AnnotationTypeDeclaration.class com.sun.mirror.declaration.AnnotationTypeElementDeclaration.class com.sun.mirror.declaration.AnnotationValue.class com.sun.mirror.declaration.ClassDeclaration.class com.sun.mirror.declaration.ConstructorDeclaration.class com.sun.mirror.declaration.Declaration.class com.sun.mirror.declaration.EnumConstantDeclaration.class com.sun.mirror.declaration.EnumDeclaration.class com.sun.mirror.declaration.ExecutableDeclaration.class com.sun.mirror.declaration.FieldDeclaration.class com.sun.mirror.declaration.InterfaceDeclaration.class com.sun.mirror.declaration.MemberDeclaration.class com.sun.mirror.declaration.MethodDeclaration.class com.sun.mirror.declaration.Modifier.class com.sun.mirror.declaration.PackageDeclaration.class com.sun.mirror.declaration.ParameterDeclaration.class com.sun.mirror.declaration.TypeDeclaration.class com.sun.mirror.declaration.TypeParameterDeclaration.class com.sun.mirror.type.AnnotationType.class com.sun.mirror.type.ArrayType.class com.sun.mirror.type.ClassType.class com.sun.mirror.type.DeclaredType.class com.sun.mirror.type.EnumType.class com.sun.mirror.type.InterfaceType.class com.sun.mirror.type.MirroredTypeException.class com.sun.mirror.type.MirroredTypesException.class com.sun.mirror.type.PrimitiveType.class com.sun.mirror.type.ReferenceType.class com.sun.mirror.type.TypeMirror.class com.sun.mirror.type.TypeVariable.class com.sun.mirror.type.VoidType.class com.sun.mirror.type.WildcardType.class com.sun.mirror.util.DeclarationFilter.class com.sun.mirror.util.DeclarationScanner.class com.sun.mirror.util.DeclarationVisitor.class com.sun.mirror.util.DeclarationVisitors.class com.sun.mirror.util.Declarations.class com.sun.mirror.util.SimpleDeclarationVisitor.class com.sun.mirror.util.SimpleTypeVisitor.class com.sun.mirror.util.SourceOrderDeclScanner.class com.sun.mirror.util.SourcePosition.class com.sun.mirror.util.TypeVisitor.class com.sun.mirror.util.Types.class

2016-11-15

《Java编程思想 第四版》源码

《Java编程思想 第四版》源码

2016-11-15

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除