Skip to content

Instantly share code, notes, and snippets.

@mathieulegrand
mathieulegrand / hetzner_nixos_luks.md
Created December 2, 2024 12:51 — forked from alicebob/hetzner_nixos_luks.md
nixos 24.05 with full disk encryption on Hetzner cloud

Setup full disk encryption on a Hetzner cloud CX42 machine. No fancy SSH unlock: you have to go to their web based terminal to enter the disk password on boot.

Notes:

  • Their web based terminal is /weird/. You can paste things, but it looks like it's set up for a german keyboard, and many characters change ("http://" into "http;//"), sometimes it converts everything to lowercase after a while, sometimes it enters some capslocks mode. I ended up typing as much as possible by hand, and only use alphanumeric passphrases so there are no surprises when copy-pasting those.
  • The (qemu) virtual machine doesn't use EFI, but Legacy Boot. Most setup instructions I found are for EFI systems.

there we go

  • In the Hetzner UI click the server in the list, go to tab [ISO Images], search for "nix", and mount "NixOS 24.05 (x86_64/minimal)"
  • Reboot, and open the terminal. (the's a button on the top with [>_], which is a shortcut for the terminal)
@mathieulegrand
mathieulegrand / FCPrivateBatteryStatus.m
Created January 30, 2016 03:01
How to get raw battery info (mAh remaining, etc.) from iOS using private APIs. For internal testing only, NOT APP STORE DISTRIBUTION!
#import <Foundation/Foundation.h>
#include <dlfcn.h>
NSDictionary *FCPrivateBatteryStatus()
{
static mach_port_t *s_kIOMasterPortDefault;
static kern_return_t (*s_IORegistryEntryCreateCFProperties)(mach_port_t entry, CFMutableDictionaryRef *properties, CFAllocatorRef allocator, UInt32 options);
static mach_port_t (*s_IOServiceGetMatchingService)(mach_port_t masterPort, CFDictionaryRef matching CF_RELEASES_ARGUMENT);
static CFMutableDictionaryRef (*s_IOServiceMatching)(const char *name);
@mathieulegrand
mathieulegrand / fsa.py
Last active August 29, 2015 14:11 — forked from danielpunkass/fsa.py
"""
Automate loading of F-Script Anywhere into any app.
By Daniel Jalkut - @danielpunkass - http://indiestack.com/
To set up:
0. Make sure you have FScript.framework installed in /Library/Frameworks (http://www.fscript.org)
1. Copy this script to ~/.lldb/fsa.py
2. Add the following to your ~/.lldbinit file:
@mathieulegrand
mathieulegrand / area_code.rb
Created July 3, 2011 13:55 — forked from mager/area_code.rb
Get area code from IP address using SimpleGeo Places & Ruby
SimpleGeo::Client.set_credentials(ENV['SIMPLEGEO_KEY'],ENV['SIMPLEGEO_SECRET'])
resp = SimpleGeo::Client.geocode_from_ip()
options = {:num=>1}
place = SimpleGeo::Client.get_places(resp[:query][:latitude], resp[:query][:longitude], options)
phone = place[:features][0][:properties][:phone]
@area_code = phone[3..-10] # Phone number format: "+1 XXX XXX-XXXX"