Skip to content

Instantly share code, notes, and snippets.

Anil N aniline

Block or report user

Report or block aniline

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@aniline
aniline / twb64.py
Created Jul 6, 2019
Tripwire style base64 encoding.
View twb64.py
#!/usr/bin/env python3
#
# Tripwire style base64 encoding.
# It makes sense only for 4 byte aligned sequences and is slow.
# See: https://github.com/Tripwire/tripwire-open-source/blob/master/src/fco/signature.cpp#L201
#
# Example usage for MD5 sum of files as appearing in tripwire reports:
#
# md5sum * | python twb64.py
#
View getserial.rs
///
/// Trivial serial read for sensor-y thingies.
/// Sends a new-line to 'trigger' whatever the thingy has to do.
///
/// Needs extern(al) crate termios and getopts (in case it was not obvious).
///
extern crate termios;
extern crate getopts;
use std::env;
@aniline
aniline / nvidia-docker-notes.org
Last active Dec 19, 2018
Nvidia docker runtime setup for CUDA images
View nvidia-docker-notes.org

Manual setup of nvidia-docker

To not use the pre-bundled images or .deb-s.

Runtime

  • Checkout (opencontainers/runc) from hash id’d from nvidia-container-runtime/runtime/runc and the nvidia-container-runtime/runtime/Makefile.
  • Patch (runc) with patch from directory matching the commit hash.
  • Build runc, and cp/rename it to nvidia-container-runtime (needs BSD make: bmake).
  • cp (runc) nvidia-container-runtime /usr/local/bin
@aniline
aniline / timer.py
Created Apr 19, 2018
Notification pop-up timer.
View timer.py
#!/usr/bin/env python
import time
import getopt
import sys
import subprocess
from gi.repository import Notify
def do_notify(message, sleep_s):
@aniline
aniline / ffvers.py
Created Jan 12, 2018
List ESR or quantum
View ffvers.py
#!/usr/bin/env python
#
# List Quantum migrated and non-migrated (ESR) firefox profiles.
# Assumes the preference 'extensions.lastAppVersion' kinda tells firefox version last used with a profile.
# Use at your own risk.
#
import os, sys, re
ff_path=os.environ['HOME']+'/.mozilla/firefox/'
@aniline
aniline / mc_cat.rs
Last active Dec 7, 2017
Multicast 'cat'
View mc_cat.rs
//
// mc_cat <mc group> <port> [<from addr>] | consumer
//
use std::env;
use std::net::{UdpSocket, SocketAddrV4, IpAddr, Ipv4Addr};
use std::str::FromStr;
use std::error::Error;
use std::io::Write;
macro_rules! eprintln(($($arg:tt)*) => { writeln!(&mut std::io::stderr(), $($arg)*).expect("Fail at failing."); } );
@aniline
aniline / tmux.conf
Created Sep 25, 2017
My .tmux.conf
View tmux.conf
set-option -g status on
set -g terminal-overrides 'xterm*:smcup@:rmcup@,rxvt*:smcup@:rmcup@'
# Emacs add prefix as well, keep telnet escape as prefix.
unbind-key C-b
set-option -g prefix C-]
set-option -g prefix2 C-x
# Emacs window management keys
unbind-key -T prefix 1
@aniline
aniline / goog_totp.py
Created Sep 12, 2017
TOTP like Google Authenticator
View goog_totp.py
import hashlib, hmac, base64, struct, time, math
def GoogleTOTP(s):
msg = int(math.floor(time.time()/30))
hm = hmac.new(base64.b32decode(s), struct.pack('>q', msg), hashlib.sha1).digest()
offs = ord(hm[-1]) & 0xF
code = str(((struct.unpack('>L',hm[offs:offs+4])[0]) & 0x7FFFFFFF) % 1000000).zfill(6)
return code
print GoogleTOTP("")
@aniline
aniline / readclip.py
Created Aug 7, 2017
An old script (better here than in Dropbox, dunno what it does).
View readclip.py
#!python
import RPi.GPIO as GPIO
import time
import sys
GPIO.setmode(GPIO.BOARD)
bint = 3
@aniline
aniline / lfsr.py
Created Mar 12, 2017
Some trials with lfsr.
View lfsr.py
#!/usr/bin/env python
import sys, time
id = 1234567890
lfsr = 0xDEADBEEF
def lfsrN(lfsr, count):
#0b10101010101
#0x80000417, 0b10000000 00000000 0000 0100 0001 0111
You can’t perform that action at this time.