Skip to content

Instantly share code, notes, and snippets.

View skinp's full-sized avatar

Patrick Pelletier skinp

View GitHub Profile
@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 / .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 / 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 / tailf.py
Created March 30, 2012 15:24
Tail -f implementation in python
import time
def tailf(filename):
f = open(filename, 'r')
f.seek(0,2)
while True:
line = f.readline()
if not line:
time.sleep(0.1)
continue
@skinp
skinp / shell.py
Created March 30, 2012 16:49
Basic web shell in python
#!/usr/bin/env python
import cgi
import subprocess
import cgitb
cgitb.enable()
def run(command):
if not command:
@skinp
skinp / genpass.py
Created May 8, 2012 13:53
Simple python password generator
#!/usr/bin/env python
# genpass.py
# Random password generation
# author: Patrick Pelletier
import md5
import random
def genpass(len=20):
''' generates a random password based on the md5 of a random float '''
@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();
}