Skip to content

Instantly share code, notes, and snippets.

@c18t
c18t / chperl
Created January 29, 2014 16:10
"plenv local <version> && plenv rehash"するやつ。.bash_aliasesに追加して下さい
# chperl - plenv local <version> && plenv rehash
chperl() {
# usage: chperl <perl_version>
_VERSION=$1
plenv local $_VERSION && plenv rehash
}
@c18t
c18t / factor.js
Last active August 29, 2015 13:56
できるだけ短いコードですばやく素因数分解してみる
l=console.log;o=414209763;r=Math.sqrt(o);for(i=2;i<=r&&i<=o;){o%i==0?(o/=i,l(i)):i++}if(o!=1)l(o)
// 0.042s
@c18t
c18t / uo_ghostscirpt.js
Created December 16, 2009 15:18
UOの幽霊語。英字以外のasciiは読める
javascript:var a=['o','0'],b=document.body;b.innerHTML=b.innerHTML.replace(/(?:^|(>))([^<]*)/g,function(){var t=RegExp.$1,s=RegExp.$2;return t+s.replace(/[^!-~\s]|[a-np-zA-Z]/g,function(p){return a[p.charCodeAt(0).toString(2).slice(-1)]})});void 0;
#!/usr/bin/env jruby
#
# require http://github.com/shokai/glitchicon
require File.dirname(__FILE__)+'/glitch'
require 'java'
import 'java.lang.System'
import 'javax.imageio.ImageIO'
import 'java.awt.image.BufferedImage'
@c18t
c18t / filetest.pl
Created October 20, 2012 10:29
Usage: # perl filetest.pl filetest.pl
#!/usr/local/bin/perl
my %X = (
-r => 'File is readable by effective uid/gid.',
-w => 'File is writable by effective uid/gid.',
-x => 'File is executable by effective uid/gid.',
-o => 'File is owned by effective uid.',
-R => 'File is readable by real uid/gid.',
-W => 'File is writable by real uid/gid.',
@c18t
c18t / chitandael.pl
Created October 29, 2012 10:37
千反田える
perl -M5.010 -MLingua::JA::Numbers -MEncode -e "%A=qw/a えー b びー c しー d でぃー e いー f えふ g じー h えっち i あい j じぇい k けい l える m えむ n えぬ o おー p ぴー q きゅー r あーる s えす t てぃー u ゆー v ぶい w だぶりゅー x えっくす y わい z ぜっと/;@A=a..z;say encode(($^O eq'MSWin32'?'cp932':'utf8'),num2ja($_)).'反田'.$A{$A[$_%26-1]}for 1..1000"
@c18t
c18t / crawl_settings.pl
Created June 27, 2013 00:50
crawler for twitter api v1.1. crawl_settings.pl で設定ファイル生成して crawl_insert.pl でDBに突っ込む
#!/usr/local/bin/perl
use 5.014;
use warnings;
use utf8;
use lib qw(lib);
use autobox;
use autobox::dump;
use autobox::Core;
@c18t
c18t / crawl_insert.pl
Last active December 19, 2015 01:08
crawler for twitter api v1.1. crawl_settings.pl で設定ファイル生成して crawl_insert.pl でDBに突っ込む
#!/usr/local/bin/perl
use 5.014;
use warnings;
use utf8;
use lib qw(lib);
use autobox;
use autobox::dump;
use autobox::Core;
@c18t
c18t / twitter_agent.pl
Last active December 19, 2015 01:08
Twitter API叩くときにいつもつかってるやつ。 require "twitter_agent.pl";
use 5.010;
use Net::Twitter::Lite::WithAPIv1_1;
sub twitter_agent {
my ($conf_app, $conf_user) = @_;
my $nt = Net::Twitter::Lite::WithAPIv1_1->new(%$conf_app, useragent_args => { timeout => 10 });
$nt->access_token($conf_user->{token});
$nt->access_token_secret($conf_user->{token_secret});
my ($pin, @userdata);
@c18t
c18t / crawl_insert.pl
Created July 4, 2013 13:09
twitter list から screen_name と user_id のリスト取ってくるやつ for twitter api v1.1
#!/usr/local/bin/perl
use 5.014;
use warnings;
use utf8;
use lib qw(lib);
use autobox;
use autobox::dump;
use autobox::Core;