Skip to content

Instantly share code, notes, and snippets.

@miguelmota
miguelmota / notes.txt
Last active April 18, 2024 19:25
arch linux arch-chroot fix /boot initramfs (ie failed update/upgrade)
1. install usb stick with arch linux
2. boot from usb
3. run `fdisk -l` to find partition with linux installation (ie /dev/sda3 Linux Filesystem)
4. mount partition: `mount /dev/sda3 /mnt`
5. arch chroot into it: `arch-chroot /mnt`
6. rebuild initramfs: `mkinitcpio -p linux` (if that doesn't work yes try `pacman -S linux` only)
7. shutdown, unplug usb, reboot
@miguelmota
miguelmota / notes.txt
Last active April 14, 2024 08:26
runc vs gvisor (runsc) vs rkt vs KataContainers vs NablaContainers
knowledge dump on container runtimes
KataContainers
- image coupled with kernel
- light vm layer
- can run in nested virturalization environments if hardware supports and you can enable it in bios (ex. only bare metal EC2 instances, limits many cloud providers)
- slower startup time
- OCI compliant
- previously known as ClearContainers by Intel
@miguelmota
miguelmota / 30-touchpad.conf
Created February 29, 2020 02:44
Arch linux enable tap to click on touchpad
Section "InputClass"
Identifier "touchpad"
Driver "libinput"
MatchIsTouchpad "on"
Option "Tapping" "on"
Option "TappingButtonMap" "lmr"
EndSection
@miguelmota
miguelmota / server.go
Last active April 12, 2024 23:13
Golang TCP server example
package server
import (
"bufio"
"fmt"
"log"
"net"
)
// Server ...
@miguelmota
miguelmota / buffer.js
Created August 24, 2014 18:33
Node.js Buffer to ArrayBuffer
// @credit: http://stackoverflow.com/questions/8609289/convert-a-binary-nodejs-buffer-to-javascript-arraybuffer
// From Buffer to ArrayBuffer:
function toArrayBuffer(buffer) {
var ab = new ArrayBuffer(buffer.length);
var view = new Uint8Array(ab);
for (var i = 0; i < buffer.length; ++i) {
view[i] = buffer[i];
}
@miguelmota
miguelmota / rss_urls.txt
Last active April 5, 2024 20:57
Cryptocurrency news RSS feeds
https://thedefiant.io/feed/
https://www.coindesk.com/arc/outboundfeeds/rss/?outputType=xml
https://cointelegraph.com/rss
https://cryptopotato.com/feed/
https://cryptoslate.com/feed/
https://cryptonews.com/news/feed/
https://smartliquidity.info/feed/
https://finance.yahoo.com/news/rssindex
https://www.cnbc.com/id/10000664/device/rss/rss.html
https://time.com/nextadvisor/feed/
@miguelmota
miguelmota / uint8_to_hex.cpp
Last active April 5, 2024 12:07
C++ uint8_t to hex string
#include <sstream>
#include <iostream>
#include <iomanip>
std::string uint8_to_hex_string(const uint8_t *v, const size_t s) {
std::stringstream ss;
ss << std::hex << std::setfill('0');
for (int i = 0; i < s; i++) {
@miguelmota
miguelmota / remove_tuxera.sh
Last active April 3, 2024 08:41
Completely uninstall and remove Tuxera NTFS on MacOS (resets trial version)
sudo rm -rf /Applications/Tuxera\ Disk\ Manager.app
sudo rm -rf /Library/Application\ Support/Tuxera\ NTFS
sudo rm -rf /Library/Filesystems/fusefs_txantfs.fs
@miguelmota
miguelmota / ip.go
Last active March 31, 2024 22:42
Golang get IP address from web HTTP request handler
package main
import (
"errors"
"log"
"net"
"net/http"
"strings"
)
@miguelmota
miguelmota / userhome.go
Last active March 31, 2024 19:42
Golang expand user home path
// UserHomeDir ...
func UserHomeDir() string {
if runtime.GOOS == "windows" {
home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH")
if home == "" {
home = os.Getenv("USERPROFILE")
}
return home
} else if runtime.GOOS == "linux" {
home := os.Getenv("XDG_CONFIG_HOME")