Skip to content

Instantly share code, notes, and snippets.

View kidpollo's full-sized avatar
💁‍♂️
Potato farming

Paco Viramontes kidpollo

💁‍♂️
Potato farming
  • San Francisco, CA
View GitHub Profile
working_directory '<%= @app_dir %>/current/'
worker_processes <%= @workers %>
listen '<%= @app_dir %>/shared/tmp/pids/<%= @app_name %>.sock', :backlog => 1024
timeout 60
pid "<%= @app_dir %>/shared/tmp/pids/<%= @app_name %>.pid"
# Based on http://gist.github.com/206253
logger Logger.new("log/unicorn.log")
#!/bin/sh
set -u
set -e
# Example init script, this can be used with nginx, too,
# since nginx and unicorn accept the same signals
# Feel free to change any of the following variables for your app:
APP_ROOT=<%= @app_dir %>/current
PID=<%= @app_dir %>/shared/tmp/pids/<%= @app_name %>.pid
ENV=<%= @node[:environment][:framework_env] %>
if ($host ~* ^([^.]+\.[^.]+)$) {
set $host_without_subdomain $1;
rewrite ^\/(\w+)(\/.*)$ http://$1.$host_without_subdomain$2 break;
}
upstream empowerkit {
server unix:/data/example/shared/tmp/pids/example.sock;
}
server {
#!/usr/bin/env ruby
## Taken from: http://snippets.dzone.com/posts/show/4935
#
# Usage:
# a = AmazonS3Asset.new
# a.copy_over_bucket("myapp_production", "myapp_production")
require 'aws/s3'
require 'mechanize'
require 'logger'
module Processors
class ImagesProcessor
def initialize(queue, image_cache_options = {})
@queue = queue || {}
@image_cache = Processors::ImageCache.new(image_cache_options)
@logger = CSV_PROCESSOR_LOG
end
it 'should notify user and add to leader board if user is an expert' do
user = mock_model(User, :is_expert? => true)
topic = mock_model(Topic, :id => 1)
collection = mock('col')
collection.should_receive(:<<).with(user)
topic.should_receive(:experts).and_return(collection)
user.should_receive(:notify_about_topic!).with(topic)
User.should_receive(:find).with(1).and_return(user)
Topic.should_receive(:find).with(1).and_return(topic)
post :notify, :topic_id => topic.id, :id => 1, :format => 'js'
def notify
@user = User.find(params[:id])
if @user.is_expert?
@topic.experts << @user
end
@user.notify_about_topic!(@topic)
end
@kidpollo
kidpollo / git.sh
Created March 4, 2011 18:35
Useful git commands
#make a new branch that tracks remote branche
git branch --set-upstream foo upstream/foo
#list the files modified on the last 10 commits and filter only spec files
git diff --name-only HEAD~10 | egrep _spec\.rb
#difference between the state of the file from 3 commits in the past
git diff HEAD~3 -- app/views/topics/merges/_new.html.haml
#run specs modified on the last 10 commits
@kidpollo
kidpollo / gist:962080
Created May 9, 2011 05:00
Tanker Gist
class Product < ActiveRecord::Base
include Tanker
tankit 'my_index' do
indexes :name
indexes :description
end
after_save :update_tank_indexes
after_destroy :delete_tank_indexes
# When searching, you need to provide a latitude and longitude
# in the query so that
# these variables are accessible on the server.
Restaurant.search_tank("tasty",
:var0 => 47.689948,
:var1 => -122.363684,
# And we'll return all results sorted by distance
:function => 1)