Skip to content

Instantly share code, notes, and snippets.

View goatslacker's full-sized avatar

Josh Perez goatslacker

View GitHub Profile
import math
pokemon = {
"bulbasaur":{"stamina":90,"attack":118,"defense":118},
"ivysaur":{"stamina":120,"attack":151,"defense":151},
"venusaur":{"stamina":160,"attack":198,"defense":198},
"charmander":{"stamina":78,"attack":116,"defense":96},
"charmeleon":{"stamina":116,"attack":158,"defense":129},
"charizard":{"stamina":156,"attack":223,"defense":176},
"squirtle":{"stamina":88,"attack":94,"defense":122},
[
{
"id": 1,
"name": "BULBASAUR",
"type1": "GRASS",
"type2": "POISON",
"stats": {
"stamina": 90,
"attack": 118,
"defense": 118
@goatslacker
goatslacker / bench-react.js
Created October 10, 2016 17:34
Benchmarking React with different variances like props, components, markup size, etc
const Benchmark = require('benchmark');
const React = require('react/dist/react.min');
const ReactDOMServer = require('react-dom/dist/react-dom-server.min');
const suite = new Benchmark.Suite();
// ==========================================================================
// LotsOfBytes test:
// > A metric shit ton of markup output by a single React element.
function Matchup(props) {
const matchups = props.name ? idealMatchup.overall(props.name) : []
return (
$(B.View, [
$(B.Header, 'Ideal Matchup'),
$(B.Text, 'This is calculated based on the opposing Pokemon\'s type and assuming the opponent has the best possible moveset combination for their Pokemon. The results do not include legendaries. Pokemon type effectiveness and resistances are also taken into account.'),
$('hr'),
$(FormPokemonName, { name: props.name }),
matchups.length ? (
$(B.Table, {
@goatslacker
goatslacker / alt-store-reducer.js
Created June 4, 2015 05:27
Writing a simple store as a reducer
import Alt from 'alt'
const alt = new Alt()
const CounterActions = alt.createActions({
inc: x => x,
dec: x => x,
});
const CounterStore = alt.createStore({
[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]](([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(![]+[])[!+[]+!![]]+([][[]]+[])[!+[]+!![]+!![]]+[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+([][[]]+[])[+[]]+([][[]]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(![]+[])[!+[]+!![]+!![]]+([]+{})[!+[]+!![]+!![]
var React = require('react')
var foo = React.createClass({
render: function () {
return React.createElement('select', null, [
React.createElement('option', {
key: 1,
value: 1,
dangerouslySetInnerHTML: { __html: '<strong>yes</strong>' },
}),
var jshint = require('jshint').JSHINT
var code = 'var hello; '
var fixmyjs = require('./fixmyjs')
jshint(code, { trailing: true })
console.log(JSON.stringify(fixmyjs(jshint.data(), code).run())) // = "var hello;"
(function () {
var fact;
fact = function (n, sum) {
while (true) {
switch (false) {
case !(arguments.length === 1):
return fact(n, 1);
case !(n === 0 && arguments.length === 2):
return sum;
default:
var underscore = require('underscore');
var _uniqueId = 0;
function _(coll) {
this._ = coll;
}
_.extend = function(obj) {
var args = [].slice.call(arguments, 1);
args.forEach(function(arg) {