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
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
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
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
# and you can handle formating in your controller | |
def action | |
params[:start_at] = params[:start_at_date] + ' ' + params[:start_at_time] | |
params.delete :start_at_date | |
params.delete :start_at_time | |
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 H; include MyHelper; end; h = H.new |
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
(ns demo.gp | |
(:use (incanter core stats))) | |
(set! *warn-on-reflection* true) | |
(def X (matrix [-4 -3 -1 0 2])) | |
(def Y (matrix [-2 0 1 2 -1])) | |
(def X* (matrix (range -5 5 0.2040816))) | |
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 Robot = function(robot){ | |
robot.turnLeft(robot.angle % 90); | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
if (robot.parentId) { | |
robot.ahead(1); | |
robot.turnGunRight(1); | |
} | |
else { |
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 cancelNavigate; | |
$(window).on("hashchange", function(ev) { | |
if(cancelNavigate) { | |
cancelNavigate = false; | |
return false; | |
} | |
if(window.onbeforeunload) { | |
var ok = confirm(window.onbeforeunload()); | |
if(ok) { | |
window.onbeforeunload = null; |
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
(custom-set-variables | |
'(web-mode-attr-indent-offset nil) | |
'(web-mode-code-indent-offset 2) | |
'(web-mode-markup-indent-offset 2) | |
'(web-mode-indentation-params '("lineup-calls" . nil)) | |
) |