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
:: development environment build script
:: by: Philip Smith
@echo off
color 0b
title Developer Environment Configurator
echo.
cls
:: -----------------------------------------------------------------------------------
:: Get System Information of Multiple Hosts
:: -----------------------------------------------------------------------------------
::
:: Scans one or many hosts via wmi queries.
:: Currenty supported datasets:
:: wmic os get /all
:: wmic qfe get /all
:: wmic logicaldisk get caption,description,filessystem,size,freespace,compressed
:: wmic process list brief
@thephilip
thephilip / rdotnet35-inst.cmd
Last active November 9, 2017 17:18
.NET3.5 Re-enabler
:: -------------------------------------
:: Inject .Net3.5 Remotely |
:: -------------------------------------
:: By: Philip Smith
:: Requires 'psexec' in PATH.
:: Download: https://live.sysinternals.com/
:: User executing script needs access to src
:: and in the administrators group on dest.
@echo off
@thephilip
thephilip / enum.js
Created August 17, 2017 15:24
Enumerated types in JavaScript
// create enumerated types in JavaScript
const EnumState;
(EnumState => { // ES6 IIFE!? No-ice
EnumState[EnumState["new"] = 1] = "new"
EnumState[EnumState["active"] = 2] = "active"
EnumState[EnumState["inactive"] = 3] = "inactive"
EnumState[EnumState["done"] = 4] = "done"
EnumState[EnumState["deleted"] = 5] = "deleted"
})( EnumState || ( EnumState = {} ) );
// Express.js
const express = require('express')
const app = express()
const router = express.Router()
router.route('/objects').get((req, res, next) => {
res.send('GET received for objects')
}).post((req, res, next) => {
res.send('POST received for objects')
// Module Skeleton
const MyModule = (function myModule(export) {
let _privateVar = 'oogieboogie'
export.myMethod = (i) => {
console.log(i);
}
export.myOtherMethod = (j) => {
console.log(j);
}
// Nodes & Trees Example
class Node {
constructor(val) {
this._val = val;
this._parent = null;
this._children = [];
}
isRoot() {
return isValid(this._parent);
// 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])
}
// using bind()
const partialBind = (fn, ...args) => {
return fn.bind(null, ...args);
};
// with a closure
const partial = (fn, ...args) => {
return (...moreArgs) => {
return fn(...args, ...moreArgs)
};
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' }