Skip to content

Instantly share code, notes, and snippets.

@phobson
phobson / microgram.tex
Created August 4, 2012 00:51
upright mus (greek letter in general) in latex
\documentclass{minimal}
\usepackage{siunitx}
\usepackage[sc]{mathpazo}
\linespread{1.05} % Palatino needs more leading (space between lines)
\usepackage[T1]{fontenc}
\begin{document}
who wins?
\si{\micro\gram\per\liter} vs. $\mu$g/L
\end{document}
@dsparks
dsparks / dput example.R
Created September 10, 2012 03:21
Illustrating the use of dput()
# Let's say you have an R object that you'd like to share with someone else
# but, for whatever reason, it is necessary to share it in text form.
# Generate a random data.frame
set.seed(1337)
NN <- 10
theData <- data.frame(Alpha = rnorm(NN),
Beta = rnorm(NN))
theData$Gamma <- theData$Alpha * 2 + theData$Beta / 2 + rnorm(NN)
print(theData)
@dsparks
dsparks / advent_zoo.R
Created November 30, 2012 16:54
Rolling means with zoo
doInstall <- TRUE
toInstall <- c("zoo")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
ftseIndex <- EuStockMarkets[, 4]
plot(ftseIndex, col = "GRAY")
# Calculate 10-day rolling mean, quickly:
smoothIndex <- rollmean(x = ftseIndex, # original series
@trestletech
trestletech / server.R
Last active February 2, 2022 09:47
A Shiny app combining the use of dplyr and SQLite. The goal is to demonstrate a full-fledged, database-backed user authorization framework in Shiny.
library(shiny)
library(dplyr)
library(lubridate)
# Load libraries and functions needed to create SQLite databases.
library(RSQLite)
library(RSQLite.extfuns)
saveSQLite <- function(data, name){
path <- dplyr:::db_location(filename=paste0(name, ".sqlite"))
@pimentel
pimentel / head.list.R
Last active June 27, 2018 03:09
Slightly more sane head() for lists in R
catDf <- data.frame(meow = rnorm(100), purr = rpois(100, 3))
aList <- list(aVector = 1:20, aDf = catDf, anotherList = list(1:200, 1:20))
# annoying as hell, right?
head(aList)
#' Return the first or last part of a list
#'
#' Returns the first or last part of a list. Instead of returning the first
#' n entries as the standard head() does, it attempts to call head()
@clhenrick
clhenrick / README.md
Last active April 1, 2024 14:55
PostgreSQL & PostGIS cheatsheet (a work in progress)
# convert c("female", "Male") to c(0,1)
# magrittr is way nicer than nested function calls
convert_sexcodes <-
function(codes)
{
require(magrittr)
tolower(codes) %>%
@jradavenport
jradavenport / world_pop.py
Last active May 30, 2016 08:51
Spinning World Population Density
# Resulting video from this code can be seen here:
# http://www.ifweassume.com/2015/02/world-population-density.html
# or
# https://vimeo.com/120308257
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import os
@atcuno
atcuno / gist:3425484ac5cce5298932
Last active March 25, 2024 13:55
HowTo: Privacy & Security Conscious Browsing

The purpose of this document is to make recommendations on how to browse in a privacy and security conscious manner. This information is compiled from a number of sources, which are referenced throughout the document, as well as my own experiences with the described technologies.

I welcome contributions and comments on the information contained. Please see the How to Contribute section for information on contributing your own knowledge.

Table of Contents

@haasn
haasn / about:config.md
Last active April 2, 2024 18:46
Firefox bullshit removal via about:config

Firefox bullshit removal

Updated: Just use qutebrowser (and disable javascript). The web is done for.