This file contains hidden or 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
| 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") |
This file contains hidden or 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
| #!/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] %> |
This file contains hidden or 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
| 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 { |
This file contains hidden or 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
| #!/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' |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| 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' |
This file contains hidden or 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
| def notify | |
| @user = User.find(params[:id]) | |
| if @user.is_expert? | |
| @topic.experts << @user | |
| end | |
| @user.notify_about_topic!(@topic) | |
| end |
This file contains hidden or 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
| #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 |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| # 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) |