Skip to content

Instantly share code, notes, and snippets.

View astatham's full-sized avatar

Aaron Statham astatham

  • Garvan Institute of Medical Research
  • Sydney, Australia
View GitHub Profile
library(rjson)
options(scipen=10000)
if (file.exists("IAMA.db")) file.remove("IAMA.db")
system("sqlite3 IAMA.db < IAMA_scraper.schema;")
while (TRUE) {
bigTab <- NULL
after <- ""
baseURL <- "http://www.reddit.com/r/iama/.json?sort=new&limit=100"
imguRupload <- function(filename, title=NULL, caption=NULL, name=basename(filename), apikey="4feb29d00face5bc1b9dae536e15c373") {
require(RCurl)
require(RJSONIO)
if (length(filename)>1) stop("'filename' must be length 1.")
if (!file.exists(filename)) stop(filename, "does not exist!")
params <- list(key=apikey, image=fileUpload(filename), name=filename)
if (!is.null(title)) params[["title"]] <- title
if (!is.null(caption)) params[["caption"]] <- caption
fromJSON(rawToChar(postForm("http://api.imgur.com/2/upload.json", .params=params)))$upload
}
imguRupload <- function(filename, title=NULL, caption=NULL, name=basename(filename), apikey="4feb29d00face5bc1b9dae536e15c373") {
require(RCurl)
require(RJSONIO)
if (length(filename)>1) stop("'filename' must be length 1.")
if (!file.exists(filename)) stop(filename, "does not exist!")
params <- list(key=apikey, image=fileUpload(filename), name=filename)
if (!is.null(title)) params[["title"]] <- title
if (!is.null(caption)) params[["caption"]] <- caption
fromJSON(rawToChar(postForm("http://api.imgur.com/2/upload.json", .params=params)))$upload
}
#!/usr/local/bin/Rscript
library(twitteR)
library(imguR)
sess <- initSession("clark_lab_linux", "password")
rstats <- searchTwitter("#rstats", sess, n=1000)
#filter out junk
rstats <- rstats[sapply(sapply(rstats, screenName), length)>0]
#make graph
posters <- sort(table(sapply(rstats, screenName)), decreasing=TRUE)
cat hg18.fa | awk '{
if (substr($0, 1, 1)==">") {filename=(substr($0,2) ".fa")}
print $0 > filename
}'
@astatham
astatham / gist:631691
Created October 18, 2010 04:05
send_jabber
#!/usr/bin/perl -w
#
# script for nagios notify via Jabber / Google Talk Instant Messaging
# using XMPP protocol and SASL PLAIN authentication.
#
# author: Andrew Elwell <A.Elwell@physics.gla.ac.uk>
# based on work by Thus0 <Thus0@free.fr> and David Cox
#
# released under the terms of the GNU General Public License v2
# Copyright 2007 Andrew Elwell.
@astatham
astatham / gist:667271
Created November 8, 2010 01:31
not %in%
> 2:3 %in% 1:5
[1] TRUE TRUE
> !2:3 %in% 1:5
[1] FALSE FALSE
library(Repitools)
library(chipseq)
library(BSgenome.Hsapiens.UCSC.hg18)
library(rtracklayer)
rootdir <- "/home/data/NGS_New"
NGS <- read.csv(paste(rootdir, "NGS_Log14.csv", sep="/"), stringsAsFactors=FALSE, header=T)
load(paste(NGS$Path[1], NGS$RdataGR[1], sep="/"))
@astatham
astatham / getimg.py
Created February 22, 2011 03:46 — forked from stchris/getimg.py
#!/usr/bin/env python
"""
getimg.py
##oh hai dere
Gets the current image of the day from NASA and sets it as the
background in Gnome. The summary / description text is written
to the image.
plotRNAcoverage <- function(rs, tx, what=c("transcripts", "exons", "introns"),
nsamples=100, main="RNA-seq bias plot", verbose="TRUE") {
what <- match.arg(what)
if (what=="transcripts") {
genes <- exonsBy(txdb, "tx")
values(genes) <- NULL
} else if (what=="exons") {
genes <- exons(txdb)
values(genes) <- NULL
genes <- split(genes, 1:length(genes))