Skip to content

Instantly share code, notes, and snippets.

@procinger
procinger / ping-test
Created October 6, 2022 08:32
GNU/Linux simple MTU Ping Test
ping 1.1.1.1 -c 1 -M do -s $((1500-28))
@t-lo
t-lo / flatcar-on-firecracker.sh
Created November 9, 2021 10:59
Script to set up Flatcar to run on firecracker. Run in an empty directory to download all components, then run ./start-flatcar.sh to run Flatcar on Firecracker.
#!/bin/bash
set -eu
function get_firecracker() {
rm -f firecracker-v0.24.6-x86_64.tgz firectl-v0.1.0
rm -rf release-*/*
wget https://github.com/firecracker-microvm/firecracker/releases/download/v0.24.6/firecracker-v0.24.6-x86_64.tgz
wget https://firectl-release.s3.amazonaws.com/firectl-v0.1.0
use std::{
fs::File,
io::{Read, Write},
time::Instant,
};
use tokio::task::{self, JoinHandle};
async fn compute() {
let handles: Vec<JoinHandle<_>> = (0..1000)
.map(|_| {
@karlkfi
karlkfi / bash2asciicast.sh
Last active February 2, 2021 07:36
bash2asciicast.sh - Convert a bash script into an asciicast recording
#!/usr/bin/env bash
# Convert a bash script into an asciicast recording
set -o errexit -o nounset -o pipefail
USER=karl
WORKDIR="~/workspace"
PROMPT="\u001b]0;Cloud Shell\u0007${USER}@cloudshell:\u001b[1;34m${WORKDIR}\u001b[00m$ \u001bkcloudshell\u001b\\\\"
@mowings
mowings / kubeadm.md
Last active December 29, 2019 21:50
Example kubeadm config file

Since there's no (or not many) real examples of valid kubeadm config files out there (for use with kubeadm --config <file>), here is an example. This version declares a control plane endpoint, the proxy for an HA setup, and also includes a KubeProxyConfiguation to tell kube-proxy to use ipvs.

You can leave off the controlPlaneEndpoint (which points to the HA proxy ip:port) if you are not running in HA mode, and you can omit the KubeProxyConfiguration if you are satisfied with using the default of iptables for the proxy mode.

To initalize an HA setup using this file with kubeadm, you can execute:

@jimmychu0807
jimmychu0807 / string-conversion.rs
Created November 21, 2019 10:20
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte
@harrysarson
harrysarson / effect-managers.md
Last active March 3, 2020 09:23
Effect managers in elm

The best guide on event managers in elm

Not because this guide is any good, but because it is the only one. This is (to the best of my knowledge) correct as of version 19.0 of the elm compiler and version 1.0.2 of elm/core.

Types of event managed things in elm

  1. Cmds
  2. Port Cmds (I believe these to be fundamentally different from normal Cmds).
  3. Subs.
@magopian
magopian / gist:297d20e95b49daf3ad934e36b1855e82
Created November 28, 2018 16:56
elm decoder very helpful to debug decoders used in event handlers (thanks @JoelQ on the elm slack)
module Main exposing (main)
import Html exposing (Html, text)
import Json.Decode as Decode exposing (Decoder)
loggingDecoder : Decoder a -> Decoder a
loggingDecoder realDecoder =
Decode.value
|> Decode.andThen
@procinger
procinger / shell_exec.c
Last active June 18, 2023 00:27
GNU/Linux x86_64 Hello World Shellcode
/*
* Shellcode executer
* gcc -fno-stack-protector -z execstack shell.c -o shell
*/
char shellcode[] = "\xeb\x20\x48\x31\xc0\x48\x31\xff\x48\x31\xf6\x48\x31\xd2\xb0\x01\x40\xb7\x01\x5e\xb2\x0c\x0f\x05\x48\x31\xc0\xb0\x3c\x40\xb7\x00\x0f\x05\xe8\xdb\xff\xff\xff\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64\x21";
int main(int argc, char **argv)
{
int (*exeshell)();
@lizrice
lizrice / Vagrantfile
Last active February 3, 2023 02:21
Vagrant file for setting up a single-node Kubernetes cluster that I can access from my desktop. Read more: https://medium.com/@lizrice/kubernetes-in-vagrant-with-kubeadm-21979ded6c63
# -*- mode: ruby -*-
# vi: set ft=ruby :
# This script to install Kubernetes will get executed after we have provisioned the box
$script = <<-SCRIPT
# Install kubernetes
apt-get update && apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list