Skip to content

Instantly share code, notes, and snippets.

View daf's full-sized avatar
✴️
halp

Dave Foster daf

✴️
halp
View GitHub Profile
@chriswhong
chriswhong / convert csv with WKT to GeoJson
Last active March 5, 2020 13:19
How to parse a CSV with a well-known text geometry column and convert to geojson FeatureCollection with the 'wellknown' package
// Use papa parse to download and parse a CSV
Papa.parse('data/nyc_zoning_lots.csv', {
download: true,
header: true,
complete: ({ data }) => {
// transform array of objects to geojson FeatureCollection
const FC = {
type: 'FeatureCollection',
features: data.map((row) => { // map csv rows to geojson features
const geometry = wellknown.parse(row.geom) // WKT to geojson geometry
const express = require('express');
const app = express();
// Application
app.get('/', function(req, res) {
if (process.env.NODE_ENV === 'development') {
for (var key in require.cache) {
delete require.cache[key];
}
}

gif-from-tweet

There are so many great GIFs out there and I want to have copies of them. Twitter makes that harder than it should be by converting them to MP4 and not providing access to the source material. To make it easier, I made a bash pipeline that takes a tweet URL and a filename, extracts the MP4 from that tweet and uses ffmpeg to convert back to GIF.

Dependencies

  • ffmpeg
    • macOS: brew install ffmpeg
    • Ubuntu/Debian: apt install ffmpeg
const fs = require('fs');
const d3 = require('d3-dsv');
const path = require('path');
const yaml = require('js-yaml');
const toMarkdown = require('to-markdown');
d3.csvParse(
fs.readFileSync('./goodreads_library_export.csv', 'utf8')
).filter(row => {
return row['Exclusive Shelf'] !== 'to-read';
@boneskull
boneskull / README.md
Last active April 10, 2024 12:47
example of how to debug mocha v4 if hanging

Here's an example of how to debug Mocha v4 if it hangs.

Ensure you're using a Node.js 8 or newer (or any version with async_hooks support).

If you run your test, you'll notice it hangs:

$ mocha test.js
@akatrevorjay
akatrevorjay / git-fshow
Last active March 30, 2024 23:41 — forked from junegunn/gist:f4fca918e937e6bf5bad
Browsing git commit history with fzf
#!/bin/zsh
# git-fshow - git commit browser
#
# https://gist.github.com/akatrevorjay/9fc061e8371529c4007689a696d33c62
# https://asciinema.org/a/101366
#
git-fshow() {
local g=(
git log
Go to: chrome://settings/searchEngines
Add a new search engine with the following settings
Gif | Gif | https://www.google.com/search?q=%s&tbm=isch&tbs=itp:animated
Type gif in the address bar press TAB and enter your search query
@hadley
hadley / ds-training.md
Created March 13, 2015 18:49
My advise on what you need to do to become a data scientist...

If you were to give recommendations to your "little brother/sister" on things that they need to do to become a data scientist, what would those things be?

I think the "Data Science Venn Diagram" (http://drewconway.com/zia/2013/3/26/the-data-science-venn-diagram) is a great place to start. You need three things to be a good data scientist:

  • Statistical knowledge
  • Programming/hacking skills
  • Domain expertise

Statistical knowledge

@mlgill
mlgill / ipython_nb_shell.sh
Last active July 23, 2018 04:04
Bash/Zsh functions for viewing/grepping only the input code of an IPython notebook and for clearing output cells.
# Two very basic functions for searching just the input code of an IPython notebook
# Written because I often want to search notebooks for snippets but the giant output
# of embedded encoded images makes it difficult.
# Ipython's nbconvert can be used to extract just the input, but this requires
# writing to a separate file and can be quite slow when used with large notebooks.
# Additionally, find/xargs can be used with igrep when the name of the notebook isn't known.
# icat could be used to convert an IPython notebook to a standard python file if
# the notebook does not contain whole-cell magics.
@lukecampbell
lukecampbell / breakpoint.py
Last active December 30, 2015 01:59
breakpoint
def breakpoint(scope=None, global_scope=None):
import traceback
from IPython.config.loader import Config
ipy_config = Config()
ipy_config.PromptManager.in_template = '><> '
ipy_config.PromptManager.in2_template = '... '
ipy_config.PromptManager.out_template = '--> '
ipy_config.InteractiveShellEmbed.confirm_exit = False