Skip to content

Instantly share code, notes, and snippets.

@proteneer
proteneer / gist:8839171
Created February 6, 2014 06:20
Keyboard events Linux
#define LINUX
#ifndef LINUX
#include <conio.h> /* kbhit(), getch() */
#else
#include <sys/time.h> /* struct timeval, select() */
/* ICANON, ECHO, TCSANOW, struct termios */
#include <termios.h> /* tcgetattr(), tcsetattr() */
#include <cstdlib> /* atexit(), exit() */
import simtk.openmm
import simtk.unit as unit
import math
state = simtk.openmm.XmlSerializer.deserialize(open('state.xml').read())
system = simtk.openmm.XmlSerializer.deserialize(open('system.xml').read())
for i, force in enumerate(system.getForces()):
force.setForceGroup(i)
system.getForce(3).setReciprocalSpaceForceGroup(6)
@proteneer
proteneer / gist:a1bd29592809e1457f8d
Last active August 29, 2015 14:01
tornado + redis
import tornado.web
import tornado.httpserver
import tornado.ioloop
import process2
import tornado.netutil
import redis
import signal
import time
import sys
import os
#include <OpenMM.h>
#include <iostream>
#include <fstream>
#include <limits>
using namespace OpenMM;
using namespace std;
extern "C" void registerSerializationProxies();
extern "C" void registerOpenCLPlatform();
@proteneer
proteneer / notify expiration
Created November 14, 2013 22:47
notify expires
import redis
import threading
class Listener(threading.Thread):
def __init__(self, r, channels):
threading.Thread.__init__(self)
self.redis = r
self.pubsub = self.redis.pubsub()
self.pubsub.subscribe(channels)
@proteneer
proteneer / Polling redis
Created November 17, 2013 06:45
polling
import redis
import threading
class Listener(threading.Thread):
def __init__(self, r, channels):
threading.Thread.__init__(self)
self.redis = r
self.pubsub = self.redis.pubsub()
self.pubsub.subscribe(channels)
@proteneer
proteneer / gist:7916922
Last active December 31, 2015 01:49
python redis hash+set wrapper
import redis
rc = redis.Redis(port=6782)
rc.flushdb()
class HashSet(object):
_rc = None
_rmaps = []
@classmethod
count = 10000
start = time.time()
for i in range(count):
rc.set('bar',1)
rc.set('bar',1)
rc.set('bar',1)
rc.set('bar',1)
print time.time()-start

Keybase proof

I hereby claim:

  • I am proteneer on github.
  • I am yutong (https://keybase.io/yutong) on keybase.
  • I have a public key whose fingerprint is A3DD C50A 4524 96E9 2A4F CFB3 91CE ACDB 2605 E878

To claim this, I am signing this object:

@proteneer
proteneer / test.py
Created May 20, 2019 15:41
Implement HVPs as batched JVPs
import functools
import numpy as onp
import jax
import jax.numpy as np
from timemachine.potentials import bonded
param_idxs = np.array([
[0,1],