Skip to content

Instantly share code, notes, and snippets.

@1beb
1beb / sails-start.sh
Last active December 31, 2015 09:49
Getting started with sails
sudo npm -g install
sails new testProject
cd testProject
sails lift
# navigate to http://localhost:1337
@1beb
1beb / hellohttp.js
Last active December 31, 2015 09:49
Basic node.js server that says "Hello Http"
var http = require('http');
var server = http.createServer(function(req, res) {
res.writeHead(200);
res.end('Hello Http');
});
server.listen(8080);
@1beb
1beb / install-node.sh
Last active December 31, 2015 09:49
How to install node.js from source
cd ~
mkdir src && cd src
wget -N http://nodejs.org/dist/node-latest.tar.gz
tar xzvf node-latest.tar.gz && cd node-v*
# when it asks if you want to change anything remove "v" from the version number
./configure
sudo checkinstall
sudo dpkg -i node_*
@1beb
1beb / rstudio.markdowntoHTML.r
Created November 30, 2012 21:28
Set options on RStudio to only print fragments, remove CSS and add table of contents to output file
options(rstudio.markdownToHTML =
function(inputFile, outputFile) {
require(markdown)
markdownToHTML(inputFile,"tmp.html",fragment.only=TRUE)
system(paste("pandoc", "-s -S --toc","tmp.html", "-o", outputFile))
}
)
@1beb
1beb / example.Rnw
Created August 13, 2012 11:55
Example of reproducible research in Rstudio documents
% Preamble
\documentclass{Article}
\usepackage{Sweave}
% Start Document
\begin{document}
% Titlepage
\begin{titlepage}
\title{A Title}
@1beb
1beb / remove_leave_a_response.php
Created February 12, 2012 03:06
Remove "Leave a response" from wordpress hybrid theme
<?php
/* On line 242, find the following code */
$meta = '<p class="entry-meta">' . __( '[entry-terms taxonomy="category" before="Posted in "] [entry-terms taxonomy="post_tag" before="| Tagged "] [entry-comments-link before="| "]', hybrid_get_textdomain() ) . '</p>';
/* And replace it with the following line */
$meta = '<p class="entry-meta">' . __( '[entry-terms taxonomy="category" before="Posted in "] [entry-terms taxonomy="post_tag" before="| Tagged "]', hybrid_get_textdomain() ) . '</p>';
/* Voila, you're finished. */
?>
@1beb
1beb / part7.r
Created June 24, 2011 17:15
Part IIV: ggplot2 Introduction Mapping Example
## Title: ggplot2 Introduction: Plotting Maps
## Description: This line by line analysis, provides an introduction to ggplot2. Mapping.
## Created by: Brandon Bertelsen: Research Manager, Credo Consulting Inc.
# install.packages(maptools)
library(maptools)
library(ggplot2)
# Must allow for licensing
gpclibPermit()
@1beb
1beb / part6.r
Created June 20, 2011 06:05
Part VI: ggplot2 introduction
## Title: ggplot2 Introduction: Correlation Heatmap
## Description: This line by line analysis, provides an introduction to ggplot2. Correlation Heatmap
## Created by: Brandon Bertelsen: Research Manager, Credo Consulting Inc.
## Heatmap example courtesy of: http://learnr.wordpress.com/2010/01/26/ggplot2-quick-heatmap-plotting/
# Run correlations
e.new <- as.data.frame(cor(e[2:ncol(e)]))
# Reset rownames
e.new <- data.frame(row=rownames(e.new),e.new)
@1beb
1beb / part5.r
Created June 20, 2011 05:24
Part V: ggplot2 introduction, scorecards
## Title: ggplot2 Introduction: Part IV
## Description: This line by line analysis, provides an introduction to ggplot2. Scorecards
## Created by: Brandon Bertelsen: Research Manager, Credo Consulting Inc.
## Save plots as objects
p1 <- ggplot(d, aes(clarity, price)) + geom_boxplot()
p2 <- ggplot(d, aes(price)) + geom_histogram() + facet_grid(~cut)
p3 <- ggplot(d, aes(price, carat, color=clarity)) + geom_point()
# Function courtesy of Hadley Wickham
@1beb
1beb / part4.r
Created June 20, 2011 04:53
Part IV: ggplot2 Introduction
## Title: ggplot2 Introduction: Part IV
## Description: This line by line analysis, provides an introduction to ggplot2. Time series.
## Created by: Brandon Bertelsen: Research Manager, Credo Consulting Inc.
# Review the economics data set from the ggplot2 intro
e <- economics
str(e)
# Let's look at geom_line
ggplot(e, aes(date, uempmed)) + geom_line()