This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 由于公司VPN就是一坨💩 | |
# http://superuser.com/questions/458730/keep-ssh-port-forwarding-connection-alive | |
while true; do | |
{ while true; do echo echo ping; sleep 10; done } | \ | |
ssh -R 5555:localhost:22 user@remotehost -o ExitOnForwardFailure=yes -v | |
sleep 10 | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Place your settings in this file to overwrite the default settings | |
{ | |
"files.exclude": { | |
"*.swap": true, | |
"*.o": true | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int is_little_endian() { | |
int a = 1; | |
return ((char *)(&a))[0]== 1; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proxy = {} | |
proxy.wrap = function(t) | |
return proxy.wraphelper(t, nil, nil) | |
end | |
proxy.wraphelper = function(t, pm, path2me) | |
-- print("wraphelper", t, pm, path2me) | |
local m = {} | |
m.__path = path2me |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package power2 | |
// 如果一个数是2的整数次方,那么 取模 可以有优化成一条 AND 指令 | |
// http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 | |
// 思想是把最高有效位塞给其余的地位,第一次塞1位,第二次塞2位,第三次塞4位 第四次塞8位 第五次塞16位 | |
// 最多需要做 lg(N) 次 SHIFT + lg(N) 次 OR 既可, N是参数的位数 | |
// run on go playground https://play.golang.org/p/-3O7xKuQ-D | |
func RoundUpPowerOf2(a uint32) uint32 { | |
if a <= 1 { | |
return 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PWD=`pwd` | |
for file in `find $PWD`; do | |
echo $file | |
sed -i 's/XXX/YYY/g' $file | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace threadpool_bench | |
{ | |
class Program | |
{ | |
static int totalRound; | |
static System.Threading.ManualResetEventSlim finishEvent; | |
static System.Threading.WaitCallback job = obj => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>netcoreapp2.0</TargetFramework> | |
<DefineConstants Condition="'$(OS)' == 'Windows_NT'">AAA;IS_WIN </DefineConstants> | |
</PropertyGroup> | |
<PropertyGroup Condition="'$(MSBuildRuntimeType)' == 'Core'"> | |
<DefineConstants Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">AAA;IS_OSX</DefineConstants> | |
<DefineConstants Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">AAA;IS_LINUX</DefineConstants> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://blogs.technet.microsoft.com/heyscriptingguy/2012/05/21/understanding-the-six-powershell-profiles/ | |
#Description | |
#Path | |
#Current User, Current Host - console | |
#$Home\[My ]Documents\WindowsPowerShell\Profile.ps1 | |
#Current User, All Hosts | |
#$Home\[My ]Documents\Profile.ps1 | |
#All Users, Current Host - console | |
#$PsHome\Microsoft.PowerShell_profile.ps1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# alias godev="source /usr/local/bin/godev" | |
EchoHelp() { | |
echo "Hello" | |
} | |
NewGoProject() { |