Skip to content

Instantly share code, notes, and snippets.

viperscape /
Last active Jun 8, 2016
script to power on/off ec2 instances based on block times, reassociates eip if needed and saves cache of eips when rerun
import boto.ec2
import sys
import datetime
from time import gmtime, strftime, sleep
import toml
# expects ec2 instance tag: power-off
# values should be in 24hr clock from:to
# eg 2400:0400
# would result in midnight to 4am
bishboria /
Last active Oct 16, 2020
Springer made a bunch of books available for free, these were the direct links
viperscape /
Last active Jun 8, 2016
ec2 snapshot script, max snaps sets revolving snapshots to expire when rerun; expects volume to have tag: snapshot, some-unique-name
import boto.ec2
import sys
def get_snaps (desc, vol,conn):
snapshots = conn.get_all_snapshots(owner='id...',
return snapshots
def op_snaps (vols,max_snaps,conn):
johnynek /
Created Nov 13, 2014
Future with map and monadic bind in Rust.
use std::comm::{Receiver, channel};
use std::io;
use std::mem::replace;
use std::task::spawn;
struct Future<'a, A> {
state: FutureState<'a, A>
View gist:ccc99ec11f49043c14ed
use std::mem;
use std::intrinsics::TypeId;
// Val
struct Val {
value: i32
impl Val {
aravindavk / gist:2b4298eeb2d8f949224b
Created Sep 24, 2014
Use Shared lib created in Rust from Python
View gist:2b4298eeb2d8f949224b
#!/usr/bin/env python
Consumer example to use the shared object created in Rust.
Rust program:
use std::num::pow;
pub struct Point { x: int, y: int }
struct Line { p1: Point, p2: Point }
gerritjvv / core.async-lazy-sequence
Created Oct 30, 2013
This is for a situation where you have N amount of threads reading from different sources and want to consume all of the data they produce as a single sequence. Can be described as merging N queues from different sources and works well when the data produced is from IO. e.g. My usage is with kafka, I have multiple kafka topics and partitions to …
View core.async-lazy-sequence
(use 'clojure.core.async)
;this is the function you want to use
(defn lazy-channels [chs]
(lazy-seq (cons (let [ [v _] (alts!! chs)] v) (lazy-channels chs))))
;now for the tesging
(def chs [ (chan) (chan) (chan) ]) ; the channels can come from anywhere, here we are using three channels for testing
khernyo /
Last active Mar 20, 2016
Make it build the android version properly
set -e
SCRIPT_DIR=$( cd "$( dirname "$0" )" && pwd )
# the location of a clean racket repo which will be copied to avoid "git clone"-ing
drj42 /
Created Feb 6, 2012
This is a cheat sheet for Emacs org-mode... in org-mode format!
danking / gist:1068185
Created Jul 6, 2011
A very simple example showing how to use Racket's lexing and parsing utilities
View gist:1068185
#lang racket
(require parser-tools/lex
(prefix-in re- parser-tools/lex-sre)
(provide (all-defined-out))
(define-tokens a (NUM VAR))
(define-empty-tokens b (+ - EOF LET IN))
(define-lex-trans number
(syntax-rules ()
You can’t perform that action at this time.