Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import sys, datetime
import requests
from StringIO import StringIO
from lxml.html import parse
import PyRSS2Gen
PAGE = 'http://www.dailysabah.com/columns/dogan-eskinat/archive'
# XPath queries
@gnufs
gnufs / cockburn.py
Last active August 29, 2015 13:57
Scrapes Patrick Cockburn's articles on Independent.co.uk and generates an RSS feed
#!/usr/bin/env python
import requests
from StringIO import StringIO
from lxml.html import parse
import datetime
import PyRSS2Gen
PAGE = 'http://www.independent.co.uk/biography/patrick-cockburn'
# XPath queries
@gnufs
gnufs / webscraper.py
Created March 31, 2012 21:22
A rudimentary web scraper
import sys, requests
from bs4 import BeautifulSoup
def scrape(url='http://example.com'):
try:
html = requests.get(url).content
except:
print "URL doesn\'t load"
exit()
page = BeautifulSoup(html)
#!/usr/bin/expect
# Login to SSH with password automatically
# Requires expect:
# sudo apt-get install expect
set timeout 60
set login $argv
spawn ssh $login
#!/bin/bash
while read line
do
/data/exssh.sh "$line"
done < hostnames.txt
#!/usr/bin/expect
# Login to SSH with password automatically
# Requires expect:
# sudo apt-get install expect
set timeout 60
spawn ssh gnufs@nsa.gov
while {1} {
@gnufs
gnufs / libo-git.sh
Created April 4, 2011 05:43
Clone and update all LibreOffice repositories
#!/bin/bash
# Clone and update LibreOffice repositories
# Browse repos at http://cgit.freedesktop.org/libreoffice
Repo=('artwork' 'base' 'bootstrap' 'build' 'calc' 'components' 'contrib/buildbot' 'contrib/dev-tools' 'contrib/dumper' 'contrib/ooeclipse' 'contrib/svn-to-git' 'contrib/test-files' 'extensions' 'extras' 'filters' 'help' 'impress' 'l10n' 'libs-core' 'libs-extern-sys' 'libs-extern' 'libs-gui' 'postprocess' 'sdk' 'testing' 'translations' 'ugly' 'ure' 'writer');
for (( i = 0; i < ${#Repo[@]}; i++ ))
do
echo "cloning ${Repo[i]}"
git clone git://anongit.freedesktop.org/libreoffice/${Repo[i]}
@gnufs
gnufs / chat.js
Created March 29, 2011 19:12
basic multi-user chat on nodejs
net = require('net');
var sockets = []; //connected people
// net.createServer == net.Server
var s = net.Server(function(socket) {
sockets.push(socket);
socket.on('data', function(d) {
for (var i = 0; i < sockets.length; i++){
@gnufs
gnufs / gist:708907
Created November 21, 2010 17:08
pointer fun
#include <stdio.h>
/* pointer fun */
main() {
int x = 81;
int y;
printf("The adress of x is %p\n", &x);
printf("The value of x is %d\n", *&x);
printf("The address of y is %p\n", &y);
printf("The value of y is %d\n", *&y);