Skip to content

Instantly share code, notes, and snippets.

View xkstein's full-sized avatar

James xkstein

  • Columbia University
View GitHub Profile
'''
This is an example connecting to the Yokogawa AQ6375-AQ6376 with LAN/pyvisa
Our versions of these devices do not support VXI-11, so you have to use socket.
This means you gotta have the @py backend for pyvisa and and address with format
`TCPIP::<IP address>::<Port>::SOCKET`
And you gotta add terminators.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@xkstein
xkstein / find_length.lym
Last active July 3, 2025 16:13
Find Length KLayout
<?xml version="1.0" encoding="utf-8"?>
<klayout-macro>
<description>Find Resonator Length</description>
<version/>
<category>pymacros</category>
<prolog/>
<epilog/>
<doc/>
<autorun>true</autorun>
<autorun-early>false</autorun-early>
@xkstein
xkstein / upload_ip.py
Last active March 1, 2024 21:51
Upload ip to firebase
'''
This is a little script for uploading raspberry pi ip's to a firebase server
The idea is to have this script set up as a service that launches at network start
Requires:
+ pyrebase
+ netifaces
Set the following ENV variables (with your firebase server's config):
+ FIREBASE_API_KEY
@xkstein
xkstein / integrate_gaussian_sympy.md
Last active November 20, 2023 20:09
Gaussian integrals over all space in Sympy

Symbolically integrate gaussians over all space!

Integrals that look like:

$$A \int_{-\infty}^{+\infty} x^{2n} e^{-x^2/a^2} dx$$

are really common in quantum mechanics (at least at the upper-division undergraduate level). Unfortunately, trying to perform one of these integrals using the built-in sympy integration function gives confusing results that are difficult to use.

This code produces more practical results by using the simple analytical solution for these integrals (shown in the back of Griffiths QM):

Notes to self about deploying SvelteKit to Github Pages

So there is a handy npm package called gh-pages that'll handle most of the gross stuff, you just have to configure it.

Prerequisites

Get to the point where npm run build compiles a working version of your website in the build/ directory. Also be in a git repo connected to Github (obv).

Adding gh-pages

@xkstein
xkstein / Dotfiles
Last active December 7, 2022 23:00
My .vimrc and .tmux.conf
@xkstein
xkstein / redis_cache.py
Last active November 15, 2022 00:22
Little redis caching util
'''Two simple examples of redis caching
Includes:
- Simple function-type decorator
- Class with method for time dependent caching
They both make entries in redis with key [function name] + [bound args]
'''
from time import sleep, time
from functools import wraps, partial
@xkstein
xkstein / multiple_dispatch_metaclass.py
Last active November 9, 2022 18:15
Python Function Overloading With MetaClasses (Terrible)
'''Script that impliments function overloading in python hatefully
Requires python 3.10, doesn't support kwargs for overloaded functions
'''
from inspect import get_annotations
class DispatchDict(dict):
def __call__(self, *args, **kwargs):
if len(self) == 1:
# Hack for non-multiple dispatch functions

Flexture Corner Spring

This script should make corner retention springs.

The variables in this script correspond to the measurements indicated in this image

Drawing Indicating Dimensions

Background