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 N = 10; | |
(function(N){ | |
var arr = []; | |
for(var i=N+1; i--;) arr.push(i); | |
arr.pop(); // last elem is 0 | |
return arr; | |
})(N).reduce(function (n, i) { | |
return n * i; | |
}, 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
ul.pagination.right() | |
// if current page is > 10, have -10 back btn | |
li.arrow(ng-if="currentPage > 10") | |
a(ng-click='goToPage(currentPage - 10)') «« | |
// have previous & nect page as clicable option | |
li(ng-repeat='n in [-1, 0, 1]' ng-class="{current: currentPage == currentPage + n}") | |
a(ng-if="currentPage + n > 0 && (currentPage + n) < (total / 10)", | |
ng-click='goToPage(currentPage + n)') {{currentPage + n}} | |
// Next btn, if next exists | |
li.arrow(ng-if="currentPage < (total / 10) + 3 && (currentPage + 3) < (total / 10)") |
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
$ ifconfig | grep 'inet ' | cut -d' ' -f2 | awk '{ print $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
#!/usr/bin/env bash | |
# haproxyd | |
# Script to start|stop|restart haproxy from /etc/init.d/ | |
HAPROXY_PATH=/usr/sbin | |
HAPROXY_DAEMON=$HAPROXY_PATH/haproxy | |
HAPROXY_CONFIG=/etc/haproxy/haproxy.cfg | |
test -x $HAPROXY_DAEMON || exit 0 | |
test -f $HAPROXY_CONFIG || exit 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 setjdk() { | |
if [ $# -ne 0 ]; then | |
removeFromPath '/System/Library/Frameworks/JavaVM.framework/Home/bin' | |
if [ -n "${JAVA_HOME+x}" ]; then | |
removeFromPath $JAVA_HOME | |
fi | |
export JAVA_HOME=`/usr/libexec/java_home -v $@` | |
export PATH=$JAVA_HOME/bin:$PATH | |
fi | |
} |
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 strict'; | |
module.exports = function allochron(funcs, onComplete, limit) { | |
funcs = typeof funcs === 'function' ? [funcs] : funcs; | |
limit = limit || 3; | |
var scope = this; | |
var length = Object.keys(funcs).length; | |
var shouldRun = {val: true}; | |
var counter = {i: length}; |
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 strict'; | |
var fs = require('fs'); | |
var path = require('path'); | |
var safeObj = require('./safeObj'); | |
module.exports = function JsonStore(name, filestoreDir) { | |
var self = this; | |
var sourceData = { }; | |
var loopPtr; |
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
module.exports = function json2xml(obj) { | |
var str = ''; | |
for(var key in obj) { | |
str += __json2xml(key, obj[key]); | |
} | |
return str; | |
}; | |
function __json2xml(parrent, props) { |
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 safeObj(obj) { | |
return (function obj() { | |
var args = Array.prototype.slice.call(arguments, 0); | |
return (function __get(obj, args) { | |
var key = args.shift(); | |
if(key !== undefined) return __get.call(this, obj[key] || { }, args); | |
return obj; | |
}).call(this, this, args); | |
}).bind(obj || {}); | |
} |
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 obj(o) { | |
var args = Array.prototype.slice.call(arguments, 1); | |
return (function __get(o, args) { | |
var key = args.shift(); | |
if(key !== undefined) return __get(o[key] || { }, args); | |
return o; | |
})(o, args); | |
} |