Skip to content

Instantly share code, notes, and snippets.

@jlehtoma
jlehtoma / wms_proto.R
Created November 13, 2011 20:01
Prototype for accessing WMS from R
# Author: Joona Lehtomäki <joona.lehtomaki@gmail.com>
# Updated: 13.11.2011
# Version: 0.0.1
if (!require("rgdal")) {
install.packages("rgdal")
}
if (!require("raster")) {
install.packages("raster")
@ziadoz
ziadoz / awesome-php.md
Last active July 13, 2024 05:29
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
@Robsteranium
Robsteranium / statistics-distributions.js
Created May 11, 2012 20:20 — forked from benrasmusen/statistics-distributions.js
JavaScript library for calculating critical values and upper probabilities of common statistical distributions
/*
* NAME
*
* statistics-distributions.js - JavaScript library for calculating
* critical values and upper probabilities of common statistical
* distributions
*
* SYNOPSIS
*
*
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active July 24, 2024 17:56
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@fabianp
fabianp / gist:3081831
Created July 10, 2012 07:33
Pool Adjacent Violators
import numpy as np
# Author : Alexandre Gramfort
# license : BSD
def pav(y):
"""
PAV uses the pair adjacent violators method to produce a monotonic
smoothing of y
@dsparks
dsparks / pretty_network.R
Created December 12, 2012 17:39
Graphing a subset of isDotR's Twitter ego net.
doInstall <- TRUE
toInstall <- c("sna", "igraph")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
adjacencyList <- read.csv("https://dl.dropbox.com/s/8wabcrtqxysp03u/Twitter_network.R.csv?dl=1")
head(adjacencyList)
adjacencyMatrix <- table(adjacencyList)
as.matrix(sort(rowSums(adjacencyMatrix))) # Out-degree
@fawda123
fawda123 / nnet_plot_fun.r
Last active December 14, 2015 12:29
nnet_plot_fun
plot.nnet<-function(mod.in,nid=T,all.out=T,all.in=T,wts.only=F,rel.rsc=5,circle.cex=5,node.labs=T,
line.stag=NULL,cex.val=1,alpha.val=1,circle.col='lightgrey',pos.col='black',neg.col='grey',...){
require(scales)
#gets weights for neural network, output is list
#if rescaled argument is true, weights are returned but rescaled based on abs value
nnet.vals<-function(mod.in,nid,rel.rsc){
library(scales)
@mages
mages / add.alpha.R
Last active December 20, 2018 14:31
How to change the alpha value of colours in R
## Add an alpha value to a colour
add.alpha <- function(col, alpha=1){
if(missing(col))
stop("Please provide a vector of colours.")
apply(sapply(col, col2rgb)/255, 2,
function(x)
rgb(x[1], x[2], x[3], alpha=alpha))
}
@mathematicalcoffee
mathematicalcoffee / autocaption_knitr.r
Created April 23, 2013 07:12
Automatically set knitr's figure caption option to the title of the ggplot in the chunk. The gist has the R code you should put in your document, as well as an example Rmd with the compiled output.
# Include the following in a chunk up the top of your document
# Then in your plot chunk, use 'fig.cap=cap()'.
# Set the title of your ggplot via `labs(title="mytitle")`, and
# it will automatically be substituted into the chunk options
# as 'fig.cap'
library(knitr)
opts_knit$set(eval.after='fig.cap')
cap <- function () {
p <- last_plot()
if (!is.null(p) && !is.null(p$labels$title)) {
@hadley
hadley / s3.r
Created May 7, 2013 13:16
Implementation of request signing for Amazon's S3 in R.
library(httr)
library(digest)
library(XML)
s3_request <- function(verb, bucket, path = "/", query = NULL,
content = NULL, date = NULL) {
list(
verb = verb,
bucket = bucket,
path = path,