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
#include <stdio.h> | |
#include <stdlib.h> | |
int main (int argc, char * argv[]) | |
{ | |
int a = 0, b = 0; | |
int * stack = malloc(sizeof(int) * 20); | |
if (stack == NULL) | |
return -1; |
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
function flatten(input) { | |
'use strict'; | |
if (!Array.isArray(input)) // need polyfill | |
return input; | |
var ret = []; | |
(function inner(input, ret) { | |
if (input.length === 0) | |
return ret; | |
var car = input.shift(0); |
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
<!DOCTYPE HTML> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>imageScroll</title> | |
</head> | |
<body> | |
</body> | |
<script type="text/javascript"> | |
function $(e) { return document.getElementById(e); } |
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
#!/usr/bin/env python | |
# -*- coding:utf8 -*- | |
import os | |
import tornado.web | |
from tornado.httpserver import HTTPServer | |
from tornado.ioloop import IOLoop | |
import uuid |
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
#!/usr/bin/env python | |
def is_cn_char(c): | |
""" | |
Chinese char detecting | |
""" | |
return 0x4e00 <= ord(c) <= 0x9fa5 | |
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
(defn diff [f] | |
(fn [x] | |
(let [dx (/ 1 Integer/MAX_VALUE)] ;nearly 0 | |
(/ (- (apply f [(+ x dx)]) (apply f [x])) dx)))) | |
(defn g [x] ; given function | |
(* x x)) | |
(def dg (diff g)) ; get dg | |
(print (float (dg 3))) ; 6 |
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
(defn F [a b c]; generate the target function | |
(fn [x] | |
(+ (* (+ (* a x) b) x) c))) | |
(def f1 (F 1 2 1)) | |
(defn | |
^{:doc "(Solve f a b) | |
f-- the target function | |
a,b the interval for isolating the root" |
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
#!/usr/bin/env python2 | |
#coding:utf-8 | |
import numpy | |
import wave | |
class MainHandler(object): | |
def __init__(self, duration=10, frequency=2000): |
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
#!/usr/bin/env python2 | |
#coding:utf-8 | |
import re | |
import time | |
import os | |
import urllib | |
import requests |
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
var fs = require('fs'), | |
path = require('path'); | |
exports.walk = function(abspath, callback){ | |
/* | |
* callback will get { dirname: {file1: file1_abs_path, subdir: { fil2: file2_abs_path, subdir2: {}.. }}; | |
* if not callback passed, it just returns a tree like above; | |
*/ |
OlderNewer