Skip to content

Instantly share code, notes, and snippets.

View akochepasov's full-sized avatar
💭
Paper! Paper!

Anton K2 akochepasov

💭
Paper! Paper!
View GitHub Profile
@avorobey
avorobey / ed.c
Last active October 16, 2018 21:22
V7 Unix ed.c modified to build on modern systems
/* Adapted from https://github.com/v7unix/v7unix/blob/master/v7/usr/src/cmd/ed.c with slight fixes. */
/*
* Editor
*/
#include <signal.h>
#include <sgtty.h>
#include <setjmp.h>
#include <stdlib.h>
#include <string.h>
@johnhw
johnhw / umap_sparse.py
Last active January 6, 2024 16:09
1 million prime UMAP layout
### JHW 2018
import numpy as np
import umap
# This code from the excellent module at:
# https://stackoverflow.com/questions/4643647/fast-prime-factorization-module
import random
@gocarlos
gocarlos / Eigen Cheat sheet
Last active February 11, 2024 14:07
Cheat sheet for the linear algebra library Eigen: http://eigen.tuxfamily.org/
// A simple quickref for Eigen. Add anything that's missing.
// Main author: Keir Mierle
#include <Eigen/Dense>
Matrix<double, 3, 3> A; // Fixed rows and cols. Same as Matrix3d.
Matrix<double, 3, Dynamic> B; // Fixed rows, dynamic cols.
Matrix<double, Dynamic, Dynamic> C; // Full dynamic. Same as MatrixXd.
Matrix<double, 3, 3, RowMajor> E; // Row major; default is column-major.
Matrix3f P, Q, R; // 3x3 float matrix.
@teeks99
teeks99 / boost.python-quickstart.md
Last active March 15, 2017 15:04
Boost Python Quickstart Example - Getting it working

I wasn't able to get the basic quickstart example for Boost.Python working without some modifications, so I wanted to document it for others.

Here are the various issues I encountered with the default example:

  • The Bjam file (in the root of boost or in the quickstart, i'm not sure) defaults to threading=single, but something else is defaulting to threading=multi, so they are incompatible (shows up as saying the boost_python-vcXXX-mt-gd-1_XX.lib is not found when it just generated boost_python-vcXXX-gd-1_XX.lib). Manually specifying threading=multi for the bjam commands seems to fix things.
  • I wanted to get this going with boost 1.57.0, but there was a change to the boost::build directory structure in 1.56+ that hasn't been reflected in the quickstarts boost-build.jam file, so I reverted back to 1.55.0.
  • Visual Studio 2010 (msvc-10.0) has a bug that keeps it
@Chaser324
Chaser324 / GitHub-Forking.md
Last active May 13, 2024 11:18
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@turnersr
turnersr / rs.py
Created April 29, 2014 04:17
Single-pass, parallel statistics algorithms for mean, variance, and standard deviation
class RunningStat(object):
"""
Based on ideas presented in
1. Numerically Stable, Single-Pass, Parallel Statistics Algorithms - http://www.janinebennett.org/index_files/ParallelStatisticsAlgorithms.pdf
2. Accurately computing running variance - http://www.johndcook.com/standard_deviation.html
"""
def __init__(self):
self.m_n = 0
self.m_oldM = 0
@markjlorenz
markjlorenz / how-to.markdown
Last active March 24, 2022 06:42
Reverse Proxy Tunneling with an amazon EC2. Poor-mans gotomypc, teamviewer, etc.

Reverse Port Tunneling with EC2

Reverse port tunneling is used to give a user outside of a networks firewall accesst to a computer inside the firewall where direct SSH connections aren't allowed. It works by the in-firewall computer SSH'ing to a middleman computer that then forwards incomming SSH connections on a given port to the firewalled computer.

Setup the middleman

  • Get an ubuntu EC2 instance
  • Download it's security keys (both in-firewall and out-firewall computers will need the private key)
  • Setup the security group to allow connections on port 10002
  • SSH into the middleman and add: GatewayPorts yes to /etc/ssh/sshd_config
@kwmsmith
kwmsmith / pairwise_cython.pyx
Last active August 12, 2022 04:25
Numba vs. Cython: Parallel Cython with OMP
#cython:boundscheck=False
#cython:wraparound=False
import numpy as np
from cython.parallel cimport prange
from libc.math cimport sqrt
cdef inline double dotp(int i, int j, int N, double[:, ::1] X) nogil:
cdef:
int k
@fabianp
fabianp / covariance.c
Created April 18, 2011 07:16
numerically stable covariance algorithm
int covariance(int n, int m, double data[], int strides[2], char mode, double matrix[])
/* This algorithm is described in:
* B.P. Welford:
* "Note on a method for calculating corrected sums of squares and products."
* Technometrics 4(3): 419-420 (1962).
* Also see:
* Peter M. Neely:
* "Comparison of several algorithms for computation of means, standard
* deviations and correlation coefficients."
* Communications of the ACM 9(7): 496-499 (1966).