This file contains hidden or 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 User < ActiveRecord::Base | |
enum :role, [:admin,:moderator,:user] | |
# You can optionally add this function to your model | |
# and it will be called after each change of the role for callbacks you might need | |
def role_changed(from,to) | |
puts "The role changed from #{from} to #{to}" | |
end | |
end |
This file contains hidden or 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
# SCIL 7 - DSL Exercise in python | |
# done by @yonbergman and @avihut | |
# Usage: | |
# c = Cart() | |
# c.items() | |
# => [<foo(100)>,<bar(50)>] | |
# c.run_rules() | |
# c.items() | |
# => WIN |
This file contains hidden or 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
require 'net/http' | |
require 'digest/md5' | |
# USAGE: noodge.rb bob #send 'nudge' to bob | |
# noodge.rb alice 'hi alice' # sends 'hi alice' to alice | |
# noodge.rb alice 'bye alice' bob # send 'bye alice' to alice as bob | |
# each time you send as someone (via 3rd param or via application request) it will save your name into the config so that next time you won't need to set it. | |
API_KEY = "YOUR Notify.io API KEY" | |
NOODGE_FILE = ".noodge_user" # A config file to hold the FROM user |
This file contains hidden or 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
# insert this somewhere right after document.load | |
@header = $('.header') | |
while (@header.height() > @header.parent().height()) | |
currentFontSize = parseInt(@header.css("font-size")) | |
@header.css("font-size", currentFontSize - 1) |
This file contains hidden or 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 Primer | |
attr_accessor :num | |
def initialize(num) | |
@num = num | |
end | |
def run | |
arr = [] |
This file contains hidden or 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://github.com/Ben-M/simple_scaffold | |
def generate_controller(update_method, params, include_white_list_code=false) | |
strong_params_method=white_list_code if include_white_list_code | |
controller_code = <<-CODE | |
<% if namespaced? -%> | |
require_dependency "<%= namespaced_file_path %>/application_controller" | |
<% end -%> | |
<% module_namespacing do -%> | |
class <%= controller_class_name %>Controller < ApplicationController |
This file contains hidden or 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |