View r_sample_extension.cc
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
///////////////////////////////////////// | |
// Sample for Embedding C++ into R // | |
///////////////////////////////////////// | |
// | |
// I keep forgetting how to do this so here's an example. | |
// If you're willing to use R's most primitive FFI interface, | |
// things are incredibly simple and easy to get going. | |
// -Brendan O'Connor (brenocon@gmail.com) | |
// | |
// Compile with, e.g. on mac: |
View jsontidy
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 | |
# jsontidy | |
# POSSIBLE USAGE | |
# [[Shell]] cat data.json | jsontidy | |
# [[TextMate]] Cmd-A Cmd-Opt-R jsontidy | |
# [[Vim] :%!jsontidy | |
# alternate implementation: python -m simplejson.tool |
View imageopen.rb
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 | |
# imageopen - # for mac, commandline open an image file without needing an extension, recognition via imagemagick | |
# brenocon@gmail.com (brendan o'connor) | |
require 'fileutils' | |
f = ARGV[0] | |
type = %x[identify #{f}].split[1].downcase |
View htmlescape.pl
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 perl | |
while (<>) { | |
s/&/&/g; | |
s/</</g; | |
s/>/>/g; | |
print $_; | |
} | |
View htmlunescape.pl
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 perl | |
while(<>) { | |
s/</</g; | |
s/>/>/g; | |
s/&/&/g; | |
print $_; | |
} |
View pskill
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 | |
# USAGE: ps wwaux | grep badprocess | pskill | |
# Like awk '{print $2}' | xargs kill, except somewhat smarter | |
class Array | |
def map_if(&b) | |
map(&b).select{|x| x} | |
end | |
end |
View mycgi.rb
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 'cgi' | |
# trying to make cgi.rb suck a tad bit less. | |
# the main thing I care about is clean, error-free parameter input. | |
# brendan o'connor (brenocon@gmail.com) | |
class MyCGI < CGI | |
def initialize | |
super("html3") | |
@converted_opts = {} | |
end |
View clean.rb
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 | |
# Parse a data table from pollster.com | |
# Get data via copy-and-paste from http://www.pollster.com/polls/us/08-us-pres-ge-mvo.php | |
# yields a messy tab-separated thingamajigger (i'm using firefox 3 on mac) | |
# This script normalizes, in an R-friendly way | |
require 'date' | |
def numclean(x) | |
x =~ /^-$/ ? "NA" : x.to_i |
View blogger.php
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
<? | |
/** | |
* *** THIS NEEDS TO BE EDITED FOR A NEW INSTALLATION *** | |
* | |
* this is supposed to be called as e.g. | |
* http://anyall.org/blog/blogger/http://socialscienceplusplus.blogspot.com/2008/10/mydebatesorg-and-poten | |
tially-coolest.html | |
* and then redirect to e.g. | |
* http://anyall.org/blog/2008/10/mydebatesorg-online-polling-and-potentially-the-coolest-question-corpus- | |
ever/ |
View get.rb
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
load '~/.irbrc' # dotfiles.org/~brendano/.irbrc | |
require 'hpricot' | |
sites=[] | |
for url in [ | |
"http://www.alexa.com/site/ds/top_sites?ts_mode=lang〈=en"] | |
h = Hpricot open(url).read | |
sites += (h/'h3'/'a').map{|x| x['href']} | |
end |
OlderNewer