Skip to content

Instantly share code, notes, and snippets.

@jsomers
jsomers / brahe.html
Last active Jul 22, 2021
Dynamically created sky map using Fourmilab's Your Sky
View brahe.html
<script>
var toUrlParam = function(date) {
return date.toISOString().split("T")[0].replaceAll("-", "%2F");
}
// https://stackoverflow.com/questions/563406/add-days-to-javascript-date
Date.prototype.addDays = function(days) {
var date = new Date(this.valueOf());
date.setDate(date.getDate() + days);
return date;
View glove-codenames.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jsomers
jsomers / college-squash.ipynb
Last active Mar 20, 2019
College Squash ratings analysis
View college-squash.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jsomers
jsomers / traffic.ipynb
Created Oct 7, 2018
NYC traffic collision data
View traffic.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jsomers
jsomers / websockets.md
Created Sep 27, 2018
Using websockets to easily build GUIs for Python programs
View websockets.md

Using websockets to easily build GUIs for Python programs

I recently built a small agent-based model using Python and wanted to visualize the model in action. But as much as Python is an ideal tool for scientific computation (numpy, scipy, matplotlib), it's not as good for dynamic visualization (pygame?).

You know what's a very mature and flexible tool for drawing graphics? The DOM! For simple graphics you can use HTML and CSS; for more complicated stuff you can use Canvas, SVG, or WebGL. There are countless frameworks, libraries, and tutorials to help you draw exactly what you need. In my case, this was the animation I wanted:

high-priority

(Each row represents a "worker" in my model, and each rectangle represents a "task.")

View drive_google_doc.rb
# Dependencies: ruby-full, watir, xvfb, iceweasel, geckodriver
# Run `Xvfb :10 -ac &` before running this script
require 'watir'
NEW_DOC_URL = "https://docs.google.com/document/create"
EMAIL_ADDRESS = ENV['DOCWRITER_EMAIL']
PASSWORD = ENV['DOCWRITER_PASSWORD']
SHARE_WITH_EMAIL = ENV['DOCWRITER_SHARETO']
@jsomers
jsomers / a-wotd-custom-word-list.md
Last active Apr 7, 2021
How to use a custom word list with OS X's "Word of the Day" screensaver
View a-wotd-custom-word-list.md

OS X's "Word of the Day" screensaver is a great way to passively learn words:

But I've always thought that its word list kind of stunk—it was full of obscure words that I could never really see myself using. I'd prefer something like Norman Schur's 1000 Most Important Words. What if you could plug your own word list into the screensaver?

On a rather obscure comment thread, someone explained where you might find the word list that Apple uses to power the screensaver. It is at /System/Library/Graphics/Quartz\ Composer\ Plug-Ins/WOTD.plugin/Contents/Resources/NOAD_wotd_list.txt. The file looks like this:

m_en_us1282510	quinsy
@jsomers
jsomers / websters-chrome.md
Created Nov 10, 2014
Adding Webster's as a Chrome search engine
View websters-chrome.md

Instructions courtesy of @chancelionheart:

  1. Access the Settings menu by clicking the Options icon in the upper-right corner of the browser window. It is the icon with three horizontal lines stacked on top of each other. Click on “Settings” near the bottom of the Options menu.

  2. Under the “Search” heading in the Settings menu, click the "Manage search engines" button.

  3. At the bottom of the Search Engines window that comes up, enter the following: Name: Use whatever you like (I used "Webster's Revised 1913+1928 Dictionary") Keyword: Also whatever you like, I just use 'd' for easy access. Url: http://machaut.uchicago.edu/?resource=Webster%27s&word=%s&use1913=on&use1828=on (replaces the search term with %s, what google chrome uses for the query)

@jsomers
jsomers / android-websters.md
Last active Jan 9, 2021
Instructions for using Webster's 1913 on Android
View android-websters.md

To use Webster's 1913 dictionary on Android, install Colordict 3, an app that accepts this StarDict format. https://play.google.com/store/apps/details?id=com.socialnmobile.colordict

Next download James's S3 archive. https://s3.amazonaws.com/jsomers/dictionary.zip

You will need to extract the .dict file from inside three containers - .dz, .tar, .bz2 from innermost to outermost. 7zip handles all of these formats.

Place the .dict, .idx and .ifo files in the dictdata directory on your sdcard or local storage root. This is where colordict looks for dictionaries.

When the files are in the right place, you can run Colordict and tap the folder icon in the top right to see the dictionaries installed and set the dictionary priority. I put the 1913 dictionary above the defaults "Wordnet" and "Wikipedia." When you look up a word, ColorDict shows the definition, if available, from these multiple sources.

@jsomers
jsomers / websters-kindle.mdown
Created May 19, 2014
How to make the Webster's 1913 your default Kindle dictionary
View websters-kindle.mdown

How to make the Webster's 1913 your default Kindle dictionary

  1. Download a Kindle-compatible version of the dictionary here. Unzip the .rar archive.

  2. Get the "Send to Kindle" program on your computer. Here's the link for the Mac.

  3. Right-click your recently downloaded (unzipped) dictionary file, and click the "Send to Kindle" menu item. It will arrive on your Kindle shortly.

  4. Once the dictionary has arrived, go to your settings -- on my newish paperwhite, it's at Home > Settings > Device Options > Language and Dictionaries > Dictionaries > English. Choose the Webster's 1913.