Skip to content

Instantly share code, notes, and snippets.

@Jatapiaro
Jatapiaro / qemu_ubuntu.md
Last active June 18, 2024 18:31
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 September 11, 2023 08:53
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"
)
@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
@ptsurbeleu
ptsurbeleu / example.cs
Created October 6, 2015 18:31
How to decode JWT token
// NOTE: For that code to work, you need install System.IdentityModel.Tokens.Jwt package from NuGet (the link includes the latest stable version)
// Link: https://www.nuget.org/packages/System.IdentityModel.Tokens.Jwt/4.0.2.206221351
using System.IdentityModel.Tokens;
// a sample jwt encoded token string which is supposed to be extracted from 'Authorization' HTTP header in your Web Api controller
var tokenString = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1uQ19WWmNBVGZNNXBPWWlKSE1iYTlnb0VLWSJ9.eyJhdWQiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDAiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC8wMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDAiLCJpYXQiOiIxNDI4MDM2NTM5IiwibmJmIjoiMTQyODAzNjUzOSIsImV4cCI6IjE0MjgwNDA0MzkiLCJ2ZXIiOiIxLjAiLCJ0aWQiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDAiLCJhbXIiOiJwd2QiLCJvaWQiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDAiLCJlbWFpbCI6Impkb2VAbGl2ZS5jb20iLCJwdWlkIjoiSm9obiBEb2UiLCJpZHAiOiJsaXZlLmNvbSIsImFsdHNlY2lkIjoiMTpsaXZlLmNvbTowMDAwMDAwMDAwMDAwMDAw
@noonat
noonat / coreos-virtualbox.md
Last active February 10, 2023 22:00
Installing CoreOS on VirtualBox
  • Download and install VirtualBox.
  • Download the CoreOS ISO
  • Create a new VM in VirtualBox
    • For the OS, Other Linux, 64-bit should be fine
    • Give the VM 1gb of memory, like your physical hardware has.
    • Create a disk of whatever size you want. I made a VMDK file that could expand dynamically up to 8gb.
  • Mount the ISO in the VM
    • Right click on the VM and click settings
  • Go to the storage tab
require 'rubygems'
require 'excon'
def download_file(url, source_path = nil)
error = nil
if source_path.nil?
source_path = File.join("/tmp", "output")
end