Skip to content

Instantly share code, notes, and snippets.

function initialize() {
var map = Gmaps.map.map
var defaultBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(<%= @lat %>, <%= @lon %>),
new google.maps.LatLng(<%= @lat %>, <%= @lon %>));
map.setZoom(15);
var input = (document.getElementById('place-search'));
@jwoertink
jwoertink / gist:5702300
Created June 3, 2013 23:19
What is the best way to index this in MongoDB? Even more so, what is the best way to index this with mongoid in rails?
{
"$or" => [{"receivers"=>"5149fb21d863673f0f000001"}, {"actor_id"=>"5149fb21d863673f0f000001"}],
"_id" => {"$ne" => "51a91dd4d8636716cc000015"},
"created_at" => {"$gt" => 2013-05-31 22:01:56 UTC},
"action" => {"$nin" => [:comment, :favorite]},
"object_type" => {"$nin" => ["User"]}
}
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '3.2.14'
gem 'cancan', '1.6.10'
gem 'carmen-rails', '1.0.0'
gem 'carrierwave', '0.9.0'
gem 'carrierwave-mongoid', '0.6.1', require: 'carrierwave/mongoid'
@jwoertink
jwoertink / gist:6265011
Created August 19, 2013 01:14
Bundles > Bundle Editor > Show Bundle Editor > Ruby on Rails > Create resources controller class
class ${1:Model}sController < ApplicationController
before_filter :find_${1/./\l$0/}, only: %i(show edit update destroy)
def index
@${1/./\l$0/}s = ${1:Model}.all
end
def show; end
def new
#
# bash completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
@jwoertink
jwoertink / gist:7378673
Created November 8, 2013 22:25
polymorphic association saving issue using mongoid
#Models
class Event
include Mongoid::Document
has_and_belongs_to_many :organizations, index: true
belongs_to :location, polymorphic: true, index: true
end
class Organization
include Mongoid::Document
has_and_belongs_to_many :events, index: true
[{"name":"Black Crowes","address":"Las Vegas, NV","starts_at":"2013-12-13T20:00:00-08:00","ends_at":"2013-12-14T00:00:00-08:00","time_zone":"America/Los_Angeles","venue_name":"Hard Rock Hotel and Casino Las Vegas - The Joint","html_url":"https://www.tabeso.com/events/52a19b79e76542ffc8000e2b","rsvp_url":null,"description":"","photos":[]},{"name":"Stone Temple Pilots","address":"Las Vegas, NV","starts_at":"2013-12-15T19:00:00-08:00","ends_at":"2013-12-16T00:00:00-08:00","time_zone":"America/Los_Angeles","venue_name":"Hard Rock Hotel and Casino Las Vegas - The Joint","html_url":"https://www.tabeso.com/events/52a1bbb360c564964c00396f","rsvp_url":null,"description":"","photos":[]},{"name":"Steve Miller Band and the Doobie Brothers","address":"Las Vegas, NV","starts_at":"2013-12-28T19:30:00-08:00","ends_at":"2013-12-29T00:00:00-08:00","time_zone":"America/Los_Angeles","venue_name":"Hard Rock Hotel and Casino Las Vegas - The Joint","html_url":"https://www.tabeso.com/events/52a1bcb460c56463300048db","rsvp_url":null,
/^(http(?:s)?\:\/\/[a-zA-Z0-9\-]+(?:\.[a-zA-Z0-9\-]+)*\.[a-zA-Z]{2,6}(?:\/?|(?:\/[\w\-]+)*)(?:|\w+\.[a-zA-Z]{2,4}?))$/
# Instance Variable
@people = [] # Array
# Local Variable
age = 32 # Integer
weight = 195.6 # Float
# = means assignment
person = {} # Hash
require './encryptor'
read_file = File.open('secret.txt')
word = read_file.read
read_file.close
e = Encryptor.new(rand(20))
encrypted_word = e.encrypt(word)
write_file = File.open('secret.txt', 'w+')