Skip to content

Instantly share code, notes, and snippets.

View paddymul's full-sized avatar

Paddy Mullen paddymul

View GitHub Profile
@paddymul
paddymul / py-rel.org
Created March 17, 2012 13:32
Python relative imports

How to use python relative imports

Don’t. They are tempting, but they are a really big mess. Let’s start by figuring out what you’re really trying to accomplish. Let’s start with a directory structure.

/Grand-
@paddymul
paddymul / sumclasses
Created January 15, 2013 15:36
find html elements with the same combination of classes applied to them
window.sumClasses = () ->
c_set = {}
$("*").each((count, el) ->
window.el = el
clist = []
_.each(el.classList, (cname) ->
clist.push(cname))
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@paddymul
paddymul / gist:dd5422d8e809d9d495b8
Created June 28, 2014 18:33
Best trips to take via citibike vs taxi
SELECT
tas.start_station_id AS start_id, tas.end_station_id AS end_id,
ROUND(tas.avg_taxi_time,2) AS avg_taxi, ROUND(cas.cb_trip_duration,2) AS avg_cb,
ROUND(cas.cb_trip_duration -tas.avg_taxi_time, 2) AS diff,
tas.tt_trip_count AS tt_cnt, cas.cb_trip_count AS cb_cnt,
'https://www.google.com/maps/dir/' || cs1.latitude || ','|| cs1.longitude || '/' || cs2.latitude ||','|| cs2.longitude
FROM
citibike_agg_stat AS cas,
taxi_agg_stat AS tas,
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider, Button, RadioButtons
class PlotController(object):
def __init__(self):
self.figs = []
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var FlatBush = require("flatbush");
var bbox_1 = require("./bbox");
var SpatialIndex = /** @class */ (function () {
function SpatialIndex(points) {
this.points = points;
this.index = null;
if (points.length > 0) {
this.index = new FlatBush(points.length);
@paddymul
paddymul / hook-add-or-update.el
Created December 31, 2021 18:42
An elisp macro that makes hook development much easier by automatically removing old version of hook
(defmacro hook-add-or-update (hook fname &rest body)
"Macro to make defining and updating hooks much easier.
Hook functions get an fname.
Before defining and adding a hook to a list, macro first checks if that fname is already defined, if so, the old version is removed from hook
used as follows
(hook-add-or-update
shell-mode-hook fourth-shell-hook
(message \"macro fourth rev 2\"))"

With the new release of buckaroo, df.head() is obsolete. I have worked to make Buckaroo usable as the default table visualization for pandas dataframes. It does this through sensible defaults and down sampling. The default process of investigating a new dataset with pandas and jupyter is to load a dataframe from csv, parquet, or some other data source. The next step is df.head() or df.describe(), if you just type df pandas will try to show the first 5 rows and last 5 rows, and possibly all of the columns. Pandas needs to limit the output to avoid overwhelming a notebook with text output, and causing performance issues. Soon you will find yourself looking up pd.options.display.width = 0 or pd.options.display.max_rows = 500

with pd.option_context('display.max_rows', None, 'display.max_columns', None):
 print (df)

Eventually you will want to look at a subset of rows, using slicing. Looking up sorting… How do I find the rows with the highest or lowest values in a column you could use some