Skip to content

Instantly share code, notes, and snippets.

View psenger's full-sized avatar
:octocat:
Makin Bacon

Philip A Senger psenger

:octocat:
Makin Bacon
View GitHub Profile
@psenger
psenger / Development.java
Last active March 2, 2020 21:39
[Example bug of Junit 4.8.1 regarding Categories and multiple BeforeClass Annotations] #Java
import org.junit.runner.*;
import org.junit.experimental.categories.*;
import org.junit.runners.*;
/**
* For use with testing a bug with Junit 4.8.1
**/
@RunWith(Categories.class)
@Categories.IncludeCategory(Development.class)
@Suite.SuiteClasses({MytestClass.class})
public class Development
@psenger
psenger / add_remove_class_with_js.md
Last active March 15, 2020 02:46 — forked from egeorjon/add_remove_class_with_js.md
[Add or Remove css class with Javascript] #css

From: StackOverflow

To change all classes for an element:

document.getElementById("MyElement").className = "MyClass";

To add an additional class to an element:

document.getElementById("MyElement").className += " MyClass";

To remove a class from an element:

@psenger
psenger / react-with-context.js
Last active October 29, 2020 22:34 — forked from hipertracker/react-with-context.js
[Example of using React context for ES6 classes] #ReactJs #JavaScript
import React, { PropTypes } from 'react';
@reactor
class Child extends React.Component {
componentDidMount() {
console.log('Child mounted with context reactor:', this.context.reactor);
}
render() {
return <span>Child Component</span>;
}
@psenger
psenger / tail.sh
Last active March 15, 2020 02:41
[How to tail files constantly for a string] #Unix
#
# How to tail files constantly for a string
#
tail -f *.log | grep --line-buffered PHIL
@psenger
psenger / webpack.config.dev.js
Last active October 29, 2020 22:33
[React-Create-App Webpack - SCSS] #ReactJs #JavaScript #Webpack #css
'use strict';
const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
const eslintFormatter = require('react-dev-utils/eslintFormatter');
@psenger
psenger / ultimate-ut-cheat-sheet.md
Last active February 6, 2020 23:43 — forked from yoavniran/ultimate-ut-cheat-sheet.md
[The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon] #JavaScript #TestHelper

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


@psenger
psenger / 1-restify-server-cheatsheet.js
Last active October 6, 2020 00:10 — forked from LeCoupa/1-restify-server-cheatsheet.js
[Restify CheatSheet] #RESTify #JavaScript
// Restify Server CheatSheet.
// See: http://journal.gentlenode.com/node-3-restify-cheatsheet/
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
@psenger
psenger / .env.DEV.enc
Last active February 26, 2024 05:11
[OpenSSL Encrypted Environment Variables] #OpenSSL #TravisCi #CodeShip #AWS #Docker #Swarm
U2FsdGVkX18bL0goCbiTjHFGnkwWagZSYjhvkaU1hXA=
@psenger
psenger / GenerateFullRangeOfChars.js
Last active February 1, 2020 00:00
[Generate Full Range of Chars in Javascript] #JavaScript #TestHelper
// I needed something to create a string of characters for testing, Im lazy.
// Generate Full Range of Chars
// I needed something to create a string of characters for testing, Im lazy.
var res = '';
for ( var i = 33; i<=126; i++ ) {
res = res + String.fromCharCode(i);
console.log('i=',i,String.fromCharCode(i));
}
console.log( 'res=', res );
@psenger
psenger / promiseSerial.js
Last active February 1, 2020 00:08
[Promise Design Patterns for serial actions] #JavaScript #Promise
/**
* Sequentially execute an array of functions that return promises.
* @example:
* .then((data)=>{
* const functions = data.map( (body) => {
* return () => {
* return requestPromise({
* method: 'PATCH',
* uri: `${HOST}:${PORT}/update`,
* headers: {Authorization: `JWT ${token}`},