Skip to content

Instantly share code, notes, and snippets.

@clipperhouse
clipperhouse / medium2md.go
Last active April 29, 2019 18:23
A Go script to convert Medium export (HTML) to Markdown, for use with Hugo. It’s a one-use type of thing for me, so it ain’t beautiful.
// A quick script for converting Medium HTML files to Markdown, suitable for use in a static file generator such as Hugo or Jekyll
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"regexp"
self: super:
let
# Import unstable channel.
# $ sudo nix-channel --add http://nixos.org/channels/nixpkgs-unstable nixpkgs-unstable
# $ sudo nix-channel --update nixpkgs-unstable
unstable = import <nixpkgs-unstable> {};
in
{
@ladinu
ladinu / encryptedNixos.md
Last active April 8, 2025 13:48
NixOS install with encrypted /boot /root with single password unlock

Requirements

  1. Encrypt everthing including /boot and /root
  2. Enter password once
  3. Support UEFI

Installation media setup

Download NixOS minimal iso and copy to USB stick. For example on Mac OSX

$ diskutil list
$ diskutil unmountDisk /dev/disk1 # Make sure you got right device
@enricofoltran
enricofoltran / main.go
Last active April 6, 2025 09:48
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
@ErikAugust
ErikAugust / spectre.c
Last active January 5, 2025 07:01
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@gaieges
gaieges / subtree.sh
Created April 5, 2017 21:57
easier way to use subtrees
#!/bin/bash
set -e
REPOS="$(cat $(dirname $0)/.subtree)"
usage() {
echo "usage: $(basename $0) <command>"
echo "commands are: "
echo " init sets up all remotes and subtrees locally"
@kennwhite
kennwhite / https.go
Last active December 24, 2023 22:06
Simple https http/2 static web server with HSTS & CSP (A+ SSLLabs & securityheaders.io rating) in Go using LetsEncrypt acme autocert
package main
import (
"crypto/tls"
"golang.org/x/crypto/acme/autocert"
"log"
"net"
"net/http"
)
@Brainiarc7
Brainiarc7 / skylake-tuning-linux.md
Last active February 21, 2025 01:29
This gist will show you how to tune your Intel-based Skylake, Kabylake and beyond Integrated Graphics Core for performance and reliability through GuC and HuC firmware usage on Linux.

Tuning Intel Skylake and beyond for optimal performance and feature level support on Linux:

Note that on Skylake, Kabylake (and the now cancelled "Broxton") SKUs, functionality such as power saving, GPU scheduling and HDMI audio have been moved onto binary-only firmware, and as such, the GuC and the HuC blobs must be loaded at run-time to access this functionality.

Enabling GuC and HuC on Skylake and above requires a few extra parameters be passed to the kernel before boot.

Instructions provided for both Fedora and Ubuntu (including Debian):

Note that the firmware for these GPUs is often packaged by your distributor, and as such, you can confirm the firmware blob's availability by running:

@jamesnvc
jamesnvc / things.sh
Created January 27, 2017 17:14
Shell script template to only act on "clean" git repos
#!/bin/bash
set -euo pipefail
set +e
if ! git diff-files --quiet --ignore-submodules ; then
echo "Uncommited changes; stash or commit before deploying"
exit 1
fi
if ! git diff-index --cached --quiet HEAD --ignore-submodules ; then
@jbenet
jbenet / gist:8f000606f2009495c56177f6ca2c19b7
Last active February 13, 2023 02:29
some notes on ideas

When people come up with ideas, they often assume that:

  • coming up with an idea is the same thing as coming up with an idea first (it isn't, read existing literature)
  • coming up with an idea first is dramatically more special than coming up with an idea (it isn't)
  • the wealth of existing literature does not include their idea (almost always it does)
  • unpublished ideas do not count (they do, lots of important discoveries happen verbally, and unfortunately sometimes only verbally :( )
  • coming up with it first is more important than fleshing out a body of work (it isn't)

And these assumptions tend to make people very unhappy. I repeatedly see people succumbing to sadness over multiple discovery. It shouldn't be sad, it should be a happy event, as it confirms our thoughts and presents an opportunity for collaborations.