Skip to content

Instantly share code, notes, and snippets.

after :: String -> [String] -> [String]
after _ [] = []
after target (x:xs)
| isInfixOf target x = [x] ++ xs
| otherwise = after target xs
main = do
contents <- readFile "the-lake-isle-of-innisfree.txt"
putStr . unlines . after "glimmer" . lines $ contents
@martinos
martinos / local_io.rb
Created January 28, 2013 22:56
For testing io stdin and stdout interaction.
module SpecHelper
def local_io(in_str)
old_stdin, old_stdout = $stdin, $stdout
$stdin = StringIO.new(in_str)
$stdout = StringIO.new
yield
$stdout.string
ensure
$stdin, $stdout = old_stdin, old_stdout
end
@danchoi
danchoi / xmonad-ubuntu.md
Created October 20, 2012 14:39
Setting up Xmonad in Ubuntu Oneiric
@danchoi
danchoi / xmonad-lion.md
Created October 20, 2012 13:08
My Xmonad installation recipe for OS X Lion

My Xmonad recipe for OS X Lion

My recipe for setting up Xmonad on Ubuntu GNU/Linux is here.

What is xmonad? Read this page to learn.

Some of these instructions were adapted from the Source Matters Blog. But I also depart from those instructions in certain ways.

@MicahElliott
MicahElliott / rbenv-howto.md
Created April 17, 2012 18:11
Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

This guide enables you to install (ruby-build) and use (rbenv) multiple versions of ruby, isolate project gems (gemsets and/or bundler), and automatically use appropriate combinations of rubies and gems.

TL;DR Demo

# Ensure system is in ship-shape.

aptitude install git zsh libssl-dev zlib1g-dev libreadline-dev libyaml-dev

@heapwolf
heapwolf / frameworks.md
Created February 14, 2012 18:28
Be a hero fork a framework

Node.js and frameworks

Everyone has heard, “if all you have is a hammer, everything looks like a nail”. It’s an old adage that almost feels like cheap, dime store philosophy; especially in an echo chamber like Twitter where everything is a sound bite. But the cautionary tale it’s so famous for is profound and important to appreciate in the abstract world of software engineering.

Node.js by design is a very sparse platform. It’s primary purpose is to bind javascript to some parts of the operating system. It’s largely doctrine agnostic. And ultimately, users are left wondering where to start when they write a program.

Its not a nail

You first need to consider the scope of Node.js. It's much larger than that of a Web Server. Remember, it was made for easily building fast, scalable network applications. And Web Servers are a subset of network applications. Developers are coming from platforms where they spent almost 100% their time inside a Web Server. They want a nail, we can give them that. [

@avaitla
avaitla / server.hs
Created January 31, 2012 09:07
basic snap modified from jaspervdj
{-# LANGUAGE OverloadedStrings #-}
import Data.Char (isPunctuation, isSpace)
import Data.Monoid (mappend)
import Data.Text (Text)
import Control.Exception (fromException)
import Control.Monad (forM_)
import Control.Concurrent (MVar, newMVar, modifyMVar_, readMVar)
import Control.Monad.IO.Class (liftIO)
import qualified Data.Text as T
import qualified Data.Text.IO as T
@raimohanska
raimohanska / AesonTest.hs
Created December 2, 2011 20:53
Data.Aeson.Generic examples with Strings
{-# LANGUAGE OverloadedStrings, DeriveDataTypeable, NoMonomorphismRestriction #-}
module AesonTest where
import qualified Data.Aeson.Generic as A
import qualified Data.ByteString.Lazy as L8
import Data.Data
import Data.Typeable
import Codec.Binary.UTF8.String as U8
import Data.Maybe
@dbi
dbi / edit.html.mustache
Created May 4, 2011 09:31
Rails form helper for mustache spike/proof of concept
<!-- A scaffolded edit view converted to mustache -->
<h1>Editing post</h1>
{{#form}}
{{#errors?}}
<div id="error_explanation">
<h2>{{error_header}}</h2>
</div>
<ul>
@danchoi
danchoi / boston.sh
Created April 20, 2011 12:50
Weather forecast for Boston
#!/bin/bash
# Shows the weather forecast for Boston, MA
curl -s 'http://weather.noaa.gov/pub/data/forecasts/state/ma/maz007.txt' |
sed -n '/^TAB/,+11p; /BOSTON/,+3p'