Skip to content

Instantly share code, notes, and snippets.

@viperscape
viperscape / ec2-power.py
Last active June 8, 2016 16:55
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
bishboria / springer-free-maths-books.md
Last active April 25, 2024 06:27
Springer made a bunch of books available for free, these were the direct links
@viperscape
viperscape / ec2-snapshots.py
Last active June 8, 2016 16:54
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...',
filters={'description':'*'+desc+'*'})
return snapshots
def op_snaps (vols,max_snaps,conn):
@johnynek
johnynek / Future.rs
Created November 13, 2014 04:20
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>
}
@Nercury
Nercury / gist:ccc99ec11f49043c14ed
Created October 30, 2014 20:25
MaybeValue example
use std::mem;
use std::intrinsics::TypeId;
// Val
struct Val {
value: i32
}
impl Val {
@aravindavk
aravindavk / gist:2b4298eeb2d8f949224b
Created September 24, 2014 12:15
Use Shared lib created in Rust from Python
#!/usr/bin/env python
"""
Consumer example to use the shared object created in Rust.
Ref: http://blog.skylight.io/bending-the-curve-writing-safe-fast-native-gems-with-rust/
Rust program: points.rs
use std::num::pow;
pub struct Point { x: int, y: int }
struct Line { p1: Point, p2: Point }
@gerritjvv
gerritjvv / core.async-lazy-sequence
Created October 30, 2013 11:07
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 …
(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
khernyo / racket-android-build.sh
Last active March 20, 2016 09:20
Make it build the android version properly
#!/bin/bash
set -e
SCRIPT_DIR=$( cd "$( dirname "$0" )" && pwd )
# the location of a clean racket repo which will be copied to avoid "git clone"-ing
REPO=$SCRIPT_DIR/../tools/racket
PLATFORM=linux-x86_64
@drj42
drj42 / org-mode-reference-in.org
Created February 6, 2012 23:53
This is a cheat sheet for Emacs org-mode... in org-mode format!
@danking
danking / gist:1068185
Created July 6, 2011 19:55
A very simple example showing how to use Racket's lexing and parsing utilities
#lang racket
(require parser-tools/lex
(prefix-in re- parser-tools/lex-sre)
parser-tools/yacc)
(provide (all-defined-out))
(define-tokens a (NUM VAR))
(define-empty-tokens b (+ - EOF LET IN))
(define-lex-trans number
(syntax-rules ()