Skip to content

Instantly share code, notes, and snippets.

View andrewmcodes's full-sized avatar
🌱

Andrew Mason andrewmcodes

🌱
View GitHub Profile
@jbaudanza
jbaudanza / config.ru
Created February 8, 2011 21:55
Example of an asynchronous rack based app on heroku
# config.ru
#
# The Heroku architecture is based on Thin, which is based on EventMachine. This means
# you can access the EventMachine API and make use of Thin's asynchronous extension to
# the rack API.
#
# This is a simple asynchronous rack backed app that will hold a request for 4 seconds
# and respond with "Hello".
#
# In theory an app structured like this should be able to handle a huge number of
require 'sunspot_ext/resque_session_proxy'
require 'sunspot_ext/resque_index_job'
Sunspot.session = Sunspot::ResqueSessionProxy.new(Sunspot.session)
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@kurko
kurko / spec_helper.rb
Created February 29, 2012 21:37
Sunspot with RSpec
#inside RSpec.configure
config.before :all do
SunspotTest.stub
end
config.before(:all, search: true) do
SunspotTest.setup_solr
Sunspot.remove_all!
Sunspot.commit
@ttscoff
ttscoff / matrixish.sh
Created September 15, 2012 18:23
A Matrix-ish display for Bash terminal
#!/bin/bash
#
# matrix: matrix-ish display for Bash terminal
# Author: Brett Terpstra 2012 <http://brettterpstra.com>
# Contributors: Lauri Ranta and Carl <http://blog.carlsensei.com/>
#
# A morning project. Could have been better, but I'm learning when to stop.
### Customization:
blue="\033[0;34m"
@Integralist
Integralist / rules for good testing.md
Last active April 24, 2024 15:09
Sandi Metz advice for writing tests

Rules for good testing

Look at the following image...

...it shows an object being tested.

You can't see inside the object. All you can do is send it messages. This is an important point to make because we should be "testing the interface, and NOT the implementation" - doing so will allow us to change the implementation without causing our tests to break.

@icyleaf
icyleaf / ar_migrate.rb
Last active May 5, 2024 14:55
ActiveRecord type of integer (tinyint, smallint, mediumint, int, bigint)
# activerecord-3.0.0/lib/active_record/connection_adapters/mysql_adapter.rb
# Maps logical Rails types to MySQL-specific data types.
def type_to_sql(type, limit = nil, precision = nil, scale = nil)
return super unless type.to_s == 'integer'
case limit
when 1; 'tinyint'
when 2; 'smallint'
when 3; 'mediumint'
when nil, 4, 11; 'int(11)' # compatibility with MySQL default
@rkjha
rkjha / nginx-config-rails4-with-puma-ssl-version.conf
Last active November 2, 2023 11:57
Nginx config for rails 4 application using puma [ssl and non-ssl version]
upstream myapp_puma {
server unix:/tmp/myapp_puma.sock fail_timeout=0;
}
# for redirecting to https version of the site
server {
listen 80;
rewrite ^(.*) https://$host$1 permanent;
}
@bosskovic
bosskovic / Gemfile
Last active September 21, 2022 14:24
Devise as authentication solution for rails API
gem 'devise', '3.2.4'
gem 'simple_token_authentication', '1.5.0'
@montanaflynn
montanaflynn / check_for_dependencies.sh
Last active January 23, 2023 13:39
Checking for dependencies in a shell script
# Easy way to check for dependencies
checkfor () {
command -v $1 >/dev/null 2>&1 || {
echo >&2 "$1 required";
exit 1;
}
}
checkfor "ffmpeg"