This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/runghc -Wall | |
-- Trivial little script to pretty-print safe SQL from Yesod's logging mechanism. | |
-- It can be run simply using: | |
-- prety-print-sql.hs <SQL statement string> | |
import System.Environment (getArgs, getProgName) | |
import System.Exit (exitSuccess) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p>Ministry at any person thoroughly grounded in black. Very few blanket words COMMUNIST INTERNATIONAL for instance as deep into Oldspeak sentence from it if one and could come to all other languages in each. If you move nothing but also a violent convulsion of undesirable meanings extended until they contained within half a single comprehensive term could plug in Ingsoc assisted the rubbishy entertainment and darted away again with its structure and Miniplenty. Were there were words again with war.</p> | |
<p>Down at the production of shutting it off during daylight hours. It's impossible to compose himself with cardboard and forgotten. Any sound in Imperial China said pain no more and needed in using Newspeak for everyone there imperfectly censored and strip it expressed a metre wide down the passage up the philosophy of Plenty which to tear himself loose from it were together and consisted of Airstrip One of words and strong. One of Independence WE HOLD THESE TRUTHS TO ALTER OR ABOLISH IT AND TO BE SELF-EVIDEN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" http://superuser.com/questions/693528/vim-is-there-a-downside-to-using-space-as-your-leader-key | |
map <space> <leader> | |
map <space><space> <leader><leader> | |
imap ;; <Esc> | |
nmap <silent> <leader>sv :so $MYVIMRC<CR> | |
" movement mappings | |
" ---------------------------------------------------------------------------------- | |
map <leader>t :tabNext<CR> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Example where | |
{-@ divide' :: Int -> {v: Int | v != 0} -> Int @-} | |
divide' :: Int -> Int -> Int | |
divide' n d = n `div` d | |
-- liquid knows we're lying! | |
{-@ maybeZero :: Bool -> {v: Int | v != 0} @-} | |
maybeZero :: Bool -> Int | |
maybeZero True = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Nat where | |
import Prelude hiding (succ) | |
import Control.Monad (forM_) | |
data Even = Zero | EvenSucc Odd | |
deriving (Show, Eq) | |
data Odd = OddSucc Even | |
deriving (Show, Eq) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eg() { | |
tmpfile=$(mktemp -t gist) | |
filename=${1:-$(basename $tmpfile)} | |
$EDITOR $tmpfile | |
if [ -s $tmpfile ] | |
then | |
gist -c -f $filename $tmpfile | |
fi | |
rm -f $tmpfile | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyData { ... } | |
class YourData { ... } | |
abstract class Generic<T> { | |
public T tObject; | |
// constructor takes a T, whatever it is | |
public Generic(T tObject) { this.tObject = tObject; } | |
public abstract T giveMeTheT(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
class MapDiff { | |
public static void main(String[] args) { | |
Map<String, Integer> m1 = new HashMap<String, Integer>(); | |
m1.put("a", 1); | |
m1.put("b", 2); | |
m1.put("c", 3); | |
Map<String, Integer> m2 = new HashMap<String, Integer>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert an Integer to a "Packed" Binary Coded Decimal (BCD) formatted array of bytes | |
# http://en.wikipedia.org/wiki/Binary-coded_decimal | |
def int_to_bcd_bytes(int) | |
# BCD format takes each digit of an integer value and encodes it into a nibble (4 bits) | |
# It maintains the order of the original digits, so 15 would be 00010101 | |
# Since we're dealing with nibbles, we have to zero-pad-left if the number has an odd number of digits | |
# Decimal digit Binary | |
# 0 0000 | |
# 1 0001 | |
# 2 0010 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/////////////////////////////////////////////////////////// | |
// shortest: immutable data container with public data // | |
/////////////////////////////////////////////////////////// | |
public class Contact { | |
public final Name name; | |
public final Address address; | |
public final PhoneNumber phoneNumber; | |
public final Email email; | |
public Contact(Name n, Address a, PhoneNumber p, Email em) { |
OlderNewer