Skip to content

Instantly share code, notes, and snippets.

@calvinfroedge
calvinfroedge / gist:9905412
Created April 1, 2014 00:34
Find the max slice of an array
function sum(a,b){
return a+b;
}
Array.prototype.min = function(){
return Math.min.apply(null, this);
}
function maxSlice(arr){
//Are there any negative numbers? If not, the entire array is the greatest segment.
import itertools
groups = [
['wordlist1'],
['wordlist2']
]
combos = list(itertools.product(*groups))
combined = map(lambda x: "".join(x), map(list, combos))
@calvinfroedge
calvinfroedge / gist:c74be9d18e28c7d5b47f
Created November 1, 2014 19:31
Engine.io socket test
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script src="bower_components/engine.io-client/engine.io.js"></script>
</head>
var dep = require('somelib');
module.exports = {
myMethod: function(callback){
dep.doSomething(function(err, res){
callback(err, res);
});
}
};
import sys
lines = open(sys.argv[1], 'r')
for line in lines:
line = line.replace("\n", "").split(";")
arr = line[0].split(",")
n = int(line[1]);
hsh = {}
app_navModule = ()->
nav = {}
nav.Link = (data) ->
data.attributes = data.attributes or {}
@href = m.prop(data.href)
@text = m.prop(data.text)
@attributes = m.prop(data.attributes)
return
@calvinfroedge
calvinfroedge / languages.json
Created March 30, 2015 02:03
JSON list of all programming languages
"["A# .NET","A# (Axiom)","A-0 System","A+","A++","ABAP","ABC","ABC ALGOL","ABLE","ABSET","ABSYS","ACC","Accent","Ace DASL","ACL2","ACT-III","Action!","ActionScript","Ada","Adenine","Agda","Agilent VEE","Agora","AIMMS","Alef","ALF","ALGOL 58","ALGOL 60","ALGOL 68","ALGOL W","Alice","Alma-0","AmbientTalk","Amiga E","AMOS","AMPL","APL","App Inventor for Android's visual block language","AppleScript","Arc","ARexx","Argus","AspectJ","Assembly language","ATS","Ateji PX","AutoHotkey","Autocoder","AutoIt","AutoLISP / Visual LISP","Averest","AWK","Axum","B","Babbage","Bash","BASIC","bc","BCPL","BeanShell","Batch (Windows/Dos)","Bertrand","BETA","Bigwig","Bistro","BitC","BLISS","Blue","Bon","Boo","Boomerang","Bourne shell","bash","ksh","BREW","BPEL","C","C--","C++","C#","C/AL","Caché ObjectScript","C Shell","Caml","Candle","Cayenne","CDuce","Cecil","Cel","Cesil","Ceylon","CFEngine","CFML","Cg","Ch","Chapel","CHAIN","Charity","Charm","Chef","CHILL","CHIP-8","chomski","ChucK","CICS","Cilk","CL","Claire","Clarion","Clean"
(map #(hash-map :_id (:id %) :_rev (:rev (:value %))) (get_all {}))
(use 'clojure.walk)
(def grouped-by-key (keywordize-keys grouped))
(count (keys grouped-by-key))
(defn delete-duplicates
[items]
(if (not= 0 (count items))
@calvinfroedge
calvinfroedge / gist:e6207d115ac2d228972e
Last active August 29, 2015 14:21
Load and cache JSONP content
/**
* Load and cache JSONP data
*/
var loadJSONP = function ( url, callback ) {
var setLocalData = false;
/*
* Setting a variable callback method since we're writing to window
*/
var callbackMethod = url.replace(/[^a-z0-9]/g, '_')
@calvinfroedge
calvinfroedge / gist:abc819cfc5d967350f9c
Created May 29, 2015 16:46
Gulpfile, coffeescript live reload server and all output to stdout, stderr
var
spawn = require('child_process').spawn,
fs = require('fs'),
gulp = require('gulp'),
watch = require('gulp-watch');
var SERVER_SRC = './server/'
var paths = {
server: [SERVER_SRC+'*', SERVER_SRC+'**/*']