Skip to content

Instantly share code, notes, and snippets.

View stravid's full-sized avatar

David Strauß stravid

View GitHub Profile
@stravid
stravid / number-to-currency-test.js
Created July 24, 2014 12:07
Testing Handlebars Helper with Ember CLI
import numberToCurrency from '../../helpers/number-to-currency';
module('number-to-currency Handlebars Helper');
test('convert invalid input to zero', function() {
equal('€ 0,00', numberToCurrency._rawFunction(null));
equal('€ 0,00', numberToCurrency._rawFunction(undefined));
});
test('handle single digit input', function() {
@stravid
stravid / 1.rb
Last active August 29, 2015 14:03
Invoice Push Update Application
require 'sinatra'
require 'json'
current_invoice_id = 0
invoices = {}
before do
content_type :json
end
@stravid
stravid / shops.yml
Created May 19, 2014 15:55
Carrierwave + Fixtures
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
ishophaircare:
name: ishophaircare
slug: ishophaircare
commission_level: 0
color: blue
custom_commission_rate: 0
sale: true
logo: <%= File.load("#{Rails.root}/test/fixtures/logo.png") %>
06:25 Grow your application organically, don't make it complicated upfront. (Rails works good for the things it was designed for.)
08:55 What if we had more logic?
10:30 Lets pretend we want to seprate it
11:30 Even it’s very small logic lets pretend there is more here
@stravid
stravid / tractor.coffee
Last active August 29, 2015 14:00
Beispiel Traktor
{
name_de: 'A 22'
start_of_production_de: 'ca. 10/1950'
tractor_number_de: 'ab ca. 5000'
number_of_produced_units_de: 'ca. 10.000'
technical_label_de: 'R 18'
wheelbase_de: '1500 mm'
length_de: '2580 mm'
chassis_clearance_de: '350 mm'
width_de: '1520 mm'
@stravid
stravid / gist:10713318
Last active August 29, 2015 13:59
Fixtures in combination with Ember CLI. Read more about it here: http://edgycircle.com/blog/2014-using-fixtures-in-combination-with-ember-cli/
// The incorrect way of defining fixtures.
var Post = DS.Model.extend({
title: DS.attr('string'),
body: DS.attr('string')
});
Post.FIXTURES = [
{ id: 1, title: 'Title A', body: 'Body A' },
{ id: 2, title: 'Title B', body: 'Body B' }
];
Tedian.ApplicationRoute = Ember.Route.extend
setupController: ->
controller = @controllerFor("sidebar")
controller.set "tasks", @store.find("task")
controller.set "projects", @store.find("project")
controller.set "timeEntries", @store.find("timeEntry")
Tedian.TimeEntry.findActive().then (timeEntry) ->
controller.set "activeTimeEntry", timeEntry
@stravid
stravid / app.js
Last active December 20, 2015 08:49
Ember.js Beispiel Anwendung für Screenguide Artikel
App = Ember.Application.create();
App.Project = Ember.Object.extend({
title: null,
features: null,
estimateSum: function() {
var features = this.get('features');
return features.reduce(
function(total, feature) {
@stravid
stravid / example.js
Last active June 2, 2018 15:14
A simple way to track how far users are scrolling. Assumes you are using Mixpanel and jQuery. Copyright © 2013 David Strauß MIT License
new MixpanelScrollTracker({
attribute: 'section',
event: 'Scrolled to',
markers: [
{ position: 500, value: 'Services' },
{ position: 700, value: 'About Us' },
{ position: 900, value: 'Contact Form' }
]
});
@stravid
stravid / category_aware_next_generator.rb
Created November 15, 2012 14:22
Category aware next attribute for a Jekyll post
module Jekyll
class CategoryAwareNextGenerator < Generator
safe true
priority :high
def generate(site)
site.categories.each_pair do |category_name, posts|
posts.sort! { |a, b| b <=> a }