Skip to content

Instantly share code, notes, and snippets.

Mike Reinstein mreinstein

Block or report user

Report or block mreinstein

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
View discrete-problem-solver.js
function createDiscreteProblem () {
return {
allAssignments: [ ],
variables: { },
constraints: [ ]
}
}
@mreinstein
mreinstein / transform-javascript.js
Created Feb 18, 2020
parse javascript from stdin as an AST and remove specific functions by name
View transform-javascript.js
import escodegen from 'escodegen'
import esprima from 'esprima'
import estraverse from 'estraverse'
let src = ''
process.stdin.on('data', function (chunk) {
src += chunk
})
@mreinstein
mreinstein / rollup-custom-plugin.js
Created Jul 26, 2019
This didn't end up being any faster than rollup-plugin-postcss. but it's probably worth holding onto in case I have to write another rollup plugin
View rollup-custom-plugin.js
import { execSync } from 'child_process';
export default function string () {
return {
name: 'sellpoints-import-autoprefix-css',
transform (code, id) {
if (!id.endsWith('.css'))
return;
@mreinstein
mreinstein / css-color-invert.js
Last active Feb 8, 2020
invert all colors on a web page
View css-color-invert.js
'use strict'
// invert all colors on the page
module.exports = function invert() {
var css = 'html {-webkit-filter: invert(100%);' +
'-moz-filter: invert(100%);' +
'-o-filter: invert(100%);' +
'-ms-filter: invert(100%); }',
head = document.getElementsByTagName('head')[0],
style = document.createElement('style')
@mreinstein
mreinstein / index.md
Created Aug 2, 2017
determine the TCP port on which a node.js program listens
View index.md

Find the pid of the running process if you don't know it:

$ ps ax | grep node
1012 ?        Ssl    0:03 node /usr/bin/signalhub listen -p 8000

In this case we're running a node program and it's pid is 1012

You can’t perform that action at this time.