Skip to content

Instantly share code, notes, and snippets.

@miyagawa
miyagawa / gitweb.psgi
Created March 27, 2010 13:54
Running gitweb.cgi on Plack
# 1. Download git and make gitweb/gitweb.cgi (See gitweb/INSTALL how to set gitweb root etc.)
# 2. Copy this file as gitweb/app.psgi
# 3. cd gitweb; plackup
# 4. Access http://localhost:3000/gitweb.cgi
use Plack::Builder;
use Plack::App::WrapCGI;
use Plack::App::File;
builder {
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SoundCloud OAuth 2 User Agent Authentication Flow Demo</title>
<script type="text/javascript" charset="utf-8" src="javascript/jquery-1.4.2.js"></script>
<script type="text/javascript" charset="utf-8">
$(function () {
var extractToken = function(hash) {
use Data::Dumper;
my @r;
my $text = q{@hoge http://example.com/#@hoge/ aaa #hash aaa @hogehoge aaa http://example.com/};
my $re = qr{(http://[A-Za-z0-9_\-\~\.\%\?\#\@/]+(?{push @r, ["HTTP", @-,@+] })|(?:^|\s)\@[A-Za-z0-9_]+(?{push @r,["AT", @-,@+]})|(?:^|\s)#[A-Za-z0-9_]+(?{push @r,["HashTag",@-,@+]}))};
warn $text;
() = $text =~/$re/g;
warn Dumper @r;
#!perl -w
# usage: fetch.pl [urls...]
use strict;
use Coro;
use Coro::Select; # この行をコメントアウトすると多重化されなくなり時間がかかるようになる
use Furl;
my @coros;
foreach my $url(@ARGV) {
push @coros, async {
@riywo
riywo / gist:836630
Created February 21, 2011 03:41
指定秒間だけtcpdumpしてmk-query-digestするshell
#!/bin/sh
SEC=$1
tcpdump -s 65535 -nn -q -tttt -x port 3306 -l > /tmp/tcpdump.3306 2> /dev/null &
PID_3306=$!
tcpdump -s 65535 -nn -q -tttt -x port 11211 -l > /tmp/tcpdump.11211 2> /dev/null &
PID_11211=$!
[[kazuho@XXXXXXXX:~/dev]]$ ls -l
total 40
drwxrwxr-x 5 kazuho kazuho 4096 Dec 28 18:04 fcgi
drwxrwxr-x 11 kazuho kazuho 4096 Jan 24 16:39 mysql-5.1
drwxrwxr-x 3 kazuho kazuho 4096 Jan 24 19:20 mysql-5.1-nondebug
drwxrwxr-x 16 kazuho kazuho 4096 Jan 24 20:37 mysql-5.5
drwxr-xr-x 9 kazuho kazuho 4096 Jan 20 17:38 p5-Furl
drwxr-xr-x 5 kazuho kazuho 4096 Feb 15 18:02 p5-test-httpd-apache2
drwxr-xr-x 9 kazuho kazuho 4096 Feb 24 18:29 q4m
drwxr-xr-x 9 kazuho kazuho 4096 Jan 24 20:47 q4m-5.5
* A history of search software in japan
今回紹介するGroongaは日本の検索ライブラリの中で新しいものです。
Groongaを紹介する前に、日本の検索事情について少しお話します。
Today I'm going to talk about a new search library from Japan.
First, I'll tell you something about how search works in Japan.
** use grep
文章を簡単に検索する方法としてgrepがあります。
/* Copyright 2011 by Yasuhiro Matsumoto
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
#!perl
use strict;
use warnings;
use Getopt::Long;
use Test::Httpd::Apache2;
use Path::Class;
my $port = 5000;
my $root = '.';
@hryk
hryk / glitch.rb
Created May 10, 2011 11:13
glitch your display.
#!/usr/bin/env macruby
#
# MacRubyで画面グリッチをフルスクリーン表示する
#
# http://twitter.com/negipo/status/67572370247913473
#
# ## Usage
#
# ./glitch.rb
#