Skip to content

Instantly share code, notes, and snippets.

@ei-grad
ei-grad / example.py
Created November 30, 2011 01:46
threaded decorator for tornado
from time import sleep
from tornado import gen
import tornado.ioloop
import tornado.web
from tornado_threaded import threaded, inline_threaded
@threaded
def slow_func(callback):
@devn
devn / hack.sh
Created March 31, 2012 17:54 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@terjesb
terjesb / accounts.clj
Created July 18, 2012 07:35 — forked from pelle/accounts.clj
Using database functions in Datomic transactions and annotating transaction history
(use '[datomic.api :only [q db] :as d])
(def uri "datomic:mem://accounts")
;; create database
(d/create-database uri)
;; connect to database
(def conn (d/connect uri))
;; borrowed from ibdknox/jayq
(defn map->js [m]
(let [out (js-obj)]
(doseq [[k v] m]
(aset out (name k) v))
out))
(defn clj->js
"Recursively transforms ClojureScript maps into Javascript objects,
other ClojureScript colls into JavaScript arrays, and ClojureScript
@cgrand
cgrand / foami.clj
Last active October 25, 2015 18:32
(ns foami.core
"FOreign Asynchronous Mechanism Interop"
(:require [clojure.core.async :as async]))
(def ^:private abandon (doto (async/chan) async/close!))
(def ^:private pending-writes (async/chan))
(defn put!
"Tries to put a val into chan, returns either: true if put succeeded, false if chan is
@philandstuff
philandstuff / codemesh2015.org
Last active November 16, 2015 19:37
Code mesh 2015 notes

Kush, an introduction to schedulers

about me

  • I work for GDS
  • Cabinet Office
  • we started by building GOV.UK
    • replaced older sites like direct gov, business link
  • we’re not just fixing websites
    • we also build and run digital services
    • working with depts across the country
    • eg: register to vote
@jadeallenx
jadeallenx / alvaro.md
Last active November 25, 2015 19:14
Yeah, I think I See What You Mean

tl;dr You should watch this.

It's interesting to me that a significant number of talks in this year's Strange Loop conference referenced a 1966 paper by Peter Landin called (somewhat tongue in cheek) "The Next 700 Programming Languages". In this paper, Landin describes a programming language which he says in a footnote might be aptly called "Church without the lambda" - but which in the paper is called "If You See What I Mean" (ISWIM).

Alvaro's talk delved deeply into the question of "What is the semantics or meaning of a program?" Alvaro's thesis is that the meaning of a program is to produce desired outcomes from a computing system but that current languages focus on

@fredyr
fredyr / Vector.purs
Last active January 1, 2016 10:56
Persistent vector in Purescript
-- Playing around with persistent vectors in Purescript
-- Imitiates the interface from Data.Array, but uses Mori.js persistent
-- vector implementation e.g. to avoid copy-on-write etc.
module Data.Vector where
import Data.Maybe
-- LOL I have no idea what I'm doing, but reverse engineering from the
-- JS output, this actually seems to work
foreign import data Mori :: *
; Released under the Apache License, Version 2.0
; http://www.apache.org/licenses/LICENSE-2.0.html
(defmacro try-let
"A combination of try and let such that exceptions thrown in the binding or
body can be handled by catch clauses in the body, and all bindings are
available to the catch and finally clauses. If an exception is thrown while
evaluating a binding value, it and all subsequent binding values will be nil.
Example:
@rantav
rantav / riemann-maintenance-mode.rb
Last active September 3, 2016 15:48
Riemann example how to check whether a host is in maintenance mode. And Ruby code to set/unset maintenance mode.
vagrant@precise64:~$ irb
1.9.3-p484 :002 > require "riemann"
=> true
# Activate maintenance-mode:
1.9.3-p484 :010 > Riemann::Client.new << {service: "maintenance-mode", host: "precise64", state: "active", ttl: Float::INFINITY}
=> nil
# Deactivate maintenance-mode:
1.9.3-p484 :011 > Riemann::Client.new << {service: "maintenance-mode", host: "precise64", state: nil, ttl: Float::INFINITY}
=> nil