Skip to content

Instantly share code, notes, and snippets.

View olegwtf's full-sized avatar

Oleg olegwtf

  • reg.ru
  • Russia, Novosibirsk
View GitHub Profile
find . -type f -regextype posix-egrep -regex '.*\.pm|.*\.c|.*\.h|.*\.xs' ! -regex '\./\.git/|.*ppport\.h' | while read fname; do perl -ne 'print unless /^=h/ .. /^=cut/' < $fname; done | sed '/^$/d;/^#/d' | wc -l
@olegwtf
olegwtf / gist:1180610
Created August 30, 2011 10:25
measure speed with lwp
use LWP::UserAgent;
use Time::HiRes;
use strict;
my $ua = LWP::UserAgent->new();
my $start = Time::HiRes::time();
my $maxbytes = 1024*1024;
my $curspeed = 0;
my $received_bytes = 0;
@olegwtf
olegwtf / gist:1188372
Created September 2, 2011 10:54
test firebird + qt
#include <QDebug>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QString>
#include <QSqlError>
#include <QVariant>
int main()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QIBASE");
@olegwtf
olegwtf / gist:1199818
Created September 7, 2011 05:18
missing right curly or square bracket
use autodie;
use Fcntl qw(SEEK_SET);
use strict;
use warnings;
my ($in1, $in2, $ot) = @ARGV;
die "usage: $0 input1 input2 output"
unless defined $in1 && defined $in2 && defined $ot;
open IN1, '<:urf8', $in1;
@olegwtf
olegwtf / gist:1369465
Created November 16, 2011 06:49
Export variable from the class
<?php
class Ax {
public $super;
function __construct() {
$this->super = "super";
$GLOBALS['super'] = &$this->super;
}
@olegwtf
olegwtf / xlslib-example.cpp
Created November 20, 2011 15:53
Creating xls with xlslib
#include <xlslib.h>
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include <ctime>
using namespace xlslib_core;
using namespace std;
@olegwtf
olegwtf / coro-lwp-issue.pl
Created November 22, 2011 16:28
Coro::LWP issue
BEGIN {
$ENV{PERL_ANYEVENT_MAX_OUTSTANDING_DNS} = 30;
}
use strict;
use Coro::LWP;
use Coro;
use LWP;
my @coros;
for (1..30) {
@olegwtf
olegwtf / pchange.pl
Created December 6, 2011 15:21
I:S:S:W runtime proxy changing test
BEGIN {
$ENV{SOCKS_DEBUG} = 1;
}
use IO::Socket::Socks::Wrapper (
Net::FTP => {
ProxyAddr => 'localhost',
ProxyPort => 1080,
SocksVersion => 5
},
Net::FTP::dataconn => {
@olegwtf
olegwtf / lambda-http.pl
Created January 12, 2012 17:37
IO::Lambda::HTTP
use strict;
use URI;
use HTTP::Request;
use IO::Lambda qw(:all);
use IO::Lambda::HTTP qw(http_request);
sub request($) {
my $url = URI->new($_[0]);
my $req = HTTP::Request->new(GET => $url, [Host => $url->host]);
$req->protocol('HTTP/1.1');
@olegwtf
olegwtf / a-g-p-warns.pl
Created January 24, 2012 01:43
Any Warnings?
use strict;
use warnings;
use AnyEvent::Google::PageRank 'rank_get';
my $cv = AE::cv;
rank_get 'http://www.google.ru', sub {
print shift, "\n";
$cv->send;
};
$cv->recv;