Tables | Are | Cool |
---|---|---|
col 3 is | right-aligned | $1600 |
col 2 is | centered | $12 |
zebra stripes | are neat | $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Issue < ActiveRecord::Base | |
named_scope :tasks, :conditions => {:tracker_id => 7} # if the id of the Tasks tracker is 7, natch | |
named_scope :open, :conditions => {:status_id => 1} # assuming 'Open' == 1 | |
end | |
# Then in your controller action: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns oraclj.util.date | |
(:import [java.sql Timestamp]) | |
(:use [clojure.string])) | |
(defn gregorian-to-julian | |
[date-map] | |
(let [year (:year date-map) | |
month (:month date-map) | |
day (:day date-map) | |
hour (:hour date-map) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 min: | |
~Objective-C + Rails: | |
Communicating w/rails from iOS/mac OS | |
Dan Hassin | |
1 min: | |
~Painless Javascript | |
koting hatduklgg | |
with wind tunnel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'http://rubygems.org' | |
gem 'rake', '0.8.7' | |
gem 'rails', '~> 3.0.7' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' | |
# New Relic monitoring |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ::ActionDispatch::Request | |
def local? | |
if Rails.env == 'production' | |
false | |
else | |
super | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xAPI.md:4: MD001 Header levels should only increment by one level at a time | |
xAPI.md:189: MD001 Header levels should only increment by one level at a time | |
xAPI.md:368: MD001 Header levels should only increment by one level at a time | |
xAPI.md:440: MD001 Header levels should only increment by one level at a time | |
xAPI.md:530: MD001 Header levels should only increment by one level at a time | |
xAPI.md:671: MD001 Header levels should only increment by one level at a time | |
xAPI.md:804: MD001 Header levels should only increment by one level at a time | |
xAPI.md:817: MD001 Header levels should only increment by one level at a time | |
xAPI.md:984: MD001 Header levels should only increment by one level at a time | |
xAPI.md:1109: MD001 Header levels should only increment by one level at a time |
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
puts "How much IP do you have?" | |
ip_have = STDIN.gets.chomp #don't really need the STDIN | |
puts "Which champion do you want to buy?" | |
champion_want = STDIN.gets.chomp | |
lucian = #{lucian_value} #The #{} construct is for inside double-quoted strings, otherwise # just indicates a comment. | |
lucian_value = 6300 | |
puts "#{champion_want} is #{champion_want} IP, so this means you need #{lucian_value} - #{ip_have}" #The math has to happen inside the #{} block... also, ip_have is read as a String, need to convert to an integer. |