Skip to content

Instantly share code, notes, and snippets.

@digal
digal / Dimensions.scala
Created April 3, 2011 19:47
Scala DSL for simple imagemagick-styles geometry strings
/**
* DSL for imagemagick-style geometry strings
* See http://www.imagemagick.org/Magick++/Geometry.html for description
* Note: offesets are not supported
*
* Implements following constructs
*
* <width> x <height> - Rect
* <Rect> <Qualifier> (where qualifier is !/%/>/<) - Geometry
*
@digal
digal / gist:8418398
Last active January 3, 2016 05:49
Hobbit symmetrization
(defn symmetrize-body-parts
"Expects a seq of maps which have a :name and :size"
[asym-body-parts]
(loop [unprocessed-parts asym-body-parts
processed-parts nil]
(println (str "processed: " processed-parts))
(println (str "unprocessed: " unprocessed-parts))
(if unprocessed-parts
(let [[current-part & remaining-parts] unprocessed-parts
processed-with-left (conj processed-parts current-part)]
[[[[[[[[[RACAbleWithStart(client, networkReachabilityStatus)
filter:^BOOL(NSNumber* statusNumber) {
AFNetworkReachabilityStatus status = statusNumber.intValue;
BOOL autoLoadOn3G = [[NSUserDefaults standardUserDefaults] boolForKey:KEY_AUTOLOAD_3G];
return (status == AFNetworkReachabilityStatusReachableViaWiFi
|| (autoLoadOn3G && status == AFNetworkReachabilityStatusReachableViaWWAN));
}]
take:1]
flattenMap: ^(id value){
@digal
digal / gist:4060940
Created November 12, 2012 18:15
gistio test
aaa
@digal
digal / gist:2380123
Created April 13, 2012 20:52
hello world program on iDCPU-16
UInt16 program[] = {
SET | X << 4 | 0x2A << 10, //SET X, 11
ADD | X << 4 | NW << 10, VMEM_DISPLAY_START + 32*6, //ADD x, VMEM + 32 * 6
SET | Y << 4 | 0x2D << 10, //SET Y, :data
IFE | MEM_Y << 4 | 0x20 << 10, //IFE [X], 20
SET | PC << 4 | 0x2C << 10, //JMP :loop
SET | MEM_X << 4 | MEM_Y << 10, //SET [Y], [X]
BOR | MEM_X << 4 | NW << 10, 0x0F00, //BOR [Y], 0x0F00 ; set char color
ADD | X << 4 | 0x21 << 10, //ADD X, 1
ADD | Y << 4 | 0x21 << 10, //ADD Y, 1
if (direction == '') {
direction = 'east';
}
var dirs;
var look = function (dir) {
if (dir == 'north') return north;
else if (dir == 'south') return south;
else if (dir == 'east') return east;
else if (dir == 'west') return west;
}
@digal
digal / .bash_profile
Created September 23, 2011 09:01
Digal's .bash_profile
# ANSI color codes
RS="\[\033[0m\]" # reset
HC="\[\033[1m\]" # hicolor
UL="\[\033[4m\]" # underline
HC="\[\033[5m\]" # blink
INV="\[\033[7m\]" # inverse background and foreground
FBLK="\[\033[30m\]" # foreground black
FRED="\[\033[31m\]" # foreground red
FGRN="\[\033[32m\]" # foreground green
FYEL="\[\033[33m\]" # foreground yellow
{
"version":{
"git.branch":"status-methods",
"git.message":"added last commit message to buildinfo",
"git.commit":"3dac634f99d19e65691fe529c3a6efd31da10959"
},
"db":{
"status":"OK",
"info":"DBTCPConnector: 127.0.0.1:27017 /127.0.0.1:27017",
"stats":{
//src
var filmToActor = g.Morphism().Out("/film/film/starring").Out("/film/performance/actor")
g.V().Has("name", "Casablanca").Save("name", "source").Follow(filmToActor).Tag("target").All()
//Output (note the different "source" values in first and remaining records):
{
"result": [
{
@digal
digal / gist:f6af29483cf8ff1dc5bc
Created June 24, 2014 14:30
swift gen result
enum ProtocolMessage : Printable, Equatable {
case Keepalive
case Hello(pubkey: NSData, password: String)
case Send(encodedMessage: NSData, toPubkey: NSData)
case HelloResponse
case Message(encodedMessage: NSData, fromPubkey: NSData)
var description: String {
get {
switch self {