Skip to content

Instantly share code, notes, and snippets.

Avatar
😏

Steve Kamerman kamermans

😏
View GitHub Profile
@kamermans
kamermans / package_esp32_index.json
Created Nov 15, 2020
FireBeetle-ESP32 Boards Package
View package_esp32_index.json
{
"packages": [
{
"maintainer": "DFRobot DFRDuino",
"help": {
"online": "http://esp32.com"
},
"websiteURL": "https://github.com/espressif/esp32-arduino",
"platforms": [
{
@kamermans
kamermans / test.vcl
Created Jul 13, 2020
Nested Varnish directors errors
View test.vcl
vcl 4.0;
import directors;
backend alpha { .host = "192.168.0.101"; }
backend bravo { .host = "192.168.0.102"; }
sub vcl_init {
new primary_director = directors.random();
primary_director.add_backend(alpha, 1.0);
@kamermans
kamermans / 2020-04-28-list.txt
Last active Apr 29, 2020
AWS EC2 Instances Costs by CPU-month (find the most cheapest CPU power instances)
View 2020-04-28-list.txt
c5.metal: $31.03 per CPU per month (96 vCPUs, 192.0 GiB RAM)
c5.24xlarge: $31.03 per CPU per month (96 vCPUs, 192.0 GiB RAM)
c5.18xlarge: $31.03 per CPU per month (72 vCPUs, 144.0 GiB RAM)
c5.12xlarge: $31.03 per CPU per month (48 vCPUs, 96.0 GiB RAM)
c5.9xlarge: $31.03 per CPU per month (36 vCPUs, 72.0 GiB RAM)
c5.4xlarge: $31.03 per CPU per month (16 vCPUs, 32.0 GiB RAM)
c5.2xlarge: $31.03 per CPU per month (8 vCPUs, 16.0 GiB RAM)
c5.xlarge: $31.03 per CPU per month (4 vCPUs, 8.0 GiB RAM)
c5.large: $31.03 per CPU per month (2 vCPUs, 4.0 GiB RAM)
m5a.16xlarge: $31.39 per CPU per month (64 vCPUs, 256.0 GiB RAM)
@kamermans
kamermans / 2020-03-15-report.txt
Last active Mar 16, 2020
COVID-19 Confirmed Cases by US County (from John's Hopkins Dataset)
View 2020-03-15-report.txt
# COVID-19 by US County
Arizona (13):
Maricopa: 2
Pinal: 2
[unknown]: 9
California (426):
Alameda: 2
Contra Costa: 9
Fresno: 1
@kamermans
kamermans / kill_orphaned_pagent.cmd
Created Mar 4, 2020
Fixes the dreaded "Pageant is already running" error by killing the conflicting gpg-agent that prevents PuTTY Pageant from starting.
View kill_orphaned_pagent.cmd
@ECHO OFF
ECHO Killing orphaned pagaent instances...
taskkill /IM "gpg-agent.exe" /F
PAUSE
@kamermans
kamermans / mockedS3Client.go
Created Feb 25, 2020
Thread-Safe AWS S3 Mock for Golang (works with GetObject, PutObject, DeleteObject, HeadBucket)
View mockedS3Client.go
package something
import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"net/url"
"path"
"sync"
@kamermans
kamermans / main.go
Last active Feb 8, 2020
Compute date palindromes efficiently
View main.go
package main
import (
"fmt"
"os"
"sort"
"sync"
"time"
)
@kamermans
kamermans / hash_benchmark.php
Created Oct 21, 2018
Compute the performance of every hashing function in PHP
View hash_benchmark.php
<?php
$loops = 100000;
$str = "whois foobar";
$algos = hash_algos();
$algo_padding = array_reduce($algos, function($carry, $val) {
$len = strlen($val);
if ($len > $carry) {
$carry = $len;
}
@kamermans
kamermans / fix_quotes.sh
Last active Sep 9, 2020
Replace fancy-quotes / curly-quotes / smart-quotes with standard ASCII single- and double-quotes in bash
View fix_quotes.sh
#!/bin/bash
# Replaces annoying "fancy" quotes created by programs like Microsoft Word and everything in MacOS
# with normal ASCII single-quotes (') or double-quotes (")
# This script does NOT replace the GRAVE ACCENT (`) since it is commonly used in Markdown and as a bash command
# See: https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html
SINGLE=$(echo -ne '\u00B4\u2018\u2019')
DOUBLE=$(echo -ne '\u201C\u201D')
sed -i "s/[$SINGLE]/'/g; s/[$DOUBLE]/\"/g" $1
@kamermans
kamermans / parse_elb_logs.php
Created May 4, 2018
AWS ELB Log Parsing Regex in PHP
View parse_elb_logs.php
<?php
// Cat your ELB logs into this script
$elb_regex = '#^(?<date>.+?) (?<elb>.+?) (?<client_ip>[\d\.]+):(?<client_port>\d+) (?<backend_ip>[\d\.]+):(?<backend_port>\d+) (?<request_processing_time>[\d\.]+) (?<backend_processing_time>[\d\.]+) (?<response_processing_time>[\d\.]+) (?<elb_status_code>\d+) (?<backend_status_code>\d+) (?<received_bytes>\d+) (?<sent_bytes>\d+) "(?<method>[A-Z]+) (?<https>https?)://(?<http_host>.+?):(?<port>\d+)(?<uri>/.*?) (?<protocol>HTTP/[\d\.]+)" "(?<http_user_agent>.+?)" (?<ssl_cipher>.+?) (?<ssl_protocol>.+?)$#';
while ($line = fgets(STDIN)) {
if (!preg_match($elb_regex, $line, $data)) {
continue;
}
You can’t perform that action at this time.