Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
int main(int argc, char* argv[])
{
int s;
@mpontillo
mpontillo / linecount.c
Created December 29, 2012 09:44
Simple line count program using POSIX file APIs.
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
void count_lines(char* filename)
{
int fd;
int s;
# modified backtrace function (uses core file) courtesy of:
# http://blog.cryptomilk.org/2010/12/23/gdb-backtrace-to-file/
bt()
{
echo 0 | \
gdb -batch-silent \
-ex "core-file core" \
-ex "set logging overwrite on" \
-ex "set logging file gdb.bt" \
-ex "set logging on" \
@mpontillo
mpontillo / encfs-agent
Last active August 29, 2015 14:06 — forked from mprymek/encfs-agent
#! /usr/bin/env python2
"""
encfs-agent
Mounts encfs filesystems with passwords generated using private keys stored in ssh-agent.
You can have any number of encrypted filesystems ("vaults") under VAULTS_DIR. Password for
each of them is derived from its name and given private key stored in ssh-agent.
You can use ssh-askpass for ssh-agent if you want.
export PS1='\[\e]0;\u@\h: \w\a\]${prompt_context:+($prompt_context)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\n\$ '
@mpontillo
mpontillo / osx-proxy-settings.sh
Created April 2, 2015 19:26
Print all proxy settings on OS X
#!/bin/bash
function print_proxy_settings() {
echo "$@"
networksetup -getwebproxy "$@"
echo ""
}
export -f print_proxy_settings
@mpontillo
mpontillo / gist:8087f57b81288b3e0d3f
Created April 7, 2015 22:34
Almost complete (missing uefi) Ubuntu trusty apt-mirror configuration
deb-amd64 http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
deb-amd64 http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
deb-amd64 http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
deb-amd64 http://archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse
deb-amd64 http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse
deb-i386 http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
deb-i386 http://archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
deb-i386 http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
deb-i386 http://archive.ubuntu.com/ubuntu trusty-proposed main restricted universe multiverse
@mpontillo
mpontillo / review.sh
Created July 29, 2015 23:53
bzr branch review script
#!/bin/bash
function get_branch {
echo $1 | cut -f 3 -d '/'
}
function die {
echo "$@"
exit 1
}
# This is a startup script for IPython. It adds a "line magic" helper that
# makes it very easy to run a Twisted reactor in a separate thread.
#
# This script has been tested in Python 2 and Python 3.
#
# Author: Mike Pontillo <pontillo@gmail.com>
#
# INSTRUCTIONS
# ============
# Place this file in: ~/.ipython/profile_default/startup/reactor.py
# -*- coding: utf-8 -*-
# IPython startup script version of Gr1N's asyncio-ipython-magic.
# To use, place this file in: ~/.ipython/profile_default/startup
import ast as _ast
import asyncio as _asyncio
from IPython.core.magic import Magics, magics_class, cell_magic