Skip to content

Instantly share code, notes, and snippets.

View amerberg's full-sized avatar

Adam Merberg amerberg

  • Equilibrium Energy
  • Massachusetts, USA
View GitHub Profile
@amerberg
amerberg / strip_comments.py
Last active June 6, 2021 20:04
A script to remove comments from LaTeX source
import ply.lex, argparse, io
#Usage
# python stripcomments.py input.tex > output.tex
# python stripcomments.py input.tex -e encoding > output.tex
#This utility is released under the WTFPL license: http://www.wtfpl.net/about/
def strip_comments(source):
tokens = (
@amerberg
amerberg / bookmarklets.js
Last active July 25, 2016 02:15
Quora bookmarklets
/* These are bookmarks for making various tasks on Quora easier.
* Since GitHub Markdown doesn't allow JavaScript links, you'll have to install the complicated way.
* Each of the lines beginning with `javascript:` below is a bookmarklet.
* To install, create a new bookmark in your browser and paste that line as the URL.
* Leave feedback in Gist comments or contact https://www.quora.com/Adam-Merberg
*/
//Get the rank of the answer belonging to the logged-in user (in a JS alert box).
//You will have to scroll down far enough that your answer has loaded before you use it.
//Perhaps a future version will do that automatically.
library(matrixStats)
library(ggplot2)
library(animation)
#set seed for replicability
set.seed(1)
#generate 10^3 deviations, 10^6 replicates
w = replicate(10^6, rweibull(10^3, 0.9, 1))
#recall Weibull is subexponential when shape parameter is < 1.
@amerberg
amerberg / monitor.js
Last active August 29, 2015 14:13
Monitor Quora questions
(function(){
//Initialize counts of how many are already monitored,
//how many we're newly monitoring, how many we failed to monitor
var already = 0;
var succeeded = 0;
var failed = 0;
var interrupt = false;
$(document).keyup(function(e){if(e.keyCode==27){interrupt = true;}});