Skip to content

Instantly share code, notes, and snippets.

@dnagir
dnagir / faster_helper.rb
Created June 28, 2012 23:55
Fast specs with Rails
ENV["RAILS_ENV"] ||= 'test'
cur_dir = File.expand_path(File.dirname(__FILE__) + '/..')
$LOAD_PATH << "#{cur_dir}"
if defined? Rails
# Most likely going with the full env
puts "Running faster_helper with full Rails env..."
# Eagerly load the Rails so that stubbed dependencies still work
# http://stackoverflow.com/questions/11133712/using-rails-model-that-is-already-declared
@jasoncodes
jasoncodes / gist:1938675
Created February 29, 2012 06:59
Default `psql` to current Rails application
function __database_yml {
if [[ -f config/database.yml ]]; then
ruby -ryaml -rerb -e "puts YAML::load(ERB.new(IO.read('config/database.yml')).result)['${RAILS_ENV:-development}']['$1']"
fi
}
function psql
{
if [[ "$(__database_yml adapter)" == 'postgresql' ]]; then
PGDATABASE="$(__database_yml database)" "$(/usr/bin/which psql)" "$@"
@Yaffle
Yaffle / gist:1284012
Last active April 2, 2018 08:03
javascript base64 encode/decode
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script type="text/javascript">
var nativeAtob = window.atob;
var nativeBtoa = window.btoa;
// http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#atob
(function (global) {
"use strict";
@anathematic
anathematic / Ruby on Rails server config.md
Last active September 26, 2015 22:58
Quick notes for Ruby 2 + postgres on Ubuntu 13.4

Security / user config

Ruby + basic permissions

sudo /usr/sbin/groupadd rvm
sudo /usr/sbin/usermod -a -G wheel,rvm USERNAME 
sudo apt-get install build-essential git-core curl python-software-properties libsasl2-dev mailutils
sudo su -

\curl -L https://get.rvm.io | bash -s stable --ruby

@tatey
tatey / transmitter_importer.rb
Created April 30, 2011 09:58
Import terrestrial transmitter data into an SQLite database for use in Antenna Mate (http://antennamate.com).
#!/usr/bin/env ruby
# Import terrestrial transmitter data into an SQLite database for use in
# Antenna Mate (http://antennamate.com).
#
# Supported Regions:
# Australia - http://www.acma.gov.au/scripts/nc.dll?WEB/STANDARD/1001/pc=PC_9150
# United States - http://www.fcc.gov/mb/video/tvq.html
#
# Usage:
@troex
troex / unicorn.sh
Created April 4, 2011 20:57
Unicorn start/stop/restart script for Debian
#!/bin/sh
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $local_fs $remote_fs mysql
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: unicorn initscript
# Description: Unicorn is an HTTP server for Rack application
### END INIT INFO
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@marijn
marijn / README.markdown
Last active October 1, 2023 13:42
List of countries in YAML, CSV and TXT format
@marijn
marijn / README.markdown
Last active May 3, 2024 14:09
List of nationalities in YAML, CSV and TXT format

List of nationalities

It's time someone compiled a list of nationalities to use within a web application. This gist attempts to make a first move at that.

List of countries

I've also compiled a list of countries