Skip to content

Instantly share code, notes, and snippets.

def test
puts "this is some test"
end
@LevelbossMike
LevelbossMike / inst_roar.rb
Created January 27, 2012 15:16
instance variables with roar to dry up representers
# use case:
# user has_many sport_sessions
# I want to return sport_sessions for a user week for week
# depending on given weekday
# module for DCI mixin
module UserRoles
module TrainingWeekRepresenter
@LevelbossMike
LevelbossMike / d3.html
Created May 6, 2012 17:22
creating table from array of json with d3
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body>
<table id="split">
<thead></thead>
<tbody></tbody>
@LevelbossMike
LevelbossMike / request.coffee
Created October 22, 2012 10:11
jakob fubar
requestFunction = (url, data) ->
$.ajax
url: url
data: data if data?
success: (response) ->
# do something with the response
console.log response
requestFunction("/posts")
@LevelbossMike
LevelbossMike / module.coffee
Created December 3, 2012 08:25
Revealing module pattern in coffeescript
@rt = @rt ? {} # create a rt namespace if not already available
@rt.module = ->
name = 'fubar'
hiddenVar = 'this is hidden'
name: (value) ->
return name unless arguments.length
name = value
@LevelbossMike
LevelbossMike / string.coffee
Created January 24, 2013 15:19
coffeescript strings
"""
<div class='lt'></div>
<div class='t show_arrow'>
<div class='arrow t'></div>
</div>
<div class 'rt'>
<div class='close'></div>
</div>
...
"""
import Ember from 'ember';
const COLORS = [
{ name: "red"},
{ name: "green"},
{ name: "refactor"}
].map((c) => Ember.Object.create(c));
export default Ember.Controller.extend({
appName:'Ember Twiddle',
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
actions: {
changeName(newName) {
this.set('appName', newName);
}
}
import Ember from 'ember';
const { computed } = Ember;
export default Ember.Component.extend({
boundingRect: computed('element', function() {
const element = this.get('element');
if (element) {
return element.getBoundingClientRect();
import DS from "ember-data";
export default DS.JSONAPIAdapter.extend();