This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Nabeatsu | |
# returns "hoge" if given value is a multiple of 3, or contains '3' in it; otherwise just the value itself (in String). | |
# | |
# Restriction of coding: | |
# DO NOT use conditional branching syntax, such as "if", "unless", "case ... when". | |
# | |
module Nabeatsu | |
class << self | |
def say(n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
srcdir="${HOME}/src/pjproject-2.0-rc" | |
cd ${srcdir} | |
( | |
cat <<END | |
#define PJ_CONFIG_IPHONE 1 | |
#include <pj/config_site_sample.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
intToRoman :: Int -> String | |
intToRoman = concat . reverse . (zipWith (\f d -> f d) fs) . split | |
where | |
split = unfoldr (\n -> if n > 0 then Just ((mod n 10), (div n 10)) else Nothing) | |
fs = map roman [('i', 'v', 'x'), ('x', 'l', 'c'), ('c', 'd', 'm'), ('m', '$', '#')] | |
roman (one, five, ten) n | |
| n >= 0 && n <= 3 = replicate n one | |
| n == 4 = [one, five] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
class String | |
def &(other) | |
self.unpack("U*").zip(other.to_s.unpack("U*")).map{|pair| pair.first & pair.last }.pack("U*") | |
end | |
end | |
puts "生" & "死" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'open-uri' | |
require 'nokogiri' | |
require 'growl' | |
doc = Nokogiri::HTML(open("http://shop.github.com/products/octodex-sticker-pack")) | |
if doc.css('#puchase-form .sold-out').empty? | |
Growl.notify do |n| | |
n.message = 'Octodex Sticker Packs are back!' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Emacs 23.3 building procedure for MacOSX | |
# thanks to http://masutaka.net/chalow/2011-07-31-2.html | |
# | |
# | |
# settings | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dbpath = /var/mongo/data | |
logpath = /var/mongo/logs/mongod.log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/perl -w | |
use Crypt::Rijndael; | |
use Digest::SHA; | |
my $cleartext = "Here is some data for the coding"; # 32 bytes | |
my $iv = 'a2xhcgAAAAAAAAAA'; | |
my $hash_1 = Digest::SHA->new(256); # SHA256 | |
$hash_1->add("Nixnogen"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
require 'base64' | |
require 'digest' | |
require 'openssl' | |
def encode(cryptkey, iv, cleardata) | |
cipher = OpenSSL::Cipher.new('AES-256-CBC') | |
cipher.encrypt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby; coding: utf-8 -*- | |
# | |
# naive imitation #1 of NSNotificationCenter of Cocoa Framework | |
# | |
class NotificationCenter | |
def self.default | |
@instance ||= NotificationCenter.new |