https://www.git-scm.com/book/zh/v2
分支重命名:
# Rename branch locally
git branch -m old_branch new_branch
# Delete the old branch
git push origin :old_branch
# Push the new branch, set local branch to track the new remote
git push --set-upstream origin new_branch
git checkout master
git merge --no-ff YourBranchNameNeedToMerge
1. 按下"i"键进入"insert"模式
2. 输入commit message之后,按"Esc"退出输入模式
3. 直接输入":wq"保存并退出,完成commit
4. 最后使用"git push origin master",将合并结果推送到"master"分支
cd your_project_folder
git init
touch .gitignore
touch README.md
git remote add origin https://github.com/your_project_name.git
git add -A
git commit -m 'init'
git push origin master
cd your_project_folder
git rm -r --cached . // 或者: git rm -r --cached ignore_file
git add -A
git commit -m 'new commit'
git push origin master
git log --grep=DOT-1234
git show your_commit_hash_number
git show your_tag_name
git diff your_file_full_path_name
git diff commit_hash_nuber_1 commit_hash_number_2
SSH key 可以让你在你的电脑和Code服务器之间建立安全的加密连接。 先执行以下语句来判断是否已经存在本地公钥:
查看文件:cat xxx.txt
创建文件:cat>xxx.txt<>xxx.txt<
复制这个公钥放到你的个人设置中的SSH/My SSH Keys下,请完整拷贝从ssh-开始直到你的用户名和主机名为止的内容。【与一。中第2步相同,复制后添加到远程设置中】
如果打算拷贝你的公钥到你的粘贴板下,请参考你的操作系统使用以下的命令:
Windows:
clip < ~/.ssh/id_rsa.pub
Mac:
pbcopy < ~/.ssh/id_rsa.pub
GNU/Linux (requires xclip):
xclip -sel clip < ~/.ssh/id_rsa.pub
nuget setApiKey -Source
一般来讲,若上传的Package依赖使用方的一些配置文件(如app.config且只应该包含仅需的部分,在Install Package时若文件已存在会自动合并)则需要将文件名后追加.transform(如app.config.transform),然后在.nuspec文件中添加对应files节点(注意:是直接在
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/implement/bin/Debug/netcoreapp1.0/win10-x64/implement.dll",
"args": [],
"cwd": "${workspaceRoot}",
"externalConsole": false,
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command.pickProcess}"
}
]
}
{
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "build",
"args": [
"${workspaceRoot}/implement"
],
"isBuildCommand": true,
"problemMatcher": "$msCompile"
}
]
}
Atom 的可定制化程度非常之高,因为它本身实际上是运行在本地的一个 html (打开 Atom ,按下Command-alt-i即可查看元素)网页, 你可以随意的更改一些style class来调整 IDE 的样式,有2个主要的命令必须记住:
通过Command-shift-p -> Open Your Stylesheet可以打开style.less文件进行编辑(以我本地为例):
@TreeViewFontFamily: Arial !important; // Arial
@TreeViewFontSize: 15px !important;
@TreeViewStatusModifiedColor: rgba(233, 28, 83, 0.9);//rgb(177, 68, 58);
@TreeViewColor: rgba(103, 103, 96, 0.93);
@TreeViewSelectedFolderItemsColor: rgba(255, 255, 255, 0.81);
@TreeViewAddedFileColor: #8BC34A !important;
@TreeViewAddedFileSelectedColor: black !important;
@TreeViewFileIconColor: inherit;
@RecentProjectBackgroundColor: rgba(236, 15, 227, 0.66);
@RecentProjectColor: white;
@RecentProjectFontFamily: fantasy;
@EditorFontFamily: fantasy !important; // "Helvetica Neue"
@EditorFontSize: 14px !important;
@TransparentColor: transparent;
@TransparentImportantColor: transparent !important;
@KeyOfObjectOrJsxElementColor: orange;
@CursorColor: yellow;
@LineNumberColor: red;
@CurrentLineNumberColor: rgb(236, 17, 161);
@TerminalColor: orange;
@MethodColor: rgb(82, 192, 233);
@ImportedVariableColor: #ccc;
@KeywordColor: rgba(236, 72, 131, 0.9);
@LanguageKeywordColor: rgba(236, 72, 131, 0.9);
@ObjectVariableColor: #ccc;
@ObjectPropertyColor: #ccc;
@PureStringColor: rgba(254, 254, 254, 0.47);
@OperatorColor: orange;
@MethodCallColor: rgba(235, 75, 171, 1);
@MethodDefineColor: orange;
atom-text-editor {
background-color: @TransparentColor;
font-family: @EditorFontFamily;
font-size: @EditorFontSize;
}
atom-text-editor .cursor {
border-color: @CursorColor;
}
.amu-panel-contrast .tree-view {
background-color: @TransparentColor;
}
atom-text-editor .gutter {
background-color: @TransparentImportantColor;
color: @LineNumberColor;
}
atom-text-editor .gutter .line-number.cursor-line {
color: @CurrentLineNumberColor;
}
.platformio-ide-terminal .xterm {
color: @TerminalColor;
::selection {
background-color: ;
}
.terminal-cursor {
background-color: ;
}
}
.recent-projects-view .project-list li.project-entry {
background-color: @RecentProjectBackgroundColor;
color: @RecentProjectColor;
font-family: @RecentProjectFontFamily;
}
.syntax--entity.syntax--name.syntax--function {
color: @MethodColor;
}
.syntax--variable.syntax--other.syntax--module.syntax--js {
color: @ImportedVariableColor;
}
.syntax--keyword.syntax--control.syntax--js {
color: @KeywordColor;
}
.syntax--variable.syntax--language.syntax--js {
color: @LanguageKeywordColor;
}
.syntax--variable.syntax--other.syntax--object.syntax--js {
color: @ObjectVariableColor;
}
.syntax--variable.syntax--other.syntax--property.syntax--js {
color: @ObjectPropertyColor;
}
.syntax--string.syntax--quoted.syntax--single.syntax--js {
color: @PureStringColor;
}
.syntax--string.syntax--quoted.syntax--double.syntax--js {
color: @PureStringColor;
}
.syntax--source.syntax--js {
color: @KeyOfObjectOrJsxElementColor;
}
.syntax--keyword.syntax--operator.syntax--comparison.syntax--js {
color: @OperatorColor;
}
.syntax--storage.syntax--type.syntax--const.syntax--js {
color: @KeywordColor;
}
.tree-view{
.list-group li:not(.list-nested-item).status-modified, .list-tree li:not(.list-nested-item).status-modified,
.list-group li.list-nested-item.status-modified > .list-item, .list-tree li.list-nested-item.status-modified > .list-item {
color: @TreeViewStatusModifiedColor;
.medium-yellow:before {
color: @TreeViewFileIconColor;
}
.medium-orange:before {
color: @TreeViewFileIconColor;
}
}
.list-group li:not(.list-nested-item), .list-tree li:not(.list-nested-item), .list-group li.list-nested-item > .list-item,
.list-tree li.list-nested-item > .list-item {
color: @TreeViewColor;
font-family: @TreeViewFontFamily;
font-size: @TreeViewFontSize;
}
li.selected.expanded {
.list-group li:not(.list-nested-item), .list-tree li:not(.list-nested-item), .list-group li.list-nested-item > .list-item,
.list-tree li.list-nested-item > .list-item {
color: @TreeViewSelectedFolderItemsColor;
}
.list-group li:not(.list-nested-item).status-modified, .list-tree li:not(.list-nested-item).status-modified, .list-group
li.list-nested-item.status-modified > .list-item, .list-tree li.list-nested-item.status-modified > .list-item {
color: @TreeViewStatusModifiedColor;
.medium-yellow:before {
color: @TreeViewFileIconColor;
}
.medium-orange:before {
color: @TreeViewFileIconColor;
}
}
}
.list-group li:not(.list-nested-item).status-added, .list-tree li:not(.list-nested-item).status-added, .list-group li.list-nested-item.status-added > .list-item, .list-tree li.list-nested-item.status-added > .list-item {
color: @TreeViewAddedFileColor;
.medium-yellow:before {
color: @TreeViewFileIconColor;
}
.medium-orange:before {
color: @TreeViewFileIconColor;
}
}
}
:focus .list-group
li:not(.list-nested-item).selected.status-added,
:focus .list-tree li:not(.list-nested-item).selected.status-added,
:focus .list-group li.list-nested-item.selected > .list-item.status-added,
:focus .list-tree li.list-nested-item.selected > .list-item.status-added {
color: @TreeViewAddedFileSelectedColor;
}
.syntax--meta.syntax--method-call, .syntax--meta.syntax--method {
color: @MethodCallColor;
}
.syntax--round {
color: @MethodDefineColor ;
}
.syntax--punctuation.syntax--definition.syntax--parameters, .syntax--punctuation.syntax--definition.syntax--array {
color: @MethodDefineColor;
}
.syntax--storage.syntax--modifier.syntax--js {
color: @KeywordColor;
}
.syntax--storage.syntax--type.syntax--class.syntax--js {
color: @KeywordColor;
}
See also:Service Stack Product Docs
DECLARE @TranCounter INT;
SET @TranCounter = @@TRANCOUNT;
IF @TranCounter > 0
SAVE TRANSACTION ProcedureSave;
ELSE
BEGIN TRANSACTION;
BEGIN TRY
-- your code here
IF @TranCounter = 0
COMMIT TRANSACTION;
END TRY
BEGIN CATCH
IF @TranCounter = 0
ROLLBACK TRANSACTION;
ELSE
IF XACT_STATE() <> -1
ROLLBACK TRANSACTION ProcedureSave;
DECLARE @ErrorMessage NVARCHAR(4000);
DECLARE @ErrorSeverity INT;
DECLARE @ErrorState INT;
SELECT @ErrorMessage = ERROR_MESSAGE();
SELECT @ErrorSeverity = ERROR_SEVERITY();
SELECT @ErrorState = ERROR_STATE();
RAISERROR (@ErrorMessage, -- Message text.
@ErrorSeverity, -- Severity.
@ErrorState -- State.
);
END CATCH
USE dbname
GO
/*================================================================================
Server: ?
DataBase: ?
Author: ?
Object: ?
Version: 1.0
Date: ??/??/????
Content: ?
----------------------------------------------------------------------------------
Modified history:
Date Modified by VER Description
------------------------------------------------------------
??/??/???? ?? 1.0 Create.
================================================================================*/
/* Policies by DBA Team
--BYDBA 1 不建议使用联合主键,而是用自增列配合"创建唯一约束"或"创建唯一索引"
--BYDBA 1.主键规范命名为:PK_表名或PK_表名_主键字段名
--BYDBA 1 xml/varhcar(max)/nvarchar(max)这三种类型的列,DBA 建议存储在独立的表中,否则会产生很大的性能问题
--BYDBA 1 char类型字段,需要预估是否包含多国字符,如果是,请使用nchar
--BYDBA 1 Money类型是不允许使用的,请用Decimal(12,2)代替
*/
CREATE Table [dbo].[Table]
(
TransactionNumber INT IDENTITY(1,1) NOT NULL,
Field1 NCHAR(10) NOT NULL,
Field2 NCHAR(3) NOT NULL CONSTRAINT DF_Table_Field2 DEFAULT ('USA'),--no forget to define the constraint name of default
Field3 INT NOT NULL CONSTRAINT DF_Table_Field3 DEFAULT (1),
Field4 INT NOT NULL,
CONSTRAINT [PK_Table] PRIMARY KEY CLUSTERED --Also can be 'PK_Table_TransactionNumber'
(
TransactionNumber ASC
)
) ON [PRIMARY]
GO
--How to create standard nonclustered index
--创建普通索引
CREATE NONCLUSTERED INDEX IX_Table_Field1 ON dbo.Table
(
[Field1]
)WITH (FILLFACTOR = 90)
Go
--How to create unique index
--创建唯一索引
CREATE UNIQUE NONCLUSTERED INDEX [IXU_Table_Code1_Code2] ON dbo.[Table]
(
[Code1],[Code2]
)WITH (FILLFACTOR=80) ON [PRIMARY]
USE [Warehouse]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[FN_FunctionName] (
@Param1 varchar(100),
@Param2 varchar(100)
) RETURNS @ResultTable table (Name varchar(100))
AS
BEGIN
INSERT INTO @ResultTable (Name) VALUES (@Param1 + @Param2)
RETURN
END
GO
--select Name from Warehouse.dbo.[FN_FunctionName]('Hello','World!')
USE [Warehouse]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[FN_FunctionName1](
@Param1 varchar(15),
@Param2 varchar(15)
) RETURNS VARCHAR(100)
AS BEGIN
RETURN @Param1 + @Param2
END
GO
--DECLARE @result VARCHAR(100)
--SET @result = Warehouse.dbo.[FN_FunctionName1]('AB','CD')
--SELECT @result AS Result
--select Warehouse.dbo.[FN_FunctionName1]('AB','CD')
USE dbname
Go
/*================================================================================
Server: ?
DataBase: ?
Team: ?
Author: ?
Object: ?
Version: 1.0
Date: ??/??/????
Content: ?
----------------------------------------------------------------------------------
Modified history:
Date Modified by VER Description
------------------------------------------------------------
??/??/???? ?? 1.0 Create.
================================================================================*/
CREATE PROCEDURE [dbo].[UP_YourProcName]
@Parameter INT
AS
SET NOCOUNT ON
--Put your code in here
-- usage
-- EXEC dbname.dbo.UP_YourProcName 123,...
USE dbname
Go
/*================================================================================
Server: ?
DataBase: ?
Team: ?
Author: ?
Object: ?
Version: 1.0
Date: ??/??/????
Content: ?
----------------------------------------------------------------------------------
Modified history:
Date Modified by VER Description
------------------------------------------------------------
??/??/???? ?? 1.0 Create.
================================================================================*/
CREATE VIEW [dbo].[UV_EC_ViewNeweggItemsBase_Endeca_V1] AS
--Put your code here
/*
BYDBA 1 解析XML时获取单一值时,不要使用nodes()
DECLARE @xml xml
SET @xml = N'text1
text2
text3
text4
text5
'
SELECT
@xml.value('(/b/c/d/text())[1]','char(5)')
,@xml.value('(/b/c/f/text())[1]','char(5)')
*/
/*About namespace 命名空间
DECLARE @xml xml
SET @xml = N'text1
text2
text3
text4
text5
'
;WITH xmlnamespaces(DEFAULT 'https://soa.newegg.com/dba'
,'https://soa.neweg.com' AS ns)
SELECT
@xml.value('(/b/c/text())[1]','char(5)') AS xml_col_val
,@xml.value('(/b/c/ns:d/text())[1]','char(5)') AS xml_col_va2
*/
/*retrieve value 取单个值
DECLARE @xml xml
SET @xml = N'text1
text2
text3
text4
text5
'
SELECT @xml.value('(/b/c/text())[1]','char(5)') AS xml_col_val
*/
/*
定义游标时,如果不是特别需要,使用LOCAL关键显式的将游标定义为局部游标,
尽量避免使用全局(GLOBAL,这是数据库的默认行为)游标;没有特殊需要的话,
尽量使用FORWARD_ONLY READ_ONLY STATIC游标,
--For example:*/
DECLARE your_cursor CURSOR
LOCAL
STATIC
FORWARD_ONLY
READ_ONLY
FOR
SELECT …
OPEN your_cursor
FETCH NEXT FROM cur INTO @your_variable
WHILE @@fetch_status = 0
BEGIN
--Put your code here to use @your_variable
FETCH NEXT FROM cur INTO @your_variable
END
CLOSE your_cursor
DEALLOCATE your_cursor
DECLARE
@rows int,
@rows_limit int,
@row_batch int,
@row_count int
;
SELECT
@rows = 0,
@rows_limit = 50000, -- 处理的最大记录数限制
@row_batch = 1000, -- 每批处理的记录数
@row_count = @row_batch
;
WHILE @row_count = @row_batch
AND @rows < @rows_limit
BEGIN;
/*------operation statement------
--DELETE
DELETE TOP(@row_batch) SRC
FROM source_table SRC -- 源表
WHERE yourcondition = 1 -- 记录处理条件
--UPDATE
UPDATE TOP(@row_batch) SRC
SET SRC.field='
FROM source_table SRC -- 源表
WHERE SRC.field is NULL -- 记录处理条件
---------operation statement-----*/
SELECT
@row_count = @@ROWCOUNT,
@rows = @rows + @row_count
;
WAITFOR DELAY '00:00:10'; -- 每批处理之间的延时
END;
DELETE TOP(100)
FROM dbo.xxxLog OUTPUT
,DELETED.[LogName]
,DELETED.[LogType]
,DELETED.[InDate]
,DELETED.[InUser]
,DELETED.[LastEditDate]
,DELETED.[LastEditUser]
INTO dbo.yyyLog
WHERE
InDate < GETDATE()-7
curl http://www.baidu.com
curl https://www.baidu.com --insecure // 忽略SSL严格验证
// 使用Basic Http验证方式(username:password)的可以把在POSTMan中添加
// Http Basic验证之后,可以在header中拿到加密后的Authorization
curl https://www.baidu.com --insecure --header "Authorization=
Basic asXSdsasdIHJKDksjG="
在命令行中用来对html做DOM文档元素筛选和查找。我觉得非常有趣的一点是它可以把DOM结构转换成JSON对象,这就大大方便了对DOM元素的访问。
参考:https://github.com/ericchiang/pup
参考:https://github.com/stedolan/jq & https://stedolan.github.io/jq/
显然,如果你在做一些网络爬虫的小玩意儿,我想是时候采用一些有趣的技术了,比如上边的 curl+pup+jq。
例如你可以在命令行中用“|”做分隔以传递结果依次处理:
curl https://www.baidu.com --insecure |
pup 'div#ftConw json{}' | jq '.[0].children[1].text'
// 结果:
{
"children": [
{
"href": "http://www.baidu.com/duty/",
"tag": "a",
"text": "使用百度前必读"
},
{
"class": "cp-feedback",
"href": "http://jianyi.baidu.com/",
"tag": "a",
"text": "意见反馈"
},
{
"src": "//www.baidu.com/img/gs.gif",
"tag": "img"
}
],
"id": "cp",
"tag": "p",
"text": "©2017 Baidu 京ICP证030173号"
}
curl https://www.baidu.com --insecure |
pup 'div#ftConw json{}' | jq '.[0].children[1].text'
//结果:
"©2017 Baidu 京ICP证030173号“
同时,你也可以把结果写入文件:
curl https://www.baidu.com --insecure |
pup 'div#ftConw json{}' | jq '.[0].children[1].text' > data.json
See Alsohttps://github.com/denghejun/node-es6-modular-design/blob/master/README.MD