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
module Mongoid | |
module Localizable | |
class LocalizedValidator < ActiveModel::EachValidator | |
def validate_each record, attribute, value | |
if options[:mode] == :only_default | |
record.errors[:attribute] << (options[:message] || :blank) unless record.send("has_#{attribute}_translation?", I18n.default_locale) | |
end | |
end | |
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
class Model | |
include Mongoid::Document | |
include Mongoid::Timestamps | |
include Mongoid::Localizable | |
localized_field :name | |
validates_default_locale :name | |
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
require 'rubygems' | |
require 'active_support' | |
# Include this module to define additional helpers | |
module MyAccessors | |
extend ActiveSupport::Concern | |
module ClassMethods | |
# This helper creates accessors | |
def create_my_accessors *names |
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 Carta { | |
private static enum Seme { Oro, Bastoni, Coppe, Spade } | |
private int value; | |
private Seme seme; | |
public Carta(int value, Seme seme) { this.value = value; this.seme = seme; } | |
public int getValue() { return int; } | |
public Seme getSeme() { return seme; } | |
} |
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
function testWithoutParentheses() { | |
var start = new Date(); | |
var end; | |
var a = 0; | |
for (var i = 0; i < 1000000000; i++) | |
if (i % 2 == 0) | |
a++; | |
end = new Date(); | |
return end-start; | |
} |
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 Product | |
options: ['size', 'fitting', 'last'] | |
constructor: (@availabilities) -> | |
@bindEvents() | |
bindEvents: -> | |
for option in @options | |
callback = _(@optionClickHandler).bind @, option | |
@container(option).find('a').click callback |
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
#using excel | |
ExcelFile::Sheet.defile :game_of_thrones_episodes do | |
#dunno @ the moment | |
end | |
ExcelFile::Row.define :episode_row do | |
attribute :name | |
attribute :index | |
attribute :description |
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
require 'mina/bundler' | |
require 'mina/rails' | |
require 'mina/git' | |
require 'mina/rvm' | |
set :domain, 'server.ovofarm.com' | |
set :user, 'user' | |
set :forward_agent, true | |
set :deploy_to, '/var/apps/studioinnovo' | |
set :repository, 'ssh://[email protected]/gawaine/studioinnovo.git' |
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
# app.coffee | |
require 'express' | |
class Server | |
constructor: -> | |
@app = express() | |
@server = http.createServer(@app) | |
@io = SocketIO.listen @server, logger: @logger | |
@configure_app() |
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
# app.coffee | |
require 'express' | |
class Server | |
constructor: -> | |
@app = express() | |
@server = http.createServer(@app) | |
@io = SocketIO.listen @server, logger: @logger | |
@configure_app() |
OlderNewer