Skip to content

Instantly share code, notes, and snippets.

@NelsonMinar
NelsonMinar / bulkinsert.js
Last active October 1, 2021 02:14
A demonstration of slow sqlite3 bulk inserts in node.js
// Demonstration that bulk insertsin Node.js sqlite3 using prepared statements is very slow.
// Usage: run with one command line argument, one of "db", "reuse", "finalize"
// Details: http://nelsonslog.wordpress.com/2014/11/16/node-js-sqlite3-very-slow-bulk-inserts/
var sqlite3 = require('sqlite3').verbose();
var start = Date.now();
var db = new sqlite3.Database('inserttest.sqlite');
var mode = process.argv[2], runs = "100";
db.serialize(function() {
@NelsonMinar
NelsonMinar / lastframe.sh
Created May 17, 2014 16:30
Extract last frame of a video file
#!/bin/bash
fn="$1"
of=${fn%.*}.jpg
lf=`ffprobe -show_streams "$fn" 2> /dev/null | awk -F= '/^nb_frames/ { print $2-1 }'`
rm -f "$of"
ffmpeg -i "$fn" -vf "select='eq(n,$lf)'" -vframes 1 "$of" 2> /dev/null
@NelsonMinar
NelsonMinar / index.html
Created July 29, 2012 21:17
Cantor pairing function
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<title>Cantor pairing function</title>
<style>
td { min-width: 2em; text-align: right; }
</style>
</head>
@NelsonMinar
NelsonMinar / idb-walk.py
Created January 11, 2018 19:02
IndexedDB database file walker for Firefox
#!/usr/bin/env python3.6
"""
Hacky code to walk all the IndexedDB storage in your Firefox profile
and print some basic information about them.
The hardcoded path here works in WSL, Linux-for-Windows. Change as needed.
"""
base_dir = '/mnt/c/Users/*/AppData/Roaming/Mozilla/Firefox/Profiles/*/storage/default/'
@NelsonMinar
NelsonMinar / google.ahk
Created December 11, 2010 17:15
AutoHotkey script to make CapsLock open URLs and search Google
; AutoHotkey script to make CapsLock open URLs and search Google with Clipboard contents.
; By Nelson Minar <nelson@monkey.org> Inspired by code at http://www.autohotkey.com/forum/topic14656.html
CapsLock::
url := RegExReplace(Clipboard, "^\s+|\s+$") ; Trim whitespace
if RegExMatch(url, "^(http|ftp|telnet)") {
; Do nothing if it already looks like a URL
} else {
; Escape the query string. Could escape more, but this seems sufficient for Chrome
StringReplace, url, url, `%, `%25, All
@NelsonMinar
NelsonMinar / index.html
Last active February 10, 2018 12:06
Demo of using Mocha + Chai in a browser without Node
<html>
<head>
<meta charset="utf-8">
<title>Mocha Tests</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/mocha/5.0.0/mocha.css" rel="stylesheet" />
</head>
<body>
<div id="mocha"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/5.0.0/mocha.js"></script>
<opml version="1.0" xmlns:fz="urn:forumzilla:">
<head>
<title>Metafilter user blogs https://metatalk.metafilter.com/24654/Who-Are-The-Bloggers-of-Metafilter</title>
<dateCreated>Sat, 20 Jan 2018 21:49:01 GMT</dateCreated>
</head>
<body>
<outline type="rss" title="Amor Bellator" text="Amor Bellator" version="RSS" xmlUrl="https://amorbellator.com/feed/" htmlUrl="https://amorbellator.com"/>
<outline type="rss" title="Boxer Indemnity Scholars" text="Boxer Indemnity Scholars" version="RSS" xmlUrl="https://boxerindemnityscholars.wordpress.com/feed/" htmlUrl="https://boxerindemnityscholars.wordpress.com"/>
<outline type="rss" title="Best Results Organizing" text="Best Results Organizing" version="RSS" xmlUrl="http://juliebestry.com/feed/" htmlUrl="http://juliebestry.com"/>
<outline type="rss" title="mike.whybark.com" text="mike.whybark.com" version="RSS" xmlUrl="http://mike.whybark.com/feed" htmlUrl="http://mike.whybark.com"/>
@NelsonMinar
NelsonMinar / windhistory.js
Created September 1, 2012 22:31
windhistory.com D3 code
// This is the core Javascript code for http://windhistory.com/
// I haven't done a full open source release, but I figured I'd put the most important
// D3 code out there for people to learn from. --nelson@monkey.org
/** Common wind rose code **/
// Function to draw a single arc for the wind rose
// Input: Drawing options object containing
// width: degrees of width to draw (ie 5 or 15)
// from: integer, inner radius
@NelsonMinar
NelsonMinar / Sigmoid hidden layer.ipynb
Created January 6, 2018 02:17
TensorFlow MNIST sigmoid recognizer
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@NelsonMinar
NelsonMinar / scrape.ipynb
Created November 28, 2017 00:21
Demo of using IPython with BeautifulSoup
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.