This file contains 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
{- This is the IRC protocol parser I'm using at http://github.com/peat/hbot ... look there for the most recent code -} | |
{-# OPTIONS_GHC -fno-warn-unused-do-bind #-} | |
module Message where | |
import Text.ParserCombinators.Parsec | |
import Data.Foldable (asum) | |
import Data.List (intercalate) | |
import Data.List.Split (splitOn) |
This file contains 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
case class MyClass( a:String, b:Int, c:Seq[String] ) | |
def derp:Either[String,MyClass] = { | |
val myA = goGetA match { | |
case Left(v) => return Left(v) | |
case Right(v) => v | |
} | |
val myB = goGetB match { |
This file contains 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
public Option<Int> myRiskyMethod() { | |
Option<Int> x = findSomeValue(); | |
Option<Int> y = ohNoFailure(); | |
return x.apply( new Add(), y ); | |
} |
This file contains 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
friend_bucket = AWS::S3.new.buckets[ ... ] | |
follower_bucket = AWS::S3.new.buckets[ ... ] | |
friend_obj = friend_bucket.objects[ ... ] | |
follower_obj = follower_bucket.objects[ ... ] | |
threads = [] | |
threads << Thread.new do | |
friend_obj.write( data, :content_type => ... ) |
This file contains 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/sh | |
# | |
# Pulls updates for your repos, including registered submodules. | |
# | |
# Put this file in the directory containing all yer git repos. | |
GITS=`find . -type d -name .git` | |
START=`pwd` | |
for i in $GITS; do |
This file contains 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
; To run these examples (assuming you have homebrew installed): | |
; | |
; $ brew install leiningen | |
; ... | |
; $ lein repl | |
; | |
; ... this drops you into the Clojure REPL (Read, Evaluate, Print, Loop). | |
; | |
; Copy and paste the lines below and play around. |
This file contains 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
FOO=/long/path/to/some/file.rb | |
echo ${FOO##*/} |
This file contains 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
<a href="https://github.com/peat" rel="me">GitHub</a> | |
<a href="https://twitter.com/peat" rel="me">Twitter</a> | |
<a href="sms:+15037014135" rel="me">SMS</a> |
This file contains 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
<link rel="openid.server" href="https://indieauth.com/openid" /> | |
<link rel="openid.delegate" href="http://peat.org/" /> |
This file contains 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
SMALL_WORDS = %w{a an and as at but by en for if in of on or the to v v. via vs vs.} | |
def titleize( sentence ) | |
capped_words = sentence.downcase.split(" ").map do |word| | |
SMALL_WORDS.include?(word) ? word : word.capitalize | |
end | |
capped_words[0] = capped_words[0].capitalize unless capped_words.empty? | |
capped_words.join(" ") |
OlderNewer