function tinyurl($url){
return(trim(file_get_contents('http://tinyurl.com/api-create.php?url='.$url)));
}
20.3.08
tinyurl php function
16.1.08
Snap: screen capture to clipboard for OS X
Snap is a simple app for OS X that takes a screen capture and copies to the clipboard. The space bar toggles between window and user modes.
Copy snap to your applications folder. I suggest dragging to your dock.
Hyperlink to snap.dmg
For those that love the terminal. Here is the magic:
% screencapture -x -i -c
Posted by Jay at 14:16
Labels: code, os x, screen capture, snap
20.2.07
Using jayridge.eda()
I uploaded the R script here:
http://jayridge.googlepages.com/jayridge.eda.R
Now u can use it by sourcing the file from within R. This example shows how to load the function and generates a nonsensical plot from within the R console. ;)
cheers!
source("http://jayridge.googlepages.com/jayridge.eda.R")
jayridge.eda(rnorm(20), "Random Deviates")
Posted by Jay at 14:32
Labels: code, R, statistics
19.2.07
jayridge.eda()
I spent a little time today writing a generic eda function in R. R is way hip but the graphics take a bit of tweaking. My particular problem was that I wanted a small footprint graphic that would give me a good idea of distribution of a univariate data set... that I wouldn't be ashamed of presenting to the executive types. Here is the function:
jayridge.eda<-function(x, title) {
# This function is based on simple.eda from the book,
# "Using R for Introdcutory Statistics", by John Verzani
#
# I found that the general function was useful but needed
# better titling and formatting for use in EDA presentations.
op<-par(no.readonly = TRUE); # save old parameters
par(mai=c(.6,.5,.2,.2))
par(family="sans")
par(cex.lab=1.2)
# Create a layout with two rows. The first row spans
# 3 columns.
#
# [,1] [,2] [,3]
# [1,] 1 1 1
# [2,] 2 3 4
layout(matrix(c(1,1,1,2,3,4), ncol=3, byrow=TRUE), heights=c(1,2))
# Frame 1: print the title, date and
plot.new()
plot.window(xlim=c(0,1), ylim=c(0,1))
title(main=title, cex.main=2)
f<-as.character(summary(x))
fStr<-sprintf("%9s %9s %9s %9s %9s %9s\n%9s %9s %9s %9s %9s %9s",
"Min","1st Qu","Median","Mean","3rd Qu","Max",
f[1],f[2],f[3],f[4],f[5],f[6])
text(0.5,0.5, labels=fStr, cex=1.4, adj=.5, family="mono")
# Frame 2: plot a histogram.
hist(x, main="Histogram", xlab=title, col="orange")
rug(x)
# Frame 3: plot a boxplot.
boxplot(x, varwidth=TRUE, col="orange", border="grey30")
rug(x,side=2)
title("Boxplot")
# Frame 4: plot a normal QQ.
qqnorm(x, col="grey30")
qqline(x,col="red")
par(op); # reset old parameters
}
And here is the fabulous output!
Posted by Jay at 18:37
Labels: code, R, statistics
7.2.07
Zend and Google calendar
So I've been spending a few days since launch reviewing the operational, product and marketing metrics for share2me. We have a 10 minute morning call @ 10 minutes before 10am every day where I update the team on basic metrics such as # of registrations and hot sources of traffic. So I started to think what a good idea it would be to put that data in a calendar that the team could subscribe to... so I don't have to consume any of the precious few 10-b4-10 minutes. After a quick search I found a fabulous (if not a tad on the undocumented) library provided by the Zend team.
Here's the basic code to post to a calendar.
<?php
require_once 'Zend/Gdata.php';
require_once 'Zend/Http/Client.php';
require_once 'Zend/Gdata/ClientLogin.php';
require_once 'Zend/Gdata/Calendar.php';
$email = 'YOU@gmail.com';
$passwd = 'PASSWD';
$feedUrl = 'http://www.google.com/calendar/feeds/BLAH';
$client = Zend_Gdata_ClientLogin::getHttpClient($email, $passwd, 'cl');
$cal = new Zend_Gdata_Calendar($client);
$timestamp = time();
$start=date('Y-m-d', $timestamp);
$end=date('Y-m-d', ($timestamp + (60 * 60 * 24)));
$xmlString = <<<XML
<entry xmlns='http://www.w3.org/2005/Atom'
xmlns:gd='http://schemas.google.com/g/2005'>
<category scheme='http://schemas.google.com/g/2005#kind'
term='http://schemas.google.com/g/2005#event'></category>
<title type='text'>Title for my event</title>
<content type='text'>This is where all the content goes.</content>
<author>
<name>Jay Ridgeway</name>
<email>YOU@gmail.com</email>
</author>
<gd:transparency value='http://schemas.google.com/g/2005#event.transparent'/>
<gd:when startTime='$start' endTime='$end'/>
</entry>
XML;
$xml = new SimpleXMLElement($xmlString);
$cal->post($xml->asXML(), $feedUrl);
?>
