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
require_relative "../../../acceptance_helper.rb" | |
# require File.expand_path("../../../../acceptance_helper", __FILE__) | |
describe "api/v1/colours" do | |
before do | |
@data = { | |
url: "http://illustrationage.files.wordpress.com/2013/08/breaking-bad-walter-white-darth-heisenberg-pj-mcquade-9.jpg", | |
filename: "breaking-bad-walter-white-darth-heisenberg-pj-mcquade-9.jpg" | |
} | |
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
# Remove git branches from stuff | |
function rmb { | |
current_branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') | |
if [ "$current_branch" != "master" ]; then | |
echo "WARNING: You are on branch $current_branch, NOT master." | |
fi | |
echo "Fetching merged branches..." | |
git remote prune origin | |
remote_branches=$(git branch -r --merged | grep -v '/master$' | grep -v "/$current_branch$") | |
local_branches=$(git branch --merged | grep -v 'master$' | grep -v "$current_branch$") |
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
before_filter :cors_preflight_check | |
after_filter :cors_set_access_control_headers | |
# For all responses in this controller, return the CORS access control headers. | |
def cors_set_access_control_headers | |
headers['Access-Control-Allow-Origin'] = '*' | |
headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS' | |
headers['Access-Control-Max-Age'] = "1728000" | |
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
test('should have a getFullName() method', function() { | |
expect(typeof this.user.getFullName).to.equal('function'); | |
}); |
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
(function(global, moduleName, undefined) { | |
var Rect = function() { | |
// Create an HTML Element | |
this._el = global.document.createElement('div'); | |
this._el.style.position = 'absolute'; | |
// Call the constructor | |
this.init.apply(this, arguments); | |
}; |
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
var rect1 = new Rect(); | |
rect1.color('blue'); // any CSS colour value | |
rect1.position(100, 200); // x, y | |
rect1.size(300, 150); // width, height | |
rect1.show(); // Shows the rectangle on screen (appends it to body) | |
rect1.hide(); // Detatches the rectabgle from the DOM | |
// I would also love a shorthand way of specifying the arguments in the | |
// constructor, at least the width, height and colour. |
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
(function (global, $, name, definition) { | |
// Checks what environment we are in and loads accordingly | |
if (typeof define === "function" && define.amd) { | |
// With AMD we require the module with its name rather than passing the variable directly | |
define(["jquery"], definition); // AMD | |
} | |
else if (typeof module !== "undefined" && module.exports) { | |
// CommonJS will need to require the node module for jQuery | |
$ = require("jquery"); | |
module.exports = definition($); // CommonJS |
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
var app = app || { views: {} }; | |
app.views.MyView = Backbone.View.extend({ | |
initialize: function() { | |
app.events.bind("some-event", this.render, this); | |
}, | |
events: { | |
"click .reload": "render" |
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
var app = app || {}; | |
app.views = app.views || {}; | |
app.views.MyView = Backbone.View.extend({ | |
render: function() { | |
// Use a handlebars template or similar here | |
var html = "Some html template content here"; | |
this.$el.html(html); | |
} |
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
var app = app || {}; | |
app.events = _.extend({}, Backbone.Events); | |
new Backbone.View({ | |
events: app.events | |
}); | |
// Trigger events | |
app.events.trigger("some-module:some-event", some, params) |