Skip to content

Instantly share code, notes, and snippets.

View bygreencn's full-sized avatar
💭
I may be slow to respond.

Sui Libin bygreencn

💭
I may be slow to respond.
View GitHub Profile
@bygreencn
bygreencn / gist:9622268
Last active August 29, 2015 13:57
stm32 168MHz delay
/* 168MHz = each clock cycle is 6ns. Loop is always 6 clock cycles?
* These can get clock stretched if we have interrupts in the background.
*/
void delay_ms(const uint16_t ms)
{
uint32_t i = ms * 27778;
while (i-- > 0) {
asm("nop");
}
}
#disable git proxy using goagent
git config --global http.proxy ""
git config --global https.proxy ""
git config --global http.sslCAinfo ""
git config --global http.sslVerify true
#enable git proxy and enable SSL certificate using goagent
git config --global http.proxy 127.0.0.1:8087
git config --global https.proxy 127.0.0.1:8087
git config --global http.sslVerify true
@bygreencn
bygreencn / gist:0d875784af992239b63a
Created July 10, 2014 09:13
MAC下运行python,出现stdio.h找不到的问题结局。
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/
#!/bin/bash
: << '#__REM__'
指定さたライブラリをiOS用にフルオートで作成します。ダウンロード、複数のアーキテクチャのビルドも自動的に行います。デフォルトではi386、x86_64、armv7、armv7s、arm64のアーキテクチャを作成します。
Create a full-auto to iOS for the library specified. I do also builds the architecture download, more than one. Create architecture i386, x86_64, armv7, armv7s, arm64 by default.
#__REM__
TARGET_VERSION="1.3.1"
#
# cairo install script for MinGW.
#
# - zlib 1.2.5
# - libpng 1.4.3
# - pixman 0.18.4
# - cairo 1.10.0
#
@echo off
if exist running exit
if "%PROCESSOR_ARCHITECTURE%" == "x86" set platform=Win
if "%PROCESSOR_ARCHITECTURE%" == "AMD64" set platform=Win_x64
if "%platform%" == "" echo Supported only x86 and amd64 cpu architectures. & pause & exit
set channel=continuous
set url=https://storage.googleapis.com/chromium-browser-%channel%/%platform%
set wget=wget.exe -N --no-check-certificate
type nul > running
if "%1" == "" (
##########################################
#
# c.f. http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4
#
# Version 2.7
#
# Latest Change:
# - Supports iPhone 5 / iPod Touch 5 (uses Apple's workaround to lipo bug)
#
# Purpose:
/*
Based on the krpano iOS 4.2 gyroscope script
by Aldo Hoeben / fieldofview.com
contributions by Sjeiti / ronvalstar.nl
Port for Pano2VR
Thomas Rauscher / gardengnomesoftware.com
This software can be used free of charge and the source code is available under a Creative Commons Attribution license:
http://creativecommons.org/licenses/by/3.0/
$ vi /etc/sysctl.conf
# 系统所有进程一共可以打开的文件数量, 每个套接字也占用一个文件描述字
fs.file-max = 1491124
# 系统同时保持TIME_WAIT套接字的最大数目,http 短链接会产生很多 TIME_WAIT 套接字。
net.ipv4.tcp_max_tw_buckets = 7000
# 关闭 tcp 来源跟踪
net.ipv4.conf.default.accept_source_route = 0
# 缩短套接字处于 TIME_WAIT 的时间, 60s -> 30s
net.ipv4.tcp_fin_timeout = 30
# 启用 TIME_WAIT 复用,使得结束 TIEM_WAIT 状态的套接字的端口可以立刻被其他套接字使用。
@bygreencn
bygreencn / readme.txt
Last active August 29, 2015 14:13 — forked from fqrouter/readme.txt
good, 你已经有了一个自己的shadowsocks代理了,现在想要把这个代理公布出去给所有人分享。
但是没有两个小时,代理就没法使用了,为什么?因为你需要额外注意以下事项(以下步骤需要比较高的linux技能)
本文只关注于确保shadowsocks服务还“活着”,如果你希望让其跑得更快,请参考
https://github.com/clowwindy/shadowsocks/wiki/Optimizing-Shadowsocks
1、 shadowsocks的timeout设置
超时时间越长,连接被保持得也就越长,导致并发的tcp的连接数也就越多。对于公共代理,这个值应该调整得小一些。推荐60秒。
2、 检查操作系统的各种限制
对于openvz的vps,特别需要检查一下