Skip to content

Instantly share code, notes, and snippets.

View thephilip's full-sized avatar
🎩
Think like a man of action, act like a man of thought.

Philip Smith thephilip

🎩
Think like a man of action, act like a man of thought.
  • Red Hat
  • Saint Petersburg, Florida
View GitHub Profile
@thephilip
thephilip / fixJNLPAssociation.cmd
Last active October 6, 2016 18:39
Java JNLP File Association Fix
@echo off
color e9
goto :CHECKPERMS
:RUN
:: Kill all IE processes
taskkill /f /im iexplore.exe /t >nul 2>&1
ping -n 1 127.0.0.1 >nul 2>&1
@thephilip
thephilip / startnet.cmd
Created October 6, 2016 18:38
Startnet Replacement Script for Custom Deployment Scripts (PIP)
@echo off
echo ##### ## ##### # ##### ##
echo ###### /### ###### / ###### /###
echo /# / / ### /# / / /# / / ###
echo / / / ### / / / / / / ###
echo / / ## / / / / ##
echo ## ## ## ## ## ## ## ##
echo ## ## ## ## ## ## ## ##
echo /### ## / /### ## /### ## /
@thephilip
thephilip / method.js
Created November 15, 2016 16:32
Method Implementation
// implements method
if (typeof Function.prototype.method !== "function") {
Function.prototype.method = function (name, implementation) {
this.prototype[name] = implementation;
return this;
};
}
@thephilip
thephilip / profile.ps1
Last active November 30, 2016 14:09
Custom PowerShell Profile
# -----------------------------
# Custom PowerShell Profile
# By: Philip Smith
# -----------------------------
# Requires -Version 3
# -----------------------------
# Customizable Variables
# -----------------------------
@thephilip
thephilip / Tuple.js
Created March 17, 2017 21:26
JavaScript Tuple Implementation
/*
* Tuple.js - JavaScript Tuple Implmentation
* ------------------------------------------------
* The Tuple object is an immutable, fixed-length
* structure used to hold a heterogeneous set of n
* typed values that can be used for inter-function
* communication. For instance, you can use it to
* build quick value objects.
*
/* Function object extension to add memoization
* to any single-argument function.
*/
Function.prototype.memoized = function () {
let key = JSON.stringify(arguments);
this._cache = this._cache || {};
this._cache[key] = this._cache[key] ||
this.apply(this, arguments);
// factorial (imperitive)
const factorial = n => {
let result = 1;
while (n > 1) {
result *=n;
n--;
}
return result;
};
const map = fn => array => array.map(fn);
const multiply = x => y => x * y;
const pluck = key => object => object[key];
const discount = multiply(0.98);
const tax = multiply(1.0925);
const custReq = request({
headers: { 'X-Custom': 'mykey' }
// using bind()
const partialBind = (fn, ...args) => {
return fn.bind(null, ...args);
};
// with a closure
const partial = (fn, ...args) => {
return (...moreArgs) => {
return fn(...args, ...moreArgs)
};
// Dependency Injection
const assert = require('assert')
function getAnimals(fetch, id) {
return fetch('http://api.animalfarmgame.com/animals/' + id)
.then(response => response.json())
.then(data => data.results[0])
}