Skip to content

Instantly share code, notes, and snippets.

@janwirth
janwirth / lodash.d.ts
Last active December 31, 2017 13:23 — forked from amir-arad/lodash.d.ts
Add last, reduce, mapKeys; extend flow
// https://gist.github.com/FranzSkuffka/d9c52982c265d44a1093f218664b6a5f
// https://raw.githubusercontent.com/donnut/typescript-ramda/master/ramda.d.ts
// https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/lodash/lodash.d.ts
declare namespace fp {
interface Dictionary<T> {
[index: string]: T;
}
@janwirth
janwirth / containedLoad.js
Last active December 18, 2017 17:08
Contain global JS libraries
// Load the given libraries without polluting the global namespace.
const libDefs = [
['https://cdn.jsdelivr.net/npm/[email protected]/dist/handlebars.min.js', 'Handlebars'],
['https://cdn.jsdelivr.net/npm/[email protected]', 'L'],
['https://cdn.jsdelivr.net/npm/[email protected]/dist/lodash.js', '_'],
['https://cdn.jsdelivr.net/npm/[email protected]', 'jQuery'],
['https://rawgit.com/joaquingatica/713768/raw/126357dd46a0e6aef4a8441a77d1e8e3ae81c0ba/typeface.js', '_typeface_js']
]
const i = document.createElement('iframe')
@janwirth
janwirth / git-to-svn.sh
Created August 21, 2017 14:50
Sync git to svn - commit history will NOT be kept. One way sync only.
#!/bin/sh
SVN_REPO=mydomain.com/svn-repo/trunk
GIT_REPO=SVN_REPO=mydomain.com/git-repo.git
# CLONE GIT
rm -rf git-downstream
git clone $GIT_REPO git-downstream --depth=1
# CLONE SVN
rm -rf svn-upstream
.ghx-done {
opacity: .4;
transition: .3s;
}
.ghx-done:hover {
opacity: 1;
}
# 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
/*!
* 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';
# 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)
@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)
# 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]
it 'should support dynamic attributes', ->
c """
div(class=foo).foo&attributes(dynamicAttributes)
""" , '<div<?php attrs(array("class" => $foo, "class" => "foo"), $dynamicAttributes); ?>></div>'