Skip to content

Instantly share code, notes, and snippets.

View randyzwitch's full-sized avatar

Randy Zwitch randyzwitch

View GitHub Profile
@randyzwitch
randyzwitch / ga-customvars.php
Created June 8, 2013 13:43
Google Analytics Custom Variables Page Level, WordPress
if (is_single () ) {
$category = get_the_category();
echo "_gaq.push(['_setCustomVar', 2,'Category','". $category[0]->cat_name. "', 3]);";
} else {
}
@randyzwitch
randyzwitch / ga-custom-page-level.js
Created June 8, 2013 13:46
Full example, tracking WordPress category into Google Analytics custom variable
<script type="text/javascript">
var _gaq =_gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
if (is_single () ) {
$category = get_the_category();
echo "_gaq.push(['_setCustomVar', 2,'Category','". $category[0]->cat_name. "', 3]);";
@randyzwitch
randyzwitch / scrappy.php
Created June 8, 2013 13:50
Removing Powered By WordPress from Scrappy Theme
<div>
<?php do_action( 'scrappy_credits' ); ?>
<a href="<?php echo esc_url( __( 'http://wordpress.org/', 'scrappy' ) ); ?>" title="<?php esc_attr_e( 'A Semantic Personal Publishing Platform', 'scrappy' ); ?>" rel="generator"><?php printf( __( 'Proudly powered by %s', 'scrappy' ), 'WordPress' ); ?></a>
<span> | </span>
<?php printf( __( 'Theme: %1$s by %2$s', 'scrappy' ), 'Scrappy', '<a href="http://carolinemoore.net/" rel="designer">Caroline Moore</a>' ); ?>
</div><!-- .site-info -->
@randyzwitch
randyzwitch / scrappy2.php
Created June 8, 2013 13:51
Removing Powered By WordPress from Scrappy Theme - Full Example
<!-- <?php do_action( 'scrappy_credits' ); ?>
<a href="<?php echo esc_url( __( 'http://wordpress.org/', 'scrappy' ) ); ?>" title="<?php esc_attr_e( 'A Semantic Personal Publishing Platform', 'scrappy' ); ?>" rel="generator"><?php printf( __( 'Proudly powered by %s', 'scrappy' ), 'WordPress' ); ?></a>
<span> | </span>
<?php printf( __( 'Theme: %1$s by %2$s', 'scrappy' ), 'Scrappy', '<a href="http://carolinemoore.net/" rel="designer">Caroline Moore</a>' ); ?> -->
@randyzwitch
randyzwitch / scrappy-header.php
Created June 8, 2013 14:02
Adding Back to Top to Scrappy WordPress
</head>
<body <?php body_class(); ?>>
<div id="page" class="hfeed site">
<a name= "TopOfPage"/a>
<?php do_action( 'before' ); ?>
<div class="wrapper">
<header id="masthead" class="site-header" role="banner">
@randyzwitch
randyzwitch / create-R-EC2.sh
Created June 8, 2013 14:06
Using R on Amazon EC2 - Part 1
#Create a user, home directory and set password
sudo useradd rstudio
sudo mkdir /home/rstudio
sudo passwd rstudio
sudo chmod -R 0777 /home/rstudio
#Update all files from the default state
sudo apt-get update
sudo apt-get upgrade
@randyzwitch
randyzwitch / r-ec2-part2.sh
Created June 8, 2013 14:07
Using R on Amazon EC2 - Part 2
#Install in order to use RCurl & XML
sudo aptitude install libcurl4-openssl-dev
sudo apt-get install libxml2-dev
@randyzwitch
randyzwitch / rstudio-ec2.sh
Created June 8, 2013 14:09
Installing RStudio Server on Amazon EC2
#Install a few background files
sudo apt-get install gdebi-core
sudo apt-get install libapparmor1
#Change to a writeable directory
#Download & Install RStudio Server
cd /tmp
wget http://download2.rstudio.org/rstudio-server-0.97.336-amd64.deb
sudo gdebi rstudio-server-0.97.336-amd64.deb
@randyzwitch
randyzwitch / julia_io.jl
Created July 23, 2013 14:10
Julia, R, and Python language comparison: IO
#R: Read in 1987.csv from airline dataset into a dataframe
#No import statement needed to create a dataframe in R
airline1987 <- read.csv("~/airline/1987.csv")
dim(airline1987)
[1] 1311826 29
#Python: use pandas to create a dataframe
import pandas as pd
airline1987 = pd.read_csv("/Users/randyzwitch/airline/1987.csv")
airline1987.shape
@randyzwitch
randyzwitch / julia-looping.jl
Created July 23, 2013 14:58
Julia, Python, looping
#Python looping to create a term-frequency dictionary
from collections import Counter
term_freq = Counter()
for word in english_dictionary:
for url in url_list:
if word in url_list:
term_freq[word] += 1