Skip to content

Instantly share code, notes, and snippets.

View manodeep's full-sized avatar
👋

Manodeep Sinha manodeep

👋
View GitHub Profile
# IDA (disassembler) and Hex-Rays (decompiler) plugin for Apple AMX
#
# WIP research. (This was edited to add more info after someone posted it to
# Hacker News. Click "Revisions" to see full changes.)
#
# Copyright (c) 2020 dougallj
# Based on Python port of VMX intrinsics plugin:
# Copyright (c) 2019 w4kfu - Synacktiv
@brittonsmith
brittonsmith / ctree_units.py
Created June 25, 2020 15:16
Provide path to tree_0_0_0.dat file and it will print out units for all fields.
import functools
import re
import sys
from unyt import \
unyt_array, \
unyt_quantity
from unyt.dimensions import \
dimensionless, \
length
#include <stdio.h>
#include <stdbool.h>
struct coro {
void *state;
};
struct range_coro {
struct coro base;
int cur, max, step;
@nadavrot
nadavrot / Matrix.md
Last active July 1, 2024 17:31
Efficient matrix multiplication

High-Performance Matrix Multiplication

This is a short post that explains how to write a high-performance matrix multiplication program on modern processors. In this tutorial I will use a single core of the Skylake-client CPU with AVX2, but the principles in this post also apply to other processors with different instruction sets (such as AVX512).

Intro

Matrix multiplication is a mathematical operation that defines the product of

@simonw
simonw / recover_source_code.md
Last active June 21, 2024 00:11
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@lgarrison
lgarrison / RR_autocorrelations.ipynb
Last active July 24, 2020 12:52
A note on the RR term in autocorrelations
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bskinn
bskinn / intersphinx_mappings.txt
Last active May 31, 2024 17:54
Various intersphinx mappings
# The entries in this file are checked regularly for validity via the Github Action
# sited at github.com/bskinn/intersphinx-gist.
# Please feel free to post an issue at that repo if any of these mappings don't work for you,
# or if you're having trouble constructing a mapping for a project not listed here.
Python 3 [latest]: ('https://docs.python.org/3/', None)
Python 3 [3.x]: ('https://docs.python.org/3.9/', None)
attrs [stable]: ('https://www.attrs.org/en/stable/', None)
Django [dev]: ('https://docs.djangoproject.com/en/dev/', 'https://docs.djangoproject.com/en/dev/_objects/')
Flask [2.2.x]: ('https://flask.palletsprojects.com/en/2.2.x/', None)
@manodeep
manodeep / Latest timings
Last active January 25, 2019 04:57
Benchmarking Pairwise Separation Codes
## Timings with halotools v0.4 and Corrfunc v2.0.0. Updated on Sep 12 (random data, Corrfunc compiled with gcc6.0)
## Note this test is capped at 1 million because the first three codes take too long and halotools randomly subsamples
## particles above 1 million. The algorithm in halotools is an *exact* copy of `Corrfunc` - so the timing comparison simply
## tests the capability of the cython compiler.
## Timings generated on Oct 17, 2016, with mostly ready version of Corrfunc v2.0. Non-periodic calculations with random points.
## Npts kdcount cKDTree KDTree halotools Corrfunc(AVX) Corrfunc(SSE42) Corrfunc(fallback)
10000 0.039 0.057 0.087 0.026 0.240 0.053 0.052
50000 0.381 0.399 0.936 0.121 0.226 0.224 0.214
@dpallot
dpallot / beautiful_idiomatic_python.md
Last active March 16, 2022 04:37 — forked from JeffPaine/beautiful_idiomatic_python.md
Beautiful Idiomatic Python

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@Zearin
Zearin / python_decorator_guide.md
Last active July 2, 2024 18:56
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].