Skip to content

Instantly share code, notes, and snippets.

View chadbrewbaker's full-sized avatar

Chad Brewbaker chadbrewbaker

View GitHub Profile
@chadbrewbaker
chadbrewbaker / WordArrayAlgs.java
Created October 3, 2011 22:03
Word Array Algorithm benchmark for Java
public class WordArrayAlgs {
static void scan(int[] src, int[] dest){
int i;
dest[0]=src[0];
for(i=1;i < src.length; i++)
dest[i]= dest[i-1]+ src[i];
}
@chadbrewbaker
chadbrewbaker / ispalendromeana.java
Created December 14, 2011 16:38
Java palindrome anagram detector
public boolean isPalindromeAnagram(String s){
//assuming this is initalized to zero
boolean bvec[] = new boolean[90];
// ' ' is ASCII 32
// 'z' is ASCII 122
// So -32 to base at zero and length 90
for(int i=0;i<s.length();i++){
bvec[(int)s.charAt(i)-32] ^= true;
}
int odds =0;
@chadbrewbaker
chadbrewbaker / fqextract.cpp
Created February 5, 2012 20:18
FASTAQ sequence extractor
//Simple fastaq sequence extractor
//Usage: fqextract.out FILEIN > FILEOUT
#include <iostream>
#include <string>
#include <fstream>
#include <cstdlib>
using namespace std;
int main(int argc,char **argv)
{
@chadbrewbaker
chadbrewbaker / atcgratio.cpp
Created February 5, 2012 21:20
Caluclates the AT - CG ratio of a file containing "ATCG\n"
// Caluclates the AT - CG ratio of a file containing "ATCG\n"
// Usage: atcgratio.out INFILE
#include <iostream>
#include <string>
#include <fstream>
#include <cstdlib>
using namespace std;
int main(int argc,char **argv)
{
@chadbrewbaker
chadbrewbaker / invoiceExample.html
Created December 2, 2012 16:50
Example QR code invoice in Dwolla
<html>
<head>
<title>Invoice Example</title>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<!-- Get these js libraries here:
https://github.com/jeromeetienne/jquery-qrcode/tree/master/src-->
<script type="text/javascript" src="https://raw.github.com/jeromeetienne/jquery-qrcode/master/src/jquery.qrcode.js"></script>
@chadbrewbaker
chadbrewbaker / Roman.rb
Created January 15, 2013 23:05
Iowa Ruby Brigade kata showing Roman numeral computation is a monoid.
# Roman Numeral Evaluation is a Monoid
# Chad Brewbaker | Software Engineer | Telligen.org
# crb002@gmail.com
# Initial release January 15, 2013
class RomanMonoid
attr_accessor :prefix, :prefix_size, :suffix, :suffix_size, :suffix_credit, :sum, :homo
def initialize(val)
@chadbrewbaker
chadbrewbaker / config.json
Last active December 11, 2015 05:18
Tributary Iowa
{"description":"countiesdata","endpoint":"","display":"svg","public":true,"require":[],"tab":"edit","display_percent":0.5958333333333333,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01}
@chadbrewbaker
chadbrewbaker / tree.rb
Last active December 11, 2015 05:19
Monolithic playground for trees in Ruby
#Node1 = Struct.new(:next,:value)
#Node2 = Struct.new(:left, :right, :value)
#Node = Struct.new(:parent, :left, :right, :value)
#root = Node.new
#n1 = Node.new(root, nil, nil, 99)
#root.left = n1
#puts root.left.value
#puts root.left.right
@chadbrewbaker
chadbrewbaker / change.rb
Created January 31, 2013 00:45
Solution for Sedgewick Analytic Combinatorics homework 1 http://ac.cs.princeton.edu/lectures/AC01-OGFs.pdf
#Solution for Sedgewick Analytic Combinatorics homework 1
#http://ac.cs.princeton.edu/lectures/AC01-OGFs.pdf
#Chad Brewbaker
#crb002@gmail.com | Software Engineer @ Telligen
#January 30, 2013
best =0
coins=*(1..100)
coins.combination(4).each{ |currency|
memo = [0]*100
@chadbrewbaker
chadbrewbaker / scrape.rb
Created February 14, 2013 15:14
ICIS scraping template from StartupWeekend
require 'rubygems'
require 'json'
require 'mechanize'
require 'json'
require 'date'
require 'net/http'
require 'net/https'
require 'csv'
module IowaCourts