Skip to content

Instantly share code, notes, and snippets.

Happy Hacking

Naja Melan najamelan

Happy Hacking
View GitHub Profile
najamelan / light.scss
Created Mar 9, 2019
Initial work in porting the rustdoc light theme to scss
View light.scss
$block-bg: #f5f5f5;
$color-stab-internal-bg: #ffb9b3;
$nav-separater-border: #000;
$stab-unstable-bg: #fff5d6;
$stab-deprecated-bg: #f3dfff;
$stab-portability-bg: #c4ecff;
$theme-picker-bg: #fff;
$kdb-box-shadow: #c6cbd1;
$pre-ignore-border-left: rgba(255, 142, 0, .4);
$pre-ignore-border-left-hover: #ff9200;
najamelan /
Last active Oct 22, 2019
Configure physical network cards to be in their own network namespace

Keeping physical network cards in a dedicated namespace could be a way to control which processes can access the network. For non privileged processes in the main namespace, it would seem that the only network card in the machine is the loopback device. WARNING: Personally I haven't managed to connect to wifi this way. The idea comes from this post, but hacked upon until it works.

Create an udev rule to move any new non-virtual interface to a new namespace as soon as it's plugged in:

# /etc/udev/rules.d/99-physical-netns.rules

SUBSYSTEM=="net", ACTION=="add", DEVPATH!="/devices/virtual/*",TAG+="systemd", ENV{SYSTEMD_WANTS}="physical-namespace@$id.service"

This will call the systemd service with the ID of the network device:

najamelan / rumprun build.log
Created Jan 4, 2018
The build log about me failing to compile rust to rumprun
View rumprun build.log
cargo build --target=x86_64-rumprun-netbsd
Compiling hello-tcp v0.1.0 (file:///home/user/code/unikernels/rumprun-packages/rust/examples/hello-tcp)
error: linking with `x86_64-rumprun-netbsd-gcc` failed: exit code: 1
= note: "x86_64-rumprun-netbsd-gcc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/usr/share/dev-template/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-rumprun-netbsd/lib" "/home/user/code/unikernels/rumprun-packages/rust/examples/hello-tcp/target/x86_64-rumprun-netbsd/debug/deps/hello_tcp-f74073b02c05897c.__rustc_fallback_codegen_unit.rcgu.o" "/home/user/code/unikernels/rumprun-packages/rust/examples/hello-tcp/target/x86_64-rumprun-netbsd/debug/deps/hello_tcp-f74073b02c05897c.alloc-allocator.rcgu.o" "/home/user/code/unikernels/rumprun-packages/rust/examples/hello-tcp/target/x86_64-rumprun-netbsd/debug/deps/hello_tcp-f74073b02c05897c.alloc-allocator.volatile.rcgu.o" "/home/user/code/unikernels/rumprun-packages/rust/examples/hello-tcp/target/x86_64-
najamelan / gist:3561e46039ca5b91be357f97fbe6739c
Created Jul 8, 2017 — forked from bds/gist:7837545
Offline Ruby Core and Stdlib Documentation with Yard
View gist:3561e46039ca5b91be357f97fbe6739c
$ gem install yard
$ wget
$ tar xzvf ruby-2.0.0-p247.tar.gz
$ cd ruby-2.0.0-p247
$ yardoc *.c
$ yardoc -b .yardoc-stdlib -o doc-stdlib
$ yard server -m ruby-core2.0 .yardoc stdlib .yardoc-stdlib
View ruby_splat.rb
# ------------------------------------------------------Method Definition-----------------------------------------------------
puts "\n---Method Definition---\n"
def say(what, *people)
people.each { |person| puts "#{person}: #{what}" }
say "Hello!", "Alice", "Bob", "Carl"
najamelan /
Last active Dec 28, 2020
Gnome Desktop Entry Format extensions - bootlegged documentation

Gnome Desktop Entry Format extensions - bootlegged documentation

Note: if you work on desktop entry files, you should refresh them to see the results: Alt-F2 and run 'r' or 'restart' to restart gnome-shell. Otherwise changes might only work after you log out.

The desktop entry specification creates a standard for application launchers. Gnome adds several extensions to the format which are widely in use, but as far as I can tell undocumented. This is an attempt to document them so I can write my own autostart launchers for gnome. Pull requests are highly welcome.

There is a guide on gnome developer that explains basics about how to integrate an application with the desktop.

Autostart applications run when the user logs into the graphical desktop environment. All desktop managers make custom extensions to the format. This attempts just to cover the Gnome extensions, and won'

View Escape.php
Correct output escaping in php is ridiculously difficult. This class does not pretend to be perfect, but is an attempt for myself to do better than scattering htmlspecialchars all over my code.
This is basically a wrapper around basic functionality like htmlspecialchars. For better security, inspired on code from Twig, who inspired themselves on Zend who inspired themselves on ESAPI. Security notice: all of the above fail to escape the comma in javascript context. This class doesn't and it also provides you with a wrapper around HTML purifier.
This comment has some bits and bops of text to make the point. References:

Keybase proof

I hereby claim:

  • I am najamelan on github.
  • I am najamelan ( on keybase.
  • I have a public key whose fingerprint is 8076 5DA9 0DA5 CF68 2FC9 2BCD FB4A 4EEE EE1D 2A89

To claim this, I am signing this object:

najamelan / gist:902ebacc761d1ae22b1f
Created Apr 29, 2014
najamelanꗈautisticiꗈorg ⴱ Public PGP Key
View gist:902ebacc761d1ae22b1f
# This is a short collection of tools that are useful for managing your
# known_hosts file. In this case, I'm using the '-f' flag to specify the
# global known_hosts file because I'll be adding many deploy users on this
# system. Simply omit the -f flag to operate on ~/.ssh/known_hosts
# Add entry for host
ssh-keyscan -H > /etc/ssh/ssh_known_hosts
# Scan known hosts
ssh-keygen -f /etc/ssh/ssh_known_hosts -H -F