An implementation of Conway's Game of Life in 140 characters of Ruby.
Created by Simon Ernst (@sier).
An implementation of Conway's Game of Life in 140 characters of Ruby.
Created by Simon Ernst (@sier).
| module Extensions | |
| module_function | |
| def separate(path) | |
| extensions = path.reverse | |
| .scan(/\G\w+\./) | |
| .map { |e| e[0..-2].reverse } | |
| .reverse | |
| file_name = path.split(".")[0..-(extensions.size + 1)].join(".") | |
| [file_name, extensions] |
| module Mokha | |
| class HomeController < Mokha::BaseController | |
| def index | |
| @view = Mokha::HomePresenter.new | |
| @view.user = User.includes(:ratings).find(current_user) | |
| @view.user.track('Opened Mokha') | |
| end |
| module MyApp | |
| class Money | |
| include Mongoid::Fields::Serializable | |
| def cast_on_read?; true; end | |
| def deserialize(object) | |
| return nil if object.blank? | |
| ::Money.new(object[:cents] || object["cents"], object[:currency] || object["currency"]) | |
| end |
| web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb |
| <% [:notice, :error, :alert, :success].each do |level| %> | |
| <% unless flash[level].blank? %> | |
| <div class="alert alert-<%= flash_class(level) %>"> | |
| <a class="close" href="#">×</a> | |
| <%= content_tag :p, flash[level] %> | |
| </div> | |
| <% end %> | |
| <% end %> |
| #!/bin/sh | |
| VBM=VBoxManage | |
| VMNAME="smartos2" | |
| VBDIR="/Users/me/Documents/VirtualBox" | |
| DISK=1024 # 1GB | |
| RAM=1024 # 1GB | |
| VRAM=128 # arbitrary | |
| mkdir -p "${VBDIR}/${VMNAME}" && cd "${VBDIR}/${VMNAME}" | |
| [[ -f ${VMNAME}.iso ]] || curl -C - -o "${VMNAME}.iso" https://download.joyent.com/pub/iso/latest.iso | |
| $VBM createvm --name $VMNAME --ostype OpenSolaris_64 --register |
| module CheapStrings | |
| def `(str) | |
| str | |
| end | |
| end | |
| module A | |
| extend CheapStrings | |
| def self.make_lots_of_strings |
In this article, I'll walk through a basic Rails (3.2.x) setup for creating a nested resource for two models. Nested resources work well when you want to build out URL structure between two related models, and still maintain a RESTful convention. This code assumes you are running RVM to manage Ruby/Gem versions, and Git for version control.
$ mkdir family # create rvm gemset
$ echo "rvm use --create ruby-1.9.2@family" > family/.rvmrc
$ cd family # install rails
$ gem install rails # create new rails project
$ rails new . # version control | When starting a project that includes refinerycms-blog: | |
| $ rake refinery:override view=refinery/pages/* | |
| $ rake refinery:override view=layouts/* | |
| $ rake refinery:override view=refinery/blog/shared/* | |
| $ rake refinery:override view=refinery/blog/posts/* | |
| $ rake refinery:override view=refinery/* | |
| $ rake refinery:override controller=refinery/blog/* | |
| $ rake refinery:override controller=refinery/* |