Skip to content

Instantly share code, notes, and snippets.

View nnathan's full-sized avatar
💭
shopt -s globstar

Naveen Nathan nnathan

💭
shopt -s globstar
  • Compton
  • 13:36 (UTC +10:00)
View GitHub Profile
@nnathan
nnathan / pingpong.c
Created December 30, 2023 01:25
Ping pong a byte over pipes and measure the exchanges (xv6 1.6 exercise)
#include <unistd.h>
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
size_t n_read;
void handle_alarm(int signum) {
printf("n_read = %lu\n", n_read);
fflush(NULL);
@nnathan
nnathan / kernel.md
Last active November 10, 2023 08:30
Linux Kernel Resources
@nnathan
nnathan / log_memory_usage_example.py
Last active April 20, 2022 02:17
Example of logging memory usage before and after invoking a function in Python using decorators
# Running the script below will yield the following results:
#
# $ ipython log_memory_usage_example.py
# INFO:root:memory use before calling make_large_string : 19,340 kb
# INFO:root:memory use after calling make_large_string : 85,840 kb
#
import functools
import logging
import resource
@nnathan
nnathan / example-ngate.json
Created February 5, 2020 01:06
Sample of n-gate entries as JSON.
[
{
"title": "Amazon Launchpad for Startups",
"titlelink": "https://www.amazon.com/gp/launchpad",
"date": "September 01, 2016",
"hnlink": "http://news.ycombinator.com/item?id=12398823",
"addendums": [],
"context": [],
"text": "Amazon would like to sell your shitty kickstarter products. Hackernews cannot decide if they're concerned enough about this centralization of power to post on medium about how dangerous it is; doing so would take away from the time they need to write android apps and monitor their adsense income and check their gmail accounts to make sure they're not missing a hangout. One-third of them complain that the images on the program website are not huge enough. Others are disgruntled because someone may compete with them."
},
@nnathan
nnathan / .bash_profile
Last active January 22, 2020 18:13
.bash_profile
# always shfmt -i 2 this dealio
# i don't need to see my username
PS1='\h:\W \$ '
# so i can recursive glob to find files e.g. echo src/**/App.java for a java src tree
# only works in bash 4.x and later, while mac still supplies crummy bash 3
if shopt 2>&1 | grep -q globstar; then
shopt -s globstar
fi
@nnathan
nnathan / Pro - bash5.terminal
Created January 15, 2020 10:23
Pro\ -\ bash5.terminal
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlueColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGKyxYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKcHCBMZHSQoVSRudWxs1QkKCwwNDg8QERJcTlNDb21wb25lbnRzVU5TUkdCXE5T
Q29sb3JTcGFjZV8QEk5TQ3VzdG9tQ29sb3JTcGFjZVYkY2xhc3NPEB4wIDAuMDU4ODYw
MTk2MjYgMC42NzY4NjYwOTQ2IDFPEBEwIDAgMC42MTI5OTM2NTc2ABABgAKABtMUFQ0W
@nnathan
nnathan / .gitconfig
Last active November 22, 2019 10:05
.gitconfig
[branch]
autosetupmerge = true
[alias]
co = checkout
ci = commit
st = status
br = branch -a -vvv
brs = branch -a -vvv --sort committerdate
co = checkout
df = diff
@nnathan
nnathan / .mbsyncrc
Created November 19, 2019 01:13
.mbsyncrc
# this config is to facilitate one-way backups from fastmail to local maildir,
# it is specifically set to "Sync Pull" on the IMAP account to ensure
# read-only access.
#
# to run:
#
# brew install isync
# mbsync -a
BufferLimit 1024m
@nnathan
nnathan / .offlineimaprc
Created November 18, 2019 02:25
.offlineimaprc for backing up on MacOS
# to do a one-shot backup:
#
# $ offlineimap -a fastmail
[general]
accounts = fastmail
ui = blinkenlights
[Account fastmail]
@nnathan
nnathan / .nvimrc
Last active November 3, 2019 12:01
" make sure to:
" mkdir -p ~/.config/nvim && echo 'source ~/.nvimrc' >> ~/.config/nvim/init.vim
" also install vim-plug:
" curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
" Then call :PlugInstall
call plug#begin()
Plug 'nnathan/desertrocks'
Plug 'fatih/vim-go', { 'tag': '*' }
" we really need to get rid of this - github.com/nnathan/desertrocks