Skip to content

Instantly share code, notes, and snippets.

View fzf's full-sized avatar

Fletcher Fowler fzf

View GitHub Profile
@henrik
henrik / hash_deep_diff.rb
Created July 14, 2009 08:38
Recursively diff two Ruby hashes.
# Recursively diff two hashes, showing only the differing values.
# By Henrik Nyh <http://henrik.nyh.se> 2009-07-14 under the MIT license.
#
# Example:
#
# a = {
# "same" => "same",
# "diff" => "a",
# "only a" => "a",
# "nest" => {
@davist11
davist11 / gist:1204569
Last active January 19, 2024 15:03
Campfire sounds
56k: "https://123.campfirenow.com/images/56k.gif"
bell: ":bell:"
bezos: ":laughing::thought_balloon:"
bueller: "anyone?"
butts: ":open_hands: :smoking:"
clowntown: "https://123.campfirenow.com/images/clowntown.gif"
cottoneyejoe: ":notes::hear_no_evil::notes:"
crickets: "hears crickets chirping"
dadgummit: "dad gummit!! :fishing_pole_and_fish:"
dangerzone: "https://123.campfirenow.com/images/dangerzone.png"
@atomicbird
atomicbird / NSObject+setValuesForKeysWithJSONDictionary.h
Created January 11, 2012 02:35
NSObject category for handling JSON dictionaries. Described in detail at http://www.cimgf.com/2012/01/11/handling-incoming-json-redux/
//
// NSObject+setValuesForKeysWithJSONDictionary.h
// SafeSetDemo
//
// Created by Tom Harrington on 12/29/11.
// Copyright (c) 2011 Atomic Bird, LLC. All rights reserved.
//
#import <Foundation/Foundation.h>
@schneems
schneems / gist:1705468
Created January 30, 2012 17:09
Receive GZIP params in Rails
def handle_gzip_params
# When the server receives a request with content-type "gzip/json" this will be called which will unzip it,
# and then parse it as json
# The use case is so clients such as Android or Iphone can zip their long request such as Inviters#addressbook emails
# Then the server can unpack the request and parse the parameters as normal.
if request.content_type == "gzip/json"
data = ActiveSupport::JSON.decode(ActiveSupport::Gzip.decompress(request.raw_post))
data = {:_json => data} unless data.is_a?(Hash)
params ||= {}
@chriseidhof
chriseidhof / nsincrementalstore.markdown
Created February 18, 2012 16:39
Accessing an API using CoreData's NSIncrementalStore

Accessing an API using CoreData's NSIncrementalStore

Note: the original location of this article is on my blog, however, it is posted here too for better readability.

In this article, we will see how to use Core Data for accessing your API. We will use the Bandcamp API as our running example. I've only been experimenting with this code for a few days, so there might be mistakes in there.

@fzf
fzf / nsincrementalstore.markdown
Created May 14, 2012 06:07 — forked from chriseidhof/nsincrementalstore.markdown
Accessing an API using CoreData's NSIncrementalStore

Accessing an API using CoreData's NSIncrementalStore

Note: the original location of this article is on my blog, however, it is posted here too for better readability.

In this article, we will see how to use Core Data for accessing your API. We will use the Bandcamp API as our running example. I've only been experimenting with this code for a few days, so there might be mistakes in there.

@ashirazi
ashirazi / .irbrc
Created July 19, 2012 18:54
pry instead of irb (everywhere including 'bundle console', 'rails console', 'irb')
# put this in your ~/.irbrc
begin
require 'pry'
Pry.start
exit
rescue LoadError
puts "Pry not found, using 'irb' instead. Try\n gem install pry"
end
@simonpang
simonpang / gist:3754248
Created September 20, 2012 06:22
Upload photo to server
#pragma mark DLCImagePickerControllerDelegate
-(void) imagePickerControllerDidCancel:(DLCImagePickerController *)picker{
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:NO];
[self dismissModalViewControllerAnimated:YES];
}
- (void)uploadMediaInfo:(NSDictionary *)info {
UIImage *resizedImage = [[info objectForKey:@"image"] imageCroppedToFitSize:CGSizeMake(800, 800)];
NSData *jpegData = UIImageJPEGRepresentation(resizedImage, 0.5);
@dariocravero
dariocravero / README.md
Created October 20, 2012 05:25
Save files in Meteor

Create a Meteor app and put the client_/server_ files in a client/server directories. Also, create a public dir to save the uploaded files.

@jkotchoff
jkotchoff / emailed_zip_file_extractor.rb
Created November 29, 2016 00:23
Rails example of how to connect to the Gmail API using Ruby and download a Zip File attachment and then unzip contents from the zip archive
class EmailedZipFileExtractor
# This class downloads an email from gmail and extracts a file out of a .zip attachment
require 'google/apis/gmail_v1'
require 'googleauth'
require 'zip'
# These credentials come from creating an OAuth Web Application client ID
# in the Google developer console
#