Skip to content

Instantly share code, notes, and snippets.

View fourcolors's full-sized avatar
🎯
Perkisizing

fourcolors fourcolors

🎯
Perkisizing
View GitHub Profile
<%= form_tag registration_index_path do %>
<%= fields_for User.new do |u| %>
<%= u.label :phone %>
<%= u.text_field :phone %>
<% end %>
<p>
<%= label_tag :workout %>
<%= check_box_tag :workout %>
</p>
<p>
@fourcolors
fourcolors / Error message
Created January 12, 2012 06:50
Problem with asset pipeline
## Error
couldn't find file 'bootstrap-dropdown'
(in /Users/node/Projects/samplator/app/assets/javascripts/application.js:9)
sprockets (2.0.3) lib/sprockets/context.rb:100:in `resolve'
sprockets (2.0.3) lib/sprockets/context.rb:140:in `require_asset'
sprockets (2.0.3) lib/sprockets/directive_processor.rb:214:in `process_require_directive'
sprockets (2.0.3) lib/sprockets/directive_processor.rb:164:in `block in process_directives'
sprockets (2.0.3) lib/sprockets/directive_processor.rb:162:in `each'
@fourcolors
fourcolors / gist:4050235
Created November 10, 2012 06:55
Backbone model override
# Method Summary
# Before a request gets sent out we need to make sure
# it's formatted correctly and contains the right
# info. We are adding the CSRF tokens in the header
# so our POST request work and making sure any
# namespaced attributes are working so the server is
# happy. If we are using other AJAX request to post
# date we will have to add something for jQuery.
preProcessSync: ->
# Fix backbone headers
# Extends Backbone.View on top of itself with some added features
# we use regularly
class Backbone.View extends Backbone.View
##
# Manages child views and renders them whenever the parent view is rendered.
# Specify views as key:value pairs of `className: view` where `className` is
# a CSS className to find the element in which to to append a rendered
# `view.el`
#
@fourcolors
fourcolors / JavascriptModuleFunction.js
Last active December 14, 2015 00:29
Creating some examples for my bog.
(function(){
console.log("Module scoped function");
})();
@fourcolors
fourcolors / nestedAttribute.coffee
Created April 9, 2013 20:10
Allow nested attributes on a backbone model
# Example usage
# @model.setNestedAttribute parent: 'foo', property: 'bar', value: 'catz', silent: true
setNestedAttribute: (options) ->
parent = options.parent
value = options.value
property = options.property
silent = options.silent
date_data = @get(parent) || {}
date_data[property] = value
{create: ‘POST’, update: ‘PUT’, destroy: ‘DELETE’}
@fourcolors
fourcolors / .zshrc
Created July 17, 2013 21:17
Alias for Canvas Javascript Tests. Use this like this. js_dev WikiPageEditViewSpec or js_test WikiPageEditViewSpec That should run only tests in that specific file.
js_dev(){
JS_SPEC_MATCHER="**/*$*.js" bundle exec rake js:dev
}
js_test(){
JS_SPEC_MATCHER="**/*$*.js" bundle exec rake js:test
}
@fourcolors
fourcolors / rev.css
Created October 3, 2013 19:33
Styles and html structure for the WikiPagesRevisions sidebar
.revision {
width: 70%;
}
.revisions {
min-width: 300px;
width: 25%;
height: 100%;
border: 1px solid #c1c7d0;
background-color: #f6f8fa;
@fourcolors
fourcolors / app.js
Created December 20, 2013 03:50
express app to host originate-ember. Be sure to add express and ejs to your package.json
/**
* Module dependencies.
*/
var express = require('express');
var http = require('http');
var path = require('path');
var app = express();