Here are some code examples from the book, written by Alex McLean.  

> hello-network.py

#!/usr/bin/python
# A script for greeting every server on the Internet.
import iptools, httplib
for ip in iptools.IpRangeList('0.0.0.0/0'):
try:
print "Greeting " + ip
cx = httplib.HTTPConnection("%s:80" % ip)
cx.request("POST", '/', "message=Hello+world!")
except:
pass

You can find a video of Franco Bifo Berardi reading this script at http://vimeo.com/48294959.


> interpellate.pl

#!/usr/bin/perl
use Graph::Easy;
my $g = Graph::Easy->new();
@ids = (0 .. 15);
$ids[rand(@ids)] = 'you';
foreach $id (0 .. $#ids) {
$to = rand(@ids) - 1;
$to++ if ($to >= $id);
$g->add_edge($ids[$id], $ids[$to]);
}
print($g->as_ascii . "Hey, you there.\n");


> ungovernable.patch

# (c) 2011 Alex McLean, released under the GPL version 2
diff -uNr linux.vanilla/drivers/cpufreq/cpufreq_ondemand.c linux.new/drivers/cpufreq/cpufreq_ondemand.c
--- linux.vanilla/drivers/cpufreq/cpufreq_ondemand.c 2011-11-21 22:47:46.000000000 +0000
+++ linux.new/drivers/cpufreq/cpufreq_ondemand.c 2011-12-03 15:22:50.649318547 +0000
@@ -494,7 +494,7 @@
}


/* Check for frequency increase */
- if (max_load_freq > dbs_tuners_ins.up_threshold * policy->cur) {
+ if (max_load_freq cur) {
/* If switching to max speed, apply sampling_down_factor */
if (policy->cur < policy->max)
this_dbs_info->rate_mult =
@@ -513,7 +513,7 @@
* can support the current CPU usage without triggering the up
* policy. To be safe, we focus 10 points under the threshold.
*/
- if (max_load_freq <
+ if (max_load_freq >=
(dbs_tuners_ins.up_threshold - dbs_tuners_ins.down_differential) *
policy->cur) {
unsigned int freq_next;

Leave a Reply

Your email address will not be published. Required fields are marked *