View lark_template.rb
# download and git methods swiped from http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb | |
require 'open-uri' | |
def download(from, to = from.split("/").last) | |
#run "curl -s -L #{from} > #{to}" | |
file to, open(from).read | |
rescue | |
puts "Can't get #{from} - Internet down?" | |
exit! |
View sync.rake
# app:sync | |
# Local and production synchronization | |
# - require yaml_db plugin | |
namespace :app | |
namespace :sync do | |
task :all => [:files, :db] | |
task :files do | |
`rsync -azv user@host:'/apps/myawesomeapp/shared/files/' #{Rails.root + 'files'}` |
View customdomain.rb
require 'net/dns/resolver' | |
# Custom Domain | |
# | |
# Require net-dns gem | |
# | |
# A Rack middleware to to resolve the custom domain to original subdomain | |
# for your multi telent application. | |
# | |
# It's all transperant to your application, it performs cname lookup and |
View gist:171192
border: 8px solid #000; | |
-moz-border-bottom-colors: #555 #666 #777 #888 #999 #aaa #bbb #ccc; | |
-moz-border-top-colors: #555 #666 #777 #888 #999 #aaa #bbb #ccc; | |
-moz-border-left-colors: #555 #666 #777 #888 #999 #aaa #bbb #ccc; | |
-moz-border-right-colors: #555 #666 #777 #888 #999 #aaa #bbb #ccc; | |
padding: 5px 5px 5px 15px; |
View gist:211379
# you'd obviously have more settings somewhere | |
set :scm, :git | |
set :repository, "git@github.com:defunkt/github.git" | |
set :branch, "origin/master" | |
set :migrate_target, :current | |
set(:latest_release) { fetch(:current_path) } | |
set(:release_path) { fetch(:current_path) } | |
set(:current_release) { fetch(:current_path) } |
View gist:287043
# Requires mod_deflate | |
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript | |
BrowserMatch ^Mozilla/4 gzip-only-text/html | |
BrowserMatch ^Mozilla/4\.0[678] no-gzip | |
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html |
View gist:324562
class UserAgent | |
attr_reader :browser, :version, :os | |
def initialize(browser, version, os) | |
@browser = browser | |
@version = version | |
@os = os | |
end | |
def self.parse(uas) |
View authentication.rb
# include this in application controller | |
module Authentication | |
protected | |
# Inclusion hook to make #current_user and #signed_in? | |
# available as ActionView helper methods. | |
def self.included(base) | |
base.send :helper_method, :current_user, :signed_in?, :authorized? if base.respond_to? :helper_method | |
end | |
# Returns true or false if the user is signed in. |
View loops.js
var myname = "Rhadney Capili"; | |
// for loop | |
for (var i=0; i < 10; i++) { | |
document.write(myname + "<br />"); | |
}; | |
// while loop | |
var i = 0; | |
while (i<10) { |
View gist:516123
var numbers = new Array(5); | |
numbers[0] = "10"; | |
numbers[1] = "20"; | |
numbers[2] = "30"; | |
numbers[3] = "40"; | |
numbers[4] = "50"; | |
for (var i=0; i < numbers.length; i++) { | |
if(numbers[i] != 30) { | |
document.write(numbers[i] + "<br />"); |
OlderNewer