Skip to content

Instantly share code, notes, and snippets.

my $root = '.';
my @indexes = qw(index.html);
use strict;
use warnings;
use Plack::App::File;
use Plack::App::Cascade;
sub directory_indexes {
my ($root, @indexes) = @_;
my $file = Plack::App::File->new(root => $root)->to_app;
@sugar84
sugar84 / gist:952361
Created May 2, 2011 21:03
twiggy vs node.js vs HTTP::Server::Simple::PSGI
----------------------------------------------------------
== Twiggy ==
app.psgi:
my $app = sub {
return [ 200, ['Content-Type' => 'text/plain'], [ "Hello world\n"] ];
};
[sugar@host dir]$ twiggy --listen 127.0.0.1:8080 app.psgi
diff --git a/lib/Starman/Server.pm b/lib/Starman/Server.pm
index c98af6f..a927e0d 100644
--- a/lib/Starman/Server.pm
+++ b/lib/Starman/Server.pm
@@ -21,6 +21,29 @@ my $null_io = do { open my $io, "<", \""; $io };
use Net::Server::SIG qw(register_sig);
+sub SSL_key_file {
+ my ($self, $host, $port, $proto) = @_;
@gfx
gfx / foo.pl
Created December 13, 2011 00:57
s///ee
->> perlbrew exec perl -e 'package Foo; s//"warn __PACKAGE__"/ee'
perl-5.10.1
==========
Foo at (eval 1) line 1.
perl-5.12.1
==========
Foo at (eval 1) line 1.
@jugyo
jugyo / gist:1751353
Created February 6, 2012 10:25
the rack middleware that handle the facebook signed request
require 'base64'
require 'openssl'
# This is inspired by [rack-facebook-signed-request](https://github.com/gamesthatgive/rack-facebook-signed-request)
#
# Usage
#
# use Rack::FBSignedRequest, :secret => 'SECRET'
#
class Rack::FBSignedRequest
@brunohq
brunohq / post-commit
Created May 11, 2012 14:37
git post-commit hook to update referenced task status in Asana with commit message
#!/bin/bash
apikey=$(git config user.asana-key)
if [ $apikey == '' ] ; then exit 0; fi
comment=$(git log --pretty=oneline -n1)
taskid_pattern='.*#([0-9]*).*'
if [[ $comment =~ $taskid_pattern ]]; then
taskid=${BASH_REMATCH[1]}
apikey=$(git config user.asanakey)
module UniqueConstraint
def self.included(model)
model.extend(ClassMethods)
end
module ClassMethods
def unique_constraint_violation_message
"#{name} must be unique"
end
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@repeatedly
repeatedly / msgpack_issue_121.md
Last active November 30, 2021 02:09
MessagePackが文字列とバイナリをわけないのは問題?

MessagePackが文字列とバイナリをわけないのは問題?

msgpack/msgpack#121

Objective Cの実装使ってるとある問題にぶちあたった.なので,文字列をちゃんとバイナリ(Raw)と分けるべき,という提案

(*) 俺は熟読したわけではないので,中身が気になる人はちゃんと本スレを読みましょう

そもそもMessagePackとは

@naan
naan / source_maps.rb
Last active December 14, 2015 13:48 — forked from alexspeller/source_maps.rb
Monkey patch for Coffee Script v.1.6.2 Source Maps for Rails.
# config/initializers/source_maps.rb
if Rails.env.development?
module CoffeeScript
class SourceMapError < StandardError; end;
class << self
def compile script, options
script = script.read if script.respond_to?(:read)