Skip to content

Instantly share code, notes, and snippets.

View johnrichardrinehart's full-sized avatar

John Rinehart johnrichardrinehart

View GitHub Profile
// The above is courtesy of @moldy via #django (freenode)
frameworks:
Django, flask, Werkzeug, Cherrypy, Rails
languages:
Ruby, Python
WSGI servers:
gunicorn, uWSGI, apache (with mod_wsgi)
if not os.path.exists(os.path.dirname(filename)):
try:
os.makedirs(os.path.dirname(filename))
except OSError as exc: # protects against race conds
if exc.errno != errno.EEXIST:
printToLog("Failed to make the directory!",1)
raise
with open(filename,"w") as f:
for chunk in res.iter_content(2**20):
f.write(chunk)
\documentclass{article}
\newenvironment{env}[2]{env is #1 and #2}{}
\begin{document}
\begin{env}{amazing, wonderful}
\end{env}
\end{document}
```diff,python
def foo():
- a = 0
+ a = 1
return
```
set nocompatible
filetype plugin on
set rtp=$HOME/vimfiles/bundle/vimtex
set rtp+=$HOME/vimfiles/bundle/vimtex/after
let g:vimtex_view_general_viewer='SumatraPDF'
@johnrichardrinehart
johnrichardrinehart / znc_cleanup.sh
Created January 18, 2017 01:01
ZNC log cleanup (cleans up messages and old logs)
#!/bin/bash
DATE=`date +%Y-%m-%d--%H:%M:%S`;
ZNCCLEANDIR=/home/john/znc_clean;
ZNCLOGDIR=/home/john/.znc/users/fuzzybear3965/networks/lovelace_freenode/moddata/log;
MESSAGESFILENAMERELATIVE="messages_$DATE.log";
OLDLOGSFILENAMERELATIVE="oldlogs_$DATE.log";
MESSAGESFILENAME=$ZNCCLEANDIR/$MESSAGESFILENAMERELATIVE;
OLDLOGSFILENAME=$ZNCCLEANDIR/$OLDLOGSFILENAMERELATIVE;
if [ -f $MESSAGESFILENAME ]; then
var Promise = require("bluebird");
var bhttp = require("bhttp");
var taskQueue = require("promise-task-queue");
var MongoClient = require('mongodb');
var queue = taskQueue();
var failedRequests = 0;
//const alphabet = "abcdefghijklmnopqrstuvwxyz"
//const urls =[]
//for (let i=0 ; i < 4; i++) {
import motor.motor_asyncio
import asyncio
client = motor.motor_asyncio.AsyncIOMotorClient('localhost', 27017)
db = client['testDB']
async def do_insert(user, collection_name):
document = {'user': user}
result = await db[collection_name].insert_one(document);
print('Added user %s' % user)
@johnrichardrinehart
johnrichardrinehart / Problem5Plot.jl
Created June 27, 2017 21:44
A plot of a cat state |3> + |-3> for PHYS776 (Resch, Spring 2017) - Assignment 2, Problem 5
import Plots
Plots.plotly()
function f(B)
return function (a,b)
(2/pi)*(
2*e^(-2*(a^2+b^2))*cos(4*b*B)
+
e^(-2*((a+B)^2+b^2))*(1+e^(8*a*B))
)
@johnrichardrinehart
johnrichardrinehart / Parallel Write
Created July 2, 2017 00:00
JuliaParallelWrite.jl
@sync @parallel for i = 1:length(x)
for j = 1:length(y)
grid[i,j] =
Cubature.hcubature(integrand(3,x[i],y[j]),[1e-2,0],[10,2*pi])[1]
end
end