Skip to content

Instantly share code, notes, and snippets.

@miyagawa
miyagawa / gist:965935
Created May 11, 2011 04:59
hijack any LWP stack with your PSGI app - it's on CPAN now http://search.cpan.org/~miyagawa/LWP-Protocol-PSGI-0.01/
use strict;
use LWP::UserAgent;
my $app = do {
use Mojolicious::Lite;
get '/' => sub { shift->render(text => "Hello World") };
get '/search' => sub {
my $self = shift;
my $foo = $self->param('q');
$self->render(text => "You searched $foo");
@earino
earino / gist:2996703
Created June 26, 2012 16:04
Snippet of code using Inline::C and leptonica for super duper fast image resizing
# stuff setting up moose and the environment omitted
sub BUILD {
my $self = shift;
my $application_environment = $ENV{'APPLICATION_ENVIRONMENT'};
my $conf = new Config::General($self->config_file);
my %config = $conf->getall;
#include "apr.h"
#include "apr_strings.h"
#include "apr_lib.h"
#define APR_WANT_STRFUNC
#include "apr_want.h"
#include "ap_config.h"
#include "httpd.h"
#include "http_config.h"
@xaicron
xaicron / gist:3490145
Created August 27, 2012 16:32
install-capnm
#!/bin/sh
set -e
HTTP_GET_COMMAND=""
if [ `which curl` ]; then
HTTP_GET_COMMAND="curl -L"
elif [ `which wget` ]; then
HTTP_GET_COMMAND="wget -O -"
elif [ `perl -v | grep "5.1[3-9]"` ]; then
HTTP_GET_COMMAND="perl -MHTTP::Tiny -e 'print +HTTP::Tiny->new->get(shift)->{content}'"
@hayajo
hayajo / gist:6291004
Last active December 21, 2015 10:19
FormValidator::Liteで配列の制約
package MyApp::Validator::Constraint;
use strict;
use warnings;
use FormValidator::Lite::Constraint;
=head1 SYNOPSYS
my $fv = FormValidator::Lite->new($q);
$fv->check(
@sunaot
sunaot / hello_ruby.md
Last active April 4, 2017 11:04
さらっと読んで Ruby がわかった気になれるプログラミング言語 Ruby のかんたんな紹介
@colinrymer
colinrymer / config-config.exs
Created March 13, 2017 21:02
Phoenix Prometheus Setup
...
# Prometheus
config :prometheus, MyApp.PhoenixInstrumenter,
controller_call_labels: [:controller, :action],
duration_buckets: [10, 25, 50, 100, 250, 500, 1000, 2500, 5000,
10_000, 25_000, 50_000, 100_000, 250_000, 500_000,
1_000_000, 2_500_000, 5_000_000, 10_000_000],
registry: :default,
duration_unit: :microseconds
@JFK
JFK / gist:4591707
Last active September 16, 2019 21:10
Ngnix + Nginx-GridFS-Replicaset(mongodb) + nginx-image-filter +nginx-proxy-cache Sample Configuration
user www-data;
#worker_processes 4;
#worker_priority 0;
#worker_cpu_affinity 0001 0010 0100 1000;
#worker_rlimit_nofile 163840;
#worker_processes 8;
#worker_priority 0;
#worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;
@jonhoo
jonhoo / README.md
Last active July 19, 2021 10:49
Distributed RWMutex in Go
@methane
methane / myprofiler.py
Created December 5, 2011 08:54
Casual MySQL profiler using "SHOW FULL PROCESSLIST"
#!/usr/bin/env python
# coding: utf-8
"""myprofiler - Casual MySQL Profiler
https://github.com/methane/myprofiler
"""
import os
import sys