Skip to content

Instantly share code, notes, and snippets.

View jbrown123's full-sized avatar
💭
Looking for a new opportunity

James Brown jbrown123

💭
Looking for a new opportunity
View GitHub Profile
@jbrown123
jbrown123 / NST_EST2021_POP.csv
Last active October 10, 2022 01:01
Include SQLite commands at the top of a data file
We can make this file beautiful and searchable if this error is corrected: Illegal quoting in line 1.
-- sqlite3 -init "NST_EST2021_POP.csv"
CREATE TABLE pop (
name text unique,
pop2020 int,
pop2021 int);
.import "NST_EST2021_POP.csv" pop --csv --skip 12
.mode list
.schema
.headers on
select count(*) from pop;
@jbrown123
jbrown123 / mylib.scad
Created February 9, 2020 22:12
A library of openscad functions that I frequently use in my designs
/*
* MyLib.scad
*
* A bunch of openscad functions that I might need from time to time in various projects
*
* Usage: use <mylib.scad>;
*
* Version: 20200209
*
* Copyright (c) 2011-2020 by James H. Brown
@jbrown123
jbrown123 / uta-wifi.user.js
Created August 15, 2019 14:35
Auto login to UTA (Utah Transit Authority) WiFi - ticks the accept conditions checkbox, then clicks the connect button
// ==UserScript==
// @name Auto login to UTA WiFi
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Check the box and press the button on the UTA wifi page
// @author James Brown
// @match http://utawifi.com/
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
@jbrown123
jbrown123 / AccessGithubWithPuTTY.md
Last active March 19, 2024 09:44
How to use PuTTY with github on Windows

How to use PuTTY with github on Windows

To make things easier, we can tell git to use the PuTTY tools rather than the built in ssh client. The PuTTY tools include an identity manager and an SSH replacement.

Follow these four steps:

  1. Download and install PuTTY using the MSI installer package from the PuTTY download page. Alternately, you can just get the "PLink" and "Pageant" executables from the same page and save them somewhere in your path.

  2. Add a new user or system environment variable:

  • Press Windows+R and enter sysdm.cpl
@jbrown123
jbrown123 / alarmclock.pl
Created March 21, 2019 14:49
A simple recurring alarm clock written in Perl (does not require any packages, just plain perl). This version is specific to Windows but could easily be converted to other platforms.
#!/usr/bin/env perl
#
# a (very simple) recurring alarm clock for windows
# easily converted to any other platform by replacing the call to the windows msg tool
# all data is stored in the file itself (in the __DATA__ section at the bottom)
# this is written in pure perl, no packages are required
#
# under windows I suggest using the ActiveState wperl interpreter to launch the alarm clock
# that prevents you from having a command processor hanging around just to run the alarm clock
# the unfortunate side effect is that you have to kill it using task manager since it never exits
@jbrown123
jbrown123 / unsplash_random.html
Created March 20, 2019 23:27
Unsplash randomly rotating images
<html>
<head>
<title>Unsplash images</title>
<script>
// randomly cycle through unsplash images in the browser window every 5-30 seconds
// this works great in full screen (F11) mode on wall monitors as random artwork
//
// tested on Chrome; should work on most modern browsers but don't blame me if it doesn't
// I used info from the following sites to create this
@jbrown123
jbrown123 / readme.md
Last active October 9, 2023 18:58
Reference bookmarklet - generate a string containing the page title, URL and any selected text

Reference bookmarklet

This bookmarklet will grab 2 or 3 bits of info from the currently viewed webpage and put them into an 'alert' so you can copy & paste into another document.

It should work in any desktop browser (chrome, firefox, ect.) on any OS but I've only personally tested it in Chrome on Windows.

You can press either enter or escape after copying the text. It doesn't make any difference which one you use.

For example, the above URL points to the bookmarklet entry on Wikipedia. If you used the reference bookmarklet on that page it would return the following:

@jbrown123
jbrown123 / initialization.sql
Last active January 25, 2024 17:24
Creating arbitrary-depth recursive queries in SQLITE (works for any SQL compliant system) using CTEs (common table expressions)
DROP TABLE IF EXISTS users;
DROP VIEW IF EXISTS bp;
CREATE TABLE users (name, cn, title, manager);
CREATE VIEW bp AS
-- create a CTE (common table expression)
-- think of this as creating a temporary table that only exists during this query
-- works somewhat like CREATE TEMPORARY TABLE bosspath(cn, path)
WITH RECURSIVE bosspath(cn,path) AS
(
@jbrown123
jbrown123 / US Zip Codes to Lat Lon from 2016 Government Census Data
Last active May 5, 2017 17:51
All US zip codes (technically "five digit ZIP code tabulation area census codes") with their corresponding latitude and longitude coordinates. Positive values = North or East; Negative values = South or West. Comma delimited for easy import. Source: http://www.census.gov/geo/maps-data/data/gazetteer.html Built with the following commands: unzip …
ZIP,LAT,LON
00601,18.180555,-66.749961
00602,18.361945,-67.175597
00603,18.455183,-67.119887
00606,18.158345,-66.932911
00610,18.295366,-67.125135
00612,18.402253,-66.711397
00616,18.420412,-66.671979
00617,18.445147,-66.559696
00622,17.991245,-67.153993
@jbrown123
jbrown123 / bookmarklet.md
Last active March 15, 2024 17:08
A simple bookmarklet to help clip a webpage to a google doc

Bookmarklet to clip webpages to google docs

Below is a simple bookmarklet (see https://en.wikipedia.org/wiki/Bookmarklet) to make it easier to capture the content of a webpage into a google doc. This is similar (but much simpler and less functionality) to Evernote Web Clipper (see https://evernote.com/webclipper/).

This bookmarklet will copy the URL and the title of the current page. Since most browsers forbid directly manipulating the clipboard contents, it makes a copy by creating a pop-up with all the data highlighted and asks the user to press control-c (the keyboard copy shortcut) and then enter. Once you press enter it will create a new google document for you in a new tab. You can simply press control-v (the keyboard paste shortcut) to put in the URL and title.

If you press escape or hit 'cancel' in the popup, nothing happens and you return to your original webpage.

If you happen to have some text selected on the current webpage, this will be appended to the end of the pasted block. However,