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 Form | |
include ActiveModel::Validations | |
include ActiveModel::Conversion | |
extend ActiveModel::Naming | |
# Subclass may provide a types hash. Any attributes not listed will | |
# default to string. | |
# self.types = { | |
# :description => :text, | |
# :state => {:type => :string, :limit => 2} |
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
var onscroll = function() { | |
var open = $(".select2-drop.select2-drop-active.select2-with-searchbox"); | |
var originalTop = open.data('original-top'); | |
var top = originalTop || parseInt(open.css('top'), 10); | |
if(!originalTop) { | |
open.data('original-top', top); | |
} | |
//ajust top | |
open.css('top', (top + $(window).scrollTop()) + 'px'); |
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 Psych | |
class << self | |
alias_method :old_dump, :dump unless method_defined?(:old_dump) | |
def dump(o, io = nil, options = {}) | |
old_dump(o, io, options).force_encoding('utf-8') | |
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
// Calls a function only once within the given wait time. Last call is | |
// considered, which is the difference between from _.throtle | |
// | |
_.buffer = function(func, wait, scope) { | |
var timer = null; | |
return function() { | |
if(timer) clearTimeout(timer); | |
var args = arguments; | |
timer = setTimeout(function() { |
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 Hash | |
def id | |
self["id"] || self[:id] | |
end | |
def type | |
self["type"] || self[:type] || self.type | |
end | |
def method_missing(meth, *args, &block) | |
if args.size == 0 |
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
<html> | |
<body> | |
<script type="text/javascript" | |
src="http://echo.gomus.com.br/player/mb.js?id=<##### ID DO PLAYER ######> "> | |
</script> | |
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
// Modified SpamLord.java to call clojure code | |
public List<Contact> processFile(String fileName, BufferedReader input) { | |
List<Contact> contacts = new ArrayList<Contact>(); | |
// for each line | |
Matcher m; | |
String email; | |
try { | |
List results = new spamlord().process(input); |
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
;; http://pragprog.com/magazines/2012-03/comparing-java-and-scalas-expressiveness | |
;; first attempt for impl in clojure.. a lot to be improved! :) | |
(let [lines (map #(clojure.string/split % #" ") | |
(line-seq (clojure.java.io/reader (clojure.java.io/file "textfile.txt")))) | |
grouped (group-by #(second %) lines) | |
parse-long (fn [log] (Long/parseLong (first log))) | |
diff-times (fn [longs] (for [x (range (count longs)) :let [ts (nth longs x)] ] | |
(if (= 0 x) ts | |
(- ts (nth longs (- x 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
# -*- coding: utf-8 -*- | |
require 'rubygems' | |
require 'active_support/core_ext/module/aliasing' | |
require 'active_record' unless defined?(ActiveRecord) | |
require 'mysql2' #0.2.7 | |
require 'active_record/connection_adapters/mysql2_adapter' | |
require 'meta_where' unless defined?(MetaWhere) | |
require 'rufus/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
''=~+( | |
('('). | |
('?'). (( | |
'{')). ("\`"| | |
'%').( ('[')^ '-').( ('`')| | |
'!').( ('`')| "\,"). '"'.( | |
('[')^ '+'). ("\["^ "\)").( ('`')| |