Skip to content

Instantly share code, notes, and snippets.

@trickster
trickster / net_lab_broadcast_domains.sh
Last active March 26, 2026 14:43 — forked from iximiuz/net_lab_broadcast_domains.sh
A bunch of helper functions to create Linux bridges, network namespaces, and interconnect everything using veth pairs.
#!/usr/bin/env bash
set -xeuo pipefail
create_bridge() {
local nsname="$1"
local ifname="$2"
echo "Creating bridge ${nsname}/${ifname}"
@Jatapiaro
Jatapiaro / qemu_ubuntu.md
Last active September 19, 2026 17:05
How to install QEMU on OSX and install an Ubuntu VM

Install QEMU on OSX

QEMU requires brew in OSX, so we need to install brew first.

Installing Brew

To install brew we need to have the developer tools enabled in our system. In order to install those tools, we have two options.

  1. Download Xcode form the AppStore
  2. In your terminal run the following command: xcode-select --install
@wybiral
wybiral / sri-profile.go
Created May 7, 2019 20:46
Experiment to get average time of SRI hash calculation from visiting browsers
package main
import (
"crypto/sha512"
"encoding/base64"
"fmt"
"log"
"math/rand"
"net/http"
"strings"
@wybiral
wybiral / noscript-tracking.go
Last active October 28, 2024 23:01
Tracking cursor position in real-time with remote monitoring (without JavaScript)
// Tracking cursor position in real-time without JavaScript
// Demo: https://twitter.com/davywtf/status/1124146339259002881
package main
import (
"fmt"
"net/http"
"strings"
)
@peerreynders
peerreynders / pushbutton.ex
Created January 3, 2019 20:53
Erlang gen_statem module documentation "handle_event_function" callback mode example "translated" to Elixir
# file: pushbutton.ex
# Translated from: http://erlang.org/doc/man/gen_statem.html#example
# callback mode: :handle_event_function
# i.e. one callback function handle_event/4 for all states
#
defmodule Pushbutton do
@behaviour :gen_statem
# The registered server name
defp name(),
@BitPatty
BitPatty / WinError.cs
Created April 27, 2018 08:23
Enum containing all the system error codes from https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx (Not including ERROR_INTERNET_* 0x2E00 - 0x2EE0)
public enum Win32Error : uint
{
/// <summary>The operation completed successfully.</summary>
ERROR_SUCCESS = 0x0,
/// <summary>Incorrect function.</summary>
ERROR_INVALID_FUNCTION = 0x1,
/// <summary>The system cannot find the file specified.</summary>
ERROR_FILE_NOT_FOUND = 0x2,
@nicklockwood
nicklockwood / StringsTest.swift
Last active May 4, 2021 04:47
string concat benchmarks
import XCTest
let count = 50000
class StringsTestTests: XCTestCase {
// MARK: Copying
func testInterpolation() {
var foo = ""
@smoser
smoser / .gitignore
Last active April 1, 2024 07:38
cloud-init ubuntu nocloud example with network config
*.img
*.raw
@ptsurbeleu
ptsurbeleu / cloud-config.yml
Last active September 1, 2017 17:33
Hand-crafted cloud-config.yml to co-locate Kontena Master & The Only Initial Node on the same Packet server
#cloud-config
write_files:
- path: /etc/kontena-server.env
permissions: 0600
owner: root
content: |
KONTENA_VERSION=latest
KONTENA_VAULT_KEY=ghV5TK5yl4zsfJlW4sWuhdPMc1ngLFAOzDYJwTSnjQpK096VWwDcTD5BKrV0ZyNZ
KONTENA_VAULT_IV=usPWA6tbnzdt0sjZI0eYFVaqZgk4pgQqOlPxrpGkOJcv9yHTRhpMW5N3ugKp7wHe
KONTENA_INITIAL_ADMIN_CODE=CoreOS999
@whatyouhide
whatyouhide / testing_defps.ex
Created January 7, 2016 22:26
Testing private functions in Elixir
defmodule TestDefp do
defmacro __using__(_) do
quote do
import Kernel, except: [defp: 2]
end
end
# Let's redefine `defp/2` so that if MIX_ENV is `test`, the function will be
# defined with `def/2` instead of `defp/2`.
defmacro defp(fun, body) do