Skip to content

Instantly share code, notes, and snippets.

Avatar

Marc Khoury koganei

View GitHub Profile
View unlockanimation.js
import $ from 'jquery';
import { angular } from './../../js/base';
import _ from 'lodash';
class unlockAnimation {
constructor($element, $rootScope) {
this.$rootScope = $rootScope;
this.listeners = {
click: this.onClick.bind(this),
View test.md

[test]('javascript:return false;')

@koganei
koganei / fizzbuzz.clj
Last active Aug 29, 2015
Haskell & Clojure Fizzbuzz
View fizzbuzz.clj
(defn fizz-buzz []
(loop [i 1]
(if (<= i 100)
(do
(if (and (= (rem i 3) 0) (= (rem i 5) 0))
(println "fizzbuzz")
(if (= (rem i 3) 0)
(println "fizz")
(if (= (rem i 5) 0)
(println "buzz")
@koganei
koganei / app.js
Created Aug 5, 2014
AngularJS DB Interface Layer
View app.js
/**
* The idea is to expose an interface from the app side that a service can fulfill
*/
angular.module('myapp', ['apiservice'])
/**
* We load the service that fulfills the interface through a config on the app side
*/
.factory('config', function(
@koganei
koganei / poemsApiService.js
Last active Aug 29, 2015
An attempt to find the best way to structure a Restangularized API service
View poemsApiService.js
(function() {
'use strict';
/**
* the poemsApi Service. Restangular has all the functions you would expect from an
* API service, so we return the Restangular resource object.
*
* @service poemsApi
* @param Restangular bower install restangular
* @return service object
@koganei
koganei / Rest_APIs_Git.md
Last active Aug 29, 2015
RESTful APIs + Git architecture
View Rest_APIs_Git.md

I've been reading some articles on RESTful APIs and it got me thinking that maybe it could profit from a git architecture.

The idea would be that when you PUT to api/dragons/haku, you are (git) staging a change to the /haku resource. A summary of the currently staged data is returned by the PUT, as well as HEAD revision number to see if the live data needs to be updated. Different sections of the APIs could have their own 'HEAD' number, so that we can know when the latest dragon has been edited, but not the latest imp.

Similarly, when you POST to /dragons, you are (git) adding a dragon to the resource repository. With GET, an HTTP header could say whether you would like the staged data, the live data or the data of a particular revision.

Semantically, it could be better to add a new verb COMMIT to commit to a certain resource, but it can easily be circumvented with _post variables or headers to support interoperability. A commit message is posted along with the COMMIT verb.

On the database side, I'm

You can’t perform that action at this time.