Skip to content

Instantly share code, notes, and snippets.

View jmervine's full-sized avatar

Joshua Mervine jmervine

View GitHub Profile
@jmervine
jmervine / gist:2127051
Created March 19, 2012 20:58
nginx default proxy example for rails
server {
#root /usr/share/nginx/www;
root /home/myuser/blog/public;
index index.html index.htm;
server_name app.hostname;
location ~ ^/assets/ {
root /home/myuser/blog/app/assets/$1;
@jmervine
jmervine / gist:2127559
Created March 19, 2012 22:08
example unicorn config file
worker_processes 2 # setting this low for aws t1.micro
listen "0.0.0.0:3000"
pid "/home/myuser/project/log/unicorn.pid"
stderr_path "/home/myuser/project/log/unicorn_stderr.log"
stdout_path "/home/myuser/project/log/unicorn_stdout.log"
#############################################################
# Aliases
#############################################################
#
# print time
alias t="date +%H:%M"
# print date
alias d="date +%b-%d-%Y"
*/5 * * * * bash -c 'IPADDR=`cat /tmp/myip.txt` perl -e 's/^(.*)home\.remotehost/$ENV{'IPADDR'} home.remotehost/g' -p -i /etc/hosts'
*/5 * * * * bash -c 'echo `wget -q -t 5 --output-document=- "http://automation.whatismyip.com/n09230945.asp"` > /tmp/myip.txt && scp /tmp/myip.txt <remote_host>:/tmp/myip.txt'
$ sudo cat /etc/nginx/sites-enabled/blog
server {
server_name blog.mervine.net;
location / {
proxy_pass http://f2h1gg.tumblr.com;
}
}
$ sudo ls -al /etc/nginx/sites-enabled/blog
lrwxrwxrwx 1 root root 23 2012-03-18 00:23 /etc/nginx/sites-enabled/blog
@jmervine
jmervine / app.rb
Created May 23, 2012 20:10
Sinatra Mobile Detection using rack-mobile-detect
require 'sinatra'
helpers do
def get_layout
@layout_default = ( request.env['X_MOBILE_DEVICE'] ? :layout_mobile : true )
end
end
before do
get_layout()
require 'mongomapper'
class Collection
include MongoMapper::Document
# default collection name is "collections" which
# looks for 'db.collections' in mongo.
set_collection_name "some_collections"
# new collection name is "some_collections" which
# looks for 'db.some_collections' in mongo.
var post_count = function() {
db.posts.find( { "_type" : /^Ditty/ } );
}
var update_posts = function() {
db.posts.update( { "_type" : "Ditty::Post" }, { $set : { "_type" : "Post" } }, true, true);
}
var tag_count = function() {
db.tags.find( { "_type" : /^Ditty/ } );
@jmervine
jmervine / newrelic.yml
Created June 16, 2012 19:30
Default NewRelic Configuration
#
# This file configures the New Relic Agent. New Relic monitors
# Ruby, Java, .NET, PHP, and Python applications with deep visibility and low overhead.
# For more information, visit www.newrelic.com.
#
# Generated June 16, 2012
#
# This configuration file is custom generated for AT&T Interactive
# Here are the settings that are common to all environments: