Skip to content

Instantly share code, notes, and snippets.

David Strauß stravid

Block or report user

Report or block stravid

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@stravid
stravid / README.md
Last active Jun 21, 2016
Ruby JSON API Stack
View README.md

Ruby JSON API Stack

What is this? I'm a little bugged out by all current approaches that are available to build JSON API APIs. I'm writing all this down to help me figure out what I want and how to accomplish it.

There are basically two sides, reading data and writing data. There are also a few parts of the stack that can be generalized. On the other side there are also parts where I think generalization is harmful.

Things like transforming parameters from dasherized to snake case, and serializing an object graph to JSON can be kept pretty generic. The thing I'm not so sure about on the read side is handling query parameters like included, fields, sort, filter, page and so on. For example using JSONAPI::Resources gives you the query parameter handling out of the box. On the other side I think it's impossible to deal with associations if you don't use the Active Record pattern and/or have 1:1 mapping between API resources and models.

On the write

View gist:7582330
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 / application.controller.js
Last active Dec 20, 2015
Ember Data Auto-Update Test Case
View application.controller.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
@stravid
stravid / app.js
Last active Dec 20, 2015
Ember.js Beispiel Anwendung für Screenguide Artikel
View app.js
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 / cURL request
Last active Oct 16, 2015
Lotus JSON Body Parsing
View cURL request
curl 'http://localhost:2300/api/players' --data-binary '{"data":{"attributes":{"name":"David"},"type":"players"}}' --compressed
{"data":null}
View gist:3878017
#!/bin/sh
set -e
function download() {
url=$1
base=$(basename $1)
if [[ ! -e $base ]]; then
echo "curling $url"
curl -O -L $url
@stravid
stravid / gist:2024450
Created Mar 12, 2012
Sublime Text 2 - Useful Shortcuts
View gist:2024450

Sublime Text 2 – Useful Shortcuts (OS X)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
View gist:2006109
#= require helpers/namespace
#= require embient/ember-routemanager
namespace 'slotcars'
slotcars.RouteManager = Ember.RouteManager.extend
wantsHistory: true # use html5 push state
delegate: null
View routes.rb
Slotcars::Application.routes.draw do
root :to => 'tracks#index'
get '/tracks/:id' => 'tracks#index'
get '/tracks/new' => 'tracks#index'
end
View gist:1678353
canvas = document.getElementById 'canvas'
canvas.width = 1024
canvas.height = 700
context = canvas.getContext '2d'
points = []
isMoving = false
$('canvas').on 'touchstart', (event) -> onTouchStart event
$('canvas').on 'touchmove', (event) -> onTouchMove event
You can’t perform that action at this time.