Skip to content

Instantly share code, notes, and snippets.

@pentaphobe
pentaphobe / wrapTest.js
Created August 1, 2017 06:38
Auto wrapping of functions
let basis = {
hello: (name) => console.log(`hello ${name}!`)
};
function wrap(fn, name, ctx) {
return function() {
let args = Array.prototype.slice.call(arguments);
console.log(`wrapped function ${name}`, args);
return fn.apply(ctx, args);
@pentaphobe
pentaphobe / scanning_demo.js
Last active July 1, 2017 09:05
Demonstration of scanning xor-encrypted data
/**
* This is an insultingly simple demo due to nerd rage
*
* There are claims of people using static XOR keys to hide shell code in malware
*
* The only thing more embarrassing than this is that it supposedly prevent detection.
*
*/
@pentaphobe
pentaphobe / updateIn.js
Created April 21, 2017 04:32
Alternate updateIn() for ImmutableJS
/**
* Convenience function for deep updates including searches in the path
*/
export default function updateIn(immutableType, pathArray, updater) {
// pathArray can contain matcher functions
let failed = false;
let parsedPath = [];
pathArray.every( (pathEl, idx) => {
if (typeof pathEl !== 'function' && typeof pathEl !== 'object') {
@pentaphobe
pentaphobe / objToCsv.js
Last active March 9, 2017 00:43
CSV generator example
'use strict';
let objToCsv = (function() {
let defaultOptions = {
showLabel: true,
lineBreak: '\r\n',
separator: ','
};
// escape quotes
@pentaphobe
pentaphobe / composeControllers.js
Created December 9, 2016 01:05
Compose controller functions
/**
*
* Late night framework experiment with @pmarabeas
*
*/
'use strict';
var angular = require('angular');
@pentaphobe
pentaphobe / element.filter.js
Created November 15, 2016 06:18
Filter function for Angular's jqlite element
/**
* Adds a filter() method to Angular's jqlite
*/
(function (angular) {
/**
* Polyfill from MDN (mostly to cover IE9 and edge browsers)
* https://developer.mozilla.org/en/docs/Web/API/Element/matches
*/
if (!Element.prototype.matches) {
@pentaphobe
pentaphobe / README.md
Created March 5, 2014 01:13
Rudimentary Bash events

Rudimentary Shell Events

Sometimes I want commands in one terminal to happen only after commands in another terminal have finished.

This is a temporary solution to a problem likely better solved by someone else somewhere :)

Usage

In one terminal:

/**
* A dodgy and simple profiler wrapping thingy
*
* It don't do much, but I whipped this up as a basic helper for a coworker so may as well store for later :)
*
*/
/**
* @param {Function} fn The function you wish to profile
* @param {Object} scope The 'this' property to bind
@pentaphobe
pentaphobe / EMES-micro-events.markdown
Last active January 4, 2016 04:39
A Pen by Keili Olsen.
@pentaphobe
pentaphobe / rapid-stache.js
Last active August 8, 2016 07:14
Rapid-stache
/**
* This doesn't pretend to be a proper, or fully-featured templating library
* it's merely a light-weight one used for rapid prototyping.
* Anti-Features:
* - no precompilation
* - no fancy iteration or repeats
* - pretty much nothing except string replacement
* - basic filters
*
* https://gist.github.com/pentaphobe/7955994