Skip to content

Instantly share code, notes, and snippets.

View deontologician's full-sized avatar
🦀
🌎

Josh Kuhn deontologician

🦀
🌎
View GitHub Profile
@deontologician
deontologician / reltime.py
Created August 28, 2012 20:34
Relative datetimes in python
def reltime(date, compare_to=None, at='@'):
r'''Takes a datetime and returns a relative representation of the
time.
:param date: The date to render relatively
:param compare_to: what to compare the date to. Defaults to datetime.now()
:param at: date/time separator. defaults to "@". "at" is also reasonable.
>>> from datetime import datetime, timedelta
>>> today = datetime(2050, 9, 2, 15, 00)
>>> earlier = datetime(2050, 9, 2, 12)
@deontologician
deontologician / virtual hyperscript.coffee
Created June 3, 2015 20:35
coffeescript virtual-hyperscript
# Example of virtual hyperscript in coffeescript
# See: https://github.com/Matt-Esch/virtual-dom/blob/master/virtual-hyperscript/README.md
render_shard = (shard, index) =>
h "li.shard", [
h "div.shard-heading", [
h "span.shard-title", ["Shard #{index + 1}"]
h "span.numkeys", ["~#{approximate(shard.num_keys)} documents"]
]
h "ul.replicas", shard.replicas.map(render_replica)
import random
from collections import Counter
from pprint import pprint
import string
DAMAGE_TYPES = [
'fire',
'water',
'earth',

Keybase proof

I hereby claim:

  • I am deontologician on github.
  • I am deontologician (https://keybase.io/deontologician) on keybase.
  • I have a public key ASD9efqidLbPdEEY0igj6zqTkKkobQRz90EpS0UgKBZiiwo

To claim this, I am signing this object:

@deontologician
deontologician / dl_notes.md
Last active July 29, 2017 07:07
DL/RL notes

Notes on Deep Reinforcement Learning

Meta

Deep learning is a lot of old techniques that work suddenly because GPUs are super powerful.

Supervised learning

  • Function approximation
@deontologician
deontologician / sweet-reql.js
Last active July 15, 2016 06:57
sweetjs reql macros
macro ? {
case infix {
$test:expr | _ $succeed:expr : $fail:expr
} => {
return #{r.branch($test, $succeed, $fail)}
}
}
operator (-) 12 left
{ $a, $b } => #{ r.expr($a).sub($b) }
@deontologician
deontologician / rxjs5.js
Created June 22, 2016 00:12
Some rxjs 5 lift magic
// Before you'd do something like:
var obs = Observable.create((subscriber) => {
some.other().observable().chain().subscribe({
next(x){ subscriber.next(x) },
error(e){ subscriber.error(e) },
complete(){ subscriber.complete() },
})
})
class Tracker(Base):
__tablename__ = 'tracker'
id = Column(Integer, primary_key=True)
state = Column(String, nullable=False)
def __repr__(self):
return 'Tracker<{.id}>'.format(self)
@deontologician
deontologician / gist:7918366
Created December 11, 2013 20:59
webapp snippets
from tornado import web
from tornado import ioloop
from sqlalchemy.engine
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
import os
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.associationproxy import association_proxy
Base = declarative_base()
class Machine(Base):
__tablename__ = 'machines'
__table_args__ = {'sqlite_autoincrement': True}