Skip to content

Instantly share code, notes, and snippets.

View shelling's full-sized avatar

shelling shelling

View GitHub Profile
#!/usr/bin/env perl
use AnyEvent::HTTPD;
my $httpd = AnyEvent::HTTPD->new(port => 3000);
use MogileFS::Client;
my $client = MogileFS::Client->new( domain => "test", hosts => ["localhost:7001"] );
use MIME::Types;
my $mime = MIME::Types->new;
@shelling
shelling / ldapi.pl
Created July 14, 2012 15:28
import schema ldif with Net::LDAPI and Authen::SASL
#!/usr/bin/env perl
# USAGE:
# perl ldapi.pl schema.ldif
# will have the same result as running
# ldapadd -Y EXTERNAL -H ldapi:/// -f schema.ldif
use Modern::Perl;
use Net::LDAP;
@shelling
shelling / spath.pl
Created July 10, 2012 06:01
prevent Data::SPath invoke methods on an object
#!/usr/bin/env perl
use Modern::Perl;
use Data::SPath spath => {};
use Data::Dumper;
{
package Hello;
1;
}
@shelling
shelling / default
Created June 15, 2012 08:46
nginx with full webdav support
# full webdav configuration with
# https://github.com/arut/nginx-dav-ext-module
server {
listen 7500;
access_log /var/log/nginx/localhost.access.log;
error_log /var/log/nginx/localhost.error.log;
location / {
@shelling
shelling / Counter.pm
Created March 31, 2012 11:31
class variables in Moose
use Modern::Perl;
use MooseX::Declare;
class Counter {
has value => (
is => "rw",
isa => "Num",
traits => ['Counter'],
default => 0,
handles => {
#!/usr/bin/env perl
use Modern::Perl;
use MooseX::Declare;
class Person {
has name => (
is => "rw",
isa => "Str",
@shelling
shelling / gist:2021107
Created March 12, 2012 10:43
emacs frame setting for windows
(if (and (>= emacs-major-version 23) (eq window-system 'w32))
(progn
(setq frame-setting
'(
(font . "Consolas-14")
(left . 120)
(width . 80)
(height . 42)
))))
@shelling
shelling / simple_migrator.rb
Created March 8, 2012 10:34
simple migrator
require "rubygems"
require "active_record"
require "logger"
config = {
:adapter => "mysql2",
:encoding => "utf8",
:reconnect => false,
:database => "migration",
:pool => 5,
@shelling
shelling / timestamp.pl
Created February 26, 2012 08:38
epoch <=> timestamp converter
#!/usr/bin/env perl
use 5.010;
use Badger::Timestamp;
my $ts = Badger::Timestamp->new($ARGV[0]);
say $ts->timestamp;
say $ts->epoch_time;
#!/usr/bin/perl6
my @hello = "hello", "world";
say @hello.perl;
for @hello -> $item {
say $item
}