Skip to content

Instantly share code, notes, and snippets.

@bokwoon95
bokwoon95 / deref.go
Last active November 4, 2022 23:11
Go Generics type signature for ensuring argument is a pointer
// https://go.dev/play/p/BT-OUMK5Rtp
package main
import (
"fmt"
)
// Deref will dereference a generic pointer.
// It will fail at compile time if pt is not a pointer.
comment_char %
escape_char /
% This file is part of the GNU C Library and contains locale data.
% The Free Software Foundation does not claim any copyright interest
% in the locale data contained in this file. The foregoing does not
% affect the license of the GNU C Library as a whole. It does not
% exempt you from the conditions of the license if your use would
% otherwise be governed by that license.
@outofambit
outofambit / screen-to-gif.sh
Last active February 12, 2022 09:19
convert screen recording to animated gif
ffmpeg -i screen.mov -pix_fmt rgb8 -r 8 -vf scale=-1:640 my-gif.gif
@jaredru
jaredru / consistentHash.js
Created July 20, 2018 04:47
JavaScript Consistent Hash
function makeLinearCongruentialGenerator(seed) {
const m = Math.pow(2, 31) - 1;
const a = 16807;
const c = 0;
let z = seed;
return function lcg() {
z = (a * z + c) % m;
return z / m;
}
@nadavrot
nadavrot / Matrix.md
Last active April 2, 2024 06:45
Efficient matrix multiplication

High-Performance Matrix Multiplication

This is a short post that explains how to write a high-performance matrix multiplication program on modern processors. In this tutorial I will use a single core of the Skylake-client CPU with AVX2, but the principles in this post also apply to other processors with different instruction sets (such as AVX512).

Intro

Matrix multiplication is a mathematical operation that defines the product of

@asukakenji
asukakenji / 0-go-os-arch.md
Last active April 24, 2024 06:51
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.17.1 darwin/amd64.

GOOS Values

GOOS Out of the Box
aix
android
@cathalgarvey
cathalgarvey / jlgz_dump.go
Created April 5, 2017 12:09
How to Read Lines from GZIP-Compressed Files in Go
package main
import (
"compress/gzip"
"os"
"bufio"
"fmt"
"log"
)
@samrocketman
samrocketman / libimobiledevice_ifuse_Ubuntu.md
Last active January 11, 2024 22:47
On Ubuntu 16.04, since iOS 10 update, libimobiledevice can't connect to my iPhone. This is my attempt to document a fix.

Why this document?

I upgraded my iPhone 5s to iOS 10 and could no longer retrieve photos from it. This was unacceptable for me so I worked at achieving retrieving my photos. This document is my story (on Ubuntu 16.04).

The solution is to compile libimobiledevice and ifuse from source.

Audience

Who is this guide intended for?

@tcbyrd
tcbyrd / README.md
Created September 22, 2016 21:09
Route53 CNAME Update

AWS CLI command to update CNAME

When you have a set of application servers running in EC2 in an active/passive configuration, the easiest way to failover is to simply update the DNS to point to the second server as soon as it's available to serve requests. If you are using Route 53 to manage your DNS configuration, with the AWS CLI you can make this change in a single command.

Initial Setup

The CLI expects the change to be submitted via a JSON-formatted configuration file. I've inclu

@r0l1
r0l1 / copy.go
Last active March 23, 2024 12:38
Copy a directory tree (preserving permissions) in Go.
/* MIT License
*
* Copyright (c) 2017 Roland Singer [roland.singer@desertbit.com]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: