Skip to content

Instantly share code, notes, and snippets.

@onishi
onishi / cube_shuffle
Created August 19, 2021 00:45
ルービックキューブをシャッフルしたい
#!/usr/bin/env perl
use strict;
use warnings;
my $count = shift || 20;
my @random = qw/R R F F U U L D M/;
my $rate_2 = 0.3;
my $rate_prime = 0.3;
my @result;
@onishi
onishi / private.xml
Created October 9, 2014 03:05
Karabiner configuration for Slack
<?xml version="1.0"?>
<root>
<appdef>
<appname>SLACK</appname>
<equal>com.tinyspeck.slackmacgap</equal>
</appdef>
<item>
<name>For Slack CTRL+TAB=move unread channel</name>
<identifier>private.app_slack_move_channel_with_ctrl_tab</identifier>
<only>SLACK</only>
@onishi
onishi / domain.psgi
Last active August 29, 2015 14:02
QUERY_STRINGにドメイン入れるとical形式でリマインダのカレンダー吐いてくれるの
use strict;
use warnings;
use Net::Domain::ExpireDate 'expire_date';
use Time::Seconds;
use Data::ICal;
use Data::ICal::Entry::Todo;
use Data::ICal::Entry::Event;
@onishi
onishi / wget.pl
Created November 14, 2012 09:30
HTMLまるごと保存
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use DateTime;
use Digest::SHA1 qw(sha1_hex);
use Encode;
use File::Path qw/make_path/;
use HTML::Parser;
@onishi
onishi / hello.pl
Created March 17, 2012 06:26
Hello World
#!/usr/bin/env perl
print "Hello, World!!";
@onishi
onishi / gist:1630307
Created January 18, 2012 01:55
Media queries for Hatena Group
@media screen and (max-device-width: 480px) {
* {
font-size: 48px;
line-height: 64px;
word-break: break-all;
}
table#banner, div#simple-header, div.sidebar, div.caption {
display:none
}
img.hatena-star-comment-button, img.hatena-star-add-button, img.hatena-star-star {
@onishi
onishi / set_uninterrupted_count
Created October 4, 2011 06:50
uninterrupted day count by MySQL Stored Procedure
CREATE TABLE entry (
blog_id INT,
created datetime
);
DROP PROCEDURE IF EXISTS set_uninterrupted_count;
DELIMITER //
CREATE PROCEDURE set_uninterrupted_count(IN id INT, OUT uninterrupted_count INT)
BEGIN
DECLARE done INT DEFAULT 0;
@onishi
onishi / mysqldiff
Created August 19, 2011 07:57
mysqldiff - mysql scheme diff
#!/usr/bin/env perl
use strict;
use warnings;
# TODO
# - drop key
@ARGV == 2 or die 'Usage: mysqldiff dbname1 dbname2';
my @tables = map {
@onishi
onishi / gist:1053219
Created June 29, 2011 05:33
decode_punycode
use IDNA::Punycode;
use Encode;
idn_prefix('xn--');
decode_punycode('xn--cho'); #=> '䑵'
decode_punycode('xn--motemen'); #=> '嵡嵣嵫嵧嵨'
decode_punycode('xn--hitode'); #=> '岴岊岲'
decode_punycode('xn--hakobe932'); #=> IDNA::Punycode が落ちて abort
@onishi
onishi / statuscode.py
Created February 16, 2011 03:35
statuscode
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
import httplib
class StatusCode(webapp.RequestHandler):
def get(self, code):
self.response.headers['Content-Type'] = 'text/html'
content = 'statuscode : ' + code + '<br>'
for c, m in httplib.responses.iteritems():