Skip to content

Instantly share code, notes, and snippets.

def enlever_tags(html):
import subprocess
lynx = subprocess.Popen('/usr/bin/lynx -stdin -dump'.split(), stdin=subprocess.PIPE, stdout=subprocess.PIPE)
lynx.stdin.write(str(html))
(stdout, stderr) = lynx.communicate()
return stdout.strip()
#!/usr/bin/env python
class CallableObject(object):
def __init__(self, val):
self.val = val
def __call__(self):
return self.val
@stesh
stesh / gist:2521025
Created April 28, 2012 18:17
If you make appropriately-named symlinks to the 'mvim' script that comes with MacVim, it will parse their names and execute the thing you want
#!/bin/bash
for i in ex {{r,}{g,m},}vim vimdiff view; do
ln -s $(which mvim) "/usr/local/bin/$i";
done
@stesh
stesh / gist:1685281
Created January 26, 2012 21:41
Le machine à rire.
initial(q0).
terminal(q3).
arc(q0, "h", q1).
arc(q1, "a", q2).
arc(q2, "h", q1).
arc(q2, "!", q3).
aef(S) :-
string_to_list(S, L),
@stesh
stesh / gist:1525428
Created December 27, 2011 23:05
Iterative postorder traversal of a binary tree
S1 = []
S2 = []
S1.push(root)
while S1:
N = S1.pop()
P2.push(N)
if N.left is not None:
#!/bin/bash
exec ssh -t "$1" tmux a -d
system_profiler SPSoftwareDataType | grep 'System Version' | cut -d ':' -f 2 | cut -d '(' -f 1 | sed "s/^.//"
( [ -f /var/run/lighttpd.pid ] && [ $(pgrep lighttpd | head -n 1) = $(head -n 1 /var/run/lighttpd.pid) ] ) || (
/etc/init.d/lighttpd restart
echo \
"To: webmaster@netsoc.tcd.ie
From: root@cubewww.netsoc.tcd.ie
Subject: Automated restart of lighttpd
Attempted automated restart of lighttpd on $(date)
" | sendmail "webmaster@netsoc.tcd.ie"
)
[q for q in[range(90)[x:x+4]for x in range(90-4)]if sum(q)==90].pop()
#include <stdio.h>
int main() {
int n, k;
n = 12345;
while (n >= 1) {
k = n%10;
printf("%d\n", k);
n /= 10;
}