Skip to content

Instantly share code, notes, and snippets.

View josephmisiti's full-sized avatar

Joseph Misiti josephmisiti

View GitHub Profile
@josephmisiti
josephmisiti / ubicommands.markdown
Last active December 16, 2016 00:27
UBI Command Examples:

UBI Command Fields

Any UBI command consists of the following fields. Some are required, others are optional.

  1. name (required) - name of the the command in UBI.
  2. short_description (required) - description of command when <commands> is executed.
  3. error_message (required) - response UBI gives when command failed.
  4. success_message (required) - response that gives when command is successful. must contain {} to be valid. {} is used as a string substution (i,e, "Your horoscope is {}", where {} will be replaced by the response of the API.
  5. number_of_parameters (required) - the number of parameters (does not include API key) your function can accept. Currently 0 ("bloomberg") or 1 ("bible john316")
@josephmisiti
josephmisiti / gen.swift
Created November 11, 2016 18:19 — forked from blainerothrock/gen.swift
A Very Simple Genetic Algorithm Written in Swift 3
#!/usr/bin/env xcrun swift
/*
gen.swift is a direct port of cfdrake's helloevolve.py from Python 2.7 to Swift 3
-------------------- https://gist.github.com/cfdrake/973505 ---------------------
gen.swift implements a genetic algorithm that starts with a base
population of randomly generated strings, iterates over a certain number of
generations while implementing 'natural selection', and prints out the most fit
string.
@josephmisiti
josephmisiti / helloevolve.py
Created November 11, 2016 18:19
helloevolve.py - a simple genetic algorithm in Python
"""
helloevolve.py implements a genetic algorithm that starts with a base
population of randomly generated strings, iterates over a certain number of
generations while implementing 'natural selection', and prints out the most fit
string.
The parameters of the simulation can be changed by modifying one of the many
global variables. To change the "most fit" string, modify OPTIMAL. POP_SIZE
controls the size of each generation, and GENERATIONS is the amount of
generations that the simulation will loop through before returning the fittest
@josephmisiti
josephmisiti / list.markdown
Last active June 21, 2019 05:34
Joseph Christmas Book List
@josephmisiti
josephmisiti / README.md
Created August 18, 2016 21:47 — forked from riccardoscalco/README.md
Topojson of Italy (province)
@josephmisiti
josephmisiti / README.md
Created July 13, 2016 17:39 — forked from joshdover/README.md
Idiomatic React Testing Patterns

Idiomatic React Testing Patterns

Testing React components seems simple at first. Then you need to test something that isn't a pure interaction and things seem to break down. These 4 patterns should help you use a pattern that is repeatable and readable for the type of test you need.

Setup

I recommend doing all setup in the most functional way possible. If you can avoid it, don't set variables in a beforeEach. This will help ensure tests are isolated and make things a bit easier to reason about. I use a pattern

@josephmisiti
josephmisiti / comprehensions.md
Created March 27, 2016 14:55 — forked from bearfrieze/comprehensions.md
Comprehensions in Python the Jedi way

Comprehensions in Python the Jedi way

Beautiful is better than ugly. Explicit is better than implicit.

-- The Zen of Python

I frequently deal with collections of things in the programs I write. Collections of droids, jedis, planets, lightsabers, starfighters, etc. When programming in Python, these collections of things are usually represented as lists, sets and dictionaries. Oftentimes, what I want to do with collections is to transform them in various ways. Comprehensions is a powerful syntax for doing just that. I use them extensively, and it's one of the things that keep me coming back to Python. Let me show you a few examples of the incredible usefulness of comprehensions.

All of the tasks presented in the examples can be accomplished with the extensive standard library available in Python. These solutions would arguably be more terse and efficient in some cases. I don't have anything against the standard library. To me there is a certain

import os, sys
from time import mktime
from datetime import datetime
from git import Repo, InvalidGitRepositoryError
MAX_COMMITS_TO_GO_BACK = 200
BRANCH_TO_SEARCH = 'analytics-caching'
def display_commit(current_commit, previous_commit):
changed_files = []
// else if (this.state.activeAccordionTab === 'ordinance-law') {
// body = (
// <div className="panel-body">
// <div className="tab-content">
// <div className="tab-pane active">
//
// <div className="col-md-12">
//
// <div className="well">
// <RadioInput name='ordlaw'
var React = require('react');
var Router = require('react-router');
var Constants = require("../../constants/Constants")
var If = require("../common/If.react")
var Accordion = React.createClass({
propTypes: {
title: React.PropTypes.string,