Skip to content

Instantly share code, notes, and snippets.

@viperscape
viperscape / ec2-power.py
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
View ec2-power.py
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 Oct 16, 2020
Springer made a bunch of books available for free, these were the direct links
@viperscape
viperscape / ec2-snapshots.py
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
View ec2-snapshots.py
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 Nov 13, 2014
Future with map and monadic bind in Rust.
View Future.rs
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
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.
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 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
khernyo / racket-android-build.sh
Last active Mar 20, 2016
Make it build the android version properly
View racket-android-build.sh
#!/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 Feb 6, 2012
This is a cheat sheet for Emacs org-mode... in org-mode format!
View org-mode-reference-in.org
@danking
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)
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 ()
You can’t perform that action at this time.