Skip to content

Instantly share code, notes, and snippets.

@mlen
mlen / flac2alac
Last active May 8, 2024 15:36
FLAC to ALAC converter. Requires Mac OS X and `flac` binary installed (ie. via Homebrew: `brew install flac`).
#!/usr/bin/env bash
set -e
convert_to_alac() {
flac="$1"
aiff="${flac%.*}.aiff"
alac="${flac%.*}.m4a"
flac -s -d --force-aiff-format -o "$aiff" "$flac"
afconvert -f m4af -d alac "$aiff" "$alac"
import unittest
class Life(object):
def __init__(self, state):
self.state = state
def next(self):
cells_to_consider = set()
#
# Network services, Internet style
#
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, most entries here have two entries
# even if the protocol doesn't support UDP operations.
#
# The latest IANA port assignments can be gotten from
#
# http://www.iana.org/assignments/port-numbers
@mlen
mlen / audio-ping.sh
Created January 11, 2013 18:01
Ping with audio output!
audio-ping() {
ping $* 1>&2 |
while read; do say "ping"; done
}
@mlen
mlen / Blink.hs
Created December 27, 2013 20:48 — forked from puffnfresh/Blink.hs
@mlen
mlen / hack.sh
Created November 13, 2013 10:34 — forked from erikh/hack.sh
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@mlen
mlen / 0README.md
Created October 25, 2013 17:14 — forked from ion1/0README.md

What is inside Haskell IO?

<lambdabot> shachaf says: getLine :: IO String contains a String in the same
            way that /bin/ls contains a list of files

There are multiple ways IO could be implemented internally. Here’s a demonstration of one.

MiniIO (below) implements an ADT of arbitrarily chosen primitives that represent I/O operations and a way to combine them. One can create, evaluate and manipulate MiniIO values without causing any side effects to occur. That is what example in Main.hs does. The same applies to real IO values in Haskell: you can create a big list of print "hello"s and later pick which ones to actually execute.

@mlen
mlen / Main.hs
Last active December 25, 2015 07:39
import Natural
main = putStrLn . show $ x > 100
where x :: Natural
x = 1 + x
import System.MIDI
import System.MIDI.Utility
import Control.Concurrent
import Control.Monad
import Data.Maybe
import Data.IORef
import Data.Tuple
import Data.Map hiding (filter, map)
import Prelude hiding (lookup, null)
sudo cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage.original
# for Mountain Lion 10.8.3 - 10.8.4
sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x54)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
# for Mountain Lion 10.8.1-10.8.2 and Lion 10.7.5
#sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x4D)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
# for Mountain Lion 10.8.0 and Lion 10.7.4 BELOW
#sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x51)|