Skip to content

Instantly share code, notes, and snippets.

@bachmeil
bachmeil / a.c
Last active May 6, 2023 01:06
ImportC example
#include <math.h>
@bachmeil
bachmeil / basic-graph.R
Created May 11, 2021 22:19
Supply and demand graph example in R
plot(-1, ylim=c(0, 12), xlim=c(0, 12), xlab="", ylab="", xaxt='n', yaxt='n', axes=0, main="Supply and Demand")
segments(0, 0, 0, 10, lwd=3)
segments(0, 0, 10, 0, lwd=3)
segments(1, 1, 9, 9, lwd=3)
segments(1, 9, 9, 1, lwd=3)
text(0, 11, "P", cex=1.6)
text(10.5, 0, "Q", cex=1.6)
text(9.3, 9.2, "S", cex=1.4)
text(9.3, 1.2, "D", cex=1.4)
points(5, 5, pch=19, cex=1.5, col="blue")
@bachmeil
bachmeil / dim-for-vectors.R
Last active February 19, 2020 20:12
In case you want dim to work for vectors
dim <- function(x) {
if (is.vector(x)) {
return(length(x))
} else {
return(.Primitive("dim")(x))
}
}
# Test code
# v <- rnorm(100)
@bachmeil
bachmeil / css.txt
Last active March 19, 2020 19:23
Fossil skin
@import url('https://fonts.googleapis.com/css?family=Roboto&display=swap');
body {
margin: 0 auto;
background-color: white;
font-family: sans-serif;
font-size:14pt;
-moz-text-size-adjust: none;
-webkit-text-size-adjust: none;
-mx-text-size-adjust: none;
@bachmeil
bachmeil / simple-editor.html
Last active February 6, 2020 15:29
Simple Trix implementation
<head>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/trix/1.2.1/trix.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/trix/1.2.1/trix.js"></script>
</head>
<div style="max-width: 850px; margin: auto;">
<trix-editor></trix-editor>
<a onclick="localsave()" href="javascript:void(0);">Save</a> <a onclick="localload()" href="javascript:void(0);">Load</a>
</div>
<script>
function localsave() {
@bachmeil
bachmeil / lecture.latex
Created October 2, 2019 19:33
Pandoc template - lecture notes
\documentclass[12pt]{article}
\usepackage[letterpaper, margin=1.25in]{geometry}
\usepackage{setspace}
\doublespacing
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
% use upquote if available, for straight quotes in verbatim environments
@bachmeil
bachmeil / single.latex
Created October 2, 2019 19:32
Pandoc template - single spaced document
\documentclass[12pt]{article}
\usepackage[letterpaper, margin=1in]{geometry}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex

Convert 25 tweets by @undercoverhist starting 2019-03-29 to latex format.

Requires getting a Twitter API key as described here.

R code:

library(twitteR)
library(rmarkdown)
setup_twitter_oauth(api key, api secret, access token, access secret) # Fill in values given by Twitter