Skip to content

Instantly share code, notes, and snippets.

View ashander's full-sized avatar

Jaime Ashander ashander

View GitHub Profile
@ashander
ashander / use-overleaf-with-repo.md
Last active October 20, 2022 12:39
Using overleaf for realtime (ish) collaboration with an existing git repo

on overleaf.com

  • start a blank overleaf project
  • go to the share menu and copy git link from "Clone with git" (e.g. https://git.overleaf.com/blahblahblaah)

in your local repo

set up overleaf as a remote

git remote add overleaf https://git.overleaf.com/blahblahblaah
git checkout -b collaboration overleaf/master
@ashander
ashander / method-dispatch.r
Last active May 12, 2016 17:25
Rephrased example from Advanced R of method dispatch (http://adv-r.had.co.nz/S3.html)
## example from http://adv-r.had.co.nz/S3.html
newmean <- function (x, ...) {
UseMethod("newmean", x)
}
newmean.numeric <- function(x, ...) sum(x) / length(x)
newmean.data.frame <- function(x, ...) sapply(x, mean, ...)
newmean.matrix <- function(x, ...) apply(x, 2, mean)
#numeric a
a <- c(1, 2, 6)
@ashander
ashander / unfavorite.js
Last active December 7, 2022 01:37
Delete all your favorites (unfavorite or unlike every tweet) on twitter.com (thx to @JamieMason and @b44rd for inspiring this)
// 1. Go to https://twitter.com/i/likes
// 2. Keep scrolling to the bottom repeatedly until all your favs are loaded.
// 3. Run this in your console (open in chrome by View > Developer > JavaScript Console)
// Notes: this may take a while if you have a lot of favs/likes
// you can only access your most recent ~2000 likes.
// inspired by https://gist.github.com/JamieMason/7580315
$('.ProfileTweet-actionButtonUndo').click()
@ashander
ashander / keybase.md
Created September 15, 2016 02:38
keybase verification

Keybase proof

I hereby claim:

  • I am ashander on github.
  • I am ashander (https://keybase.io/ashander) on keybase.
  • I have a public key ASB64liKYYs5Ynv_-hUY2oWx0u_J4KWK9CbksBDJliS7fgo

To claim this, I am signing this object:

@ashander
ashander / msprime_covering.py
Last active October 31, 2016 23:08
Msprime records $\sum_i (l_i - r_i)$ will _not_ sum to `n-1` for `n` samples (unless there is no recombination)
import msprime
pop = __import__('random').randint(2, 20000)
sum = 0
with open('example.tsv', 'w') as f:
msprime.simulate(pop, recombination_rate = 10).write_records(f)
with open('example.tsv', 'r') as f:
f.readline()
l = f.readlines()
for line in l:
vec = line.split('\t')
@ashander
ashander / README.md
Last active January 16, 2017 21:39
SNAP foods typically purchased
@ashander
ashander / Makefile
Last active January 27, 2017 07:41
Equity distribution (from Survey of Consumer Finances)
README.md: README.Rmd
Rscript -e 'rmarkdown::render("README.Rmd")'
cp README_files/figure-markdown_strict/equity-vigesimals-1.png equity-vigesimals-1.png
cp README_files/figure-markdown_strict/equity-deciles-by-age-1.png equity-deciles-by-age-1.png
rscfp2013.dta: scfp2013s.zip
unzip scfp2013s.zip
scfp2013s.zip:
wget https://www.federalreserve.gov/econresdata/scf/files/scfp2013s.zip
@ashander
ashander / README.md
Last active May 3, 2017 17:35
Follow tweets and retweets (etc) on streaming API
@ashander
ashander / make_and_delete_tree.sh
Last active March 21, 2017 21:42
what does `unlink` do in R?
mkdir -p tmp tmp/c
touch tmp/a tmp/b tmp/c/d
$ tree tmp
# tmp
# ├── a
# ├── b
# └── c
# └── d
cd tmp
strace -o ../strace.log Rscript -e 'unlink(c("a", "b", "c"), recursive=TRUE)'
@ashander
ashander / comet-and-conda-errors.md
Last active June 6, 2023 01:12
Error attempting to use numpy via conda on SDSC's Comet resource --- due to default number of threads requested by OpenMP

The error below can be avoided by export OMP_NUM_THREADS=2 (or possibly a higher number). To see this run:

env OMP_NUM_THREADS=2 python -c 'import numpy'

environment

system