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
public abstract class MainThreadCallback implements Callback { | |
private static final String TAG = MainThreadCallback.class.getSimpleName(); | |
abstract public void onFail(final Exception error); | |
abstract public void onSuccess(final String responseBody); | |
@Override | |
public void onFailure(final Request request, final IOException e) { |
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
package codepath.com.recyclerviewfun; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class Contact { | |
private String mName; | |
private boolean mOnline; | |
public Contact(String name, boolean online) { |
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
# For Varnish NewRelic Tracking | |
# https://gist.github.com/2820068 | |
C{ | |
#include <stddef.h> | |
#include <stdio.h> | |
#include <sys/time.h> | |
}C | |
sub vcl_recv { |
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
# | |
# Add X-Request-Start header so we can track queue times in New Relic RPM beginning at Varnish. | |
# Taken from https://gist.github.com/494265 & modified to compile on OSX. | |
# | |
sub vcl_recv { | |
// NewRelic X-Request-Start tracking | |
C{ | |
#include </etc/varnish/newrelic.h> | |
}C |
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' | |
haystack = (1..1_000_000).to_a | |
needles = 1.upto(100).map {|n| n * 10_000} | |
module EachDetector | |
def self.find(haystack, needle) | |
haystack.each do |v| | |
return true if v == needle | |
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
# Credit to Mike Perham for this gem of an idea | |
# http://www.mikeperham.com/2007/12/17/creating-a-counter_cache-column/ | |
class RailsMigration < ActiveRecord::Migration | |
def self.up | |
add_column :media, :followers_count, :integer, :default => 0, :null => false | |
# Populate the media follower counter cache in one fell swoop. | |
sql = "update media, (select operable_id, count(*) as the_count from follow_operations "\ | |
"group by operable_id) as follows set media.followers_count = follows.the_count "\ | |
"where media.id = follows.operable_id;" |
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
# you can make as many tabs as you wish... | |
# tab names are actually arbitrary at this point too. | |
--- | |
- tab1: cd ~/foo/bar | |
- tab2: | |
- mysql -u root | |
- use test; | |
- show tables; | |
- tab3: echo "hello world" | |
- tab4: cd ~/baz/ && svn up |
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
project :test => :shoulda, :renderer => :haml, :stylesheet => :sass, :script => :jquery, :orm => :activerecord, :dev => true | |
#default routes | |
APP_INIT = <<-APP | |
get "/" do | |
"Hello World!" | |
end | |
get :about, :map => '/about_us' do | |
render :haml, "%p This is a sample blog created to demonstrate the power of Padrino!" |
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
project :test => :shoulda, :renderer => :haml, :stylesheet => :sass, :script => :jquery, :orm => :activerecord, :dev => true | |
#default routes | |
APP_INIT = <<-APP | |
get "/" do | |
"Hello World!" | |
end | |
get :about, :map => '/about_us' do | |
render :haml, "%p This is a sample blog created to demonstrate the power of Padrino!" |
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
$ padrino-gen project sample_blog -t shoulda -e haml -c sass -s jquery -d activerecord -b | |
create | |
create app/app.rb | |
create config/apps.rb | |
create config/boot.rb | |
create config.ru | |
create public/favicon.ico | |
create .gitignore | |
exist app | |
create app/controllers |
NewerOlder