Skip to content

Instantly share code, notes, and snippets.

@noonat
noonat / gevent_thread_wait.py
Created February 23, 2017 19:16
Spawn a thread and make the greenlet wait for it to exit.
from __future__ import print_function
import time
import gevent
from gevent import hub, _threading
def ticker():
while True:
package main
import (
"flag"
"log"
"os"
"os/signal"
"strings"
"github.com/Shopify/sarama"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style type="text/css">
body {
margin: 0;
padding: 0;
}
canvas {
// really slow: ~50s
try {
return ret.concat.apply([], ret);
} catch (e) {
if (e instanceof RangeError && ret.reduce) {
return ret.reduce(function(a, b) {
return a.concat(b);
}, [])
} else {
throw e;
@noonat
noonat / get_subs.py
Last active December 19, 2015 10:09
#!/usr/bin/env python
from __future__ import print_function
import argparse
import os
import requests
import sys
import zlib
from pythonopensubtitles import opensubtitles, utils
@noonat
noonat / level1.py
Created January 24, 2013 20:34
Some code to solve the Colossal Cue puzzles at http://adventure.cueup.com/
m = 4294967296
a = 69069
c = 1
seed = 6
for i in range(4):
seed = (a * seed + c) % m
print "%i" % (seed % 36)
@noonat
noonat / Cube.as
Created February 28, 2011 08:59
Molehill Example: Spinning Cube
/**
* Spinning cube in Molehill.
* http://ltslashgt.com/2011/02/28/molehill-spinning-cube/
*/
package {
import com.adobe.utils.AGALMiniAssembler;
import flash.display.Sprite;
import flash.display.Stage3D;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
FILES=$(echo "man1/mailq.1
man1/newaliases.1
man1/postalias.1.gz
man1/postcat.1.gz
man1/postconf.1.gz
man1/postdrop.1.gz
man1/postfix.1.gz
man1/postkick.1.gz
man1/postlock.1.gz
man1/postlog.1.gz
@noonat
noonat / powerset.coffee
Created February 3, 2012 22:18
Power sets
powerSet = (set) ->
p = [[]]
for val in set
for i in [0...p.length]
p[p.length] = p[i].concat([val])
p
$ mongo
MongoDB shell version: 2.0.0
connecting to: test
> quit
function () {
return nativeHelper.apply(quit_, arguments);
}
> quit.toString = function() { return 'Type quit() to quit.'; }
function () {
return "Type quit() to quit.";