Skip to content

Instantly share code, notes, and snippets.

View cmtt's full-sized avatar
😷

Matthias Thoemmes cmtt

😷
  • Berlin, Germany
View GitHub Profile
@cmtt
cmtt / index.js
Created May 23, 2016 11:20
requirebin sketch
const moment = require('moment');
// http://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html
// "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"
console.log(moment("2009-06-30T18:30:00+02:00").format('YYYY-MM-DDTHH:mm:ssZ'));
@cmtt
cmtt / gulpfile.js
Created December 27, 2015 15:29
Gulpfile example: Concatenating multiple files using gulp-di
var di = require('gulp-di')(gulp)
.provide('extensions', ['jpg', 'png', 'txt']) // Add the "extension" constant
.tasks('./tasks') // Load all tasks from the tasks directory
.modules('./modules') // Load helper functions from the modules directory
.resolve(); // Finally resolve all dependencies.
@cmtt
cmtt / gulpfile.js
Created December 27, 2015 15:18
Gulpfile example: Concatenating several extensions
var gulp = require('gulp');
var concat = require('gulp-concat');
var extensions = ['jpg', 'png', 'txt'];
extensions.forEach(extTask);
/**
* Creates a "concat-all" task for the specified extension.
* @method extTask
* @param {string} extension
@cmtt
cmtt / gulpfile.js
Created December 27, 2015 15:15
Gulpfile example: Concatenating files
var gulp = require('gulp');
var concat = require('gulp-concat'); // A gulp plugin which concatenates the
// input steams.
gulp.task('concat-all-texts', function () { // Declare a task
return gulp.src('texts/**/*.txt') // Get all .txt files from the "texts"
// folder, including sub-directories
.pipe(concat('all.txt')) // "Pipe" the stream to concat which would
// concatenate all input streams.
@cmtt
cmtt / deep-pluck.js
Last active August 29, 2015 14:13
Deep pluck: Pluck values from nested objects
/**
* @function
* @param {Object} arr
* @param {string} key
* @param {boolean} withGaps
* @param {*} arr
*/
function _pluck (arr, key, withGaps) {
if (typeof key === 'number') {