Skip to content

Instantly share code, notes, and snippets.

🎭
ヾ(⌐■_■)ノ♪

Darek Greenly Zielak

🎭
ヾ(⌐■_■)ノ♪
Block or report user

Report or block Zielak

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Zielak
Zielak / string.map.js
Created Oct 30, 2018
but string doesn't have `map` method... hold my beer
View string.map.js
String.prototype.map = function(predicate) {
const arr = []
for (var i = 0; i < this.length; i++) {
arr.push(predicate(this.charAt(i), i))
}
return arr.join('')
}
// ᕕ( ᐛ )ᕗ
@Zielak
Zielak / locationSearch2object.js
Created Aug 10, 2018
Get things from url after `?` and turn it into an object.
View locationSearch2object.js
location.search.slice(1).split('&').map(pair => pair.split('=')).reduce((params, curr) => { params[curr[0]] = curr[1]; return params }, {})
@Zielak
Zielak / prematurePromiseRejection.js
Created Jan 9, 2018
breaking a long running Promise, because it runs too long.
View prematurePromiseRejection.js
var test = new Promise((resolve, reject) => {
var longReject;
var LONG = new Promise((resolve, reject) => {
longReject = reject;
setTimeout(() => resolve(), 5000)
})
.then(() => console.log('LONG: resolved after 5 seconds'))
.catch(() => console.warn('LONG: rejected!'))
setTimeout(() => {
@Zielak
Zielak / es6-console-wrap.js
Last active Jun 30, 2017
Wraps console log, warn, info and error. Will add module's name before printing log. Userful when you have bunch of modules logging different stuff
View es6-console-wrap.js
const MODULE_NAME = 'ModuleX'
const log = (...args) => console.log.apply(console, [`[${MODULE_NAME}] > `, ...args])
const info = (...args) => console.info.apply(console, [`[${MODULE_NAME}] > `, ...args])
const warn = (...args) => console.warn.apply(console, [`[${MODULE_NAME}] > `, ...args])
const error = (...args) => console.error.apply(console, [`[${MODULE_NAME}] > `, ...args])
log('testing', ['apple', 'orange', 'car'], 1337)
@Zielak
Zielak / hook.post.js
Created Mar 8, 2015
Make source maps work in Windows. Temporary fix
View hook.post.js
var os = require('os');
var fs = require('fs');
// Change the project name to match yours
// Find it in your flow file
// project.app.name = ?
var projectName = 'grayscale';
exports.hook = function(flow, done) {
You can’t perform that action at this time.