This file contains 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
In response to all the responses to: | |
http://twitter.com/rtomayko/status/1155906157 | |
You should never do this in a source file included with your library, | |
app, or tests: | |
require 'rubygems' | |
The system I use to manage my $LOAD_PATH is not your library/app/tests |
This file contains 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 -e | |
pkg=vim | |
mandir=/usr/share/man | |
bindir=/usr/local/bin | |
priority=30 | |
update-alternatives --install /usr/bin/vim vim $bindir/vim $priority | |
update-alternatives --install /usr/bin/vimdiff vimdiff $bindir/vim $priority |
This file contains 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 ActiveRecord::Base | |
before_validation :strip_whitespace_from_attributes!, :stringify_content_attributes! | |
private | |
# Will strip trailing and leading whitespace from all attributes and convert | |
# empty strings to nil. | |
def strip_whitespace_from_attributes! | |
for col in self.class.content_columns.collect{|c| c.name.to_sym} | |
if !self[col].nil? && self[col].respond_to?(:strip) |
This file contains 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
set :rails_env, :production | |
set :unicorn_binary, "/usr/bin/unicorn" | |
set :unicorn_config, "#{current_path}/config/unicorn.rb" | |
set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid" | |
namespace :deploy do | |
task :start, :roles => :app, :except => { :no_release => true } do | |
run "cd #{current_path} && #{try_sudo} #{unicorn_binary} -c #{unicorn_config} -E #{rails_env} -D" | |
end | |
task :stop, :roles => :app, :except => { :no_release => true } do |
This file contains 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
=begin | |
Author: Jabari Zakiya, Original: 2009-12-25 | |
Revision-2: 2009-12-31 | |
Revision-3: 2010-6-2 | |
Revision-4: 2010-12-15 | |
Revision-5: 2011-5-11 | |
Revision-6: 2011-5-15 | |
Module 'Roots' provides two methods 'root' and 'roots' | |
which will find all the nth roots of real and complex |
This file contains 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 | |
workspaces = {} | |
`wmctrl -d`.each_line do |line| | |
columns = line.split | |
if columns[7] == "N/A" | |
workspace_name = columns[8..-1].join(" ") | |
else | |
workspace_name = columns[9..-1].join(" ") | |
end |
This file contains 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
diff --git a/postgresql/9.0/main/pg_hba.conf b/postgresql/9.0/main/pg_hba.conf | |
index 18831d3..f0d0e1d 100644 | |
--- a/postgresql/9.0/main/pg_hba.conf | |
+++ b/postgresql/9.0/main/pg_hba.conf | |
@@ -80,13 +80,13 @@ | |
# (custom daily cronjobs, replication, and similar tasks). | |
# | |
# Database administrative login by UNIX sockets | |
-local all postgres ident | |
+# local all postgres trust |
This file contains 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
require 'rubygems' | |
require 'rack' | |
class Object | |
def webapp | |
class << self | |
define_method :call do |env| | |
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
[200, {}, send(func, *attrs)] | |
end |
This file contains 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
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776 | |
$ cd /usr/src | |
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz | |
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz | |
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz | |
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz | |
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz |
This file contains 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
# config/environment/development.rb: | |
# require 'lib/sc_middleware' | |
# config.middleware.use ScMiddleware | |
class ScMiddleware | |
def initialize(app) | |
@app = app | |
SC::Rack::Service.filesystem = true | |
@project = SC::Project.load(File.dirname(__FILE__)+"/../public/self_video", :parent => SC.builtin_project) | |
@sproutcore = SC::Rack::Service.new([@project]) |
OlderNewer