Skip to content

Instantly share code, notes, and snippets.

View paulgb's full-sized avatar

Paul Butler paulgb

View GitHub Profile
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@z-m-k
z-m-k / LICENSE
Last active October 30, 2016 22:37
A Python class that allows to incorporate d3js and Python (IPython notebook mainly). See at: http://nbviewer.ipython.org/4484816/ipyD3sample.ipynb
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. {http://fsf.org/}
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
@badocelot
badocelot / damlevdist.py
Last active September 8, 2023 00:13
Damerau-Levenshtein edit distance calculator in Python. Based on pseudocode from Wikipedia: <https://en.wikipedia.org/wiki/Damerau-Levenshtein_distance>
# Damerau-Levenshtein edit distance implementation
# Based on pseudocode from Wikipedia: https://en.wikipedia.org/wiki/Damerau-Levenshtein_distance
def damerau_levenshtein_distance(a, b):
# "Infinity" -- greater than maximum possible edit distance
# Used to prevent transpositions for first characters
INF = len(a) + len(b)
# Matrix: (M + 2) x (N + 2)
matrix = [[INF for n in xrange(len(b) + 2)]]
@tdhopper
tdhopper / The error I get from the code below
Last active December 23, 2015 22:39
Causes error. Seems to be related to type.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-7-01896d0e98b9> in <module>()
5 df = pd.DataFrame({"content":["tim hopper", "this data tim"]})
6 mapper = DataFrameMapper([("content", CountVectorizer())])
----> 7 mapper.fit_transform(df)
C:\Anaconda\lib\site-packages\sklearn\base.pyc in fit_transform(self, X, y, **fit_params)
406 if y is None:
407 # fit method of arity 1 (unsupervised transformation)
@bbengfort
bbengfort / lsys.py
Last active August 16, 2023 06:03
Draw an L-System with Python's turtle graphics library, where the L-System is defined with a turning angle (d) a line length (l) and an axiom in the using the characters 'F', 'f', '+', and '-' to indicate rules. You can also iterate the axiom for fractal like patterns.
#!/usr/bin/env python
import turtle
D = 90
L = 10
def iterate(axiom, num=0, initator='F'):
"""
Compute turtle rule string by iterating on an axiom
meta-chart.com
stylecaster.com
abcgreeknews.blogspot.gr
universeparadise.com
cultofmac.com
washingtontimes.com
smithsonianmag.com
EngagingEdu.com, mathwarehouse.com
minecraft-mp.com
youngcons.com
#define _USE_MATH_DEFINES
#include <math.h>
struct Point
{
double x, y;
};
// A class that contains a 2D angle as a pair of sine + cosine values.
// Sometimes, this approach saves substantial CPU time that would be wasted running these trigonometry functions.