Skip to content

Instantly share code, notes, and snippets.

John T. Prince jtprince

Block or report user

Report or block jtprince

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
import subprocess
class SaveIndixDataError(Exception):
""" There was some error with saving indix data to the database. """
class SaveIndixDataMismatchError(SaveIndixDataError):
""" Number of submitted records did not match number processed. """
View doba-convert-text-email-to-html.rb
#!/usr/bin/env ruby
# for working with Doba_Product descriptions
require 'redcarpet'
if ARGV.size == 0
puts "usage: #{File.basename(__FILE__)} <file>.txt ..."
puts "output: text and html, ready for sql upload"
puts ""
puts "notes:"
View risk2_saver.rb
# Very simple tk application to save progress on Microprose's Risk II game
# (written many years ago)
# Create a bat file to run, like this:
# ----save_risk.bat----
# c:\cygwin\bin\rubyw /home/john/risk2_saver.rb c:/Users/john/Desktop/RISK_SAVES
require 'Win32API'
require 'fileutils'
require 'tk'
import scipy.stats as sts
from math import log
def fisher_combine_p_values(pvalues):
degrees_freedom = 2*len(pvalues)
summed = sum(-2*log(pval) for pval in pvalues)
return 1.0 - sts.chi2.cdf(summed, degrees_freedom)
#print(fisher_combine_p_values( [0.05, 0.05] ))
jtprince / quiet boot for arch
Created Dec 11, 2014
some notes on quiet boot in arch
View quiet boot for arch
# for syslinux, you want something like this:
APPEND root=/dev/sda2 rw vga=current quiet loglevel=0
# OR
APPEND root=/dev/sda2 rw vga=865 quiet loglevel=0
# edit the files systemd-fsck-root.service and systemd-fsck@.service located at /usr/lib/systemd/system/ to configure StandardOutput and StandardError like this:
jtprince /
Last active Aug 29, 2015
dynamically include all files in folder with the package (and alternatively import each of those source files)
import os
_python_source_files = list(
lambda basename: basename.endswith(".py") and
not basename.startswith('_'),
os.listdir( os.path.dirname(os.path.realpath(__file__)) )
jtprince /
Created Sep 19, 2014
delete all tables in an sqlite database that match a regular expression
#!/usr/bin/env python
import sys
import sqlite3
import argparse
import re
parser = argparse.ArgumentParser(description='deletes tables matching some regular expression')
parser.add_argument('database', help='the database file')
parser.add_argument('regexp', help='the regexp you are matching')
jtprince / opening_an_inherited_class.rb
Created Aug 1, 2014
ruby, do I need to include the inheritance each time I open a class? Answer: NO (but the inheritance must be there the 1st time or you'll get a superclass mismatch TypeError)
View opening_an_inherited_class.rb
# [be careful, though, if you switch the order of introduction, then you will get this error:
# <file>.rb:11:in `<main>': superclass mismatch for class Dog (TypeError)
class Dog < Hash
def silly(key)
self[key] = 88 + key.to_i
# This is the *key* point: we can re-open this class and it won't give us any trouble!
class Dog
jtprince / Rakefile
Last active Aug 29, 2015
Rakefile Template (after "bundle gem <some_gem>")
View Rakefile
require "bundler/gem_tasks"
@module_name = Mspire::Mass
@gem_name = 'mspire-mass'
@gem_path_name = @gem_name.gsub('-','/')
require "#{@gem_path_name}/version"
require 'rspec/core'
require 'rspec/core/rake_task'
jtprince / risk2_saver.rb
Created May 29, 2014
Save and load your Risk II (Hasbro Interactive) game with this simple ruby GUI
View risk2_saver.rb
require 'Win32API'
require 'fileutils'
require 'tk'
# supposed to hide base window... not working with cygwin ruby
getConsoleWindow ="kernel32" , "GetConsoleWindow" , [] , 'L')
ptr_to_console =
wndConsole = "user32" , "ShowWindow" , ['p' , 'i'] , 'i' ) ptr_to_console , 1 )
You can’t perform that action at this time.