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
numeronym :: String -> String | |
numeronym a@(x:[]) = a | |
numeronym a@(x:y:[]) = a | |
numeronym x = (head x):(middle x) ++ [last x] where | |
middle = show . length . init . tail |
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
// lib.rs | |
pub mod tokenizer { | |
use std::str::Chars; | |
// use std::fs::read_to_string; | |
pub struct WSP<'a> { | |
text: Chars<'a>, | |
curr: String, | |
punc: Option<String>, |
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 Beer (song) where | |
import Data.Char (toLower) | |
song :: String | |
song = go 99 "" where | |
go (-1) acc = acc | |
go n acc = go (n - 1) $ acc ++ (bottleLine n ++ takeOneLine n) | |
showBottles :: Int -> String |
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 Control.Monad.State | |
import qualified Data.Sequence as S | |
data St = St { offsets :: S.Seq Int | |
, pos :: Int | |
, moves :: Int | |
} | |
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
use std::collections::HashMap; | |
#[derive(Debug, Eq, PartialEq)] | |
struct Cell<'a> { | |
row: u32, | |
column: u32, | |
neighbors: HashMap<Direction, &'a Cell<'a>>, | |
} | |
impl<'a> Cell<'a> { |
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
(ns noc.pv) | |
(defprotocol IPVec | |
(x [x] "get X") | |
(y [y] "get Y") | |
(z [z] "get Z")) | |
(extend-protocol IPVec | |
clojure.lang.PersistentVector | |
(x [v] (first v)) |
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 RenamerMixin(serializers.Serializer): | |
def to_internal_value(self, data): | |
for key, value in self.renamed.iteritems(): | |
data[value] = data.pop(key) | |
return super(RenamerMixin, self).to_internal_value(data) |
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 SetOn<T> { | |
contents: T[]; | |
constructor(private identFunction: (a: T) => any, initialContents: T[] = []) { | |
for (let o of initialContents) { | |
this.add(o); | |
} | |
} | |
private areEq(a: T, b: T) { | |
return this.identFunction(a) === this.identFunction(b); | |
} |
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
# /wherever/setup_pgb.sh | |
#! /bin/bash | |
mkdir /var/run/pgbouncer | |
chown samuelraker:staff /var/run/pgbouncer | |
# /Library/LaunchDaemons/setup_pgb.plist | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> |
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
def mono(a, b): | |
""" | |
Maybe monad-esque reducing function to determine monotonicity | |
""" | |
if a is False: | |
return False | |
elif a > b: | |
return False | |
else: | |
return b |
NewerOlder