Skip to content

Instantly share code, notes, and snippets.

@janwirth
janwirth / gist:94e0a3a9db75a260cc68
Created April 27, 2015 19:16
.env file for vagrant provisioning
APP_ENV=local
// Note the new way of requesting CoffeeScript since 1.7.x
require('coffee-script/register');
// This bootstraps your Gulp's main file
require('./Gulpfile.coffee');
@janwirth
janwirth / db_quicksearch
Last active September 5, 2015 03:53
Surchkürzel code für DB Suche in Chrome. Verwendung: [Keyword] start to ziel
javascript:
var s='%s';
url='http://reiseauskunft.bahn.de/bin/query.exe/dn?getstop=1&S=%s&Z=%s';
query='';
urlChunks=url.split('%s');
console.log(s);
sChunks=s.split(' to ');
console.log(sChunks);
for(i=0; i<sChunks.length; i++)query+=urlChunks[i]+sChunks[i];
location.replace(query);
@janwirth
janwirth / webfontMixin.styl
Last active November 12, 2015 09:03 — forked from Nitive/fonts.styl
Font face mixin for WOFF & WOFF2
// font-face mixin
font-url(file)
return 'fonts/' + file
webfont(family, file, weight = normal, style = normal)
@font-face
font-family family
file += '/' + file
url(font-url(file + '.woff2')) format('woff2'),
url(font-url(file + '.woff')) format('woff')
it 'should support dynamic attributes', ->
c """
div(class=foo).foo&attributes(dynamicAttributes)
""" , '<div<?php attrs(array("class" => $foo, "class" => "foo"), $dynamicAttributes); ?>></div>'
# a function that takes a function and returns a function
reduce = (operation) ->
# the returned function accepts a list
(list) ->
# and applies the operation passed to the outer function recursively to the list
if list.length > 2
return operation list[0], reduce(operation)(list.slice(1, list.length))
# until it is empty
else
return operation list[0], list[1]
@janwirth
janwirth / inspect.jade
Created May 10, 2016 09:29
Inspect mixin for jade
// inspect an object
mixin inspect(data, indentDepth)
- indentDepth = typeof indentDepth != "undefined" ? indentDepth : 2 // default indentDepth = 2
pre=JSON.stringify(data, null, indentDepth)
# based on http://www.paulund.co.uk/smooth-scroll-to-internal-links-with-jquery
$ ->
$('a[href*=#]:not([href=#])').on 'click.smoothscroll', (e) ->
e.preventDefault()
target = @hash
$target = $(target)
/*!
* vue-dragula v1.0.3
* (c) 2016 Yichang Liu
* Released under the MIT License.
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('dragula')) :
typeof define === 'function' && define.amd ? define(['dragula'], factory) :
(global.vueDragula = factory(global.dragula));
}(this, function (dragula) { 'use strict';
# deep map obj with function in context
deepMap = (obj, f, ctx) ->
res = {}
for key of obj
val = obj[key]
if typeof val == 'object'
res[key] = deepMap(val, f, ctx)
else
res[key] = f.call(ctx, val, key)
res