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 node | |
var util = require('util'), | |
http = require('http'), | |
fs = require('fs'), | |
url = require('url'), | |
events = require('events'); | |
var DEFAULT_PORT = 9898; |
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"), | |
util = require('util'); | |
/** | |
* need an absolute path | |
* @param {[type]} root [description] | |
* @return {[type]} [description] | |
*/ | |
function traverseFolder(root, config) { |
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
angular.module("ui.ssnau.flexBox", []) | |
.directive("flexBox", function () { | |
var isDragging = false; | |
var meta = {}; | |
var hasBind = false; | |
var ndCurtain = $("<div style='position:absolute;width:100%;height:100%;opacity:0;z-index:1000;background:blue;left:0px;top:0px;'></div>"); | |
function bindMouseEvent(elem) { | |
$(elem).on("mousemove", function (e) { | |
if (!isDragging) return; |
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 qsort(arr) { | |
partition(arr, 0, arr.length - 1); | |
} | |
function partition(arr, left, right) { | |
// check terminate | |
if (left >= right) return; | |
// select a pivot, for simplicity select the right most one | |
var pivot = arr[right]; |
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
public class Solution { | |
public int totalNQueens(int n) { | |
upperlim = (1<<n) - 1; | |
count = 0; | |
dfs(0,0,0); | |
return count; | |
} | |
public void dfs(int row, int leftX, int rightX) { | |
if (row == upperlim) { |
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> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<style> | |
textarea, | |
pre { |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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 re_vars = /(['"\/]).*?[^\\]\1|\.\w*|\w*:|\b(?:(?:new|typeof|in|instanceof) |(?:this|true|false|null|undefined)\b|function *\()|([a-z_]\w*)/gi | |
// [ 1 ][ 2 ][ 3 ][ 4 ][ 5 ] | |
// find variable names: | |
// 1. skip quoted strings and regexps: "a b", 'a b', 'a \'b\'', /a b/ | |
// 2. skip object properties: .name | |
// 3. skip object literals: name: | |
// 4. skip javascript keywords | |
// 5. match var name | |
function wrap(s, nonull) { | |
s = s.trim() |
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 benchmark(func){ | |
var s = Date.now(); | |
var obj = {a: 1, b: 2}; | |
Array(10000).join(' ').split('').forEach(function(){ | |
func('c = a * b', obj) | |
func('c', obj) | |
}); | |
var e = Date.now(); | |
console.log( 'total cost:' + (e - s)); |
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 repeat(_char, num) { | |
return (new Array(num + 1)).join(_char); | |
} | |
function stringify(object, blanks) { | |
blanks = blanks || 4; | |
var leading = repeat(' ', blanks); | |
switch (true) { | |
case Array.isArray(object): | |
return "[" + object.map(function(item) {return stringify(item, blanks + 4)}).join(', ') + "]"; |
OlderNewer