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
The Traveling Hacker -------------------- | |
Today you will be building a tool for a travel agency that determines the | |
total distance traveled on a tour with many stops. As luck would have it, some | |
of the core functionality you need has already been implemented, and you won't | |
need to worry about coding a mileage and routing system from scratch. | |
But there's a catch: The mileage and routing system you'll be using lies on | |
the other side of a service boundary, and only minimal work has been done on | |
the client side. Essentially, all that has been written so far is a bit of |
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
// As see on: http://cocoawithlove.com/2008/10/sliding-uitextfields-around-to-avoid.html | |
#import <Foundation/Foundation.h> | |
static const CGFloat KEYBOARD_ANIMATION_DURATION = 0.3; | |
static const CGFloat MINIMUM_SCROLL_FRACTION = 0.2; | |
static const CGFloat MAXIMUM_SCROLL_FRACTION = 0.8; | |
static const CGFloat PORTRAIT_KEYBOARD_HEIGHT = 216; | |
static const CGFloat LANDSCAPE_KEYBOARD_HEIGHT = 162; |
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
// need an algebraic data structure | |
// a..e are defined as meta param names | |
// f variable will hold all the declared Algebraic Data Types | |
newdata("Maybe", function(spec){ | |
// the data constructor name as key | |
// the parameters specified as an array | |
spec["Just"] = [a]; | |
spec["Nothing"] = []; | |
}); |
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
{-# LANGUAGE NoMonomorphismRestriction #-} | |
module Tree where | |
-- Example of how ADT's work by implementing the List type | |
-- data List a | |
-- = EmptyList -- [] | |
-- | ConsList a (List a) -- (1:[]) | |
-- (1:2:[]) | |
-- (ConsList 1 (ConsList 2 EmptyList)) |
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
{-# LANGUAGE TypeSynonymInstances, NoMonomorphismRestriction #-} | |
module Iteratee where | |
import Control.Applicative hiding (many) | |
import Control.Monad (liftM, ap) | |
import Data.Char (isSpace, isAlpha) | |
import Data.Monoid | |
import qualified Prelude as P | |
import Prelude hiding (head, break) |
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
{-# LANGUAGE FlexibleInstances #-} | |
module Database.MongoDB.Extensions where | |
import Database.MongoDB hiding (find) | |
import Data.List (find) | |
import Control.Monad ((=<<)) | |
import Data.ByteString (ByteString) | |
import qualified Data.ByteString as B | |
instance Val (Maybe Value) where | |
val Nothing = Null |
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
{-# LANGUAGE MultiParamTypeClasses, GeneralizedNewtypeDeriving #-} | |
import Data.Char | |
import Control.Monad | |
import Control.Monad.State | |
type ErrorMessage = String | |
data User = User { | |
name :: String | |
, age :: Int |
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
class Proc | |
alias_method :old_call, :call | |
public | |
def curried? | |
!!@curried | |
end | |
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
#!/usr/bin/ruby | |
# | |
# This script installs to /usr/local only. To install elsewhere you can just | |
# untar https://github.com/mxcl/homebrew/tarball/master anywhere you like. | |
# | |
# | |
# 30th March 2010: | |
# Added a check to make sure user is in the staff group. This was a problem | |
# for me, and I think it was due to me migrating my account over several | |
# versions of OS X. I cannot verify that for sure, and it was tested on |
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
{-# LANGUAGE OverloadedStrings #-} | |
{-| | |
This is where all the routes and handlers are defined for your site. The | |
'site' function combines everything together and is exported by this module. | |
-} | |
module Site |