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 Event < ActiveRecord::Base | |
def self.new_with_token params = {} | |
params[:token] = generate_token | |
while (Event.find_by_token(params[:token])) | |
params[:token] = generate_token | |
end | |
Event.new(params) | |
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
array = ["a", "b", "b", "a", "c", "b"] | |
occurences = array.inject(Hash.new(0)) { |h,k| h[k] += 1; h } | |
array.sort_by { |k| occurences[k] } |
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
%script{:charset => "utf-8", :type => "text/javascript"} | |
var is_ssl = ("https:" == document.location.protocol); | |
var asset_host = is_ssl ? "https://s3.amazonaws.com/getsatisfaction.com/" : "http://s3.amazonaws.com/getsatisfaction.com/"; | |
document.write(unescape("%3Cscript src='http://getsatisfaction.com/javascripts/feedback-v2.js' type='text/javascript'%3E%3C/script%3E")); | |
%script{:charset => "utf-8", :type => "text/javascript"} | |
var feedback_widget_options = {}; | |
feedback_widget_options.display = "overlay"; | |
feedback_widget_options.company = "sharypic"; |
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
%script{:charset => "utf-8", :type => "text/javascript"} | |
var is_ssl = ("https:" == document.location.protocol); | |
var asset_host = is_ssl ? "https://s3.amazonaws.com/getsatisfaction.com/" : "http://s3.amazonaws.com/getsatisfaction.com/"; | |
document.write(unescape("%3Cscript src='http://getsatisfaction.com/javascripts/feedback-v2.js' type='text/javascript'%3E%3C/script%3E")); | |
%script{:charset => "utf-8", :type => "text/javascript"} | |
var feedback_widget_options = {}; | |
feedback_widget_options.display = "overlay"; | |
feedback_widget_options.company = "sharypic"; | |
feedback_widget_options.placement = "right"; |
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 Jobbr | |
module Mongoid | |
include ::Mongoid | |
extend self | |
# Return all Mongoid models. | |
# You can also pass a parent class to get all Mongoid childrens |
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 | |
# Helps to override find method in an embedded document. | |
# Usage : | |
# - add to your model "include Mongoid::EmbeddedFindable" | |
# - override find method with: | |
# def self.find(id) | |
# find_through(Book, 'chapter', id) | |
# end | |
module EmbeddedFindable |
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
def within_box_events | |
# reading lower_left corner and upper_right corner parameters | |
ll_lng = Float(params[:lower_left][:lng]) | |
ll_lat = Float(params[:lower_left][:lat]) | |
ur_lng = Float(params[:upper_right][:lng]) | |
ur_lat = Float(params[:upper_right][:lat]) | |
# getting coordinates of a 9 times broader box, to get better clustering behavior at edges | |
q_ll_lng = [ll_lng - ((ur_lng - ll_lng) / 2), -180].max | |
q_ur_lng = [ur_lng + ((ur_lng - ll_lng) / 2), 180].min |
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
defmodule TimeHelper do | |
def wait_until(fun), do: wait_until(500, fun) | |
def wait_until(0, fun), do: fun.() | |
def wait_until(timeout, fun) defo | |
try do | |
fun.() | |
rescue |
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
gulp = require('gulp') | |
uglify = require('gulp-uglify') | |
gulpif = require('gulp-if') | |
reload = require('./watch').reload | |
source = require('vinyl-source-stream') | |
streamify = require('gulp-streamify') | |
bundle_dir = "./public/" | |
vendor_dir = "./node_modules/" | |
src_dir = "./assets/javascripts/" |
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
Unique (cost=2407390.71..2407390.72 rows=2 width=4) (actual time=3338.080..3338.252 rows=918 loops=1) | |
Buffers: shared hit=559 | |
-> Sort (cost=2407390.71..2407390.72 rows=2 width=4) (actual time=3338.079..3338.145 rows=963 loops=1) | |
Sort Key: locations.id | |
Sort Method: quicksort Memory: 70kB | |
Buffers: shared hit=559 | |
-> Nested Loop (cost=0.00..2407390.71 rows=2 width=4) (actual time=2.466..3337.835 rows=963 loops=1) | |
Join Filter: (((pois.coordinates)::geography && _st_expand((locations.coordinates)::geography, 500::double precision)) AND ((locations.coordinates)::geography && _st_expand((pois.coordinates)::geography, 500::double precision)) AND _st_dwithin((pois.coordinates)::geography, (locations.coordinates)::geography, 500::double precision, false)) | |
Rows Removed by Join Filter: 4531356 | |
Buffers: shared hit=559 |
OlderNewer