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 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
# 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
#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
(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
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
#!/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
/* Navn: Nikolaj Lepka | |
Email: [email protected] | |
Gruppe: A425b | |
Studieretning: Datalogi */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#define DAYSIZE 4 | |
#define TEAMSIZE 4 |
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
#include <stdlib.h> | |
#include <stdio.h> | |
#include "list.h" | |
DEFINE_LIST(int); /* defines the int_list type */ | |
int main(void) { | |
int_list *lst = EMPTY; | |
PUSH(8, &lst, int_list); | |
PUSH(4, &lst, int_list); |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace Utilities | |
{ | |
static class Pair | |
{ | |
public static Pair<T1, T2> Make<T1, T2>(T1 fst, T2 snd) |