Skip to content

Instantly share code, notes, and snippets.

View gertig's full-sized avatar

Andrew Gertig gertig

View GitHub Profile
@gertig
gertig / hack.sh
Created March 31, 2012 12:05 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@gertig
gertig / 0_instructions.txt
Created March 30, 2012 14:42 — forked from stan/0_instructions.txt
Sprocket 2 in Rails 3.0.x ala Rails 3.1
Some brief instructions on how to use Sprocket 2 in Rails to get CoffeeScript
powered JS and SASS powered CSS with YUI compression all via the magic of rack.
This stuff will be native in Rails 3.1 and the layout of the files on the
filesystem will be different but this guide will get you working with it
while we wait for all that to finalize.
Ignore the number prefixes on each file. This is just to ensure proper order in the Gist.
It's based on eric1234 gist https://gist.github.com/911003. ijust made it 3.1 compliant in terms of convention
@gertig
gertig / embedifyiframe.html
Created March 21, 2012 17:36
Embedify iframe
<iframe src="http://embedify.heroku.com/datapoints/" width=100% height=200px >
This is an in-line frame. You can <a href="framesrc.html">view the frame</a> and then hit your back arrow to return to the page.
</iframe>
@gertig
gertig / test.html
Created March 21, 2012 17:35
Embedify
<script type="text/javascript" src="http://embedify.heroku.com/widget/datapoints/"></script>
@gertig
gertig / gist:1989090
Created March 6, 2012 21:36
Replace double quotes with two single quotes
var str = "Dear diary "this" is a string with quotes."
str.replace(/"([^"]*)"/g, "''$1''");
- (void)viewDidLoad {
self.currentPage = 0;
self.dataSource = [[NSMutableArray alloc] init];
}
- (void)fetchData {
[[SVHTTPClient sharedClient] GET:@"https://api.github.com/users/AndrewGertig/watched"
parameters:[NSDictionary dictionaryWithValue:[NSNumber numberWithInt:self.currentPage] forKey:@"page"]
completion:^(id response, NSError *error) {
[self.dataSource addObjectsFromArray:response];
@gertig
gertig / api.rb
Created January 6, 2012 03:31 — forked from lucatironi/api.rb
Snippets for an API with grape
# Server App
# This file must be in lib/myapp/api.rb
module MyApp
module Entities
class Products < Grape::Entity
expose :id, :code, :name, :short_description
expose :description, :unless => { :collection => true }
expose (:category) { |model, options| model.category.name }
expose (:brand) { |model, options| model.brand.name }
end
@gertig
gertig / hn_scraper.rb
Created November 12, 2011 15:38
grab top stories from hacker news (supports pagination)
require 'rubygems'
require 'nokogiri'
require 'open-uri'
def is_numeric_or_short(str)
return str.length <= 5
end
url = "http://news.ycombinator.com"
doc = Nokogiri::HTML(open(url))
@gertig
gertig / peepcode.rb
Created August 18, 2011 20:40 — forked from jmazzi/peepcode.rb
A script to download all Peepcode screencasts with ruby & wget (supports resume)
require 'mechanize'
@username = 'user@domain.com'
@password = 'hi2u'
@download_path = File.expand_path 'downloads'
@wget_cookie = File.expand_path(File.dirname(__FILE__)) + '/wget-cookies.txt'
unless File.directory? @download_path
puts "@{download_path} doesn't exist!"
exit
@gertig
gertig / devise_ajax_signup
Created August 17, 2011 19:31
Devise Ajax Signup
#registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
def create
params[:user][:password_confirmation] = params[:user][:password]
super
end
end
<!-- Inside any View --->
<%= form_for(:user, :url => "#", :html => { :id => "ajax_signup"}) do |f| %>