Skip to content

Instantly share code, notes, and snippets.

View mikepfirrmann's full-sized avatar

Mike Pfirrmann mikepfirrmann

View GitHub Profile
@mikepfirrmann
mikepfirrmann / numbers_and_words.txt
Created May 4, 2021 14:24
Input to WayBetter developer interview coding exercise
the Dorian used 0.00039800 know. 0.04128765358980413 want I to 0.00092700 Gray
0.00008100 I you What 0.00079500 what you want. want do 0.00001000
turning round. exclaimed 0.00063700 I dont know 0.00053500 0.00074800
he dont 0.00005400 mean Basil you 0.00086500 what know 0.00080200
be 0.00070700 I that 0.00028500 0.00022700 some Dorianor day. shall
am 0.00067400 Well vain. to 0.00005500 I for punished be 0.00008200
me 0.00005500 owe 0.00050800 I You you. taught only 0.00032800 to
Harry at said lastmore 0.00097100 0.00097900 Basil he 0.00006900 than
0.00089000 0.00047200 moments. great deal I 0.00078500 to a owe few
0.00064200 green the garden 0.00060700 flickering for 0.00014600 a
@mikepfirrmann
mikepfirrmann / attribute-access-test.rb
Created March 13, 2013 15:33
Demonstration of accessing a namespaced attribute of an SVG nested within HTML using Nokogiri.
#!/usr/bin/env ruby
require 'nokogiri'
puts "Using Nokogiri version: #{Nokogiri::VERSION}"
# HTML5 document with inline SVG.
html = <<-HTML
<!DOCTYPE html>
<html>
@mikepfirrmann
mikepfirrmann / pretty-exception.rb
Created October 2, 2012 16:24
Print a prettier stack trace for Ruby exceptions
def colorize(text, color_code)
"\e[#{color_code}m#{text}\e[0m"
end
begin
# Here be dangerous things.
rescue => e
print "\r" << (' ' * 50) << "\n"
stacktrace = e.backtrace.map do |call|
if parts = call.match(/^(?<file>.+):(?<line>\d+):in `(?<code>.*)'$/)
@mikepfirrmann
mikepfirrmann / cgm-to-svg.rb
Created September 26, 2012 19:06
Convert all CGM files in a directory to SVG files using Uniconvertor.
#!/usr/bin/env ruby
# Run this from a directory containing *.cgm files to create SVG copies.
Dir.glob('*.cgm').each do |file|
cmd = "uniconvertor '#{file}' '#{File.basename(file, '.cgm')}.svg'"
puts cmd
system cmd
end
@mikepfirrmann
mikepfirrmann / install-uniconvertor.sh
Created September 26, 2012 19:05
Install Uniconvertor from source
#!/bin/bash
# http://ubuntuforums.org/showthread.php?t=1865589 says to do this
sudo apt-get install build-essential python-all-dev liblcms1-dev libjpeg62-dev libpaps-dev
# Uniconvertor packages do not seem to install properly on Ubuntu 12.04, so
# I installed from source.
svn co https://sk1.svn.sourceforge.net/svnroot/sk1/trunk/sk1libs /tmp/sk1libs
sudo python /tmp/sk1libs/setup.py install
@mikepfirrmann
mikepfirrmann / pretty-exception.py
Created September 24, 2012 15:23
Print a prettier stack trace for Python exceptions
try:
# put whatever code here
except:
import traceback, StringIO, re, os
def colorize(text, color):
control_sequence_introducer = "\x1B["
return "{0}{1}m{2}{0}0m".format(control_sequence_introducer, color, text)
exception_output = StringIO.StringIO()