Skip to content

Instantly share code, notes, and snippets.

View nmccready's full-sized avatar

nmccready nmccready

View GitHub Profile
@nmccready
nmccready / install-gradle-centos.sh
Created July 23, 2019 20:54 — forked from parzonka/install-gradle-centos.sh
Install gradle on redhat/centos linux
# installs to /opt/gradle
# existing versions are not overwritten/deleted
# seamless upgrades/downgrades
# $GRADLE_HOME points to latest *installed* (not released)
gradle_version=2.9
wget -N https://services.gradle.org/distributions/gradle-${gradle_version}-all.zip
sudo unzip -foq gradle-${gradle_version}-all.zip -d /opt/gradle
sudo ln -sfn gradle-${gradle_version} /opt/gradle/latest
sudo printf "export GRADLE_HOME=/opt/gradle/latest\nexport PATH=\$PATH:\$GRADLE_HOME/bin" > /etc/profile.d/gradle.sh
. /etc/profile.d/gradle.sh
@nmccready
nmccready / composition.js
Created July 8, 2019 16:53
Simple Function Composition to not rely out `this`
/* Similar to recompose withProps but for object composition */
export const withProps = (extension) => (state) => {
const ext = extension(state);
return {
...state,
...ext,
};
};
@nmccready
nmccready / arguments.sh
Created April 23, 2019 20:16
argument collector
#!/bin/sh
set -e
set -o pipefail
# collect arguments to forward on
while [[ "$#" > 0 ]]; do case $1 in
# example to save value
# -v|--data-volume) shift; dataVolume=$1;; # --data-volume someval
*) args[${#args[@]}]=$1;;
esac; shift; done
@nmccready
nmccready / Component.js
Created April 4, 2019 16:13
withContext HOC providing Contexts
// usage example
const ChildComponent = ({ CanvasContext }) => {
const { setCanvasEl } = useContext(CanvasContext);
return <canvas ref={setCanvasEl} />;
}
const Component = ({ CanvasContext }) => {
const {canvasEl } = useContext(CanvasContext);
const contexts = { CanvasContext };
// .. do something with canvasEl
@nmccready
nmccready / operators.js
Last active February 28, 2019 16:58
RxJS Operator Simplification / Creation 6.x
export const basic = (subscriber) => (origSource) =>
origSource.lift({
call(dest, source) {
return source.subscribe(subscriber(dest));
}
});
export const through = (cb) =>
basic((dest) => {
return {
@nmccready
nmccready / lodashExt.js
Created February 25, 2019 16:20
Lodash memoizeDebounce and throttle extensions
import { debounce, throttle } from 'lodash';
import memoize from 'memoizee';
// Memoize to use unique args, and debounce to only get the last call
// https://github.com/lodash/lodash/issues/2403#issuecomment-290760787
export const memoizeDebounce = (func, wait = 0, options = {}) => {
const { leading, maxWait, trailing, ...memoizeOptions } = options;
const mem = memoize(
() => debounce(func, wait, { leading, maxWait, trailing }),
@nmccready
nmccready / launch.json
Created January 24, 2019 18:04
vscode settings
{
"version": "0.2.0",
"configurations": [
{
"name": "Spear UI",
"type": "node",
"request": "launch",
"env": {
"ELECTRON_ARGS": "[\\\"--inspect-brk\\\"]",
"DEBUG": "SPEAR*,spear-ui*"
@nmccready
nmccready / requiredArgs.sh
Created January 15, 2019 17:59
required arguments shell
#!/bin/sh
set -e
set -o pipefail
while [[ "$#" > 0 ]]; do case $1 in
-f|--from) shift; FROM=$1;;
-t|--to) shift; TO=$1;;
-d|--dest) shift; DEST=$1;;
*) echo "Unknown parameter passed: $1"; exit 1;;
esac; shift; done
@nmccready
nmccready / betterCommentsCrap.js
Created December 14, 2018 18:25
Better COmments Example
// BY BETTER COMMENTS https://marketplace.visualstudio.com/items?itemName=aaron-bond.better-comments
// TODO Yay Common standard
// * TODO urgent or some other meaning (better comments says urgent but red seems better)
// !! TODO Urgent or Deprecated?
// @todo not identifiable as this is a standard for block comments
// !! @todo look to get color I must put !!
// ? should we do this
// NOTE - probabaly can add something for this
// FIXME
@nmccready
nmccready / gitSubmodulesUnFuck.sh
Last active March 22, 2024 15:09
unfuck git submodules
rm -rf $@ && git checkout origin/master $@ && git submodule update --init