Skip to content

Instantly share code, notes, and snippets.

View piaoger's full-sized avatar

Piaoger piaoger

View GitHub Profile
@piaoger
piaoger / maxstacksize.html
Created March 21, 2014 02:32
Get max call stack size in browser
<!-- 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:
@piaoger
piaoger / git-sync-all-branches.sh
Created August 31, 2015 01:34
git-sync-all-branches
# 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
@piaoger
piaoger / setfiletime.js
Created August 24, 2015 03:40
Set file time in node.js
// 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);
@piaoger
piaoger / test_mmap_ios.m
Last active July 8, 2020 18:34
mmap on ios
// 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>
@piaoger
piaoger / install-valkan-library.sh
Created March 8, 2019 09:29
install libvulkan in Ubuntu
##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
@piaoger
piaoger / filetime.go
Last active May 11, 2017 03:41
get/set filetime in golang
import (
"os"
"syscall"
"time"
)
func statTimes(name string) (atime, mtime, ctime time.Time, err error) {
fi, err := os.Stat(name)
if err != nil {
@piaoger
piaoger / json_toml_marshal_unmarshal.go
Last active April 17, 2017 08:07
marshal and unmarshal of json/toml
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"github.com/BurntSushi/toml"
"errors"
)
// borrowed from golang playgroud:
@piaoger
piaoger / kill-processes.sh
Last active November 23, 2016 07:02
kill processes by name
#!/bin/bash
appname=python
getpids() {
local pids=$(ps -ef | grep $1 | grep -v grep| awk '{print $2}')
echo $pids
}
pids=`getpids $appname`
@piaoger
piaoger / bootstrap-nodejs.sh
Last active November 13, 2016 13:21
bootstrap.sh
#!/bin/bash
###########################################################
# how to use
# curl -f -L https://gist.githubusercontent.com/piaoger/b6da9366ef28a065f152/raw/c06e66e7b4ff22fbb7295fd8a30899cd7d11936c/bootstrap.sh -O
# sh bootstrap.sh
###########################################################
echo off
@piaoger
piaoger / linux-date-handling.sh
Last active November 13, 2016 13:13
handling date in linux bash
# 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)