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
def deleteFile(dfile : File) : Unit = { | |
if(dfile.isDirectory){ | |
val files = dfile.listFiles | |
if(files != null) | |
files.foreach{ f => deleteFile(f) } | |
} | |
dfile.delete | |
} |
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
#!/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 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
// a signal of 0 can be used to test for the existence of a process. | |
var exec = require('child_process').exec | |
var tryKill | |
function isRunning(pid, cb) { | |
var err = null, | |
result = null; | |
if (typeof pid !== 'number') { | |
err = "pid must be number" | |
} else { |
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
<body> | |
<!-- from https://github.com/airbnb/airpal/blob/master/src/main/resources/assets/index.html > | |
<!-- to avoid being banded by GFW --> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> | |
<script>window.jQuery || document.write('<script src="app/javascripts/vendor/jquery-1.9.0.min.js"><\/script>')</script> | |
</body> |
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
# 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 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
// 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 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
function copyFileSync(srcFile, destFile) { | |
var BUF_LENGTH, buff, bytesRead, fdr, fdw, pos; | |
BUF_LENGTH = 64 * 1024; | |
buff = new Buffer(BUF_LENGTH); | |
fdr = fs.openSync(srcFile, 'r'); | |
fdw = fs.openSync(destFile, 'w'); | |
bytesRead = 1; | |
pos = 0; | |
while (bytesRead > 0) { |
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
// 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 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
// Draw rotating Torus with GLFW3 | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <math.h> | |
#include <GLFW/glfw3.h> | |
static void drawTorus(int numMajor, int numMinor, float majorRadius, float minorRadius) | |
{ | |
static double PI = 3.1415926535897932384626433832795; |
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
// An OpenGL3 Exmaple: glew, glfw and nanovg. | |
// 2D and 3D in same scene. Torus is drawn with static display list. | |
#include <stdlib.h> | |
#include <math.h> | |
#include <stdio.h> | |
#include "GL/glew.h" |