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
# ======================================================= | |
# Importing and searching RSS with ElasticSearch and Tire | |
# ======================================================= | |
# | |
# This script downloads, parses and indexes Stackoverflow RSS feed with ElasticSearch | |
# via the [Tire](https://github.com/karmi/tire) Rubygem. | |
# | |
# Requirements | |
# ------------ | |
# |
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
#import <CoreText/CoreText.h> | |
@interface NSAttributedString (Height) | |
-(CGFloat)boundingHeightForWidth:(CGFloat)inWidth; | |
@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
require 'benchmark' | |
N = 10000 | |
ARRAY = begin | |
[].tap do |array| | |
(1..1000).to_a.each do |entry| | |
array << '' if rand(5) == 0 | |
array << entry.to_s | |
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
# Author: Pieter Noordhuis | |
# Description: Simple demo to showcase Redis PubSub with EventMachine | |
# | |
# Update 7 Oct 2010: | |
# - This example does *not* appear to work with Chrome >=6.0. Apparently, | |
# the WebSocket protocol implementation in the cramp gem does not work | |
# well with Chrome's (newer) WebSocket implementation. | |
# | |
# Requirements: | |
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby |
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 ToHaml | |
def initialize(path) | |
@path = path | |
end | |
def convert_all! | |
Dir["#{@path}/**/*.erb"].each do |file| | |
haml_file = file.gsub(/\.erb$/, '.haml') | |
puts "Converting #{File.basename(file)} to #{File.basename(haml_file)}" | |
`html2haml -rx #{file} #{haml_file}` |
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
// Page init code is at the bottom | |
var Map = (function(map, $){ | |
var exports = map || {}; | |
var geo = new google.maps.Geocoder(), | |
geocode = { | |
address: [ config.project_location.street, | |
config.project_location.city, | |
config.project_location.country].join(", ") |
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
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"REST URL PATH"]]; | |
NSData *imageData = UIImageJPEGRepresentation(image, 1.0); | |
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; | |
[request setHTTPShouldHandleCookies:NO]; | |
[request setTimeoutInterval:60]; | |
[request setHTTPMethod:@"POST"]; | |
NSString *boundary = @"unique-consistent-string"; |