Skip to content

Instantly share code, notes, and snippets.

View lazyoracle's full-sized avatar
:atom:
Onwards and Upwards

Anurag Saha Roy lazyoracle

:atom:
Onwards and Upwards
View GitHub Profile
@lazyoracle
lazyoracle / qho-aho.py
Created September 5, 2023 16:58
Compare Harmonic & Anharmonic Oscillator
import numpy as np
import matplotlib.pyplot as plt
E_J = 20e9
w = 5e9
anharm = -300e6
N_phis = 101
phis = np.linspace(-np.pi,np.pi,N_phis)
mid_idx = int((N_phis+1)/2)
@lazyoracle
lazyoracle / qiskit_circuit_transpiler.py
Created February 20, 2023 10:18
transpile circuits using qiskit
from qiskit import *
import qiskit
circ = QuantumCircuit(1)
circ.h(0)
transpiled_circ = qiskit.compiler.transpile(circ, basis_gates = ['rx', 'ry', 'rz'])
transpiled_circ.draw()
print(transpiled_circ)
@lazyoracle
lazyoracle / pycma_options.py
Created November 25, 2022 16:29
Show options for pycma is a legible way
# https://github.com/CMA-ES/pycma/tree/master
import cma
from pprint import pprint
import argparse
parser = argparse.ArgumentParser(description='search term for pycma options')
parser.add_argument('-s', '--search', type=str, help='search for options containing this term')
args = parser.parse_args()
pprint(cma.CMAOptions(args.search))
@lazyoracle
lazyoracle / environment-tensorflow-m1.yml
Created December 28, 2021 00:33
Setting up tensorflow with GPU support on Apple Silicon
# install miniforge for arm64
# https://github.com/conda-forge/miniforge
name: tensorflow
channels:
- apple
- conda-forge
dependencies:
- ipykernel=6.6
- jupyter=1.0
- matplotlib=3.5
@lazyoracle
lazyoracle / environment-c3-dev-m1.yml
Last active January 2, 2022 23:01
Dependency file for c3-toolset development on Apple Silicon using conda-forge
name: c3-dev
channels:
- conda-forge
dependencies:
- ipykernel=6.6
- jupyter=1.0
- matplotlib=3.5
- notebook=6.4
- pip=21.3
- python=3.8
@lazyoracle
lazyoracle / combining-git-repositories.md
Created November 9, 2021 19:33 — forked from msrose/combining-git-repositories.md
How to combine two git repositories.

Combining two git repositories

Use case: You have repository A with remote location rA, and repository B (which may or may not have remote location rB). You want to do one of two things:

  • preserve all commits of both repositories, but replace everything from A with the contents of B, and use rA as your remote location
  • actually combine the two repositories, as if they are two branches that you want to merge, using rA as the remote location

NB: Check out git subtree/git submodule and this Stack Overflow question before going through the steps below. This gist is just a record of how I solved this problem on my own one day.

Before starting, make sure your local and remote repositories are up-to-date with all changes you need. The following steps use the general idea of changing the remote origin and renaming the local master branch of one of the repos in order to combine the two master branches.

@lazyoracle
lazyoracle / numba_parallel_integration.py
Last active July 12, 2021 18:37
Numerical Integration using Trapezoidal rule - parallelized with Numba
from typing import Callable
from numba import njit, prange
import numpy as np
@njit()
def my_square(x: float) -> float:
return x**2
def bayes_numr(x: float, t: float) -> float:
return (1. / np.sqrt(2. * np.pi)) * np.exp(-np.square(x) / 2.) * np.square(np.cos(x * t / 2.0))
@lazyoracle
lazyoracle / get-call-graph.sh
Created May 31, 2021 13:56
Creating static call graphs in Python using pyan3
pip install -U pyan3==1.1.1
pyan3 <path/to/file> --uses --no-defines --colored --grouped --annotated --dot > call-graph.dot
pip install graphviz
python
>>> from graphviz import render
>>> render('dot', 'png', 'call-graph.dot')
'call-graph.dot.png'
>>> render('dot', 'svg', 'call-graph.dot')
'call-graph.dot.svg'
@lazyoracle
lazyoracle / scihub.js
Created April 26, 2021 08:38
Javascript bookmarklet for Sci-Hub
javascript: (function(){ window.open(location.origin.replace%28/%5Ehttps/, 'http') + '.sci-hub.se' + location.pathname + location.search, '_blank')})();
@lazyoracle
lazyoracle / google_translate_bookmarklet.js
Last active March 14, 2021 09:55
Javascript Bookmarket for Google Translate
javascript: (function(){ window.open('https://translate.google.com/translate?sl=auto&tl=en&u=' + location.origin + location.pathname)})();