Skip to content

Instantly share code, notes, and snippets.

Anders Rasmussen DivineGod

Block or report user

Report or block DivineGod

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
@DivineGod
DivineGod / index.js
Created Jun 7, 2016
npmlog@3 reduced test
View index.js
var Logger = require('npmlog')
var express = require('express')
var app = express()
app.get('/', function(req, res) {
res.send('Hello')
})
console.log('starting server')
@DivineGod
DivineGod / index.js
Last active Aug 29, 2015
requirebin sketch
View index.js
var h = require('virtual-dom/h');
var diff = require('virtual-dom/diff');
var patch = require('virtual-dom/patch');
var createElement = require('virtual-dom/create-element');
var _ = require('underscore');
// 1: Create a function that declares what the DOM should look like
function render(count) {
var els = _(count).times(function(n) { return h('li', {}, [String(n), 'this has<html><b> in it']); });
return h('div', {}, _.shuffle(els));
View keybase.md

Keybase proof

I hereby claim:

  • I am divinegod on github.
  • I am divinegod (https://keybase.io/divinegod) on keybase.
  • I have a public key whose fingerprint is FF3B 85F1 5FED 1BBE 4DE2 DAE7 4436 2922 E568 02FA

To claim this, I am signing this object:

@DivineGod
DivineGod / inflate.py
Last active Dec 23, 2015
Convert a flat dict into an object
View inflate.py
def kwargs_to_obj(**kwargs):
""" Return an object populated from a kwargs dict.
Useful for mapping html form post request to python object.
>>> kwargs_to_obj(**{'horse.age':23, 'horse.color': 'bleu', 'horse.legs[]': 'fl,fr,rl,rr'})
{'horse': {'color': 'bleu', 'age': 23, 'legs': ['fl', 'fr', 'rl', 'rr']}}
"""
result = {}
for k, v in kwargs.items():
name_path = k.split('.')
View ngram.py
#!/usr/bin/env python3
import re
split_regex = re.compile(r'\W').split
def ngram_word(n, text):
"""Returns n-grams from text as a list of strings
>>> ngram_word(3, 'Hello, world! rejoice and be happy')
['hello world rejoice', 'world rejoice and', 'rejoice and be', 'and be happy']
You can’t perform that action at this time.