Skip to content

Instantly share code, notes, and snippets.

View cobalamin's full-sized avatar
👾

Simon Welker cobalamin

👾
View GitHub Profile
@cobalamin
cobalamin / CarbonCopy.dvtcolortheme
Last active August 29, 2015 14:21
CarbonCopy, a Xcode6 color theme utilising the Input font family and the Polychromatic plugin
<?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">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.770437 0.783913 0.778299 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Menlo-Bold - 11.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0.770437 0.783913 0.778299 1</string>
@cobalamin
cobalamin / UIViewKeyframeAnimationOptionsExtension.swift
Created June 24, 2015 08:33
Using all UIViewAnimationOptions as UIViewKeyframeAnimationOptions
// This enables using all available UIViewAnimationOptions enum values as UIViewAnimationOptions in a Swifty way,
// by brute-force bridging all values with an explicit extension to UIViewKeyframeAnimationOptions.
//
// Thus, code like
//
// let o1 : UIViewKeyframeAnimationOptions = .CalculationModeLinear
// let o2 : UIViewAnimationOptions = .CurveLinear
// let os : UIViewKeyframeAnimationOptions = [o1, UIViewKeyframeAnimationOptions(o2.rawValue)]
//
// becomes:
@cobalamin
cobalamin / FlipVars.swift
Created June 24, 2015 09:29
Swift operator to flip the values of two variables
infix operator >!< {
associativity left
precedence 140
}
func >!<<T>(inout a: T, inout b: T) {
(a, b) = (b, a)
}
// example:
@cobalamin
cobalamin / List.hs
Created April 16, 2016 17:08
My own Haskell list implementation, as an exercise. It has instances for Functor, Applicative, Monad, Monoid, Foldable and Traversable, and a decent enough Show instance
module List where
data List a = Cons a (List a) | Empty
(+++) :: List a -> List a -> List a
(+++) Empty ys = ys
(+++) (Cons x xs) ys = Cons x (xs +++ ys)
instance (Show a) => Show (List a) where
show xs = "<" ++ show' xs ++ ">"
module Noop (
Noop(..),
noop
) where
-- Groundbreaking work to do nothing safely
import Control.Applicative
import Control.Monad
newtype Noop a = Noop { runNoop :: a -> () }
-- Groundbreaking work to do nothing except be unsafe all the time
-- Don't export NoNoop data constructor so users can't construct a safe NoNoop
module NoNoop (
makeNoNoop,
runNoNoop,
NoNoop
) where
import System.IO.Unsafe
@cobalamin
cobalamin / JSIdentifier.hs
Last active April 28, 2016 12:33
JSIdentifier
--- this is fun :o
import Text.Trifecta
import qualified Data.CharSet as CS
import qualified Data.CharSet.Unicode as U
(<>) :: Monoid m => m -> m -> m
(<>) = mappend
startOfIdentifier :: CS.CharSet
@cobalamin
cobalamin / gjhc.sh
Created May 11, 2016 21:09
The Glorious Good Job Haskell Compiler
#!/bin/bash
### THE GLORIOUS GOOD JOB HASKELL COMPILER
compliments=(
"Wow, what a monad!"
"Outstanding work with the types."
"You look beautiful today, and so does your code."
"Hey, that's pretty good."
"Nice meme."
"\"If it compiles, it works\"? -- Well, I'm just the compiler, what would I know. But it did compile, so, well done."
@cobalamin
cobalamin / HaskellAtomStart.md
Last active April 2, 2021 15:00
Getting Haskell Up And Running with Atom

[ work in progress ]

Getting Haskell Up And Running

Foreword

Hi there! So you heard about Haskell, the programming language. You might have seen some simple Hello World examples, you might have not, but anyways: now you are wondering how you're going to get something in Haskell running on your computer. Worry not, we will work through it.

This tutorial is intended for total beginners and is thus intentionally verbose at times. The information collected here is available in a lot of other places, but I try to be extra beginner-friendly through a gentle style. It is written to be used with the text editor Atom (we will set it up in the course of this!), but there'll be links to instructions for some other common editors.

@cobalamin
cobalamin / .bashrc
Created May 19, 2016 17:13
Bash function to (freshly) build and run the executable for a standard Stack project.
# Uses rather unreliable heuristic from the current path name
stack-buildrun() {
stack clean &&
stack build &&
stack exec "`pwd | xargs basename`-exe"
}