Skip to content

Instantly share code, notes, and snippets.

@superlou
superlou / gist:1086741
Created July 16, 2011 20:29
Automatic join model not created
== Activity Model ==
has_many :rule_assignments, :dependent => :destroy # RuleAssignment has activity_id, and rule_type, rule_id
has_many :be_located_in_rules, :through => :rule_assignments, :source => :rule, :source_type => 'BeLocatedInRule'
== BeLocatedInRules Controller ==
def create
@rule = @activity.be_located_in_rules.build(params[:be_located_in_rule])
...
@rule.save # successfully create the BeLocatedInRule, but no join model (RuleAssignment)
@superlou
superlou / gist:1087737
Created July 17, 2011 16:15
Centering
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<style type="text/css">
#flag { url(images/heartseedLightImage2.jpg) no-repeat }
#green { background:green; display:block; float: left; width: 100px }
#white { background:yellow; display:block; float: left; width: 100px }
#red { background:red; display:block; float: left; width: 100px }
@superlou
superlou / gist:1362773
Created November 13, 2011 21:46
Source switching debug info
Attempting fallback
0:00:05.293557425 8185 0xe5f730 DEBUG basesrc gstbasesrc.c:3104:gst_base_src_change_state:<v4l2src0> PLAYING->PAUSED
0:00:05.293593887 8185 0xe5f730 DEBUG basesrc gstbasesrc.c:2895:gst_base_src_set_playing:<v4l2src0> unlock
0:00:05.293610433 8185 0xe5f730 LOG v4l2src gstv4l2src.c:749:gst_v4l2src_unlock:<v4l2src0> Flushing
0:00:05.293711344 8185 0x1545090 DEBUG v4l2src v4l2src_calls.c:191:gst_v4l2src_grab_frame: stop called
0:00:05.293737276 8185 0x1545090 DEBUG basesrc gstbasesrc.c:2232:gst_base_src_get_range:<v4l2src0> create returned -2 (wrong-state)
0:00:05.293754932 8185 0x1545090 INFO basesrc gstbasesrc.c:2405:gst_base_src_loop:<v4l2src0> pausing after gst_base_src_get_range() = wrong-state
0:00:05.293777495 8185 0x1545090 DEBUG basesrc gstbasesrc.c:2545:gst_base_src_loop:<v4l2src0> pausing task, reason wrong-state
0:00:05.293807345
@superlou
superlou / home.js
Created January 21, 2012 22:00
Modules undefined
// Module Room
define([
"namespace",
"use!backbone"
],
function(namespace, Backbone) {
var Room = namespace.module();
define([
"namespace",
"use!backbone",
"modules/message",
"text!templates/room_tpl.html",
"text!templates/room_row_tpl.html"
],
function(namespace, Backbone, Message, room_tpl, room_row_tpl) {
var Room = namespace.module();
@superlou
superlou / gist:1812642
Created February 13, 2012 01:52
Loop until unique?
var name_is_unique = false;
var name;
while (!name_is_unique) {
name = namer.generate();
var waiting_on_db = true;
User.find({name: name}, function(err,docs) {
if (docs.count > 0) {
name_is_unique = true;
// Set up Mongoose
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var ObjectId = Schema.ObjectId;
var UserSchema = new Schema({
id: ObjectId,
name: String,
registered: {type: Boolean, default: false},
password_hash: {type: String, default: ""},
var Router = Backbone.Router.extend({
routes: {
"": "index",
"profiles": "profiles",
"profiles/:id": "index"
},
index: function() {
var home = new Home.Model({con_name: "Bureaucracon"});
var home_view = new Home.Views.Main({model: home});
// ============================================================================
// TASKS
// ============================================================================
task.registerTask("server", "Run development server.", function(prop) {
var props = ["server"];
// If a prop was passed as the argument, use that sub-property of server.
if (prop) { props.push(prop); }
var options = config(props) || {};
@superlou
superlou / Output
Created March 19, 2012 01:04
Undefined 'name' for nil:NilClass
#<Tag:0x00000005002fd0>
New Con
NoMethodError: undefined method `name' for nil:NilClass
/home/lsimons/RubymineProjects/connie/app/models/con.rb:16:in `rename_tag'
/home/lsimons/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:405:in `_run__1766852513517797900__save__1160347338664056617__callbacks'
/home/lsimons/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/lsimons/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
/home/lsimons/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:81:in `run_callbacks'