Skip to content

Instantly share code, notes, and snippets.

require 'open-uri'
class ArchiveGeneratorService
class << self
def update
returning new do |generator|
generator.generate
generator.upload
end
end
end
@interface AddProjectTableViewController : UITableViewController <ABPeoplePickerNavigationControllerDelegate, AttributeUpdatesControllerOwner, CLLocationManagerDelegate, ReverseGeocoderDelegate, UIActionSheetDelegate, UINavigationControllerDelegate> {
@marcel
marcel / ReverseGeocoder.h
Created October 24, 2008 15:26
Small library to do reverse geocoding (translating a lat/lon pair into an address)
// Created by Marcel Molina Jr on 10/8/08.
//
#import <UIKit/UIKit.h>
#import <JSON/JSON.h>
#import <CoreLocation/CoreLocation.h>
@class ReverseGeocoder;
@protocol ReverseGeocoderDelegate
- (void)reverseGeocoder:(ReverseGeocoder *)geocoder
lookupReturnedAddress:(NSString *)address;
scala> val xml = <people>
| <person>
| <name>Ara</name>
| </person>
| <person>
| <name>Marcel</name>
| </person>
| </people>
xml: scala.xml.Elem =
<people>
curl -u USER:PASSWORD "http://twitter.com/statuses/friends_timeline.xml?count=3"|grep "<id>"
<id>4702392817</id>
<id>734493</id>
<id>4701231820</id>
<id>5768872</id>
<id>4700654729</id>
<id>23006794</id>
curl -u USER:PASSWORD "http://twitter.com/statuses/friends_timeline.xml?count=3&page=5"|grep "<id>"
<id>4695217538</id>
<id>5768872</id>
- identifier: 1
status_code: 400
message: "Error in 'since_id' parameter: invalid id."
name: invalid_since_id
- identifier: 2
status_code: 400
message: Invalid request.
lable: invalid_request
- identifier: 3
status_code: 400
module Twurl
class OAuthClient
class << self
def rcfile(reload = false)
if reload || @rcfile.nil?
@rcfile = RCFile.new
end
@rcfile
end
module Kernel
def m(object=Object.new, pattern=nil)
methods = object.public_methods(false).sort
methods = methods.grep pattern unless pattern.nil?
ObjectMethods.new(methods)
end
class ObjectMethods < Array
def inspect
puts sort
@marcel
marcel / gist:821588
Created February 10, 2011 23:19
Nested default procs
intersections = Hash.new do |h, k|
# k = segment type 1
h[k] = Hash.new do |h, k|
# k = segment value 1
h[k] = Hash.new do |h, k|
# k = segment type 2
h[k] = {}
end
end
end
@marcel
marcel / ConcurrentBlockingQueueConsumer.scala
Created March 24, 2011 22:43
Abstracts away the common pattern of producing items into a queue that are consumed concurrently by a pool of workers.
import java.util.concurrent.{BlockingQueue, ArrayBlockingQueue, CountDownLatch, Executors, TimeUnit}
/*
Abstracts away the common pattern of producing items into a queue that are
consumed concurrently by a pool of workers.
*/
class ConcurrentBlockingQueueConsumer[T](queue: BlockingQueue[T], producer: Iterator[T], concurrencyLevel: Int) {
lazy val stopLatch = new CountDownLatch(1)
lazy val pool = Executors.newFixedThreadPool(concurrencyLevel)