Skip to content

Instantly share code, notes, and snippets.

View machine.js
const machine = Machine({
id: 'machine',
type: 'parallel',
states: {
order: {
initial: 'DoesNotExist',
states: {
DoesNotExist: {
on: {
MB_send_order: 'UNSENT',
View machine.js
const fetchMachine = Machine({
id:'newOrder',
initial: 'DoesNotExist',
states: {
DoesNotExist: {
on: {
MB_create_order: 'UNSENT',
}
},
UNSENT: {
@meetbryce
meetbryce / .zshrc
Last active Dec 9, 2019
Autoload virtualenv from .venv when moving into a directory
View .zshrc
# autoload venv if there's a .venv file
# Support for bash
PROMPT_COMMAND='prompt'
# Mirrored support for zsh. See: https://superuser.com/questions/735660/whats-the-zsh-equivalent-of-bashs-prompt-command/735969#735969
precmd() { eval "$PROMPT_COMMAND" }
function prompt()
{
if [ "$PWD" != "$MYOLDPWD" ]; then
@meetbryce
meetbryce / script.js
Last active Jun 18, 2018
Calculate binary statistical significance (with 99% confidence)
View script.js
// require('jStat');
function calculateSignificance(a_sessions, a_conversions, b_sessions, b_conversions) {
a_cr = a_conversions / a_sessions;
b_cr = b_conversions / b_sessions;
a_stdErr = Math.sqrt(a_cr * (1 - a_cr) / a_sessions);
b_stdErr = Math.sqrt(b_cr * (1 - b_cr) / b_sessions);
// get_z_score()
const z_score =
@meetbryce
meetbryce / setup.md
Created Oct 17, 2017 — forked from shashankmehta/setup.md
Setup PHP and Composer on OSX via Brew
View setup.md

First install Brew on your MAC

  • Setup Brew: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • brew update
  • brew tap homebrew/dupes
  • brew tap homebrew/php
  • Install PHP 7.0.+ brew install php70
  • Install mcrypt: brew install mcrypt php70-mcrypt
  • Finally, install composer: brew install composer
@meetbryce
meetbryce / Add API stage as key, value (property) to POST data in API Gateway
Created Sep 11, 2016
Template for adding new key:value pair (property) to your AWS API Gateway Body Mapping Template
View Add API stage as key, value (property) to POST data in API Gateway
{
"stage" : "$context.stage",
#foreach( $key in $input.path('$').keySet() )
"$key": "$input.path('$').get($key)"#if($foreach.hasNext),
#end
#end
}
@meetbryce
meetbryce / Stop Permssion Errors on Firebase & AngularFire Logout - README.md
Last active Feb 22, 2019
Prevent permission denied errors from Firebase on logout (caused by active $firebaseArray & $firebaseObject connections not being destroyed). Example code follows John Papa's style guide.
View Stop Permssion Errors on Firebase & AngularFire Logout - README.md
View gulpfile.js
var gulp = require('gulp');
var electron = require('gulp-atom-electron');
var del = require('del');
gulp.task('clean:dist', function () {
return del(['dist/**', '!dist']);
})
gulp.task('default',['clean:dist'], function () {
var electronConfig = { version: '0.33.6', platform: 'darwin', token: '326cd8521a4fa11371bb89e1bec56a03f704a7e5' };
@meetbryce
meetbryce / Best Practice Wordpress Theme Title Code
Last active Aug 29, 2015
Best Practice Wordpress Theme Title Code
View Best Practice Wordpress Theme Title Code
<title><?php
if (is_home () ) { echo sprintf('The %s Blog', get_bloginfo(‘name’)); }
elseif ( is_category() ) { single_cat_title(); echo ‘ - ‘ ; bloginfo(‘name’); }
elseif (is_single() ) { echo sprintf('%s – The %s Blog', single_post_title(false), get_bloginfo(‘name’));}
elseif (is_page() ) { single_post_title();}
else { wp_title('',true); echo sprintf(' Blog – %s', get_bloginfo(‘name’));}
?></title>
@meetbryce
meetbryce / avg_or_sum_array_with_js.js
Last active May 12, 2019
Average or Sum the values in an array using Javascript (and Underscore.js)
View avg_or_sum_array_with_js.js
// requires Underscore.js
// uses jQuery style funciton declaration (if you aren't using jQuery, simply re-arrange the declaration)
function sum(arr) {
// returns the sum total of all values in the array
return _.reduce(arr, function(memo, num) { return memo + num}, 0);
}
function average(arr) {
// returns the average of all values in the array