Instantly share code, notes, and snippets.

View ssh_vpn.md

SSH VPN

Here's an example of setting up a basic point to point VPN using SSH tunnels.

First you need a server in the cloud that isn't behind a NAT.

Ensure that the host and server has port 22 open and is running sshd.

If you're using AWS, make sure to check your security groups.

View population_variance_stddev_sample_variance_stddev.md

Population Variance/Stddev vs Sample Variance/Stddev

According to: http://vortex.ihrc.fiu.edu/MET4570/members/Lectures/Lect05/m10divideby_nminus1.pdf the reason why we use n - 1 is because that ensures that the average of all sample variances of every combination of sample (with replacement) of a population is equal to the population variance!

import random
import numpy as np

def calculate_variance(population):
View combinations.py
import math
# getting combinations of choices is the same as getting the "binomial coefficient"
# a "binomial coefficient" is the coefficient of the x^k term in the
# "polynomial expansion" of the "binomial power"
# a binomial is a polynomial with is the sum of 2 monomials
# ax^m - bx^n
# the a and b are coefficients
# the m and n are distinct non-negative integers
View multi_input_multi_output_unix_processes.md

Multi-input and Multi-output Unix Processes

When writing a multi-input and/or multi-output process. Use this style:

process --foo=foo --bar=bar --output-foo=output_foo --output-bar=output_bar

To represent STDIN or STDOUT you can optionally use -.

View stress_testing_tools.md

Stress Testing Tools

  • iperf - For network bandwidth
  • owamp - For one-way latency
  • fio - For filesystem testing
  • stress-ng - For memory testing, CPU testing
  • dnsperf - Testing DNS
  • tc from iproute2 - For simulating network behaviours
  • tsung - Distributed Application Protocol Load Generator
  • ostinato - Packet Generator
View nixos_recovery.md

NixOS Recovery

Usually if you screw up the configuration.nix you can rollback to a previous generation during boot.

Then you use https://nixos.org/nixos/manual/#sec-rollback to fix the rollback generation.

However if you really screw it up, and none of the generations work, you may need use a recovery method.

Get a NixOS ISO (it's best to get one that has a same or similar version as your current one).

View convolution_correlation_deep_learning.md

Convolution and Correlation in Deep Learning, Tensorflow and Theano

Convolution used in deep learning frameworks is not the standard matrix multiplication, nor is it the hadamard product.

Convolution in deep learning works by applying a kernel (a small matrix) to a larger input matrix. You slide this kernel on the input matrix from the top left to the bottom right. You perform element-wise multiplication on each slide (where the sliding distance is the stride length), then you sum all the multplications into a single number. This number is then put in the output matrix.

Strictly speaking, convolution requires the kernel to be flipped horizontally and vertically (transposed).

View nix_checkphase_calling_project_scripts.md

Nix checkPhase calling project scripts

When using checkPhase and calling scripts in your project, you may need to run patchShebangs bin prior.

This is because your scripts don't have their shebangs patched, so they may be trying to call /usr/bin/env bash. And this path does not exist inside the Nix build environment.

View pulseaudio_profiles.md

Pulseaudio Profiles

Pulseaudio provides many profiles for audio devices.

The main device you're likely to have is Built-in Audio.

This device should have its profile set to Analog Stereo Duplex most of the time.

Assuming you have a laptop, the built-in microphone will be an analog microphone.

View 20111011_SteveYeggeGooglePlatformRant.md

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real