Skip to content

Instantly share code, notes, and snippets.

View nomeyer's full-sized avatar

Nick Omeyer nomeyer

View GitHub Profile
@nomeyer
nomeyer / performance.js
Last active March 24, 2016 19:49
JavaScript to measure the performance of something
var start = performance.now();
var end = performance.now();
console.log('Doing stuff took ' + (end-start) + 'ms');
@nomeyer
nomeyer / npm_list.sh
Last active March 14, 2016 14:53
List installed packages (from https://docs.npmjs.com/cli/ls)
npm ls
#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.6
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
@nomeyer
nomeyer / simple_scraper.py
Last active March 13, 2016 21:05
Ridiculously simple scraper (out of date)
import urllib2
import BeautifulSoup
request = urllib2.Request("http://www.gpsbasecamp.com/national-parks")
response = urllib2.urlopen(request)
soup = BeautifulSoup.BeautifulSoup(response)
for a in soup.findAll('a'):
if 'national-park' in a['href']:
print 'found a url with national-park in the link'
import os
import sys
walk_dir = sys.argv[1]
print('walk_dir = ' + walk_dir)
# If your current working directory may change during script execution, it's recommended to
# immediately convert program arguments to an absolute path. Then the variable root below will
# be an absolute path as well. Example:
In [1]: df1 = pd.DataFrame({'A': ['A0', 'A1', 'A2', 'A3'],
...: 'B': ['B0', 'B1', 'B2', 'B3'],
...: 'C': ['C0', 'C1', 'C2', 'C3'],
...: 'D': ['D0', 'D1', 'D2', 'D3']},
...: index=[0, 1, 2, 3])
...:
In [2]: df2 = pd.DataFrame({'A': ['A4', 'A5', 'A6', 'A7'],
...: 'B': ['B4', 'B5', 'B6', 'B7'],
...: 'C': ['C4', 'C5', 'C6', 'C7'],
import pandas
df = pandas.DataFrame(data)
# Randomly sample 70% of your dataframe
df_0.7 = df.sample(frac=0.7)
# Randomly sample 7 elements from your dataframe
df_7 = df.sample(n=7)
@nomeyer
nomeyer / new_doc.html
Created March 11, 2016 13:52
Some HTML boilerplate for a new document
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="">
</head>
<body>
<script type="text/javascript" src=""></script>
</body>