Skip to content

Instantly share code, notes, and snippets.

View dtothefp's full-sized avatar

David Fox-Powell dtothefp

  • Flexport
  • United States
View GitHub Profile
import request from 'superagent';
import cheerio from 'cheerio';
import vo from 'vo';
import {readFile} from 'fs';
/**
* An example generator
*/
function *gen(init) {
//confusing because what is stored in `first` variables is not what is returned from
const requireTest = require.context('./test', true, /_test\.js$/);
requireTest.keys().forEach(requireTest); //stolen directly from @shama
const transportationList = (
<ul>
<li>Armored Car</li>
<li className="active">Hyperloop</li>
</ul>
);
ReactDOM.render(
transportationList,
document.getElementById(‘app’)
.even {
background-color: lavenderblush;
}
.odd {
background-color: goldenrod;
}
.even {
background-color: lavenderblush;
}
.odd {
background-color: goldenrod;
}
// HOC and context
// provide context with HOC
import App from './components/App';
import ProvideContext from './containers/ProvideContext';
const transportationTypes = [
'armored car',
'fire engine',
'golf cart',
git ls-remote https://github.com/docker/compose | grep refs/tag | grep -o "[0-9]\.[0-9]\{1,2\}\.[0-9]\{1,2\}$" | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | tail -n 1

Variables

  • $0 - The name of the Bash script.
  • $1 - $9 - The first 9 arguments to the Bash script. (As mentioned above.)
  • $# - How many arguments were passed to the Bash script.
  • $@ - All the arguments supplied to the Bash script.
  • $* - All the arguments supplied to the Bash script seperated by the IFS.
  • $? - The exit status of the most recently run process.
  • $$ - The process ID of the current script.
  • $USER - The username of the user running the script.
  • $HOSTNAME - The hostname of the machine the script is running on.

Bubble Sort

  • good for nearly sorted lists
  • look at consecutive pairs
  • passes over entire list
    • everytime do a pass, the largest card in first pair not in correct position will be moved into correct position
  • each pass one card is guaranteed to be moved to correct position
function *foo(x) {
var y = 2 * (yield (x + 1));
var z = yield (y / 3);
return (x + y + z);
}
//this "instantiates" (not sure if this is correct??) the generator
//and returns an object with a `next` method
var it = foo( 5 );