Skip to content

Instantly share code, notes, and snippets.

View neilmock's full-sized avatar

Neil Mock neilmock

View GitHub Profile

You can inherit the environment variables from PID 1 by iterating over the list of null-terminated strings in /proc/1/environ, parsing the first characters up to the first = as the variable name, setting the remaining value as that variable, and exporting it.

The Code Snippet

This works with multiline environment variables, and environment variables with arbitrary values, like strings, including = or JSON blobs.

Paste this in your current terminal session to inherit the environment variables from PID 1:

@neilmock
neilmock / python-setup-init.el
Created July 18, 2022 14:35 — forked from Nathan-Furnal/python-setup-init.el
Trimmed down python setup for Emacs. This is a basic `init.el` file for Python, you can pick the bits you like.
;;; init.el --- Fun stuff all around -*- lexical-binding: t; -*-
;;; Commentary:
;; This is a simple init.el which offers a Python configuration. Each package
;; usage is annotated with the how and why of its use. `use-package' is used to
;; manage the configuration as it provides lots of facilities to load modes,
;; define custom variables and key-maps, etc.
;;; Code:
@neilmock
neilmock / tmux-cheatsheet.markdown
Created June 14, 2022 15:42 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@neilmock
neilmock / colorize-emacs.bashsource
Created April 12, 2022 09:44 — forked from algal/colorize-emacs.bashsource
Setting up truecolor (24 bit color) in emacs in the terminal, under iTerm2, blink.sh, and others.
# sourcing this file will define a bash functions that
# tries to run subsequent calls to emacs with 24 bit color.
#
# It sets TERM=xterm-emacs-leg if
# - we've created a user-local terminfo record for xterm-emacs-leg, and
# - we're using iTerm2 or something has set COLORTERM=truecolor
#
# This will cause emacs to use 24 bit color only when it will work,
# inside or outside of tmux. I haven't found a way to auto-detect Blink.sh yet.
#
@neilmock
neilmock / gruvbox_blink_sh.js
Created March 25, 2022 20:46 — forked from jearbear/gruvbox_blink_sh.js
Gruvbox blink.sh theme
@neilmock
neilmock / qemu-networking.md
Created December 30, 2019 20:10 — forked from extremecoders-re/qemu-networking.md
Setting up Qemu with a tap interface

Setting up Qemu with a tap interface

There are two parts to networking within QEMU:

  • The virtual network device that is provided to the guest (e.g. a PCI network card).
  • The network backend that interacts with the emulated NIC (e.g. puts packets onto the host's network).

Example: User mode network

@neilmock
neilmock / sshd.go
Created July 23, 2019 21:33 — forked from jpillora/sshd.go
Go SSH server complete example - Read more here https://blog.gopheracademy.com/go-and-ssh/
// A small SSH daemon providing bash sessions
//
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
//
// Client:
@neilmock
neilmock / PhantomTypeReasonML.md
Created December 21, 2017 17:33 — forked from busypeoples/PhantomTypeReasonML.md
Phantom types in ReasonML

Phantom types in ReasonML

Introduction

"A phantom type is a parametrised type whose parameters do not all appear on the right-hand side of its definition..." Haskell Wiki, PhantomType

The following write-up is intended as an introduction into using phantom types in ReasonML.

Taking a look at the above definition from the Haskell wiki, it states that phantom types are parametrised types where not all parameters appear on the right-hand side. Let's try to see if we can implement a similar example as in said wiki.

let rec merge x y =>
switch (x, y) {
| ([], l) => l
| (l, []) => l
| ([hx, ...tx], [hy, ...ty]) =>
if (hx < hy) {
[hx, ...merge tx [hy, ...ty]]
} else {
[hy, ...merge [hx, ...tx] ty]
}