Skip to content

Instantly share code, notes, and snippets.

View willywos's full-sized avatar
🐥
Living el pollo loco

Willy willywos

🐥
Living el pollo loco
View GitHub Profile
@willywos
willywos / gitbashprofile
Created November 24, 2011 05:55
bash profile with git
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
PS1="\\[$(tput setaf 7)\\]\\w \$(parse_git_branch)> \\[$(tput sgr0)\\]"
@willywos
willywos / gitio
Created January 5, 2012 04:25 — forked from defunkt/gitio
Turn a github.com URL into a git.io URL.
#!/usr/bin/env ruby
# Usage: gitio URL [CODE]
#
# Turns a github.com URL
# into a git.io URL
#
# Copies the git.io URL to your clipboard.
url = ARGV[0]
code = ARGV[1]
@willywos
willywos / gist:3329664
Created August 12, 2012 04:09
Calling same method on different objects in ruby
#
# This is the base class
# for the classes below.
# Each class calls :register which
# saves its self into subclasses
#
# When the display method is called on
# the base class it loops through the collection
# insdie @@subclasses and if the instance method
@willywos
willywos / form_builder.rb
Created August 31, 2012 15:49
Add required mark to methods in a form.
#config/initializers/form_builder.rb
class ActionView::Helpers::FormBuilder
alias :orig_label :label
def label(method, content_or_options = nil, options = nil, &block)
if content_or_options && content_or_options.class == Hash
options = content_or_options
else
content = content_or_options
@willywos
willywos / unicorn.rb
Created October 9, 2012 01:44
unicorn.rb
# 2 workers and 1 master
worker_processes 2
# Load the app into the master before forking workers for fast worker spawn times
preload_app true
# Restart any workers that haven't responded in 30 seconds
timeout 30
pid "/tmp/unicorn.my_site.pid"
@willywos
willywos / nginx.conf
Created October 9, 2012 01:47
nginx.conf
worker_processes 1;
user nobody nogroup;
pid /tmp/nginx.pid;
error_log /tmp/nginx.error.log;
events {
worker_connections 1024; # increase if you have lots of clients
# Set this to on if you have more than 1 working processes
@willywos
willywos / gist:4277008
Created December 13, 2012 15:11
Websnap example on heroku
#The code in the rake task looks like this:
#lib/tasks/scheduler.rake
desc "Updates the images for winter conditions"
task :update_images => :environment do
puts "Updating Images"
WinterCondition.update_images
puts "Done Updating Images"
end
@willywos
willywos / State.rb
Created March 21, 2013 19:50
State.rb - Ruby Class to deal with the United States of AMERICA!
class State
#usage:
#State.new.state_by_abbreviation("WY")
#=> "Wyoming"
#State.new.abbreviation_by_state("Wyoming")
#=> "WY"
#State.new.abbreviations
#-Returns all abbreviations
#State.new.names
#-Returns all States Names
# config/initializers/database_limits.rb
module ActiveRecord
module ConnectionAdapters
module DatabaseLimits
def index_name_length
#this is a monkey patch to get the ms sql db schema to work in sqlite.
#errors with the names in sql server being to long for sqlite cause of
#of the original 64 character limit. Switch it to 84 to allow the longer
#names.
84
<html>
<head>
<title>dug.js - Retriever dropdown</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>