Skip to content

Instantly share code, notes, and snippets.

@jsooriah
jsooriah / books.md
Created May 25, 2020 10:29 — forked from abstractart/books.md
Free Programming Ebooks - O'Reilly Media. Codeship free ebooks here - https://bit.ly/2oQ0knQ
@jsooriah
jsooriah / iOS-UploadImage.h
Created October 24, 2015 13:12 — forked from mombrea/iOS-UploadImage.h
example of a multi-part form post in objective-c
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";
@jsooriah
jsooriah / UINavigationController+Fade.h
Created October 2, 2015 12:51 — forked from ksm/UINavigationController+Fade.h
UINavigationController custom pop/push transition animation
/*
Copied and pasted from David Hamrick's blog:
Source: http://www.davidhamrick.com/2011/12/31/Changing-the-UINavigationController-animation-style.html
*/
@interface UINavigationController (Fade)
- (void)pushFadeViewController:(UIViewController *)viewController;
- (void)fadePopViewController;
@jsooriah
jsooriah / JS.js
Created November 12, 2012 17:36 — forked from mnmly/JS.js
// 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(", ")
@jsooriah
jsooriah / haml.rake
Created October 1, 2012 15:19 — forked from Catharz/haml.rake
Rake task to convert views from erb to haml
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}`
# 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
@jsooriah
jsooriah / gist:3664726
Created September 7, 2012 09:49 — forked from joel/gist:3090583
ARRAY.reject! { |c| c.empty? } vs ARRAY.reject!(&:empty?)
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
@jsooriah
jsooriah / NSAttributedString+height.h
Created April 18, 2012 13:51
Gives the height an NSAttributedString will take up when constrained to a given width.
#import <CoreText/CoreText.h>
@interface NSAttributedString (Height)
-(CGFloat)boundingHeightForWidth:(CGFloat)inWidth;
@end
@jsooriah
jsooriah / elasticoverflow.rb
Created May 3, 2011 17:03 — forked from karmi/elasticoverflow.rb
Importing and searching RSS with ElasticSearch and Tire
# =======================================================
# 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
# ------------
#