Skip to content

Instantly share code, notes, and snippets.

@Neener54
Neener54 / 0_reuse_code.js
Created November 18, 2016 16:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@Neener54
Neener54 / .railsrc
Last active September 18, 2015 00:28 — forked from ivanoats/.railsrc
# .railsrc
-B #Skip Bundle
-T #Skip Test-Unit
-d postgresql #Use postgres
@Neener54
Neener54 / 000_postgresql_fancy_datatypes
Last active August 29, 2015 14:27 — forked from pcreux/000_postgresql_fancy_datatypes
Postgresql fancy datatypes with Rails / ActiveRecord. Run it with `rake`!
# Postgresql fancy datatypes!
* array
* hstore (=~ hash)
* json
* jsonb
Philippe Creux - [@pcreux](http://twitter.com/pcreux)
(function() {
var arrays, basicObjects, deepClone, deepExtend, deepExtendCouple, isBasicObject,
__slice = [].slice;
deepClone = function(obj) {
var func, isArr;
if (!_.isObject(obj || _.isFunction(obj))) {
return obj;
}
if (_.isDate(obj)) {
rivets.configure({
adapter: {
subscribe: function(obj, keypath, callback) {
obj.on('change:' + keypath, callback)
},
unsubscribe: function(obj, keypath, callback) {
obj.off('change:' + keypath, callback)
},
read: function(obj, keypath) {
return obj.get(keypath)
$.scrollWindowTo = function(pos, duration, cb) {
if (duration == null) {
duration = 0;
}
if (pos === $(window).scrollTop()) {
$(window).trigger('scroll');
if (typeof cb === "function") {
cb();
}
return;
@Neener54
Neener54 / gist:5135829
Last active December 14, 2015 19:19 — forked from anonymous/gist:5135758
@events = Event.where("venue_id = ?", current_user.venue.id).past_events
@events = Event.where("venue_id = ?", current_user.venue.id).upcoming_events
class Events
def past_events
past ||= self.select{|event| event.date < Date.today}
end
def upcoming_events
@Neener54
Neener54 / gist:4036557
Created November 8, 2012 03:35
Venues Controllers
class VenuesController < ApplicationController
def venue_thanks
@user = User.find(current_user)
@venue = Venue.where(:user_id => @user.id)
if @venue.blank?
@venue = Venue.new(:name => params[:name], :address => params[:address], :max_guest_allowed => params[:max_guest_allowed], :user_id => @user )
@msg = "Thanks for creating a venue!"
@venue.save
else