Skip to content

Instantly share code, notes, and snippets.

@nadavrot
nadavrot / Matrix.md
Last active April 26, 2024 08:28
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

@mdonkers
mdonkers / server.py
Last active April 30, 2024 23:26
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
License: MIT License
Copyright (c) 2023 Miel Donkers
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
@wonderbeyond
wonderbeyond / graceful_shutdown_tornado_web_server.py
Last active February 22, 2023 05:34 — forked from mywaiting/graceful_shutdown_tornado_web_server.py
The example to how to shutdown tornado web server gracefully...
#!/usr/bin/env python
"""
How to use it:
1. Just `kill -2 PROCESS_ID` or `kill -15 PROCESS_ID`,
The Tornado Web Server Will shutdown after process all the request.
2. When you run it behind Nginx, it can graceful reboot your production server.
"""
import time
@Brainiarc7
Brainiarc7 / VAAPI-hwaccel-encode-Linux-Ffmpeg&Libav-setup.md
Last active March 26, 2024 18:18
This gist contains instructions on setting up FFmpeg and Libav to use VAAPI-based hardware accelerated encoding (on supported platforms) for H.264 (and H.265 on supported hardware) video formats.

Using VAAPI's hardware accelerated video encoding on Linux with Intel's hardware on FFmpeg and libav

Hello, brethren :-)

As it turns out, the current version of FFmpeg (version 3.1 released earlier today) and libav (master branch) supports full H.264 and HEVC encode in VAAPI on supported hardware that works reliably well to be termed "production-ready".

@macks22
macks22 / pmf-and-modified-bpmf-pymc.py
Last active May 13, 2021 13:37
Probabilistic Matrix Factorization (PMF) + Modified Bayesian BMF
"""
Implementations of:
Probabilistic Matrix Factorization (PMF) [1],
Bayesian PMF (BPMF) [2],
Modified BPFM (mBPMF)
using `pymc3`. mBPMF is, to my knowledge, my own creation. It is an attempt
to circumvent the limitations of `pymc3` w/regards to the Wishart distribution:
@mblondel
mblondel / projection_simplex.py
Last active March 11, 2024 12:07
Projection onto the simplex
"""
License: BSD
Author: Mathieu Blondel
Implements three algorithms for projecting a vector onto the simplex: sort, pivot and bisection.
For details and references, see the following paper:
Large-scale Multiclass Support Vector Machine Training via Euclidean Projection onto the Simplex
Mathieu Blondel, Akinori Fujino, and Naonori Ueda.
@vene
vene / lbfgs_l1logistic.py
Last active January 14, 2023 20:30
Solving L1-regularized problems with l-bfgs-b
"""l-bfgs-b L1-Logistic Regression solver"""
# Author: Vlad Niculae <vlad@vene.ro>
# Suggested by Mathieu Blondel
from __future__ import division, print_function
import numpy as np
from scipy.optimize import fmin_l_bfgs_b
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active April 25, 2024 02:01
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@rmcgibbo
rmcgibbo / LICENSE
Last active July 24, 2022 02:58
Parallel Sparse Matrix Dense Matrix Product in C/Cython/Python.
Copyright 2013 Robert T. McGibbon
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE O
@ConstantineLignos
ConstantineLignos / picosat_additions.h
Last active March 12, 2018 23:20
Building picosat on Windows.
/* Turn off features that will not work on Windows.
*/
#define NGETRUSAGE
#define NALLSIGNALS