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
  • 22:47 (UTC +11:00)
View GitHub Profile
@nnathan
nnathan / k-and-r-1.24.c
Created October 30, 2019 06:47
freenode ##c caze K&R C exercise 1.24 example from https://ideone.com/94U6aJ
#include <stdio.h>
#include <stdlib.h>
typedef void effector(int);
typedef struct transition transition;
struct transition {
int state;
effector *effect;
};
@nnathan
nnathan / transition.c
Created October 30, 2019 06:39
caze transition table from https://ideone.com/DdKmwq
#include <stdio.h>
#include <stdlib.h>
typedef void effector(int);
typedef struct transition transition;
struct transition {
int state;
effector *effect;
};
@nnathan
nnathan / check.sh
Last active October 26, 2019 22:19
Go repository build script.
#!/usr/bin/env bash
set -e
if [ -t 1 ]
then
CYAN='\033[0;36m'
YELLOW='\033[0;33m'
GREEN='\033[0;32m'
RED='\033[0;31m'
@nnathan
nnathan / burncd.md
Created June 10, 2019 01:24
idea for audio cd burning gui on mac

Audio CD Burning for Mac

When it comes to burning audio CDs on a mac (since at least 10.9) there's really only two options: iTunes or using cdrdao.

iTunes has a very simple GUI and it makes it pretty easy to burn but instead of doing DAO (Disc-At-Once) burning it does TAO (Track-At-Once) which is extremely tempremental and results in more coasters than good burns. It may do DAO for CD-TEXT cds but even then I get a burn success rate of 10%.

cdrdao on the other hand does DAO and is incredibly reliable.

it would be nice to write an open source public domain native mac program that bundles cdrdao and LAME and provides a small GUI that implements the Audio CD burning interface provided by iTunes.

@nnathan
nnathan / Pro.terminal
Created June 5, 2019 11:05
Terminal.app profile
<?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 / urandompoll.c
Last active May 27, 2019 16:53
example poll program
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/poll.h>
#define TIMEOUT 5
int main (void)
@nnathan
nnathan / urandom.patch
Last active May 27, 2019 21:49
patch for /dev/urandom to block on cold start when random.urandom_can_block=y in kernel cmdline
From ad8f2da2749e24ca038ea7d4bd96ce61df937ee1 Mon Sep 17 00:00:00 2001
From: Naveen Nathan <[email protected]>
Date: Mon, 27 May 2019 10:05:01 +0000
Subject: [PATCH] random: urandom reads block when CRNG is not initialized.
Adds a compile-time option to ensure urandom reads block until
the cryptographic random number generator (CRNG) is initialized.
This fixes a long standing security issue, the so called boot-time
entropy hole, where systems (particularly headless and embededd)
# imap
## .muttrc_auth should contain the following
## set folder = "imaps://mail.messagingengine.com/"
## set imap_user = "[email protected]"
## set imap_pass = "hunter2"
source ~/.muttrc_auth
set imap_idle = yes
set spoolfile = "+INBOX" # specifies default mailbox
set postponed = "+INBOX/Drafts" # stores a copy of message until its sent (draft)
@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 / r.c
Last active January 8, 2019 01:17
regex alternation is not commutative
/* turns out this is wrong, the regex "quic | noise" contains spaces you need to consider */
/*
* $ ./r
* "quic | noise" matches "high pitched noise coming from car"
* $ ./r s
* "noise | quic" matches "a quick fix"
* "noise | quic" matches "high pitched noise coming from car"
*/
#include <stdio.h>