Skip to content

Instantly share code, notes, and snippets.

Avatar

Jake Gustafson jgusta

  • Guitartricks
  • San Francisco
View GitHub Profile
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
View match.js
/*
source: https://codeburst.io/alternative-to-javascripts-switch-statement-with-a-functional-twist-3f572787ba1c
the match() function is an alternative to a switch statement.
Benefits are:
The chain is an expression, unlike a switch statement.
Each case has its own scope.
The default case (.otherwise()) is mandatory.
result = match(2)
@jgusta
jgusta / dump_walk.php
Created Nov 25, 2019
A function that returns a big string version of var_dump or print_r except it descends into private props and shows things in as compact manner as possible.
View dump_walk.php
<?php
if (!function_exists('dump_walk')) {
/**
* This function is like print_r($node, true) but cleaner
* @param $node
* @param string $indent_string
* @param int $depth
* @param null $parentType
* @return string
*/
@jgusta
jgusta / clearCacheFiles.php
Created Apr 25, 2017
The removed clearCacheFiles() function
View clearCacheFiles.php
function clearCacheFiles($cacheLocation) {
if (is_string($cacheLocation)) {
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($cacheLocation), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
if ($file->isFile()) {
@unlink($file->getPathname());
}
}
}
}
@jgusta
jgusta / gist:8787983
Last active Aug 29, 2015
Mango Quinoa Black Bean Salad
View gist:8787983
2 cups cooked quinoa, cooked in vegetable or chicken broth, at room temperature or chilled
1 (15-ounce) can black beans, drained and rinsed
2 medium mangos, peeled and diced
2 red bell pepper, diced
4 green onions, white and green parts thinly sliced
1/2 cup chopped fresh cilantro
4 tablespoon red wine vinegar
3 tablespoons extra virgin olive oil
1-2 tablespoons fresh lime juice
1/2 teaspoon kosher salt
You can’t perform that action at this time.