Skip to content

Instantly share code, notes, and snippets.

View aero's full-sized avatar

aero aero

  • Seoul, Republic of Korea
View GitHub Profile
@kfly8
kfly8 / bbs.pl
Created February 28, 2015 07:06
Perl入学式 #6 の掲示板の練習問題で、DBに記事を格納する形にしてみる
#!/usr/bin/env perl
use Mojolicious::Lite;
use DBIx::Sunny;
app->attr(dbh => sub { DBIx::Sunny->connect('dbi:mysql:dbname=bbs', 'root','') });
get '/' => sub {
my $c = shift;
my $entries = app->dbh->select_all('SELECT * FROM entry');
@melo
melo / gist:1937200
Created February 29, 2012 02:54
Compiling perl 5.14.2 with perlbrew on CentOS 6 64bit with mod_perl support
# the fpic is needed for mod_perl
# so is usesshrplib
# use 64bitall just makes sense as uselargefiles
# the ldflags mimic the settings of the system perl
perlbrew install -j 8 5.14.2 \
-Dcccdlflags=-fPIC \
-Duseshrplib \
-Duse64bitall \
@olegwtf
olegwtf / json_ordered.pl
Created March 26, 2012 04:39
Save JSON object keys ordering as is
use strict;
use Tie::IxHash;
use JSON::PP;
# magic start
my $obj_parser_sub = \&JSON::PP::object;
*JSON::PP::object = sub {
tie my %obj, 'Tie::IxHash';
$obj_parser_sub->(\%obj);
use Plack::App::CGIBin;
use Plack::App::PHPCGI;
use Plack::Builder;
use File::Zglob;
my $cgibin = Plack::App::CGIBin->new(
root => "/usr/local/nagios/sbin",
exec_cb => sub { my $file = shift; $file =~ m!\.cgi$! and -x $file },
)->to_app;
my $static = Plack::App::File->new(root => "/usr/local/nagios/share")->to_app;
@tsee
tsee / terrain.h
Created April 25, 2013 17:53
terrain.h - a naive C implementation
#define NW 0
#define NE 1
#define SW 2
#define SE 3
#include <math.h>
#include <limits.h>
#include <stdlib.h>
#include <EXTERN.h>
@krimdomu
krimdomu / gist:6080102
Created July 25, 2013 14:15
rex and expect
# Rexfile
use Expect;
set connection => "OpenSSH";
my $expect_timeout = 5;
my $git_password = 'f00b4r';
my $sudo_password = 'test';
@dwarring
dwarring / gist:6127599
Last active December 20, 2015 11:59
perl6 brainf*ck program
use v6;
grammar Brainfuck::Grammar {
rule TOP {^ [<cmd> || .+? ]* $}
proto token cmd { <...> }
token cmd:sym<ptr-inc> {\>}
token cmd:sym<ptr-dec> {\<}
token cmd:sym<inc> {\+}
token cmd:sym<dec> {\-}
token cmd:sym<input> {\,}
@xiongchiamiov
xiongchiamiov / activate
Last active January 30, 2017 17:32 — forked from rahulg/activate
export GOPATH="$(builtin cd "$(dirname "${BASH_SOURCE[0]:-$_}" )" && pwd)"
export OLDPS1=$PS1
export PS1="[go:$(basename $GOPATH)] $PS1"
alias gcd="cd $GOPATH"
deactivate() {
export PS1=$OLDPS1
unset GOPATH
unset OLDPS1
unalias gcd
unset deactivate
@rodchyn
rodchyn / opkg-clean
Created August 8, 2012 11:24
opkg clean script
#!/bin/sh
opkg update
PACKAGES=`opkg --force-space --noaction install $1 | grep http | cut -f 2 -d ' ' | sed 's/.$//'`
for i in $PACKAGES
do
LIST=`wget -qO- $i | tar -Oxz ./data.tar.gz | tar -tz | sort -r | sed 's/^./\/overlay/'`
for f in $LIST
do
if [ -f $f ]
then
@calid
calid / 00-preamble.md
Last active October 3, 2022 10:45
ZeroMQ Perl Performance Comparison: FFI vs XS bindings

ØMQ Perl Performance Comparison: FFI vs XS bindings

Comparison of the performance of FFI vs XS zeromq bindings. For FFI the ZMQ::FFI bindings are used, first using FFI::Raw on the backend and then using FFI::Platypus. For XS ZMQ::LibZMQ3 is used.

Comparison is done using the zeromq weather station example, first by timing wuclient.pl using the various implementations, and then by profiling wuserver.pl using Devel::NYTProf. When profiling the server is changed to simply publish 1 million messages and exit.