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 sort_asc(values) { | |
var n = values.length; | |
for (var i = 1; i < n; i++) { | |
var v = values[i]; | |
var k = i - 1; | |
while (k >= 1 && v > values[k]) { | |
values[k + 1] = values[i]; | |
k = k - 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 python | |
import sys | |
def get_tokens(src): | |
file = open(src) | |
return [token.strip(' \t\n\r') for token in file.readlines()] | |
def diff_tokens(a, b): | |
return [x for x in a if x not in b] |
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 brew_get_home_path_formula { | |
echo $(brew info ${1} | grep -E -o "/usr/local/Cellar/${1}/(\d+\.?)+") | |
} | |
## i.e. set GRADLE_HOME in .bashrc | |
export GRADLE_HOME=$(brew_get_home_path_formula gradle)/libexec |
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
# CCZE Colourize Config for Centos | |
# http://lintut.com/colorize-log-files-on-linux-using-ccze-tool/ | |
# http://www.tecmint.com/how-to-enable-epel-repository-for-rhel-centos-6-5/ | |
CCZE=`which ccze` | |
if [ "$TERM" != dumb ] && [ -n "$CCZE" ] | |
then | |
function colourify { `$@` | $CCZE -A } | |
alias colourify=colourify | |
alias configure='colourify ./configure' |
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
// If you don't need new for bound functions do this | |
function bind(fn, c) { | |
if (Function.prototype.bind && | |
fn.bind === Function.prototype.bind) { | |
return Function.prototype.bind.apply(fn, | |
Array.prototype.slice.call(arguments, 1)); | |
} | |
var args = Array.prototype.slice.call(arguments, 2); | |
return function () { |
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 extend(child, parent) { | |
var F = function () { | |
this.__construct = function () { | |
parent.apply(this, arguments); | |
}; | |
this.constructor = child; | |
}; | |
F.prototype = parent.prototype; | |
// append from subclass prototype |
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
import javax.annotation.Priority; | |
import javax.ws.rs.Priorities; | |
import javax.ws.rs.container.ContainerRequestContext; | |
import javax.ws.rs.container.ContainerResponseContext; | |
import javax.ws.rs.container.ContainerResponseFilter; | |
import javax.ws.rs.core.MultivaluedMap; | |
import javax.ws.rs.ext.Provider; | |
import java.io.IOException; | |
// @see http://simplapi.wordpress.com/2013/04/10/jersey-jax-rs-implements-a-cross-domain-filter/ |
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
/** | |
* Simple emitter with broadcast, emit, on event functions. | |
*/ | |
app.factory('emitter', function ($rootScope) { | |
var service = {}; | |
angular.forEach(['broadcast' 'emit', 'on'], function (key) { | |
service[key] = angular.bind($rootScope['$' + $key], $rootScope); | |
}); | |
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
{ | |
"color_scheme": "Packages/Theme - Spacegray/base16-eighties.dark.tmTheme", | |
"default_font_size": 10, | |
"flatland_square_tabs": true, | |
"font_face": "PragmataPro", | |
"font_options": | |
[ | |
"subpixel_antialias", | |
"no_round" | |
], |
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 | |
# | |
# Resources: | |
# - http://superuser.com/questions/490425/how-do-i-switch-between-java-7-and-java-6-on-os-x-10-8-2 | |
# | |
JAVA_VMS="/Library/Java/JavaVirtualMachines" | |
####################### | |
# List available jdks # |