Skip to content

Instantly share code, notes, and snippets.

View mythosil's full-sized avatar

Akito Tabira mythosil

View GitHub Profile
#include <stdio.h>
void func() __attribute__((deprecated));
int main(int argc, char** argv)
{
func();
return 0;
}
@mythosil
mythosil / hydropathy_plot.rb
Created June 28, 2011 11:40
calculate and plot hydropathy score
require 'gruff'
f = open(ARGV[0])
seq = f.read.delete(" \n").upcase
f.close
hydropathy_index = {
'A' => 1.8,
'B' => -3.5,
'C' => 2.5,
@mythosil
mythosil / chat_redis.pl
Created July 20, 2011 17:27
AnyEvent::Redis subscribe
use strict;
use warnings;
use AnyEvent::Redis;
my $redis = AnyEvent::Redis->new(
host => '127.0.0.1',
port => 6379,
encoding => 'utf8',
on_error => sub { warn @_ },
@mythosil
mythosil / anyevent_pubsub.pl
Created July 21, 2011 15:02
AnyEvent::Redis pubsub
use strict;
use warnings;
use AnyEvent::Handle;
use AnyEvent::Redis;
my $redis_sub = AnyEvent::Redis->new(
host => '127.0.0.1',
port => 6379,
encoding => 'utf8',
@mythosil
mythosil / prefork_echo.pl
Created July 22, 2011 16:57
prefork echo server
use strict;
use warnings;
use IO::Socket::INET;
use Parallel::Prefork;
sub MaxRequestsPerChild { 100 };
my $listen = IO::Socket::INET->new(
Listen => 5,
@mythosil
mythosil / pubsub_server_using_redis.pl
Created July 23, 2011 02:18
prefork pubsub server using redis
use strict;
use warnings;
use IO::Socket::INET;
use Parallel::Prefork;
use AnyEvent::Handle;
use AnyEvent::Redis;
$| = 1;
@mythosil
mythosil / statusbar.m
Created July 27, 2011 06:54
cocoa sample for showing statusbar
/*
* statusbar.m
* sample for showing something to status-bar
*
* How to compile and run.
* $ gcc statusbar.m -framework Cocoa
* $ ./a.out
*/
#import <Cocoa/Cocoa.h>
@mythosil
mythosil / prefork_test.cpp
Created July 29, 2011 10:04
prefork sample
#include <iostream>
#include <vector>
#include <ctime> /* time */
#include <csignal> /* signal, kill */
#include <unistd.h> /* fork, usleep */
#include <sys/wait.h> /* wait */
#include <sys/types.h> /* pid_t */
using namespace std;
class prefork {
@mythosil
mythosil / zeromq_echo_server.pl
Created July 30, 2011 03:32
echo server using zeromq
use strict;
use warnings;
use ZeroMQ qw/:all/;
my $server_addr = 'tcp://127.0.0.1:1986';
my $context = ZeroMQ::Context->new;
my $sock = $context->socket(ZMQ_REP);
$sock->bind($server_addr);
@mythosil
mythosil / zeromq_echo_client.pl
Created July 30, 2011 03:32
tcp client using zeromq
use strict;
use warnings;
use ZeroMQ qw/:all/;
use Data::Dumper;
my $peer_addr = 'tcp://127.0.0.1:1986';
my $context = ZeroMQ::Context->new;
my $sock = $context->socket(ZMQ_REQ);
$sock->connect($peer_addr);