Skip to content

Instantly share code, notes, and snippets.

@zertrin
zertrin / cleanup.py
Created January 29, 2015 16:20
Cleaning up when killed (Python recipe)
#!/usr/bin/env python
# From http://code.activestate.com/recipes/533117-cleaning-up-when-killed/
from signal import signal, SIGTERM
from sys import exit
import atexit
def cleanup():
print "Cleanup"
###
#
# Preseed for a Debian based machine on kvm
#
# Boot this file with: press TAB on the installer
# add the following to the boot parameters:
#
# install keymap=en_US locale=en_US netcfg/get_hostname=testserve \
# netcfg/get_domain=carfax.eu preseed/url=http://192.168.XXX.XXX:8000/wheezy.preseed
#
@zertrin
zertrin / datevect_interval.matlab
Created April 29, 2014 11:40
datevect_interval(start_d, end_d, interval_min, incl)
function datevector = datevect_interval(start_d, end_d, interval_min, incl)
% This function creates a vector of dates (in MATLAB datenum format)
% that covers a time interval beginning at 'startdate' and ending at
% 'end_date' (excluded) in intervals of 'interval_min' minutes
%
% Example:
% datevect_interval([2011 1 1 2 0 0], [2011 6 30 2 0 0], 15)
% creates a vector containing all datenums
% from Jan 1st 2011 02:00 to Jun 30th 01:45
% every 15 minutes

Keybase proof

I hereby claim:

  • I am zertrin on github.
  • I am zertrin (https://keybase.io/zertrin) on keybase.
  • I have a public key whose fingerprint is 4846 4D5D B849 5D47 1E83 48FE 5D2C 0DC0 ACF8 1B81

To claim this, I am signing this object:

@zertrin
zertrin / python_resources.md
Created February 21, 2014 13:49 — forked from jookyboi/python_resources.md
Python-related modules and guides.

Packages

  • lxml - Pythonic binding for the C libraries libxml2 and libxslt.
  • boto - Python interface to Amazon Web Services
  • Django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  • Fabric - Library and command-line tool for streamlining the use of SSH for application deployment or systems administration task.
  • PyMongo - Tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.
  • Celery - Task queue to distribute work across threads or machines.
  • pytz - pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher.

Guides

@zertrin
zertrin / 0_reuse_code.js
Created February 21, 2014 13:49
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@zertrin
zertrin / mysqlbackup.sh
Created June 28, 2013 09:27
A script to easily backup mysql databases. Typically for use in a daily cron job.
#!/usr/bin/env bash
DBUSER="mysqlbackup"
DBPASS="password"
DONTBACKUP=( "mysql" "information_schema" "performance_schema" "test" )
BACKUPROOT="/data/mysqlbackup"
DATEFORMAT=`date +%F`
BACKUPDIR="${BACKUPROOT}/${DATEFORMAT}"
@zertrin
zertrin / retrieve-cert.sh
Created June 23, 2013 14:43
A script to retrieve a SSL certificate from a server
#!/bin/sh
#
# A script to retrieve a SSL certificate from a server
# usage: retrieve-cert.sh remote.host.name [port]
#
REMHOST=$1
REMPORT=${2:-443}
echo |\
openssl s_client -connect ${REMHOST}:${REMPORT} 2>&1 |\
@zertrin
zertrin / contact.html
Last active December 18, 2015 13:19
Tout ce qu'il faut pour chiffrer un texte avec OpenPGP côté client en Javascript
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Me contacter</title>
<link rel="stylesheet" media="all" href="css/main.css">
</head>
<body>
<div class="center">
<div class="header block">
@zertrin
zertrin / vimdiff.md
Last active December 17, 2015 18:28 — forked from mattratleph/vimdiff.md

vimdiff cheat sheet

##vimdiff commands

]c :        - next difference
[c :        - previous difference
do          - diff obtain
dp          - diff put
zo          - open folded text

zc - close folded text