Skip to content

Instantly share code, notes, and snippets.

View zacksiri's full-sized avatar
💜
Building the Future of Software / Arming the Rebels

Zack Siri zacksiri

💜
Building the Future of Software / Arming the Rebels
View GitHub Profile
@zacksiri
zacksiri / hello.coffee
Created February 5, 2014 14:14
CoffeeScript example
console.log "Hello World"
superheroes = ["superman", "thor", "batman"]
for hero in superheroes
console.log hero
person_1 =
name: "Zack"
email: 'zack@artellectual.com'
require 'benchmark'
class Selector
def initialize(key)
@key = key
end
def selector_if
if @key == :success
defmodule Bank do
use Application.Behaviour
# See http://elixir-lang.org/docs/stable/Application.Behaviour.html
# for more information on OTP Applications
def start(_type, _args) do
Bank.Supervisor.start_link
end
def start do
(0..10).each do |i|
"/Users/blah/#{i}.html"
end
@zacksiri
zacksiri / gist:1049034
Created June 27, 2011 15:02
Mongoid Validation error
mongoid (2.0.2) lib/mongoid/relations/referenced/many.rb:219:in `block in load!'
mongoid (2.0.2) lib/mongoid/relations/referenced/many.rb:217:in `tap'
mongoid (2.0.2) lib/mongoid/relations/referenced/many.rb:217:in `load!'
mongoid (2.0.2) lib/mongoid/relations/referenced/many.rb:400:in `method_missing'
i18n (0.5.0) lib/i18n/exceptions.rb:41:in `block in initialize'
i18n (0.5.0) lib/i18n/exceptions.rb:41:in `each'
i18n (0.5.0) lib/i18n/exceptions.rb:41:in `initialize'
i18n (0.5.0) lib/i18n/backend/base.rb:37:in `new'
i18n (0.5.0) lib/i18n/backend/base.rb:37:in `translate'
i18n (0.5.0) lib/i18n.rb:155:in `translate'
@zacksiri
zacksiri / gist:1049044
Created June 27, 2011 15:06
user form page
<%= form_for @user, validate: true do |f| %>
<% if @user.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
<ul>
<% @user.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
@zacksiri
zacksiri / gist:1049056
Created June 27, 2011 15:13
User Model
class User
include Mongoid::Document
devise :database_authenticatable,:registerable,:omniauthable,:recoverable, :rememberable, :trackable , :timeoutable , :confirmable #, :validatable
devise :encryptable, :encryptor => 'sha512'
validates_presence_of :email, :if => :sign_up
validates_presence_of :email, :first_name, :last_name, :add1, :add2, :id_number, :if => :edit_page
validates_uniqueness_of :email , :case_sensitive => true
attr_accessor :edit_page, :sign_up
@zacksiri
zacksiri / gist:1049029
Created June 27, 2011 14:58
user Model mongoid document
validates_presence_of :email, :if => :sign_up
validates_presence_of :email, :first_name, :last_name, :add1, :add2, :id_number, :if => :edit_page
validates_uniqueness_of :email , :case_sensitive => true
attr_accessor :edit_page, :sign_up
references_many :transactions, :dependent => :delete, :inverse_of => :user
field :customer_id, type: Integer, default: 0
field :title, type: String
field :first_name, type: String
@zacksiri
zacksiri / routes.rb
Created March 13, 2012 09:38
Example of routes.rb
namespace "api" do
resources :contacts
end
#....
@zacksiri
zacksiri / routes.rb
Created March 13, 2012 09:42
Route for launching rails app
match ':account_id/*path', to: 'launcher#index'