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 / keybase.md
Created May 31, 2020 08:09
Keybase and Github

Keybase proof

I hereby claim:

  • I am lazyoracle on github.
  • I am anuragsaharoy (https://keybase.io/anuragsaharoy) on keybase.
  • I have a public key whose fingerprint is F42A 6BA6 F29D 2691 5E3D C12D 6085 B4EE EE1A CD25

To claim this, I am signing this object:

@lazyoracle
lazyoracle / qoptimize_c3_cla.md
Last active January 30, 2021 20:37
Contributor License Agreement for C3

Individual Contributor License Agreement

Thank you for your interest in contributing to the open source software project C3 (“Project”) made available by the owners of the q-optimize Github organisation or its affiliates ("Owner"). This Individual Contributor License Agreement (“Agreement”) sets out the terms governing any source code, object code, bug fixes, configuration changes, tools, specifications, documentation, data, materials, feedback, information or other works of authorship that you submit or have submitted, in any form and in any manner, to the Project (collectively “Contributions”). If you have any questions respecting this Agreement, please contact c3@q-optimize.org.

You agree that the following terms apply to all of your past, present and future Contributions. Except for the licenses granted in this Agreement, you retain all of your right, title and interest in and to your Contributions.

Copyright License. You hereby grant, and agree to grant, to the Owner a non-exclusive, perpetu

@lazyoracle
lazyoracle / multiprocessing.py
Last active April 26, 2021 08:37
Simple multiprocessing in python
def sum_up_to(number):
return sum(range(1, number + 1))
a_pool = multiprocessing.Pool() # Create pool object
result = a_pool.map(sum_up_to, range(10)) # Run `sum_up_to` 10 times simultaneously
@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)})();
@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 / 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 / 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 / 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 / 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 / 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