Skip to content

Instantly share code, notes, and snippets.

View Ahrengot's full-sized avatar
🤟

Jens Ahrengot Boddum Ahrengot

🤟
View GitHub Profile
import _ from 'underscore';
let toNumbers = function(arr) {
return _.map(arr, _.partial(parseInt, _, 10));
}
let execFuncs = function(arr) {
return _.map(arr, function(item) {
return _.isFunction(item) ? item() : item;
})
{
"center":{
"lat":56.16,
"lng":10.18
},
"zoom":"12",
"filters":"1",
"wp":{
"markers":[
{
var _ = require( 'underscore' );
// Gulp + gulp tools
var gulp = require('gulp');
var $ = require( 'gulp-load-plugins' )();
var livereload = require('gulp-livereload');
var opn = require ('opn');
// Webpack
var webpack = require("webpack");
@Ahrengot
Ahrengot / react-autosave-mixin.js
Last active August 29, 2015 14:21
React + Backbone autosave mixin
var _ = require('underscore');
var AutoSaveMixin = {
componentWillMount: function() {
this.queueAutoSave = _.debounce( this.queueAutoSave, 1800 )
},
saveData: function() {
this.setState({ loading: true }, function() {
this.props.model.save().always(() => {
this.setState({loading: false});
@Ahrengot
Ahrengot / query-params-to-obj.js
Created January 7, 2015 13:33
Query params to JavaScript object
/*
Takes something like domain.com/?param1=one&param2=two and converts it into something like
{ param1: 'one', param2: 'two' }
*/
var query = {};
if ( location.search ) {
var pieces, param, i, len;
var chunks = location.search.slice(1).split("&");
@Ahrengot
Ahrengot / sass-easing-functions.scss
Created September 18, 2014 20:24
Sass easing functions
$ease-in-sine: cubic-bezier( 0.47, 0, 0.745, 0.715 );
$ease-out-sine: cubic-bezier( 0.39, 0.575, 0.565, 1 );
$ease-in-out-sine: cubic-bezier( 0.445, 0.05, 0.55, 0.95 );
$ease-in-quad: cubic-bezier( 0.55, 0.085, 0.68, 0.53 );
$ease-out-quad: cubic-bezier( 0.25, 0.46, 0.45, 0.94 );
$ease-in-out-quad: cubic-bezier( 0.455, 0.03, 0.515, 0.955 );
$ease-in-cubic: cubic-bezier( 0.55, 0.055, 0.675, 0.19 );
$ease-out-cubic: cubic-bezier( 0.215, 0.61, 0.355, 1 );
@Ahrengot
Ahrengot / react-bb-search.js
Created September 15, 2014 14:59
React.js input field + Backbone router
var SearchRouter = Backbone.Router.extend({
routes: {
"search/:query": "search",
"": "root"
},
root: function() {
this.trigger( "reset" );
},
search: function(query) {
this.trigger( "search", decodeURIComponent( query ) );
@Ahrengot
Ahrengot / min-max.scss
Created June 23, 2014 10:15
pixel-based min-max media queries
@media (min-width: 480px) and (max-width: 767px) {
// Do something
}
@media (min-width: 768px) {
// Do something else
}
define ["underscore", "backbone", "gsap"], (_, Backbone) ->
# The clockwork tells the rest of the system, when it's time to move
# tasks from scheduled to active.
#
# Internally, the timer uses TweenLite from GreenSock. This might seem a little strange, but
# TweenLite, unlike a good old setTimeout, can tell you how long is left in the current timer clock
# and it is more predictable. A setTimeout for 10 seconds is not 10 seconds in reality, but 10 seconds +
# any script execution time during those 10 seconds — Thus making the timer unpredictable after
# the app has been open for a longer period of time.
define ["underscore", "gsap"], (_) ->
class ParallaxFun
constructor: ->
@center = { x: window.innerWidth >> 1, y: window.innnerHeight >> 1 }
@updated = no
$(document).on( "mousemove", @updateMousePos );
setTimeout( @doParallax, 1000 )
updateMousePos: (e) =>
@center.x = e.clientX