Skip to content

Instantly share code, notes, and snippets.

View larrynung's full-sized avatar

larrynung larrynung

View GitHub Profile
@larrynung
larrynung / latency.txt
Created October 14, 2022 01:58 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@larrynung
larrynung / my.cnf
Created December 19, 2019 06:20 — forked from fevangelou/my.cnf
Optimized my.cnf configuration for MySQL/MariaSQL (on cPanel/WHM servers)
# Optimized my.cnf configuration for MySQL/MariaSQL on cPanel/WHM servers
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# === Updated December 2018 ===
#
# The settings provided below are a starting point for a 2GB - 4GB RAM server with 2-4 CPU cores.
# If you have less or more resources available you should adjust accordingly to save CPU,
# RAM and disk I/O usage.
# The settings marked with a specific comment or the word "UPD" after the value
@larrynung
larrynung / seperate.pl
Created November 18, 2019 07:30 — forked from temmings/seperate.pl
Do "mysqldump --routines" to separate files. (fuzzy)
#!/usr/bin/perl
#
# mysqldump -routines --no-create-info --no-data --no-create-db --compact | perl $0
use strict;
use warnings;
use utf8;
my $output_dir = "out";
@larrynung
larrynung / docker-container-ip.sh
Created August 6, 2019 07:34 — forked from mugifly/docker-container-ip.sh
Simple inspector for Docker container IP address (shell script)
#!/bin/bash
# Simple inspector for Docker container IP address
# https://gist.github.com/mugifly/3bb1c54b48764340eda8
print_help () {
echo -e "USAGE: docker-container-ip.sh KEYWORD\n"
echo "KEYWORD: A keyword string for target container."
echo " e.g. dokku.mysql.foobar"
echo -e "\n[Example usecases]"
echo " Connect to MySQL database in container:"
@larrynung
larrynung / schemaSync.sh
Created July 31, 2019 06:40 — forked from rluisr/schemaSync.sh
Sync MySQL schema. This script doesn't delete table record if tables is exists AND if table doesn't exists, import table without record.
#!/bin/bash -eu
#
# This script can sync MySQL schema without `DROP TABLE`.
# And If table isn't exists, import tables from source.
#
# Finally there is a confirmation screen.
#
# Need these packages: mysql, mysqldump, mysqldiff
# GitHub: @rluisr
using System;
namespace StackExchange.Redis
{
static class RedisKeyspaceNotifications
{
/// <summary>
/// NOTE: For this sample to work, you need to go to the Azure Portal and configure keyspace notifications with "Kxge$" to
/// 1) turn on expiration notifications (x),
/// 2) general command notices (g) and
@larrynung
larrynung / youtube-dl.md
Created December 14, 2018 17:15
Using youtube-dl to download courses from Pluralsight

Download courses from learning sites with youtube-dl

You can download whole courses from an array of tutorial sites with the CLI tool youtube-dl. In the example further down I'm using my Pluralsight account to get videos from a course at their site. Here is a list of all supported sites that you can download from with this tool

The flags you have to supply may vary depending on which site you make a request to.

You can get a free 3 month trial to Pluralsight by signing up for free to Visual Studio Dev Essentials

Installation

@larrynung
larrynung / k8s in 5 minutes
Created November 21, 2018 04:18 — forked from William-Yeh/k8s in 5 minutes
k8s in 5 minutes
1. Install Docker CE and enable Kubernetes:
See Figure 1 and 2 in https://medium.com/slalom-technology/get-kubernetes-running-locally-on-osx-and-windows-b3b5f176b5bb
2. (Optionally) Install k8s dashboard:
```
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
$ kubectl proxy
```
@larrynung
larrynung / tscontract.ts
Created April 3, 2018 07:04 — forked from SoEasy/tscontract.ts
TypeScript contract-based decorators
type MethodDecorator = (target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) =>
TypedPropertyDescriptor | void;
type AssertFn = (...args: Array<any>) => void;
class TSContract {
private static isCustomContractInterruptionCb: boolean = false;
private static contractInterruptionCb(message: string): void {
console.warn(message);