Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

def unpack_string(octet_string):
ret = []
for hex in octet_string.split(' '):
octets = struct.unpack('2c', hex)
for octet in octets:
b_repr = bin(int(octet, 16)).replace('b','')
ret.append( b_repr.ljust(4, '0'))
return [b[0]+1 for b in enumerate([a for a in "".join(ret)]) if b[1] == '1']
import re
LAN_REGEXP = re.compile('^([\w-]+),([\w-]+),?([\w-]+)?,?(\d+)?$')
CORE_REGEXP = LAN_REGEXP
ELINK_REGEXP = LAN_REGEXP
LINK_REGEXP = re.compile('^([\w-]+),?([\w-]+)?,?(\d+)?$')
def parse_ifDescr(ifDescr):
type = ifDescr[:ifDescr.find(',')]
print type
2009-06-11 12:42:44,623 [DEBUG] [nav.ipdevpoll.schedule.JobHandler.inventory.[uninett-gw.uninett.no]] Now calling plugin: nav.ipdevpoll.plugins.topology.Topology(u'uninett-gw.uninett.no')
2009-06-11 12:42:44,623 [DEBUG] [nav.ipdevpoll.plugins.topology.Topology.[uninett-gw.uninett.no]] Collecting cdpCacheTable columns
2009-06-11 12:42:44,760 [DEBUG] [nav.ipdevpoll.plugins.topology.Topology.[uninett-gw.uninett.no]] Found 21 cdpcache entries
2009-06-11 12:42:44,760 [DEBUG] [nav.ipdevpoll.plugins.topology.Topology.[uninett-gw.uninett.no]] Found CDP Connection from teknobyen-ekstern-sw1.uninett.no (GigabitEthernet0/2)
2009-06-11 12:42:44,761 [DEBUG] [nav.ipdevpoll.plugins.topology.Topology.[uninett-gw.uninett.no]] Found CDP Connection from teknobyen-5etg-ap4 (FastEthernet0)
2009-06-11 12:42:44,762 [DEBUG] [nav.ipdevpoll.plugins.topology.Topology.[uninett-gw.uninett.no]] Found CDP Connection from teknobyen-4etg-ap4 (FastEthernet0)
2009-06-11 12:42:44,762 [DEBUG] [nav.ipdevpoll.plugins.topology.Topology.[uninett-gw.
#! /usr/bin/perl
use XML::Template;
my $doc = XML::Template::process_file('../xml/form.xml', {
'title' => 'Form test',
'#myform/action' => 'foobar'
});
print $doc->toString;
SELECT DISTINCT ON (transaction)
settlement,
uka_transaction_id,
uka_project_id,
transaction,
transaction_type,
transaction_sum,
CASE
WHEN transaction_type = 3 THEN transaction_sum - count(ticket) * -15
ELSE transaction_sum - count(ticket)*15
klette@groove:~$ sudo aptitude remove mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Reading task descriptions... Done
The following packages will be REMOVED:
mysql-client-5.0{u} mysql-server mysql-server-5.0{u}
0 packages upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
<?php
require_once 'PHPUnit/Framework.php';
require_once 'untaint.php';
class IntTest extends PHPUnit_Framework_TestCase {
public function testValidInt() {
$data = array('foo' => 1, 'bar' => -9999999999);
$values = Untaint::check(array('foo'=>UNTAINT_INT, 'bar'=>UNTAINT_INT), $data);
<?php
$untaint = new Untainter();
class MyImageUntainter {
function validate($data){
return check_for_valid_image_data($data);
}
}
numbers = [num[0].replace(' ', '') for num in numbers if (num[0].startswith('9') and len(num[0]) == 8) \
or (num[0].startswith('4') and len(num[0]) == 8) \
or (num[0].startswith('+474') and len(num[0]) == 11) \
or (num[0].startswith('+479') and len(num[0]) == 11)\
or (num[0].startswith('00479') and len(num[0]) == 12)\
or (num[0].startswith('00474') and len(num[0]) == 12)]
#encoding: utf-8
import urllib
from django.db import connection
from django.conf import settings
from django.http import HttpResponse
from django.shortcuts import render_to_response
def generate_ticket_pdf_url(purchase_id):