git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git
cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
| # Makefile for generating R packages. | |
| # 2011 Andrew Redd | |
| # | |
| # Assumes Makefile is in a folder where package contents are in a subfolder pkg. | |
| # Roxygen uses the roxygen2 package, and will run automatically on check and all. | |
| PKG_VERSION=$(shell grep -i ^version pkg/DESCRIPTION | cut -d : -d \ -f 2) | |
| PKG_NAME=$(shell grep -i ^package pkg/DESCRIPTION | cut -d : -d \ -f 2) | |
| R_FILES := $(wildcard pkg/R/*.R) |
git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git
cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
brew install git bash-completion
Configure things:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
| # | |
| # Get appraised value of car from Edmunds.com using the developer API with R | |
| # Reference: http://developer.edmunds.com/docs/read/The_Vehicle_API | |
| # | |
| # set working dir | |
| setwd('~/R/carvalue') | |
| #load libraries | |
| library(RJSONIO) |
| # download docx2txt by Sandeep Kumar | |
| wget -O docx2txt.pl http://www.cs.indiana.edu/~kinzler/home/binp/docx2txt | |
| # make a wrapper | |
| echo '#!/bin/bash | |
| docx2txt.pl $1 -' > docx2txt | |
| chmod +x docx2txt | |
| # make sure docx2txt.pl and docx2txt are your current PATH. Here's a guide | |
| http://shapeshed.com/using_custom_shell_scripts_on_osx_or_linux/ |
| notify <- function(msg="Operation complete") { | |
| in.osx <- (Sys.info()['sysname'] == "Darwin") | |
| in.rstudio <- (Sys.getenv("RSTUDIO") == "1") | |
| in.rgui <- (Sys.getenv("R_GUI_APP_REVISION") != "") | |
| if (in.rstudio) { # hack to see if running in RStudio | |
| title <- "RStudio" | |
| sender <- activate <- "org.rstudio.RStudio" | |
| } |
| require(ggplot2) | |
| set.seed(42) | |
| df <- data.frame(x=1:50, y=rnorm(50, 10, 2), int=rbinom(50,1,0.3)) | |
| ggplot(df, aes(x=x, y=y)) + | |
| geom_ribbon(aes(ymin=0, ymax=y, fill='#1E90FF'), alpha=0.3) + | |
| geom_abline(intercept=10, slope=-0.1 | |
| , aes(colour='Linear')) + |
This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.
The script is here:
#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"
| ## | |
| # Creates an alias called "git hist" that outputs a nicely formatted git log. | |
| # Usage is just like "git log" | |
| # Examples: | |
| # git hist | |
| # git hist -5 | |
| # git hist <branch_name> | |
| # git hist <tag_name> -10 | |
| ## | |
| git config --global alias.hist "log --pretty=format:'%C(yellow)[%ad]%C(reset) %C(green)[%h]%C(reset) | %C(red)%s %C(bold red){{%an}}%C(reset) %C(blue)%d%C(reset)' --graph --date=short" |
Magic words:
psql -U postgresSome interesting flags (to see all, use -h or --help depending on your psql version):
-E: will describe the underlaying queries of the \ commands (cool for learning!)-l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)