This file contains 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
<!-- A script to get max call stack size in browser | |
In my Macbook pro | |
Firefox 28: | |
maxStackSize = 350801 (dynamic, but always above 300000) | |
error: InternalError: too much recursion | |
Safari 7.0.2 | |
maxStackSize = 58034 | |
error: RangeError: Maximum call stack size exceeded. | |
Chrome 33: |
This file contains 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
# fetch all branches | |
# From: http://stackoverflow.com/questions/10312521/how-to-fetch-all-git-branches | |
#!/bin/bash | |
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master`; do | |
git branch --track ${branch##*/} $branch | |
done | |
git fetch --all |
This file contains 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
// set file add/mode time | |
var fs = require('fs') | |
function setFileTime(filePath, atime, mtime) { | |
fs.utimesSync(filePath, atime, mtime); | |
} | |
var date = new Date('Thu Aug 20 2015 15:10:36 GMT+0800 (CST)'); | |
setFileTime('/tmp/scache/fdf/admin.log', date, date); |
This file contains 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
// It's tested on ios 8.2 .. | |
// Apple document about virtual memory: | |
// Both OS X and iOS include a fully-integrated virtual memory system that you cannot turn off; it is always on. | |
// https://developer.apple.com/library/mac/documentation/Performance/Conceptual/ManagingMemory/Articles/AboutMemory.html | |
// Discussing mmap on ios: | |
// http://stackoverflow.com/questions/13425558/why-does-mmap-fail-on-ios | |
// http://stackoverflow.com/questions/9184773/is-there-a-practical-limit-on-the-number-of-memory-mapped-files-in-ios | |
#include <sys/mman.h> |
This file contains 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://vulkan.lunarg.com/ | |
## https://vulkan.lunarg.com/sdk/home | |
# 18.04 | |
wget -qO - http://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add - | |
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-1.1.101-bionic.list http://packages.lunarg.com/vulkan/1.1.101/lunarg-vulkan-1.1.101-bionic.list | |
sudo apt update | |
sudo apt install lunarg-vulkan-sdk |
This file contains 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
import ( | |
"os" | |
"syscall" | |
"time" | |
) | |
func statTimes(name string) (atime, mtime, ctime time.Time, err error) { | |
fi, err := os.Stat(name) | |
if err != nil { |
This file contains 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
import ( | |
"bytes" | |
"encoding/json" | |
"errors" | |
"fmt" | |
"github.com/BurntSushi/toml" | |
"errors" | |
) | |
// borrowed from golang playgroud: |
This file contains 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
#!/bin/bash | |
appname=python | |
getpids() { | |
local pids=$(ps -ef | grep $1 | grep -v grep| awk '{print $2}') | |
echo $pids | |
} | |
pids=`getpids $appname` |
This file contains 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
#!/bin/bash | |
########################################################### | |
# how to use | |
# curl -f -L https://gist.githubusercontent.com/piaoger/b6da9366ef28a065f152/raw/c06e66e7b4ff22fbb7295fd8a30899cd7d11936c/bootstrap.sh -O | |
# sh bootstrap.sh | |
########################################################### | |
echo off |
This file contains 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
# I want compress yesterday's log, so I have to learn how to get yesterday with bash | |
# yesterday=$(date --date='-1 day' +%Y-%m-%d) | |
# today=$(date +%Y-%m-%d) | |
# yesterday_log=service_log_${yesterday}.log | |
# zip ${yesterday_log}.zip ${yesterday_log} | |
## today | |
today=$(date +%Y-%m-%d) |
NewerOlder