Skip to content

Instantly share code, notes, and snippets.

View jrunning's full-sized avatar

Jordan Running jrunning

View GitHub Profile
@jrunning
jrunning / mysql-coalesce-wtf.sql
Last active August 11, 2020 08:41
MySQL COALESCE() silently casts its return to the type of subsequent non-NULL arguments
-- The MySQL docs say COALESCE() "returns the first non-NULL value in the list,
-- or NULL if there are no non-NULL values." This turns out not to be true.
-- If the value to be returned is an integer, COALESCE() first casts it to
-- the type of a subsequent non-NULL argument. ಠ_ಠ
mysql> SELECT 0 = '',
-> COALESCE(0, '') = '',
-> COALESCE(0, ''),
-> COALESCE(0, NULL),
-> COALESCE(0, 98.6, NULL),
@jrunning
jrunning / deep_exclude.rb
Created November 30, 2012 23:32
Hash#deep_exclude
require 'test/unit/assertions'
include Test::Unit::Assertions
class Hash
# A convenience method for removing deeply-nested keys from a Hash
#
# Usage:
#
# hash = { :a => { :m => 13 }, :b => 2 }
#
@jrunning
jrunning / input.coffee
Created November 30, 2012 17:07
CoffeeScript object literal gotcha
# try it live: http://bit.ly/TwZV18
# CoffeeScript # JavaScript
foo # foo({
bar: 1 # bar: 1,
baz: 2 # baz: 2,
qux: 3 # qux: 3
# });
" Syntax-highlight Ruby comments as Markdown a la Docco
" TODO: Make multi-line comments work right
" Make nested comments work right
" Exclude "# => " ("result of expression") comments
let s:saved_syntax = b:current_syntax
unlet b:current_syntax
syntax include @Markdown syntax/markdown.vim
rundll32 printui.dll PrintUIEntry /y /n "LIB04430"
C:\Program Files\MyProgram\my_program.exe
rundll32 printui.dll PrintUIEntry /y /n "\\print1\LibraryTechServicesMFP"
@jrunning
jrunning / thinkup-twitter-crawler-error.log
Created March 22, 2012 19:52
ThinkUp Twitter crawler error
14:46 TwitterPlugin: Starting to collect data for swirlee on Twitter.
14:46 TwitterCrawler: 237 of 350 Twitter API calls left this hour; 131 budgeted for ThinkUp until 15:39.
14:46 TwitterCrawler: Successfully fetched swirlee's details from Twitter. Twitter's tweet count is 23954
14:46 TwitterCrawler: 11 tweet(s) found and 0 saved
14:46 TwitterCrawler: 9162 tweets are in ThinkUp; swirlee has 23954 tweets according to Twitter.
14:46 TwitterCrawler: Twitter only makes 3200 tweets available, so some of the oldest ones may be missing.
14:46 TwitterCrawler: No new mentions found.
14:46 TwitterCrawler: Checking for new favorites.
14:46 TwitterCrawler: Saved 0 new favorites.
14:46 TwitterCrawler: New follower count is 1392 and ThinkUp has 1588; -196 new follows to load
@jrunning
jrunning / fixredbox.md
Created March 16, 2012 00:10
What's wrong with Redbox.com

To make a generalization, you have two kinds of customers, A and B. Type A goes to Redbox.com to see if s/he can rent a movie. "A" has a specific movie in mind and might go to a B&M store if it Redbox doesn't have it. Type B goes to Redbox.com to see what movies s/he can rent, and I'm a solid "B." I love movies but I don't read Entertainment Weekly or movie blogs, and if I watch TV it's online. I don't know when any particular movie is coming out, so when I go to Redbox.com it's because "I'm looking for a movie to watch," not "looking to watch this movie."

I think Redbox.com's main problem is that it's designed for "A," not "B," i.e. not me. Here's my experience, starting from the homepage and logged in:

  1. I see a GIANT BANNER AD and five other movies, none of which I happen to be interested in.
SELECT tblPeople.[First Name], tblPeople.Email
FROM tblPeople
INNER JOIN tblMembership ON tblPeople.[Person ID] = tblMembership.[Person ID]
WHERE tblMembership.[Valid To] IN (#12/31/2012#) AND
tblPeople.Email IS NOT NULL
ORDER BY tblPeople.Email
;

Usage

$ chmod a+x matts_split.sh

$ ./matts_split.sh path/to/blob_file.baz path/to/tab_separated_offsets.tab

@jrunning
jrunning / Notes.md
Created November 21, 2011 00:46
Files injected by "Love you" script c. 2011-11-11 (my comments denoted by `{jrunning}`)

Image of "Love you" "dashboard"

Image of "dashboard"