Skip to content

Instantly share code, notes, and snippets.

View elecnix's full-sized avatar

Nicolas Marchildon elecnix

View GitHub Profile
@elecnix
elecnix / paraxmms.c
Created January 10, 2009 03:57
Control XMMS with parallel port
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/kd.h>
#include "parapin.h"
@elecnix
elecnix / postgres_gmetric.sh
Created July 6, 2009 21:16
Publish PostgreSQL metrics to Ganglia
#!/bin/bash
database=$1
if [ "$database" == "" ] ; then
echo "Usage: $0 <database>" > /dev/stderr
exit 1
fi
if [ ! -r /home/darwin/check_postgres/check_postgres.pl ] ; then
exit 1
@elecnix
elecnix / gist:173564
Created August 24, 2009 00:36
time zone per user
class ApplicationController < ActionController::Base
before_filter :restore_time_zone
after_filter :remember_time_zone
protected
def restore_time_zone
Time.zone = cookies[:time_zone] if cookies[:time_zone]
Time.zone = current_user.time_zone if current_user && current_user.time_zone
@elecnix
elecnix / git-croncheck
Created March 4, 2010 03:14
check-repo-status
#!/bin/bash
# Put this in your crontab to be notified when your repo is dirty or commits needs to be pushed to a remote.
# Example crontab:
# MAILTO=user@yourdomain
# 0 * * * Mon-Fri /path/to/check-repo-status /path/to/repo
cd $1
git status | grep 'working directory clean' 2>/dev/null 1>/dev/null || {
git status
git diff
exit
@elecnix
elecnix / gpx-upload.pl
Created June 19, 2010 02:53
"Upload to OpenStreetMap" script for Nautilus
#!/usr/bin/perl -w
# For Gnome users, name this file "Upload to OpenStreetMap", make it executable, and place it
# into your ~/.gnome2/nautilus-scripts/ folder. Then, when you right-click a file, you can go
# to "Scripts", and "Upload to OpenStreetMap". You will be prompted to enter a description for
# the GPX trace, and a visibility.
#
# Based on: http://wiki.openstreetmap.org/wiki/Batch_Upload#Perl
# Converted to Zenity by Nicolas Marchildon (elecnix), June 2010
@elecnix
elecnix / postgresql-relation-size.sql
Created July 6, 2010 21:50
Show largest PostgreSQL tables
SELECT
pg_relation_size(c.oid),
pg_size_pretty(pg_relation_size(c.oid)),
relkind,
relname,
nspname
FROM
pg_class c,
pg_namespace n
WHERE
@elecnix
elecnix / open_mailto.sh
Created September 22, 2010 03:04
set-gmail-as-default-mail-client-in-ubuntu
#!/bin/bash
# To install:
# mkdir ~bin
# Paste this in ~bin/open_mailto.sh
# chmod a+x ~bin/open_mailto.sh
# Go to System \ Preferences \ Preferred Applications
# Under Mail Reader, select Custom, and then put /home/username/bin/open_mailto.sh into the Command window, changing "username" to your username.
# Voilà! Credits to: http://www.howtogeek.com/howto/ubuntu/set-gmail-as-default-mail-client-in-ubuntu/
google-chrome "https://mail.google.com/mail?view=cm&tf=0&to=`echo $1 | sed 's/mailto://'`"
@elecnix
elecnix / mail-history.sh
Created September 29, 2010 02:55
Send by e-mail new entries in the Bash history of all users.
#!/bin/bash
#
# Send by e-mail new entries in the Bash history of all users.
#
# usage: mail-history <email> <subject>
#
TMPFILE=`tempfile 2>/dev/null` || TMPFILE=`mktemp` || exit 1
declare -i CHANGES
CHANGES=0
@elecnix
elecnix / utorrent4linux
Created October 4, 2010 02:37
Open with uTorrent in Nautilus
#!/bin/bash
#
# Make this script executable, then go to a folder with a .torrent file,
# right-click on it, go to Properties, Open With, Add, Select a customized
# application, then browse to the script. Make that the default.
#
# Now, when you right-click on the .torrent, utorrent should be the first choice,
# and double-clicking the file should open it in utorrent.
#
# Note: you should adjust the path to utorrent.exe and the drive letter.
@elecnix
elecnix / calibre-le-devoir.py
Created January 5, 2011 19:08
Calibre recipe for ledevoir.com
__license__ = 'GPL v3'
__author__ = 'Lorenzo Vigentini'
__copyright__ = '2009, Lorenzo Vigentini <l.vigentini at gmail.com>'
__version__ = 'v1.01'
__date__ = '14, January 2010'
__description__ = 'Canadian Paper '
'''
http://www.ledevoir.com/
'''