Skip to content

Instantly share code, notes, and snippets.

View roykolak's full-sized avatar

Roy Kolak roykolak

  • Detective.io
  • Chicago, IL USA
View GitHub Profile
.iframe-container {
-webkit-margin-start: -20px;
-webkit-transition: margin 100ms, opacity 100ms;
bottom: 0;
left: 0;
opacity: 0;
position: absolute;
right: 0;
top: 0;
z-index: 1;
@roykolak
roykolak / uber.js
Created March 25, 2012 17:30
postMessage example in Chrome Uber
cr.define('uber', function() {
...
function invokeMethodOnWindow(targetWindow, method, opt_params, opt_url) {
var data = {method: method, params: opt_params};
targetWindow.postMessage(data, opt_url ? opt_url : '*');
}
return {
...
invokeMethodOnWindow: invokeMethodOnWindow
@roykolak
roykolak / object_class.js
Created October 6, 2011 21:37 — forked from dkordik/object_class.js
Ruby's .class for Javascript... kinda
Object.prototype.class = function () {
return "8th Grade";
}
@roykolak
roykolak / history.js
Created September 16, 2011 21:02
chrome history js
/**
* Get search results for a selected depth. Our history system is optimized
* for queries that don't cross month boundaries, but an entire month's
* worth of data is huge. When we're in browse mode (searchText is empty)
* we request the data a day at a time. When we're searching, a month is
* used.
*
* TODO: Fix this for when the user's clock goes across month boundaries.
* @param {number} opt_day How many days back to do the search.
*/
.radio.specialist_radio
- check_for_errors(@user.errors['fittings.specialist']) do
= fitting.radio_button :specialist_id, specialist.id
= image_tag specialist.avatar.url, :class => 'avatar'
= fitting.label "specialist_id_#{specialist.id}", specialist.full_name
module Specialists::UsersHelper
def check_for_errors(field_error, &block)
if field_error.blank?
block.call
else
haml_tag :div, :class => 'field_with_errors' do
block.call
end
end
end
class Fitting < ActiveRecord::Base
validates_presence_of :user, :timestamp, :specialist
validates_presence_of :left_ear, :if => Proc.new { right_ear.blank? }
validates_presence_of :right_ear, :if => Proc.new { left_ear.blank? }
belongs_to :user
belongs_to :left_ear, :class_name => 'Product', :foreign_key => 'left_ear_id'
belongs_to :right_ear, :class_name => 'Product', :foreign_key => 'right_ear_id'
belongs_to :specialist
has_many :programs, :order => 'slot ASC'
task :seed do
content = ''
File.open('extension/history.html', 'r') do |file|
file.each do |line|
content += line
end
end
fixtures = '';
Dir["spec/javascripts/fixtures/*.html"].each do |file_name|
$.fn.spin = function() {
var opts = {lines: 12, length: 5, width: 3, radius: 10, color: '#333', speed: 1, trail: 52, shadow: false};
this.each(function() {
var spinner = $(this).data('spinner');
if (spinner) spinner.stop();
if (opts !== false) {
$(this).data('spinner', new Spinner(opts).spin(this));
}
});
return this;
FilterView = Backbone.View.extend({
initialize: function() {
$(this.el).html('').hide();
},
render: function(results) {
var self = this;
$('#filterViewTemplate').tmpl(this.model.toJSON()).appendTo($(this.el));
$(this.el).fadeIn("fast", function() {
Visit.search(self.model.options(), function(results) {