Skip to content

Instantly share code, notes, and snippets.

View ytnobody's full-sized avatar
♨️
470

Satoshi Azuma a.k.a. ytnobody ytnobody

♨️
470
View GitHub Profile
@ytnobody
ytnobody / mymap.pl
Created August 7, 2012 02:19
map function in pure-perl
sub mymap (&@) {
my ( $code, @list ) = @_;
my @res ;
for my $item ( @list ) {
$_ = $item;
push @res, $code->();
}
return @res;
}
@ytnobody
ytnobody / fizzbuzz.4th
Last active October 8, 2015 07:58
A practice for gforth (fizzbuzz question)
: SEQ ( nx ny -- nx ... ny )
SWAP OVER OVER
< IF
BEGIN
OVER 1 + SWAP
OVER OVER >=
UNTIL
DROP
ELSE
BEGIN
@ytnobody
ytnobody / env
Created October 26, 2012 23:36
env script for carton + perlbrew app on cron
#!/bin/sh
export HOME=/home/ytnobody
cd $HOME/work/myapp
. ~/perl5/perlbrew/etc/bashrc
perlbrew use perl-5.12.3
export PERL5OPT="-Ilib"
exec carton exec "$@"
@ytnobody
ytnobody / crontab-with-env
Created October 26, 2012 23:38
crontab with env script
MYAPP_HOME=/home/ytnobody/work/myapp
SETLOCK=/usr/local/bin/setlock
LOGGER=/bin/logger
*/5 * * * * $SETLOCK /tmp/myapp.lock $MYAPP_HOME/bin/env $MYAPP/bin/getter | $LOGGER -t MYAPP
@ytnobody
ytnobody / to-8bit.pl
Created December 6, 2012 02:08
pngを8bitに
use strict;
use warnings;
use Imager;
my $i = Imager->new;
$i->read(file => 'meat.png');
my $img = $i->to_rgb8;
$img->write(file => 'lite-meat.png');
@ytnobody
ytnobody / pfm.pl
Created February 27, 2013 02:16
P::FMつかってみた
use strict;
use warnings;
use Parallel::ForkManager;
my $pm = Parallel::ForkManager->new(4);
for my $i ( 1 .. 30 ) {
my $sleep = int(rand(5)+3);
my $pid = $pm->start and next;
printf "PID:%s NUM:%s START sleep %s\n", $pid, $i, $sleep;
@ytnobody
ytnobody / banana.pl
Created March 14, 2013 06:21
へんなIRCBot
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use AnyEvent;
use AnyEvent::Twitter::Stream;
use AnyEvent::IRC::Client;
use Encode;
use Net::Twitter::Lite;
use Text::MeCab;
@ytnobody
ytnobody / hoge.lua
Created April 10, 2013 09:05
loadstring + if
#!/usr/bin/env lua
i = 20
f = loadstring("if (i == 20) then return true else return nil end")
if ( f() ) then
print "ok"
else
print "ng"
end
@ytnobody
ytnobody / rbenvsetup
Last active December 17, 2015 19:28
automated rbenv setup
#!/bin/sh
#
# rbenvsetup http://is.gd/rbenvsetup
# Tue May 28 11:03:00 JST 2013 v0.01 by ytnobody
#
RBENV_REPO=git://github.com/sstephenson/rbenv.git
RBENV_ROOT=$HOME/.rbenv
PROF_FILE=$HOME/.bash_profile
#!/usr/bin/env bash
# shellcheck disable=SC2016
#
# plenvsetup http://is.gd/plenvsetup
# Tue Jan 7 17:29:22 JST 2020 v0.06 by ytnobody
#
set -e
die () {