Skip to content

Instantly share code, notes, and snippets.

@tomjadams
tomjadams / gist:70639
Created February 26, 2009 03:44 — forked from DylanFM/gist:70625
Without the destructive update
# sans destructive update
def f(rss, n)
rss.inject(0) {|acc, rs| rs.include?(n) ? acc + 1 : acc}
end
+ (FKEither *)doParseContent:(NSString *)rssContent {
PXRss20ParserDelegate *parser = [[PXRss20ParserDelegate alloc] initWithContent:rssContent];
FKEither *maybeItems = [parser.parse.right map:[NSArray liftFunction:[FKFunction functionFromSelector:@selector(parseItem:)]]];
[parser release];
return maybeItems;
}
+ (PXRss20Item *)parseItem:(NSDictionary *)item {
return [PXRss20Item title:[item objectForKey:@"item"] link:[NSURL URLWithString:[item objectForKey:@"link"]] description:[item objectForKey:@"description"]];
}
#!/bin/sh
NUM_CORES=2
FJ_ARTIFACTS_DIR=/home/me/functionaljava/artifacts/latest
cd FJ_ARTIFACTS_DIR
javac -d /tmp/ -classpath functionaljava.jar demo/1.5/concurrent/Fibs.java
java -classpath /tmp/:functionaljava.jar concurrent.Fibs ${NUM_CORES}
module UserAgentHelper
def on_iphone_like_device?
request && (request.user_agent =~ /iPhone/ || request.user_agent =~ /iPod.*AppleWebKit.*Mobile.*Safari/)
end
end
// OLD
- (NSDictionary *)parsePerks:(NSArray *)perks {
NSMutableArray *convertedPerks = [NSMutableArray arrayWithCapacity:[perks count]];
for (NSDictionary *perk in perks) {
PLPerk *convertedPerk = [[PLPerk alloc] initWithProgramName:[perk objectForKey:@"program_name"]
shortDescription:[perk objectForKey:@"perk_title"] longDescription:[perk objectForKey:@"perk_desc"]
location:[self parseLocation:[perk objectForKey:@"locations"]]];
[convertedPerks addObject:convertedPerk];
[convertedPerk release];
package com.foo.http
import scapps.http.BaseApp
import scapps.http.route.OptionKleisli._
import scapps.http.route.Route._
import scalaz._
import scalaz.http.servlet.{HttpServletRequest}
import scalaz.http.response._
import scalaz.http.request._

Interesting FP Reading

Papers

  • [Why Functional Programming Matters][whyfp]
  • [Applicative Programming with Effects][app]
  • [The Essence of the Iterator Pattern][iter]
  • [Generalising Monads to Arrows][arrows]
@tomjadams
tomjadams / notes.md
Created July 25, 2011 11:36 — forked from nkpart/notes.md
My Lion Install Notes
@tomjadams
tomjadams / pr.md
Created March 23, 2014 23:26 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

(1..2).each { |i| puts i }