Skip to content

Instantly share code, notes, and snippets.

@paulyc
paulyc / cross-compile-arm.sh
Created November 26, 2018 01:20 — forked from joshmh/cross-compile-arm.sh
Cross compile to ARM
# New ARM processors
# This is for newer Ubuntus
export AR=arm-linux-gnueabihf-ar
export CC=arm-linux-gnueabihf-gcc
export CXX=arm-linux-gnueabihf-g++
export LINK=arm-linux-gnueabihf-g++
./configure --without-snapshot --dest-cpu=arm --dest-os=linux
make
make install DESTDIR=~/node-armhf/
@paulyc
paulyc / machine-diskutil.sh
Created December 5, 2018 09:21 — forked from cristobal/machine-diskutil.sh
Machine Diskutil to mount/unmont external volumes inside docker machines running on Virtualbox
#!/usr/bin/env sh
# @see http://stackoverflow.com/questions/30040708/how-to-mount-local-volumes-in-docker-machine
# @see https://github.com/boot2docker/boot2docker/blob/master/doc/FAQ.md
################################################################################
# Dependency Section #
# #
################################################################################
check_deps() {
## Make sure commands are available

Keybase proof

I hereby claim:

  • I am paulyc on github.
  • I am paulyc (https://keybase.io/paulyc) on keybase.
  • I have a public key whose fingerprint is 8D5F 36F6 17E8 B9B3 E4E0 E517 D4E0 5A5C 5412 7D08

To claim this, I am signing this object:

@paulyc
paulyc / utf16dumbestthingever.txt
Created February 12, 2019 13:54
UTF-16 = Dumbest Thing Ever
UTF-16 is the dumbest thing ever. It's the kind of thing only a committee could love.
All strings should be stored as UTF-8.
Supposedly UTF-16 encodes all characters as 2 bytes, so that unlike UTF-8, a string can be
easily indexed without having to read the whole string.
Except for those pesky extended/astral plane characters. Which you can't possibly hope to
avoid, especially considering that EMOJI are astral plane characters, requiring FOUR BYTES
to store in UTF-16. OR IN UTF-8! So you still have to parse the whole string to find a character
index due to those pesky surrogage pairs. Advantage nullified.
@paulyc
paulyc / hostapd.conf
Created March 8, 2019 17:47 — forked from noahwilliamsson/hostapd.conf
WPA-EAP (Enterprise) configuration for hostapd
interface=wlan0
# --------------------------------------
bss=wlan1
ssid=EAP
# IEEE 802.11 specifies two authentication algorithms. hostapd can be
# configured to allow both of these or only one. Open system authentication
# should be used with IEEE 802.1X.
# Bit fields of allowed authentication algorithms:
# bit 0 = Open System Authentication
all: alfa.pdf
alfa.pdf: alfa.latex
latexmk -pdf $<
alfa.png: alfa.pdf
convert -density 150 -flatten $< $@
clean: alfa.latex
latexmk -CA $<
@paulyc
paulyc / full-disk-encryption-arch-uefi.md
Created May 25, 2019 15:25 — forked from huntrar/full-disk-encryption-arch-uefi.md
Arch Linux Full-Disk Encryption Installation Guide [Encrypted Boot, UEFI, NVMe, Evil Maid]

Arch Linux Full-Disk Encryption Installation Guide

This guide provides instructions for an Arch Linux installation featuring full-disk encryption via LVM on LUKS and an encrypted boot partition (GRUB) for UEFI systems.

Following the main installation are further instructions to harden against Evil Maid attacks via UEFI Secure Boot custom key enrollment and self-signed kernel and bootloader.

Preface

You will find most of this information pulled from the Arch Wiki and other resources linked thereof.

Note: The system was installed on an NVMe SSD, substitute /dev/nvme0nX with /dev/sdX or your device as needed.

@paulyc
paulyc / journalctl_enable_persistent_storage.md
Created June 4, 2019 12:00 — forked from JPvRiel/journalctl_enable_persistent_storage.md
Enable persistent storage for the systemd journal log

Enable persistent storage for the systemd journal log

Overview

The assumed default setting in /etc/systemd/journald.conf is Storage=auto which implies that systemd journaling will only persist the journal if the expected storage location is available. Otherwise, the journal data is stored in memory and lost between reboots. On Ubuntu 16.04, /var/log/journal does not exist by default. Create it to keep and query events from previous boots.

Considerations:

  • Syslog still provides the persistant log records for Ubuntu 16.04, so enabling persistant systemd journal logging does cause a level of duplicaiton.
  • There are sane defaults:
@paulyc
paulyc / single_p_multi_c_buffer.c
Created June 7, 2019 17:15 — forked from s8sg/single_p_multi_c_buffer.c
A blazing fast single producer multiple consumer lockless queue
/* NOTE: The design decision of the req pool is tuned to get the
* best possible performance. Below point describes
* the design decisions:
* >> reqpool is a buffer queue where the producer adds at the start
* and consumers consume from the end
* >> it is strictly one consumer and multiple producers queue
* >> It is unbounded queue and avoids any resource allocation on heap
* >> It is lockless and use atomic operation to avoid race condition
* for consumers
*/
@paulyc
paulyc / moonobject.js
Created June 17, 2019 01:28 — forked from L-A/moonobject.js
Moon phase calculation
var MoonInfo = function(day, month, year) {
var n0 = parseInt( "0" );
var f0 = parseFloat( "0.0" );
var AG = f0; // Moon's age
var DI = f0; // Moon's distance in earth radii
var LA = f0; // Moon's ecliptic latitude
var LO = f0; // Moon's ecliptic longitude
var Phase = " ";
var Zodiac = " ";