Skip to content

Instantly share code, notes, and snippets.

View muscar's full-sized avatar

Alex Muscar muscar

View GitHub Profile
#!/bin/bash
while true; do
echo "(Re-)starting server on port $1"
/server -port $1
done
alex@Sapiens lyst (bac-1830-pg-mod-analytics-migration) $ cat ~/.zprezto/modules/prompt/functions/prompt_gentoo_setup
#
# A theme that resembled the gentoo default prompt.
#
# Authors:
# Alex Muscar <muscar@gmail.com>
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Screenshots:
#
class Node
macro def accept(visitor) : LLVM::Value
visitor.visit self
end
end
...
def visit(node: ReturnStmtNode)
val = node.value.accept self
function git_add_modified
for f in (git ls-files -m)
if y_or_n "Add $f?"
git add $f
end
end
end
function git_show_modified_filed
for sha in (git log -n $argv[1] | grep commit | cut -d' ' -f2)
@muscar
muscar / gist:9bc1e7e818d51c059dda
Created July 9, 2014 14:57
Unsafe optionals in Swift
func tryIncUnsafe(n: Int!) -> Int? {
return n + 1
}
@muscar
muscar / gist:3732f15691e33ea5b04b
Created July 9, 2014 14:56
Unsafe optionals in Swift
func tryInc(n: Int?) -> Int? {
if let x = n {
return x + 1
}
return nil
}
class Person {
let age: Int
init(age: Int) {
self.age = age
}
}
let p1: Person? = Person(age: 27)
let p2: Person? = nil
func tryInc(n: Int?) -> Int? {
if let x = n {
return x + 1
}
return nil
}
func tryIncUnsafe(n: Int!) -> Int? {
return n + 1
}
@muscar
muscar / expr.cpp
Created January 11, 2014 10:51
A simple language
struct expr { };
struct num : expr
{
int value;
num(int value) : value(value) { }
};
struct plus : expr
//
// main.cpp
// wirth
//
// Created by Alex Muscar on 6/20/13.
// Copyright (c) 2013 Alex Muscar. All rights reserved.
//
#include <iostream>
#include <vector>