Skip to content

Instantly share code, notes, and snippets.

View gjcourt's full-sized avatar

George Courtsunis gjcourt

View GitHub Profile
@gjcourt
gjcourt / -
Created February 7, 2014 21:56
diff --git a/storm-core/src/clj/backtype/storm/scheduler/EvenScheduler.clj b/storm-core/src/clj/backtype/storm/scheduler/EvenScheduler.clj
index 28b9202..9e10fab 100644
--- a/storm-core/src/clj/backtype/storm/scheduler/EvenScheduler.clj
+++ b/storm-core/src/clj/backtype/storm/scheduler/EvenScheduler.clj
@@ -22,15 +22,16 @@
:implements [backtype.storm.scheduler.IScheduler]))
(defn sort-slots [all-slots]
- (let [split-up (vals (group-by first all-slots))]
- (apply interleave-all split-up)
#!/bin/sh
echo "Lines of code" $(
find enki -name \*.html -o -name \*.css -o -name \*.js -o -name \*.coffee -o -name \*.py \
| grep -vE "/migrations/" \
| grep -vE "enki/static/admin" \
| grep -vE "enki/static/CACHE" \
| grep -vE "enki/static/css/lib" \
| grep -vE "enki/static/css/mobile" \
| grep -vE "enki/static/js/lib" \
This file has been truncated, but you can view the full file.
A
a
aa
aal
aalii
aam
Aani
aardvark
aardwolf
Aaron
@print: ->
console.log '[DEBUG]', arguments... if DEBUG
return
App.Storage = _.extend { Database: {} }, App.Storage
class App.Storage.Database.Statement
__error: (args...) ->
console.error args...
constructor: (@query, @args=[], @success=(->), @error=@__error) ->
@gjcourt
gjcourt / orm.coffee
Last active August 29, 2015 14:07
Database and ORM
App.Storage = _.extend { Database: {} }, App.Storage
class App.Storage.Database.Statement
__error: (args...) ->
console.error args...
constructor: (@query, @args=[], @success=(->), @error=@__error) ->
@gjcourt
gjcourt / name_mangling.py
Last active August 29, 2015 14:20
Name Mangling example.
class Foo(object):
def __init__(self, **kwargs):
self.__attr = kwargs.pop('attr', None)
@property
def bar(self):
return self.__attr
def test_foo():
@gjcourt
gjcourt / javascript html truncate.js
Created January 5, 2011 02:49
javascript translation of Benjamin Thomas' ruby code
/*
truncate text within HTML
does not work with malformed html
*/
function html_truncate(elem, num_words, truncate_string) {
// local state
var original = elem,
current = elem.childNodes[0],
count = 0;
@gjcourt
gjcourt / JSON Object Equality.js
Created February 25, 2011 04:26
test if two JSON objects are equivalent
/**
* not so simple check for object equality
*/
var equal = function(a, b) {
function check(a, b) {
for (var attr in a) {
if (a.hasOwnProperty(attr) && b.hasOwnProperty(attr)) {
if (a[attr] != b[attr]) {
switch (a[attr].constructor) {
case Object:
@gjcourt
gjcourt / detect.js
Created May 20, 2011 19:46
Javascript Object Key Detection
function detect(obj, attr, exact) {
var results = [],
re = new RegExp(attr, 'i');
// helper function for the recursion
function detectHelper(obj, attr, exact, path, results) {
for (var a in obj) {
// sanity check
if (!obj.hasOwnProperty(a))
continue;