Skip to content

Instantly share code, notes, and snippets.

View josephmisiti's full-sized avatar

Joseph Misiti josephmisiti

View GitHub Profile
@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 = []
@josephmisiti
josephmisiti / springer-free-maths-books.md
Created December 28, 2015 19:49 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of maths books available for free, here are the direct links
@josephmisiti
josephmisiti / README.md
Last active December 2, 2015 16:18 — forked from mbostock/.block
X-Value Mouseover

A line chart with mouseover so that you can read the y-value based on the closest x-value. The x-value is found using d3.mouse and scale.invert. The y-value is then found by bisecting the data.

@josephmisiti
josephmisiti / README.md
Last active September 10, 2015 03:52 — forked from joyrexus/README.md
time in go

Working with time in Go is pretty straightforward.

Times

Get the current local time:

now := time.Now()                                   // 02 Apr 15 14:03

Construct a time with Date(y, m, d, h, m, s, ns, loc):

@josephmisiti
josephmisiti / .tm_properties
Last active September 9, 2015 17:32
My global textmate 2 config
# Basic Settings
fontName = "Panic Sans"
fontSize = 15
# Extra files to include
myExtraIncludes = ".env,.gitignore,.htaccess,.pryrc,.rspec,.rspec_parallel,.rvmrc,.ruby-gemset,.ruby-version,.tm_properties,.travis.yml"
fileBrowserGlob = "{*,$myExtraIncludes}"
include = "{$include,$myExtraIncludes}"
includeInFileChooser = "{$includeInFileChooser,$myExtraIncludes}"
@josephmisiti
josephmisiti / README.md
Last active June 14, 2022 02:00 — forked from mango314/README.md
a map of all 2166 Census Tracts of New York City in Python Matplotlib

Census Tracts of New York City

Here at PyData NYC, I heard a tutorial of how to use numpy and iPython notebooks. In a previous gist, I wrote drew all the zip codes of the Bronx in d3.js

This would be great for reproducing inforgraphics like Educational Attainment in New York City -- Brooklyn which looks a bit like a jigsaw puzzle:

Where to Obtain the Data

/**
* FreeBSD privilege escalation CVE-2013-2171 (credits Konstantin Belousov & Alan Cox)
*
* tested on FreeBSD 9.1
* ref: http://www.freebsd.org/security/advisories/FreeBSD-SA-13:06.mmap.asc
*
* @_hugsy_
*
* Syntax :
$ id