Skip to content

Instantly share code, notes, and snippets.

View Psvensso's full-sized avatar
🏠
Working from home

Per Svensson Psvensso

🏠
Working from home
  • Stockholm
View GitHub Profile
@Psvensso
Psvensso / AssetFile
Created November 13, 2012 08:58
Normal Gemfile
require 'json'
require 'rake-pipeline-web-filters'
APPNAME = 'Digiex'
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
WebFilters = Rake::Pipeline::Web::Filters
class HandlebarsFilter < Rake::Pipeline::Filter
def initialize(&block)
Debugging EmberJS and EmberData:
Log router transitions:
window.App = Ember.Application.create({
LOG_TRANSITIONS: true,
});
Log object bindings:
Ember.LOG_BINDINGS = true
@Psvensso
Psvensso / Adapter
Last active December 19, 2015 02:29
Ember Cache
ajax: function (url, type, hash, cache) {
var adapter = this;
function rsvp(resolve, reject, url, type, hash, cache, adapter) {
if (!!cache) {
hash.localCache = true;
hash.cacheTTL = 12; // in hours.
hash.cacheKey = 'ApplicAd-DataCache-' + url;
}
hash = hash || {};
@Psvensso
Psvensso / Gulpfile.js
Created March 2, 2014 23:16
Starting Gulpfile for EmberJS with custom minispade, templating, SASS compillation... worx on my machine...
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
clean = require('gulp-clean'),
concat = require('gulp-concat'),
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
clean = require('gulp-clean'),
concat = require('gulp-concat'),
'use strict';
var Rx = require('rx');
var Promise = require('bluebird');
function getPromiseByNum(num) {
if (num < 2) {
return Promise.resolve(num);
} else {
return Promise.reject(num);
@Psvensso
Psvensso / http2server.js
Created September 1, 2015 19:35
Http2 node server testing with JSPM and systemjs-builder....
var fs = require('fs');
var path = require('path');
var http2 = require('http2');
var connect = require('connect');
var app = connect();
var Builder = require("systemjs-builder");
/**
* Get the config from our config.js file that JSPM sets up for us.
* */
import 'jquery'; // import a module without any import bindings
import $ from 'jquery'; // import the default export of a module
import { $ } from 'jquery'; // import a named export of a module
import { $ as jQuery } from 'jquery'; // import a named export to a different name
export var x = 42; // export a named variable
export function foo() {}; // export a named function
export default 42; // export the default export
export default function foo() {}; // export the default export as a function
System.config({
defaultJSExtensions: true,
transpiler: "babel",
babelOptions: {
"optional": [
"es7.objectRestSpread",
"es7.decorators",
"es7.classProperties",
"runtime"
]
@Psvensso
Psvensso / filewatcher.js
Last active November 8, 2015 17:10
No dependency filewatcher
var EventEmitter = require('events').EventEmitter;
var path = require('path');
var fs = require('fs');
var exec = require('child_process').exec;
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;