Skip to content

Instantly share code, notes, and snippets.

@kingreza
kingreza / PokerEngine.swift
Last active December 27, 2024 22:51
A simple poker engine that deals cards and detects various hands.
//
// main.swift
// PokerTest
//
// Created by Reza Shirazian on 11/8/19.
// Copyright © 2019 Reza Shirazian. All rights reserved.
//
import Foundation
@jboner
jboner / latency.txt
Last active December 27, 2024 22:50
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
@dcchambers
dcchambers / md2pdf.md
Last active December 27, 2024 22:47
Generate a PDF from Markdown files with Pandoc

Generate a PDF from a Markdown file with Pandoc

Easy Steps For Mac OS

  1. Have Homebrew installed and a markdown file you want to render to PDF.
  2. Install Pandoc brew install pandoc
  3. Install basictex brew cask install basictex - needed for the pdflatex tool.
  4. Symlink the pdflatex to your /usr/local/bin so pandoc can easily find it. ln -s /Library/TeX/Root/bin/x86_64-darwin/pdflatex /usr/local/bin/pdflatex
  5. Use Pandoc to generate a PDF from a Markdown file. pandoc input.md -o output.pdf
  • By default the margins are pretty large. To optionally change the margins: pandoc input.md -o output.pdf -V geometry:margin=1in
@peppergrayxyz
peppergrayxyz / qemu-vulkan-virtio.md
Last active December 27, 2024 22:44
QEMU with VirtIO GPU Vulkan Support

QEMU with VirtIO GPU Vulkan Support

With its latest reales qemu added the Venus patches so that virtio-gpu now support venus encapsulation for vulkan. This is one more piece to the puzzle towards full Vulkan support.

An outdated blog post on clollabora described in 2021 how to enable 3D acceleration of Vulkan applications in QEMU through the Venus experimental Vulkan driver for VirtIO-GPU with a local development environment. Following up on the outdated write up, this is how its done today.

Definitions

Let's start with the brief description of the projects mentioned in the post & extend them:

@truemogician
truemogician / upgrading_postgresql_in_windows.md
Last active December 27, 2024 22:38
Upgrading PostgreSQL in Windows

Upgrading PostgreSQL in Windows

The official documentation for PostgreSQL provides a guide to upgrading using pg_upgrade. However, it can be a bit like a treasure hunt with hidden traps. This gist will walk you through a clear and robust method for upgrading PostgreSQL on Windows, using the upgrade from version 14 to 16 as an example.

1. Install the New Version of PostgreSQL

Before you embark on the upgrade journey, make sure you have the new version installed. This is because the pg_upgrade utility used during the upgrade process belongs to the newer version.

To get started, visit the official download page, download the installer, and run it. A word of caution: do not overwrite the old installation, as you'll need its binaries and data for the upgrade.

// routes1.go
func Routes1(mux *http.ServeMux) {
mux.Handle("/route1/a", handler1A)
mux.Handle("/route1/b", handler1B)
mux.Handle("/route1/c", handler1C)
}
// routes2.go
func Routes2(mux *http.ServeMux) {
mux.Handle("/route2/x", handler2X)
@dot-mike
dot-mike / README.md
Last active December 27, 2024 22:34
Inital setup script for Ubuntu server

Inital Ubuntu setup script

This script is meant to be run on a fresh Ubuntu LTS installation.

@kmjones1979
kmjones1979 / nginx.conf
Last active December 27, 2024 22:33
This is an example NGINX configuration for the blog: Performing A/B Testing with NGINX - This demonstrates split_clients based routing on an argument named token
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events { worker_connections 1024; }
http {
default_type text/html;
log_format main '$remote_addr -> $request $status $body_bytes_sent bytes -> $upstream_addr';
access_log /var/log/nginx/access.log main;
@6220119
6220119 / outbound-email-with-cloudflare.md
Created November 13, 2023 05:36 — forked from irazasyed/outbound-email-with-cloudflare.md
Using Gmail SMTP with Cloudflare Email Routing: A Step-by-Step Guide

Using Gmail SMTP with Cloudflare Email Routing: Step-by-Step Guide

Learn how to send emails through Gmail SMTP with Cloudflare Email Routing in this comprehensive guide.

Step 1: Enable 2-Factor Authentication

To proceed with this method, ensure that you have enabled two-factor authentication for your Google account. If you haven't done so already, you can follow the link to set it up → Enable 2FA in your Google account.

Step 2: Create an App Password for Mail

@masklinn
masklinn / cheatsheet.md
Last active December 27, 2024 22:22
launchctl/launchd cheat sheet

I've never had great understanding of launchctl but the deprecation of the old commands with launchctl 2 (10.10) has been terrible as all resources only cover the old commands, and documentation for Apple utilities is generally disgracefully bad, with launchctl not dissembling.

Mad props to https://babodee.wordpress.com/2016/04/09/launchctl-2-0-syntax/ which contains most details

domains

Internally, launchd has several domains, but launchctl 1 would only ask for service names,