Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/ruby -w
# encoding: utf-8
require 'bundler/setup'
require 'nokogiri'
require 'httpclient'
require 'uri'
require 'ruby-debug'
require 'unicode_utils'
#include <stdio.h>
#include <sys/stat.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include "parse_http.h"
http_request_t* http_request_create(size_t prealloc, size_t growth, void *userdata){
http_request_t *ret;
for dir in [&viewdir, &directory]
if !isdirectory(dir)
call mkdir(dir)
endif
endfor
sub filter(&@) {
local $_;
my ($code, $what) = @_;
my $t = ref($what);
if($t eq 'ARRAY'){
for(my $i = 0; $i < @$what; ++$i){
$_ = $what->[$i];
splice(@$what, $i--, 1) unless $code->($what->[$i]);
package Timeshifter::ContinuousReadWrite;
use strict;
use warnings;
use base qw(Tie::Handle Exporter);
use File::Temp qw(mktemp);
our @EXPORT_OK = qw(continuous_open);
use constant {
READ_MODE => 1,
#!/bin/bash
DELAY=5
MIN_USAGE=20
MAX_USAGE=95
WAIT_FOR=10
MAX_RESTARTS_PER_SECOND=5
warn(){
echo "$@" >&2
def _command(self, parser = default_parser, name = None):
def wrap(func):
if not inspect.isfunction(func):
raise RuntimeError, "Only functions allowed to be decorated as command!"
if not name:
name = func.__name__
if not hasattr(func, '__doc__') or not func.__doc__:
raise RuntimeError, "%s must have documentation!" % (name,)
[ 64.180]
X.Org X Server 1.12.4
Release Date: 2012-08-27
[ 64.180] X Protocol Version 11, Revision 0
[ 64.180] Build Operating System: Linux 3.4.8-1-ARCH x86_64
[ 64.180] Current Operating System: Linux nq.od.ua 3.5.5-1-ARCH #1 SMP PREEMPT Tue Oct 2 22:30:55 CEST 2012 x86_64
[ 64.180] Kernel command line: root=/dev/sda3 ro
[ 64.180] Build Date: 27 August 2012 08:04:39AM
[ 64.180]
[ 64.180] Current version of pixman: 0.26.2
def setup_constants(name, bases, dict):
print name
for idx, i in enumerate(dict['HEADER']):
name = 'COLUMN_' + i.upper().replace(' ', '_')
dict[name] = idx + 1
return type(name, bases, dict)
class Test:
__metaclass__ = setup_constants
def setup_constants(name, bases, dict):
print name
for idx, i in enumerate(dict['HEADER']):
name = 'COLUMN_' + i.upper().replace(' ', '_')
dict[name] = idx + 1
return type(name, bases, dict)
class Test:
__metaclass__ = setup_constants