Skip to content

Instantly share code, notes, and snippets.

💭
I may be slow to respond.

JIANG Di dd1994

💭
I may be slow to respond.
  • Hangzhou
Block or report user

Report or block dd1994

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dd1994
dd1994 / swipeFunc.js
Created Jul 6, 2016 — forked from localpcguy/swipeFunc.js
Simple Mobile Swipe function to get the swipe direction
View swipeFunc.js
var swipeFunc = {
touches : {
"touchstart": {"x":-1, "y":-1},
"touchmove" : {"x":-1, "y":-1},
"touchend" : false,
"direction" : "undetermined"
},
touchHandler: function(event) {
var touch;
if (typeof event !== 'undefined'){
@dd1994
dd1994 / web-servers.md
Created Apr 8, 2016 — forked from willurd/web-servers.md
Big list of http static server one-liners
View web-servers.md

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@dd1994
dd1994 / dabblet.css
Created Mar 29, 2016
The first commented line is your dabblet’s title
View dabblet.css
/**
* The first commented line is your dabblet’s title
*/
background: #eee;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@dd1994
dd1994 / loop.js
Created Dec 12, 2015
cycle reference
View loop.js
'use strict'
let ary = []
let obj1 = {
a: 1,
b: ary
}
ary.push(obj1)
@dd1994
dd1994 / bind.js
Last active Dec 12, 2015
implement Function.prototype.bind
View bind.js
'use strict'
let bind = function (fn, obj) {
return function () {
fn.apply(obj, arguments)
}
}
let foo = function () {
@dd1994
dd1994 / fn_stack.js
Created Dec 11, 2015
show function call stack
View fn_stack.js
'use strict'
function baz() {
debugger
console.log('baz')
bar()
}
function bar() {
debugger
@dd1994
dd1994 / set_timeout.js
Last active Nov 28, 2015
an example of setTimeout and clearTimeout
View set_timeout.js
'use strict'
let timeoutID1 = setTimeout(function(arg1, arg2) {
console.log(arg1)
console.log(arg2)
}, 2000, 'hello1', 'go1')
let timeoutID2 = setTimeout(function(arg1, arg2) {
console.log(arg1)
console.log(arg2)
@dd1994
dd1994 / repl.js
Created Nov 28, 2015
node repl example
View repl.js
'use strict'
const repl = require('repl')
let r = repl.start("-> ")
let c = r.context
c.msg = "awesome repl"
@dd1994
dd1994 / ns-cheatsheet.clj
Created Nov 1, 2015 — forked from ghoseb/ns-cheatsheet.clj
Clojure ns syntax cheat-sheet
View ns-cheatsheet.clj
;;
;; NS CHEATSHEET
;;
;; * :require makes functions available with a namespace prefix
;; and optionally can refer functions to the current ns.
;;
;; * :import refers Java classes to the current namespace.
;;
;; * :refer-clojure affects availability of built-in (clojure.core)
;; functions.
@dd1994
dd1994 / gcd.clj
Last active Nov 3, 2015
get greatest common divisor(use Clojure)
View gcd.clj
(defn gcd
[div rem]
(if (= rem 0)
div
(gcd rem (mod div rem))))
You can’t perform that action at this time.