Skip to content

Instantly share code, notes, and snippets.

View Laeeth's full-sized avatar

Laeeth Isharc Laeeth

View GitHub Profile
@Laeeth
Laeeth / latency.txt
Created October 27, 2015 02:57 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
pure:
nothrow:
// T[] = T[] op T[]
void arrayOp(string op, T)(T[] res, in T[] a, in T[] b)
in
{
assert(res.length == a.length);
assert(res.length == b.length);
}
@s-ludwig
s-ludwig / pipedprocess.d
Created January 15, 2014 10:54
Vibe.d compatible process wrapper class.
class PipedProcess {
import stdfilestream;
private {
ProcessPipes m_pipes;
StdFileStream m_stdout;
StdFileStream m_stdin;
Thread m_waitThread;
SysTime m_startTime;
SysTime m_endTime;
@s-ludwig
s-ludwig / stdfilestream.d
Last active August 2, 2016 18:46
Wrapper class to make an existing `File` stream usable in a vibe.d event loop.
// NOTE: This class is now part of vibe.d, see http://vibed.org/api/vibe.stream.stdio/StdFileStream
@ericpulvino
ericpulvino / dhcp_snooping.sh
Last active June 3, 2019 14:28
Quick Script to Emulate Basic DHCP Trusted Ports / DHCP Snooping / DHCP Filtration
#!/bin/bash
# Root Check
if [ $(whoami) != 'root' ]; then
echo "ERROR: Must be root to run $0"
exit 1;
fi
TRUSTED_PORTS=( swp1 swp3 )
@schveiguy
schveiguy / get_recursive.d
Created February 21, 2020 17:49
Another recursive range possibility, using simple linked-list stack.
import std.range;
struct StackFrame(T)
{
StackFrame* prev;
T range;
}
struct StackRange(T, alias recurse) if (isInputRange!(typeof(recurse(T.init))))
{
@Laeeth
Laeeth / OVERLAYFS
Created April 8, 2021 01:02 — forked from mutability/OVERLAYFS
readonly root via overlayfs
- install the two shellscripts into the appropriate places under /etc/initramfs-tools
- run update-initramfs
- put "overlay=yes" on the kernel command line
- reboot
With the overlay in place, the real root is mounted readonly on /ro.
Only the root fs is changed, other filesystems are mounted normally.
Remove "overlay=yes" (or change it to something other than yes) and reboot to go back to readwrite.
(This probably means that you want the commandline config to live somewhere other than on the root fs, e.g. under /boot)
@jpcy
jpcy / Notes on embedding Mono on Windows.md
Last active October 26, 2022 21:13
Notes on embedding Mono on Windows
@Khady
Khady / config.el
Last active February 27, 2023 12:25
OCaml and Reasonml emacs configuration
(use-package company
:ensure t
:custom
(company-quickhelp-delay 0)
(company-tooltip-align-annotations t)
:hook
((prog-mode utop-mode) . company-mode)
:config
(company-quickhelp-mode 1)
:bind
@rolandcrosby
rolandcrosby / gist:c26571bf4e263f695d2f
Last active March 27, 2023 18:34
Convert rich text on the clipboard to Markdown
if encoded=`osascript -e 'the clipboard as «class HTML»'` 2>/dev/null; then echo $encoded | perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))' | pandoc --no-wrap -f HTML -t markdown; else; pbpaste; fi
# for my .vimrc:
# command PasteMarkdown :read !if encoded=`osascript -e 'the clipboard as «class HTML»'` 2>/dev/null; then echo $encoded | perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))' | pandoc --no-wrap -f HTML -t markdown; else; pbpaste; fi
# nnoremap ,pmd :PasteMarkdown<CR>