Skip to content

Instantly share code, notes, and snippets.

Alex unthingable

Block or report user

Report or block unthingable

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@unthingable
unthingable / DataDictJSOexample.java
Created Jan 19, 2012
JSNI return types with CellTable
View DataDictJSOexample.java
public class DataDictJSO extends JavaScriptObject {
...
public final native void put(String key, String obj) /*-{
this[key] = obj;
}-*/;
/**
* A slick way to get down to the object.
* @param keys can be "foo" or "foo.bar.baz"
* @param <T>
View gist:1932927
Exception in thread "Code server for admin from Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:10.0.1) Gecko/20100101 Firefox/10.0.1 on https://127.0.0.1/admin.html?gwt.codesvr=127.0.0.1:9997 @ pb8&uE4{OBKn@'!N" java.lang.NullPointerException
at com.google.gwt.dev.shell.ModuleSpace.dispose(ModuleSpace.java:146)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:215)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:662)
View gist:2897398
AbstractBase(models.Model):
foo = somefield
class Base(AbstractBase):
c1 = models.OneToOneField('C1', null=True, blank=True)
c2 = models.OneToOneField('C2', null=True, blank=True)
def c(self):
#only one additional query to get the base
if self.c1_id:
View cache.py
Stamped = namedtuple('Stamped', 'stamp obj')
cache = {}
def cached(ttl, func, *args, **kw):
'Simple inline cache for function calls'
key = (func.__name__,) + args
entry = cache.get(key, None)
@unthingable
unthingable / mapping.json
Last active Dec 18, 2015
elasticsearch ttl: why y no work?
View mapping.json
{
"foobar" : {
"pwpage" : {
"dynamic_templates" : [ {
"string_template" : {
"mapping" : {
"index" : "not_analyzed",
"type" : "string"
},
"match" : "*",
@unthingable
unthingable / mytemplate.json
Last active Dec 18, 2015
es dynamic templates
View mytemplate.json
{
"mytemplate": {
"mappings": {
"_default_": {
"_all": {
"enabled": false
},
"_ttl": {
"default": "1d",
"enabled": true
@unthingable
unthingable / init.el
Last active Dec 31, 2015
color-theme sensitive hl-line
View init.el
;; (set-face-background hl-line-face "medium purple")
;; fix hl-line color dynamically:
(require 'hexrgb)
(defun my-fix-hl-line-color ()
"Adjust hl-line color relative to current color theme"
(interactive)
(let*
((color (face-attribute 'default :background))
(value (hexrgb-value color))
(threshold 0.32)
@unthingable
unthingable / solution.py
Last active Jan 3, 2016
nuclear class splitting (https://github.com/nucleic/atom) Problem: Atom subclasses require all attributes to be Fields (subclasses of Member). In practice this means you can neither drop atomic fields into an existing class, not create new class attributes inside methods; quite annoying. Atomizer will split a class into a real Atom and a "deatom…
View solution.py
from atom.api import Atom, Int
# This is not OK:
class A(Atom):
x = Int()
y = 0
def f(self):
self.y = 1 # not OK
self.z = 5 # very not OK!
@unthingable
unthingable / euclidean.clj
Last active Mar 22, 2016
Euclidean Rhythm generator in Clojure
View euclidean.clj
(defn split-seq [s]
"Extract a tail of all same elements: [1 1 0 0 0] -> [[1 1] [0 0 0]]"
(let [l (last s)]
(split-with #(not= l %) s)))
(defn recombine
"Distribute tail: [[1] [1] [1] [0] [0]] -> [[1 0] [1 0] [1]]"
([a b] [a b])
([a b c] [a b c])
([a b c & more]
@unthingable
unthingable / tabbar.hs
Last active Aug 29, 2015
simple tabbed panel example
View tabbar.hs
import Window
import Mouse
import Graphics.Input (Input, input, clickable)
import Dict
-- UTIL
enumerate : [a] -> [(Int, a)]
enumerate l = zip [1..length l] l
You can’t perform that action at this time.