Skip to content

Instantly share code, notes, and snippets.

View jl2's full-sized avatar

Jeremiah LaRocco jl2

View GitHub Profile
60.times{|a|puts (0..240).map{|b|x=i=0;x=x*x+Complex(b/4.0-45,a-30)/30until x.abs>4||99<i+=1;i>99?'#':'.'}*''}
#!/usr/bin/ruby
require 'nokogiri'
require 'open-uri'
# Handle command line
account = ARGV.shift || 'jl_2'
num = ARGV.shift || 10
if num.to_i > 200
puts "Can only fetch up to 200 tweets at a time."
@jl2
jl2 / gpxparse.c
Created May 7, 2010 05:14
Parse GPX file using libxml2
/* gpxparse.c
Copyright (c) 2010, Jeremiah LaRocco jeremiah.larocco@gmail.com
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
#!/usr/bin/python
# pyget.py
# Copyright (c) 2010, Jeremiah LaRocco jeremiah.larocco@gmail.com
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#!/usr/bin/perl
# select_demo.pl
# Copyright (c) 2010, Jeremiah LaRocco jeremiah.larocco@gmail.com
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#!/usr/bin/python3
# flickrtests.py
# Copyright (c) 2010, Jeremiah LaRocco jeremiah.larocco@gmail.com
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
;; Copyright (c) 2010 Jeremiah LaRocco
;; All rights reserved.
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions
;; are met:
;; 1. Redistributions of source code must retain the above copyright
;; notice, this list of conditions and the following disclaimer.
;; 2. Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
#!/usr/bin/python
def is_palindrome(number):
return str(number) == str(number)[::-1]
if __name__ == "__main__":
# Assumes that the largest palindrome will be created by two numbers in the range 900-1000
print('{}*{} = {}'.format(*max((i,j,i*j)
for i in range(1000, 900, -1)
for j in range(1000, 900, -1)
-- Convert an Nfa to a Dfa using the algorithms from section 3.7.1 of the "Dragon book"
toDfa :: Nfa -> Dfa
toDfa nfa =
let
dstrt = e_closure nfa (n_start nfa)
init = Map.fromList [(dstrt, genStates dstrt)]
dfa = getps init
stateNames = genStateMap dfa
partial = Map.mapKeys (\x -> lookupDefault x 0 stateNames) dfa
dfaTrans = Map.map (\x -> Map.map (\y -> (lookupDefault y 0 stateNames)) x) partial
#!/usr/bin/python3
import urllib.request
import xml.dom.minidom
fh = urllib.request.urlopen('http://twitter.com/statuses/user_timeline/jl_2.xml')
doc = xml.dom.minidom.parse(fh)
for stat in doc.getElementsByTagName("status"):
print('Date: {}\nTweet: {}'.format(stat.getElementsByTagName("created_at")[0].firstChild.nodeValue,
stat.getElementsByTagName("text")[0].firstChild.nodeValue))