Skip to content

Instantly share code, notes, and snippets.

from flask import Flask, request, jsonify
from time import sleep
def my_uber_func(num):
sleep(5)
return 3 * num
app = Flask(__name__)
<?php
//1. paste this class definition on top of includes/class-sensei-analysis-overview-list-table.php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class Sensei_Update_All_User_Course_Completions {
@pgk
pgk / ioc.py
Created February 18, 2016 13:04
mport inspect
class Container(object):
def __init__(self):
self.registry = {}
def register(self, interface, implementation):
self.registry[interface.__name__] = implementation
@pgk
pgk / Generator Examples.ipynb
Last active August 29, 2015 14:09
Generator Examples ipython notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
/*
* Streaming example
*/
var slice = Array.prototype.slice;
/*
* All streams respond to certain events
*/
# to start the server:
# pip install twisted
# pip install cyclone
# cyclone run cyclone_ex.py
import cyclone.web
from twisted.internet import defer, task, reactor
@defer.inlineCallbacks
import random
print [i + 1 for i in random.sample(range(52), 52)]
@pgk
pgk / permutations.lua
Created October 22, 2012 18:42
Lua set permutations of N iterator with coroutines
local table = require 'table'
function permutations(N)
local level, set, co = -1, {}, nil
for i = 1, N do set[i] = 0 end
co = coroutine.create(function () permute(set, level, N, 1) end)
return function ()
@pgk
pgk / gist:3155814
Created July 21, 2012 13:22
Alicia's Garbage bin code (slightly amended)
if (skoupidontenekes_xoris_sakoula()) {
try {
anazitise_sakoula_skoupidiwn_sthn_porta_ths_kouzinas();
} catch (ksexases_na_psonisis_sakoules_skoupidion) {
while (o_geitonas_einai_apo_kato()) {
wait(1000);
}
throw new skoupidi_sto_fotagogo_tou_geitona();
}
} else {
@pgk
pgk / glassfish301.rb
Created January 7, 2012 22:57
Glassfish 3.0.1 Homebrew Formula
require 'formula'
class Glassfish301 < Formula
url 'http://download.java.net/glassfish/3.0.1/release/glassfish-3.0.1.zip'
homepage 'http://glassfish.org/'
md5 'a24f6ca15bb6b38d4cb2998d607abcde'
skip_clean :all
def install