This file contains hidden or 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
| #!/bin/bash | |
| function compile-c() { | |
| if [ $# -eq 0 ] | |
| then INPUT="*.c" | |
| else INPUT="$1.c" | |
| fi | |
| gcc -ansi -pedantic -Wall -Werror $INPUT -o program | |
| } |
This file contains hidden or 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
| function setup-latex() { | |
| if [ $# -eq 0 ] | |
| then FILENAME="default.tex" | |
| else FILENAME="$1.tex" | |
| fi | |
| echo "Creating $FILENAME for you..." | |
| touch $FILENAME | |
| echo "\documentclass[12pt, a4paper]{article}" > $FILENAME | |
| echo "\usepackage[utf8]{inputenc}" >> $FILENAME |
This file contains hidden or 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
| (defun copy-to-clipboard () | |
| (interactive) | |
| (if (region-active-p) | |
| (progn (shell-command-on-region | |
| (region-beginning) (region-end) | |
| "pbcopy") | |
| (message "Copied region to clipboard!") | |
| (deactivate-mark)) | |
| (message "No mark set."))) |
This file contains hidden or 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
| #pbcopy only exists on OSX (as far as I know), for linux find an equivalent | |
| function cp-file-contents() { | |
| if [ $# -eq 0 ] | |
| then echo "Missing arguments" | |
| elif [ $# -gt 1 ] | |
| then echo "Too many arguments" | |
| else | |
| cat $1 | pbcopy | |
| echo "contens copied" | |
| fi |
This file contains hidden or 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
| # Fancy prompt | |
| # \u = user, \H = hostname, \D = formatted date, \A 24-hour time in hours:minutes | |
| # \w = full path of current working directory, with ~ as home, \$ for # when root and $ when user | |
| # example output: | |
| # ╓[ElectricCoffee]─[coffeebook-pro]─[2014-09-22, 21:58]─[~/Desktop] | |
| # ╙[$]-[ | |
| PS1="╓[\u]─[\H]─[\D{%Y-%m-%d}, \A]─[\w]\n╙[\$]-[" |
This file contains hidden or 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
| package extension.monad | |
| trait Monad[A, M[_]] { | |
| // >>= :: Monad m => m a -> (a -> m b) -> m b | |
| def flatMap[B](input: A => M[B]): M[B] // AKA "bind" | |
| } | |
| trait Functor[A, F[_]] { | |
| // fmap :: Functor f => (a -> b) -> f a -> f b | |
| def map[B](input: A => B): F[B] // AKA "fmap" |
This file contains hidden or 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
| package com.wausoft.extensions | |
| object SafeString { | |
| class StrOps(input: String) { | |
| private def toOption[A](in: => A) = try { | |
| Some(in) | |
| } catch { | |
| case _: Throwable => None | |
| } |
This file contains hidden or 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
| package com.wausoft.core | |
| import com.wausoft.dice.Die | |
| import com.wausoft.dice.Die.Multiple | |
| object Program extends App { | |
| // define the five different Grime Dice | |
| val red = new Die("red" , 4, 4, 4, 4, 4, 9) | |
| val olive = new Die("olive" , 5, 5, 5, 5, 5, 0) | |
| val blue = new Die("blue" , 7, 7, 7, 2, 2, 2) |
This file contains hidden or 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
| /* | |
| * The premise of this is simple; it allows you to chain subroutines without using a block | |
| * The idea comes from Haskell's Monads, where by language design you can't normally | |
| * predict the order of statement execution due to the language being lazy, | |
| * so instead an operator was added that allowed you to call statements sequencially | |
| * | |
| * Rather than writing something like this: | |
| * def printStuff(): Unit = { | |
| * println("blah") | |
| * println("bloo") |
This file contains hidden or 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
| package io.wausoft | |
| import org.joda.time.{Seconds, DateTime} | |
| import scala.collection.mutable | |
| case class Ack(m: Int, n: Int) | |
| object Program extends App { | |
| // Basic ackermann without cache, overflows at around Ack(3,11) after a few seconds | |
| def compute(a: Ack): Int = a match { |