Skip to content

Instantly share code, notes, and snippets.

@mcastelino
mcastelino / iptables-cheatsheet.md
Last active May 2, 2024 21:27
iptables-cheatsheet

The netfilter hooks in the kernel and where they hook in the packet flow

The figure below calls out

  • The netfilter hooks
  • The order of table traversal
@bschapendonk
bschapendonk / CreateValidateJWT.cs
Last active October 22, 2023 08:01
How to create and validate a JWT using System.IdentityModel.Tokens.Jwt
using System;
using System.IdentityModel.Tokens;
using System.Security.Claims;
using System.Security.Cryptography;
namespace CreateValidateJWT
{
class Program
{
static void Main(string[] args)
@JonCole
JonCole / Redis-BestPractices-General.md
Last active April 27, 2024 12:50
Redis Best Practices

Some of the Redis best practices content has moved

This content from this markdown file has moved a new, happier home where it can serve more people. Please check it out : https://docs.microsoft.com/azure/azure-cache-for-redis/cache-best-practices.

NOTE: Client specific guidance listed below is still valid and should still be considered. I will update this document once all content has been moved.

@ianblenke
ianblenke / .ebextensions_00_tune_ec2.config_.yaml
Created July 23, 2015 19:12
Tuning EC2 with an ElasticBeanstalk ebextension
packages:
yum:
wget: []
curl: []
commands:
00_remove_99_swap.conf.bak:
command: rm -f /etc/sysctl.d/99_swap.conf.bak
test: test -f /etc/sysctl.d/99_swap.conf.bak
ignoreErrors: true
00_remove_99_filesystem.conf.bak:
@adamveld12
adamveld12 / MersennePrimeRandom.cs
Last active March 15, 2022 01:27
Mersenne prime random number generator in C#
/// <summary>
/// Implementation of Mersenne Twister random number generator
/// </summary>
public class MersennePrimeRandom
{
private readonly uint[] _matrix = new uint[624];
private int _index = 0;
public MersennePrimeRandom() : this((uint)(0xFFFFFFFF & DateTime.Now.Ticks)) { }

Create an AMI using Packer

What is Packer?

Packer is a tool from Hashicorp that allows you to create machine images in a variety of formats from a single spec file. This can be a very powerful thing when you want to automate the deployment of applications to a variety (or even just more than one, really) platforms.

In our case, we want to deploy an application to VMware and AWS, and soon to Docker. Doing that with a single spec file gives us

  • platforms that are consistent, even if they're different
ruby doctor.rb
/usr/bin/ruby1.8 (1.8.6)
OpenSSL 0.9.8g 19 Oct 2007: /usr/lib/ssl
SSL_CERT_DIR=""
SSL_CERT_FILE=""
HEAD https://status.github.com:443
OpenSSL::SSL::SSLError: certificate verify failed
The server presented a certificate that could not be verified:
@markhuge
markhuge / README.md
Last active March 25, 2016 12:57
Fix failing node deployments on AWS Elastic Beanstalk

Fix failing node deployments on AWS Elastic Beanstalk

Elastic beanstalk runs npm install with a system user that has no homedir. During the npm install step, it's expecting a $HOME env variable for the npm cache (which doesn't exist). add this file to your project's .ebextensions directory to have it use root's homedir as a temporary path.

This workaround was provided by AWS support, but it doesn't appear to be documented anywhere. Determining root cause on this was a massive pain in the ass. Sharing this so others don't need to feel the pain.

package main
import (
"io"
"net"
"os"
"fmt"
"strings"
"syscall"
"unsafe"