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
@marcel
marcel / extractor.scala
Last active August 29, 2015 14:26
unapply tuple extraction
import scala.util.matching.Regex
import scala.util.matching.Regex.Match
trait RegexExtractor[M] {
def pattner: Regex
def unapply(line: String): Option[M] = {
pattern.findFirstMatchIn(line) map { matches =>
extractMatches(matches)
}
@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