Skip to content

Instantly share code, notes, and snippets.

@rjp
rjp / Bufferme.py
Created May 13, 2014 08:26
Bufferme
# -*- coding: utf-8 -*-
#!/usr/bin/env python
# Coded poorly by Brett Kelly
# http://nerdgap.com
# @inkedmn
# -*- coding: utf-8 -*-
import urllib2
import urllib
require 'rubygems'
require 'hpricot'
require 'open-uri'
url = ARGV[0]
doc = Hpricot(open(url))
a = []
doc.search('//p').each { |para|
if para.inner_text =~ /^\s*-/ then
rjp> unset b;b[0]=m;b[1]=o;b[2]=o
for i in $(seq 0 25); do
a=$(echo ${b[*]} | tr -d ' ')
z=$(lynx -nolist -dump "http://www.google.co.uk/search?q=$a&ie=utf-8&oe=utf-8" | sed -ne 's/Results .* of about \([^ ]*\) .*$/\1/p' | tr -d ',')
echo $((i+2)) $z
b[${#b[*]}]=o
sleep 1
done > plotpoints.csv
rjp> ploticus -png -o ~/public_html/mooo.png -prefab lines x=1 y=2 ylog=log data=plotpoints.csv delim=space pointsym=none linedet="color=skyblue width=0.5" xlbl="number of Os" ylbl="hits in the google"
# make a heatmap legend for ploticus scatterplot heatmaps
# using colors.png as a palette, first pixel of each line
# > echo png2html > /tmp/.png.$$
# > png2html colors.png /tmp/.png.$$ test_png.html 2
# > perl -nle '/#(......)/ && print "$1"' test_png.html > colors.txt
legentry () {
a="xrgb($1)"; b=$1; c="$2+"
if [ ${b:0:1} = "-" ]; then a="${b:1}"; fi
if [ "$3" ]; then c="$2-$3"; fi
class String
alias :old_to_i :to_i
def to_i
x = self.old_to_i
if x == 0 then # maybe it didn't parse
return self.hex
end
return x
end
end
sqlite> select substr(' '||count(1),-5,5) as c, coalesce(value, '-No Exif-') as x from photos e1 left outer join exif e2 on e1.id=e2.id where e2.tag='Model' or e2.tag is null group by x order by 0+c desc ;
1382 Canon EOS 350D DIGITAL
1328 Canon DIGITAL IXUS 30
953 -No Exif-
911 Canon DIGITAL IXUS 65
831 Canon EOS 400D DIGITAL
590 Canon EOS 300D DIGITAL
442 K800i
190 BlackBerry 8900
sqlite> select count(1) as t, a.raw as c, b.myclean as d from exif a, exif b where a.id=b.id and a.tag='Model' and b.tag in ('Focal Length') group by c, d order by t desc limit 10;
973|Canon DIGITAL IXUS 30|5.8 mm
664|Canon DIGITAL IXUS 65|5.8 mm
627|Canon EOS 350D DIGITAL|105 mm
317|Canon EOS 400D DIGITAL|60 mm
198|Canon EOS 350D DIGITAL|55 mm
191|Canon DIGITAL IXUS 30|17.4 mm
181|Canon EOS 400D DIGITAL|105 mm
137|Canon EOS 400D DIGITAL|24 mm
134|Canon EOS 300D DIGITAL|55 mm
sqlite> select * from exif where id=4004581772 limit 20;
4004581772|AFPoint Selected||Auto|
4004581772|AFPoints In Focus||Center|
4004581772|Aperture|f/5.0|5.0|f/5.0
4004581772|Auto Bracketing||0|
4004581772|Bits Per Sample||8|
4004581772|Blue Balance||1.0546875|
4004581772|Camera Temperature||19 C|
4004581772|CircleOfConfusion||0.005 mm|
4004581772|Color Components||3|
TEST 1 - one 100BASE-TX port
1,1,100BASE-TX
1 0 100BASE-TX 1000BASE-TX => 1|
TEST 2 - one 100BASE-TX port
1,1,100BASE-TX
2 0 100BASE-TX 1000BASE-TX =>
0 1 100BASE-TX 1000BASE-TX =>
zgrep 'Accepted' /var/log/auth.log* | awk '{print $9,$11}' | sort -u | while read i; do set -- $i; u=$1; h=$2; m=$(whois $h | egrep '^role|^netname' |sed -ne 's/^[^:]*: *//p' | tr '\n' ':'); echo "$u ${m:-$h}"; done | sort -u