Skip to content

Instantly share code, notes, and snippets.

@Mons
Mons / gist:715308
Created Nov 25, 2010
AnyEvent::HTTP::Server WS Echo sample
View gist:715308
#!/usr/bin/env perl
use uni::perl;
use lib::abs '../../lib';
use AnyEvent::Impl::Perl; # Better to use Impl::Perl for tests
use AE;
use AnyEvent::HTTP::Server;
AnyEvent::HTTP::Server->new(
host => '89.208.136.108',
@Mons
Mons / strlen-bench.c
Created Nov 2, 2012
Comparison of strlen and for(;;buf++)
View strlen-bench.c
/*
Compile me:
$ gcc -Wall -o strlen-bench strlen-bench.c -lrt -g -ggdb -O3
*/
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
View mybench.c
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#include "picohttpparser.h"
#include "httpfast.h"
#include <unistd.h>
#include <time.h>
@Mons
Mons / Makefile.PL
Created Nov 15, 2012
Remove some CFLAGS from $Config
View Makefile.PL
BEGIN {
require Config;
if (tied %Config::Config) { eval {
for (keys %Config::Config) {
local *Config::STORE = sub {
View hashing-experiment.c
if (sizeof(uintmax_t) == 8) {
size_t i;
uintmax_t
*l = (uintmax_t *) str->str,
xx = 0x2020202020202020ULL;
;
for (i=0; i < str->len / 8; i++) {
xx ^= l[i];
}
unsigned char x =
@Mons
Mons / benchmark.h
Created Nov 21, 2012
Small benchmark utility
View benchmark.h
/*
Usage:
#include "benchmark.h"
int test1 (va_list ap) {
char *str1 = va_arg( ap, char * );
char *str2 = va_arg( ap, char * );
...
return ...;
}
@Mons
Mons / asmbench.c
Created Nov 21, 2012
Comparison for asmlib
View asmbench.c
/*
Compile me:
gcc -o asmbench asmbench.c -L. -laelf64 -lrt -O0 && ./asmbench
Asmlib is here: http://agner.org/optimize/#asmlib
*/
#include "benchmark.h"
@Mons
Mons / XSTesting.xs
Created Nov 27, 2012
Creating callback from XS
View XSTesting.xs
/*
* Usage:
my $x = XSTesting::makecb("my arg");
say $x->();
*/
#include "EXTERN.h"
#include "perl.h"
@Mons
Mons / unidecodes
Last active Dec 16, 2015
Unicode transliterations
View unidecodes
0020 # SPACE
0021 ! # EXCLAMATION MARK
0022 " # QUOTATION MARK
0023 # # NUMBER SIGN
0024 $ # DOLLAR SIGN
0025 % # PERCENT SIGN
0026 & # AMPERSAND
0027 ' # APOSTROPHE
0028 ( # LEFT PARENTHESIS
0029 ) # RIGHT PARENTHESIS
View init.lua
if avd == nil then
avd = { version = 1.0 };
else
avd.version = 1.0
end
-- work with sessions user
function avd.session ()
box.fiber.detach()
box.fiber.name("avd.session")