Skip to content

Instantly share code, notes, and snippets.

View vamdt's full-sized avatar

vamdt vamdt

  • Foggy Beijing
View GitHub Profile
// 拿到嵌套数组的前五个
(function(){
var first_arr = [[1,3,4], [3,4,5,6,0], [34,56,23,56,34] [32,45]];// => [[1,3,4],[3,4]]
var second_arr = [[1,3,4,7], [3,4,5,6,0], [34,56,23,56,34] [32,45]]; // => [[1,3,4,7],[3]]
var third_arr = [[1,3,4,7,9], [3,4,5,6,0], [34,56,23,56,34] [32,45]]; // => [[1,3,4,7,9]]
var fourth_arr = [[1,3,4,7,9, 10], [3,4,5,6,0], [34,56,23,56,34] [32,45]]; // => [[1,3,4,7,9]]
function five(arr) {
var count = 0, result = [], left_count = 0;
for (var i = 0; i <= arr.length; i++) {
@vamdt
vamdt / odd_collection.js
Last active August 29, 2015 14:03
数字求奇数数集合
//数字shift1,change next to last
//eg:1234567890
// =>345678902..1
// =>5678904....3
// =>789046.....5
// =>90468......7
// =>4680.......9
// =>806........4
// =>60.........8
// =>0..........6
@vamdt
vamdt / add_module_nest.rb
Created October 13, 2014 03:13
Add module nest to ruby class
#!/usr/bin/env ruby
module_name = "Api"
files = Dir["*.rb"]
files.each do |file|
data = IO.read(file)
data.gsub!("\n", "\n ")
new_data = "module #{module_name}\n\n " + data + "\nend"
IO.write(file, new_data)
end
# find all png-suffix images in current dir and sub dirs.
# use sips resize image size to 262 * 82
# and make their name to *.small.png
find . -type f -name "*.png" -exec sips -z 82 262 '{}' --out '{}'.small.png ';'
@vamdt
vamdt / CapsLockDoCtrl.bat
Created January 19, 2015 15:29
Create ahk script that make capslock as another ctrl, then copy to statup folder
echo CapsLock::Ctrl >> caps5ctrl.ahk
copy /y caps5ctrl.ahk "C:\Users\annnng\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
@vamdt
vamdt / regex.js
Created February 12, 2015 13:03
Common regex
// 中文 英文 数字
var chinese_english_num_re = /[\u4e00-\u9fa5a-zA-Z0-9]+/;
@vamdt
vamdt / ci_php_lint.sh
Last active August 29, 2015 14:26
php lint run in ci(jenkins)
#!/usr/bin/env bash
# APP_ROOT/deploy/ci_php_lint.sh
cd $(dirname $0)
cd ..
exit_code=0
for i in $(git ls-files --ignored --exclude='**/*.php')
do
@vamdt
vamdt / php_info_in_cli_example.sh
Created August 18, 2015 04:56
php info show in cli
#!/usr/bin/env bash
# eg, check gd extensions
php -r 'phpinfo();' | grep -A 20 gd$
@vamdt
vamdt / go-update.sh
Created September 14, 2015 11:47
go update script
#!/usr/bin/env bash
usage() {
printf 'go-update.sh go$VERSION.$OS-$ARCH.tar.gz\n'
exit 1
}
[ -z "$1" ] && usage
go_pkg_name="$1"
@vamdt
vamdt / 关于群策工具的开发.md
Last active December 21, 2015 00:09
关于群策工具的开发

关于群策工具的开发

用到的工具(非必需)

Chrome && Chrome Plugins