Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View skinp's full-sized avatar

Patrick Pelletier skinp

View GitHub Profile
@skinp
skinp / .Xresources
Created January 16, 2012 00:54
.Xdefaults or .Xresources - config for yeahconsole
yeahconsole*toggleKey: Alt+t
yeahconsole*consoleHeight: 30
yeahconsole*aniDelay: 1
yeahconsole*restart: 1
yeahconsole*background: black
yeahconsole*foreground: white
"yeahconsole*font: -*-fixed-medium-r-*-*-15-*-*-*-*-*-iso8859-*
xterm*background: black
xterm*foreground: white
@skinp
skinp / readfile.c
Created January 16, 2012 01:06
Reads a file and prints content to stdout. Uses a dynamic buffer. Is not meant to be used...
/*
* readfile
*
* Patrick Pelletier (pp.pelletier@gmail.com) - July 2010
*
* Program that reads a file and outputs it's content to stdout.
*
* Uses a dynamic buffer to store the content temporarly.
* It makes a good example of how to allocate a dynamic char buffer.
* Was written as an exercice while bored with no internet connection @Recon 2010
@skinp
skinp / .screenrc
Last active September 29, 2015 14:57
My basic config file for screen
startup_message off
nethack on
defscrollback 5000
shell -/bin/bash
#termcapinfo xterm* 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l'
hardstatus alwayslastline
hardstatus string '%{= kG}%{g}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][ %{B}%Y-%m-%d %{W}%c %{g}]'
@skinp
skinp / ajax.js
Created February 28, 2012 17:33
Basic Ajax...
function ajax(url) {
try {
xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
// browser doesn't support ajax. handle however you want
}
xmlhttp.onreadystatechange = triggered;
xmlhttp.open("GET", url);
@skinp
skinp / compound_interest.awk
Created March 30, 2012 15:15
Compound interest in awk
#!/bin/awk
# Input: "Initial_cash interest_rate number_of_years yearly_deposit"
{
initial_amount = $1
interest_rate = $2
number_of_years = $3
yearly_deposit = $4
total = initial_amount
current_year = 1
@skinp
skinp / run.py
Created March 30, 2012 15:23
Run a command in python
#!/usr/bin/env python
import subprocess
import sys
def run(command):
if not command:
raise Exception("Commande vide")
else:
print command
p = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@skinp
skinp / ajax.js
Created June 15, 2012 17:57
Ajax function call
function ajax(url, callback) {
var x = new XMLHttpRequest();
x.onreadystatechange = function(){
if (x.readyState == 4) {
callback(x.responseText);
}
};
x.open("GET", url);
x.send();
}
@skinp
skinp / timing.py
Created June 18, 2012 14:19
Context manager to time python code...
from timeit import default_timer
class Timer(object):
def __init__(self, verbose=False):
self.verbose = verbose
self.timer = default_timer
def __enter__(self):
self.start = self.timer()
@skinp
skinp / git-env-setup.sh
Created September 25, 2012 18:54
Setup git environment
#!/bin/bash
if [ $# -ne 2 ]
then
echo "Usage: $0 <name> <email>"
exit 1
fi
git config --global user.name $1
git config --global user.email $2
@skinp
skinp / google.py
Created November 2, 2012 20:38
Google reader star list
#!/usr/bin/env python
import urllib
import urllib2
import getpass
from xml.dom import minidom
class Grua:
def __init__(self, username, password):