Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# This script will setup Evm (Emacs Version Manager) and Cask on
# Travis to use for Emacs Lisp testing.
#
# In .travis.yml, add this:
#
# - curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw > x.sh && source ./x.sh
#
# Emacs 24.3 is installed in the above script because Cask requires
@canweriotnow
canweriotnow / chruby_ruby-build.sh
Last active August 13, 2019 10:46 — forked from havenwood/chruby_ruby-build.sh
On Debian, Ubuntu, or Mint: install Ruby 2.3.1 with chruby and ruby-build, ruby-install, and gem_home
# Install apt-get packages:
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
# Install chruby:
cd
wget https://github.com/downloads/postmodern/chruby/chruby-0.3.9.tar.gz
tar -xzvf chruby-0.3.9.tar.gz
cd chruby-0.2.3
sudo make install
App = new Marionette.Application();
App.addRegions {
"headerRegion": "#header"
"topMenuRegion": "#top-menu"
"mainRegion" : "#main"
}
App.on 'initialize:after', ->
Backbone.history.start()
# db/migrate/XXXXXXXXXXXXX_add_authentication_token_to_users.rb
class AddAuthenticationTokenToUsers < ActiveRecord::Migration
def change
add_column :users, :authentication_token, :string
add_index :users, :authentication_token, :unique => true
end
end

Polymorphic Associations reversed

It's pretty easy to do polymorphic associations in Rails: A Picture can belong to either a BlogPost or an Article. But what if you need the relationship the other way around? A Picture, a Text and a Video can belong to an Article, and that article can find all media by calling @article.media

This example shows how to create an ArticleElement join model that handles the polymorphic relationship. To add fields that are common to all polymorphic models, add fields to the join model.

@canweriotnow
canweriotnow / gist:2492535
Created April 25, 2012 19:25 — forked from thommahoney/gist:2491946
RailsConf 2012 Lightning Talks
5 min:
~Objective-C + Rails:
Communicating w/rails from iOS/mac OS
Dan Hassin
1 min:
~Painless Javascript
koting hatduklgg
with wind tunnel
@canweriotnow
canweriotnow / unicorn
Created July 5, 2011 17:38
/etc/init.d script for unicorn
#!/bin/sh
#
# init.d script for single or multiple unicorn installations. Expects at least one .conf
# file in /etc/unicorn
#
# Modified by jay@gooby.org http://github.com/jaygooby
# based on http://gist.github.com/308216 by http://github.com/mguterl
#
## A sample /etc/unicorn/my_app.conf
##