This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'distribution' | |
require 'gnuplot' | |
require 'csv' | |
params = { | |
step: 0.01, | |
stop: 1.0, | |
xwiggle: 0.01, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'Win32API' | |
require 'fileutils' | |
require 'tk' | |
# supposed to hide base window... not working with cygwin ruby | |
getConsoleWindow = Win32API.new("kernel32" , "GetConsoleWindow" , [] , 'L') | |
ptr_to_console = getConsoleWindow.call() | |
wndConsole = Win32API.new( "user32" , "ShowWindow" , ['p' , 'i'] , 'i' ) | |
wndConsole.call( ptr_to_console , 1 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# [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 | |
end | |
end | |
# This is the *key* point: we can re-open this class and it won't give us any trouble! | |
class Dog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
_python_source_files = list( | |
filter( | |
lambda basename: basename.endswith(".py") and | |
not basename.startswith('_'), | |
os.listdir( os.path.dirname(os.path.realpath(__file__)) ) | |
) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 [email protected] located at /usr/lib/systemd/system/ to configure StandardOutput and StandardError like this: | |
(...) | |
[Service] | |
Type=oneshot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] )) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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:" |