Skip to content

Instantly share code, notes, and snippets.

View mtheoryx's full-sized avatar
🐳
Making happy little clouds

David Poindexter mtheoryx

🐳
Making happy little clouds
View GitHub Profile
@mtheoryx
mtheoryx / factorial.js
Last active December 15, 2016 23:27
one liner factorial function in javascript with ES2016
const factorial = n => (n <= 1) ? 1 : n * factorial(n-1);
console.log(factorial(0)); //1
console.log(factorial(1)); //1
console.log(factorial(3)); //6
console.log(factorial(4)); //24
console.log(factorial(5)); //120
@mtheoryx
mtheoryx / recursion.js
Last active August 28, 2016 22:29
Simple functional recursion in JavaScript
//Let's do some recursion!
// What is recursion? Well, I got a great tip on explaining
// this from the Youtuber, funfunfunction
// whose video on the topic you can find here:
// https://www.youtube.com/watch?v=k7-N8R0-KY4
// In short, a recursive fuction is a function that calls
// itself... until it doesn't (we call that the base case)
@mtheoryx
mtheoryx / expect.sh
Created August 23, 2016 21:28
mocha snoop reporter
// expectedResult.should.not.be( [null, null, null] );
mocha --reporter snoop
...
1 test failed: Expected [null, null, null] to not be like it is, but it do.
0 info it worked if it ends with ok
1 verbose cli [ '/Users/davpoind2/.nvm/versions/node/v4.4.0/bin/node',
1 verbose cli '/Users/davpoind2/.nvm/versions/node/v4.4.0/bin/npm',
1 verbose cli 'run',
1 verbose cli 'commit' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'precommit', 'commit', 'postcommit' ]
5 info precommit [email protected]
6 info commit [email protected]
davpoind2@DRP3:~/code/contrib/stack-overflow-copy-paste [git:pr/object-size]
β†’: npm run commit
> [email protected] commit /Users/davpoind2/code/contrib/stack-overflow-copy-paste
> git-cz
[email protected], [email protected]
Line 1 will be cropped at 100 characters. All other lines will be wrapped after 100 characters.

😼 | 🚢 🏑 | πŸ‘ πŸ”” πŸ”” πŸƒ | πŸ’€ πŸ’€ πŸšͺ | 😱 πŸ”₯ πŸ’© 😱 😱 πŸ‘£ πŸ‘£ | πŸ’€ 😐 😧 | 😰 😑 | πŸƒ πŸ”«

@mtheoryx
mtheoryx / loljs.null.js
Created June 22, 2016 23:20
NULL!! Y U NO PRIMITIVE?!
//Null is a special thing in JavaScript, and I find it funny
//What isi null?
console.log(typeof null)
// -> object
// Cool! So, if I wanted to see how to use an object
// Properties, functions, fun stuff
// what would I do? List out them keys!
Object.keys({'test': 'bob', 'bob': () => {}}).forEach(key => console.log(`Key from example: ${key}`));
@mtheoryx
mtheoryx / index.js
Created March 12, 2016 17:43
Use webpack for a totally static site, with hot reload!
.
β”œβ”€β”€ build
β”‚Β Β  β”œβ”€β”€ index.html
β”‚Β Β  └── main.js
β”œβ”€β”€ drp-redesign.md
β”œβ”€β”€ drp_profile.png
β”œβ”€β”€ node_modules
β”‚Β Β  └── file-loader
β”‚Β Β  β”œβ”€β”€ README.md
β”‚Β Β  β”œβ”€β”€ index.js
@mtheoryx
mtheoryx / gist:4510a108310c60cd4cdc
Created November 10, 2015 01:14 — forked from ghais/gist:3989200
Is Hell exothermic or endothermic
The following is supposedly an actual question given on a University of Washington chemistry mid-term. The answer by one student was so
"profound" that the professor shared it with colleagues, via the Internet, which is, of course, why we now have the pleasure of enjoying it as well.
Is Hell exothermic (gives off heat) or endothermic (absorbs heat)?Most of the students wrote proofs of their beliefs using Boyle's Law (gas cools when it expands and heats when it is compressed) or some variant.
One student, however, wrote the following:
Object.prototype.toString = function() {
console.log("NO STRINGS FOR YOU!!");
return null;
}