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 'https://rubygems.org' | |
gem 'rails', '3.2.1' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' | |
gem 'haml-rails' |
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
# This configuration file works with both the Compass command line tool and within Rails. | |
require 'compass/h5bp' | |
# Require any additional compass plugins here. | |
project_type = :rails | |
# Set this to the root of your project when deployed: | |
http_path = "/" |
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 ApiController < ApplicationController | |
def integer_to_string | |
render :json => { :value => params[:value] }.to_json | |
end | |
def concat | |
sum = params[:a] + params[:b] | |
render :soap => { :value => sum }.to_json | |
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
<%= { :new_form => render(:partial => 'blah/form.html.haml') }.to_json -%> |
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
a = [0, 2, 3] | |
a[3, 1] ## => [] # official special case | |
a[4, 1] ## => nil | |
a[5, 1] ## => nil | |
## | |
a = [0, 1, 2, 3] |
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 Sensitive < ActiveRecord::Base | |
attr_accessor :plain_data | |
attr_protected :encrypted_data, :encrypted_key, :encrypted_iv | |
before_save :encrypt_sensitive | |
def decrypt_sensitive(password) | |
if self.encrypted_data | |
private_key = OpenSSL::PKey::RSA.new(File.read(APP_CONFIG['private_key']),password) | |
cipher = OpenSSL::Cipher::Cipher.new('aes-256-cbc') |
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
<!-- haml --> | |
%blockquote | |
I am not running for president. - | |
%strong | |
everyone | |
, ever | |
<!-- html --> |
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
server { | |
listen 443; | |
ssl on; | |
ssl_certificate /opt/nginx/conf/server.crt; | |
ssl_certificate_key /opt/nginx/conf/server.key; | |
server_name www.sub.domain.com; | |
root /Users/Dan/code/my_app/public; | |
passenger_enabled on; | |
keepalive_timeout 70; | |
} |
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
# lib/some_presenter | |
class some_presenter | |
attr_accessor :my_object | |
def initialize(some_object) | |
self.my_object = some_object | |
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
debugger | |
// $form.serialize => "authenticity_token=H38DglaC0V2fJYzFyVwmzl83iqPpgbrCbxjYeHwPoWI%3D&comment%5Bcontent%5D=adf&commit=Post+Comment" | |
$form.ajaxSubmit({ | |
//$.ajax({ | |
url: form.action + '.json', | |
data: $form.serialize(), | |
type: 'post', | |
//dataType: 'json', | |
context: $form.parent(".responses, #comments"), | |
success: insertComment }); |