Skip to content

Instantly share code, notes, and snippets.

@josephsdavid
josephsdavid / colors.conf
Created March 10, 2019 23:18
Color scheme
background #faf6f3
foreground #4f2e18
selection_background #4d4d4c
selection_foreground #ffffff
#: black
color0 #282828
color8 #928374
#: red
color1 #cc241d
#!/usr/bin/env bash
###############################################################################
# _ _ _ _ __ _ #
# | |__ ___ _ __| |__ ___| |_| |_ _ / _| |_ _ _ _ __ ___ #
# | '_ \ / _ \ '__| '_ \/ __| __| | | | | |_| __| \ /\ / | '_ ` _ \ #
# | | | | __/ | | |_) \__ \ |_| | |_| | _| |_ \ V V /| | | | | | #
# |_| |_|\___|_| |_.__/|___/\__|_|\__,_|_| \__| \_/\_/ |_| |_| |_| #
# #
###############################################################################
# Initialise {{{
```let
pkgs = import <nixpkgs> {};
in
pkgs.mkShell {
buildInputs = with pkgs; [
python37
python37Packages.pandas
python37Packages.numpy
python37Packages.rpy2
python37Packages.matplotlib
@josephsdavid
josephsdavid / example.md
Last active May 26, 2019 22:42
Example R for DDS

Example for homework 3

Making a MWE (minimal working example)

test<-mtcars
test[2,] <- NA
head(test)
#                    mpg cyl disp  hp drat    wt  qsec vs am gear carb
# Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
# Mazda RX4 Wag       NA  NA   NA  NA   NA    NA    NA NA NA   NA   NA
library(rvest)
library(tidyverse)
# html scraper is a function of the url and the element of the list
html_scraper <- function(url, elem){
read_html(url) %>% html_nodes("table") %>% . [[elem]] %>% html_table -> out
return(out)
}
# usage
# html_scraper( 'http://pokemondb.net/pokedex/all' , 1 )
#!/usr/bin/env bash
#
# Source:
# https://gitlab.com/gaugek/dots/
#
dir="$HOME/Videos/recordings"
name="$(date '+%Y-%m-%d.%H:%M:%S')" # Needs .mp4 after this is listed in the actual recording part
re="\e[31m"
@josephsdavid
josephsdavid / arpcast.R
Created June 18, 2019 05:39
R function for basic AR() forecasting
arpgen <- function(phi,vec,l,mu){
v <- vec[length(vec):(length(vec)-(length(phi)-1))]
f <- sum(phi*(v)) + mu*(1-sum((phi)))
if (l==1) return(f)
return(arpgen(phi,append(vec,f),l-1,mu))
}
arp <- function(phi,vec,l,mu){
as.numeric(lapply(1:l, arpgen, phi = phi, vec = vec, mu = mu))
@josephsdavid
josephsdavid / psi.md
Last active June 20, 2019 03:42
Calculating AR(p) psi weights with R

Calculating psi weights of an AR(p) time series in R

Test Case

phis <- c(1.7,-.72)

Control

@josephsdavid
josephsdavid / beer.R
Last active June 19, 2019 17:58
beer
library(dplyr) # so we can use %>% pipes!
rawBeer <- read.csv(file = "../data/raw/Beers.csv",header=TRUE, sep=",",stringsAsFactors=FALSE)
rawBrew <- read.csv(file= "../data/raw/Breweries.csv", header=TRUE, sep=",", stringsAsFactors=FALSE)
head(rawBeer)
# Name Beer_ID ABV IBU Brewery_id Style
# 1 Pub Beer 1436 0.050 NA 409 American Pale Lager
# 2 Devil's Cup 2265 0.066 NA 178 American Pale Ale (APA)
# 3 Rise of the Phoenix 2264 0.071 NA 178 American IPA
# 4 Sinister 2263 0.090 NA 178 American Double / Imperial IPA
# 5 Sex and Candy 2262 0.075 NA 178 American IPA
@josephsdavid
josephsdavid / beer.R
Created June 21, 2019 03:21
99 bottles of beer in R
beersong <- function(n=99) {
if (n==1) {
cat("\n",n," bottle of beer on the wall, ",n,
" bottles of beer.\nTake one down and pass it around,",
" no more bottles of beer on the wall.\n", sep="")
cat("\nNo more bottles of beer on the wall, no more bottles of beer.\n",
"Go to the store and buy some more, 99 bottles of beer on the wall.\n", sep="")
} else {
cat("\n",n," bottles of beer on the wall, ",n,
" bottles of beer.\nTake one down and pass it around, ",