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 perl | |
| use strict; | |
| use warnings; | |
| # クロージャの実装方法 | |
| # count_one()とcount_so_far()は$countに束縛されたクロージャ | |
| { | |
| my $count = 0; | |
| sub count_one { ++$count } |
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 | |
| 101.times do |i| | |
| if i%3 == 0 && i%5 == 0 | |
| puts "fizzbuzz" | |
| elsif i%3 == 0 | |
| puts "fizz" | |
| elsif i%5 == 0 | |
| puts "buzz" | |
| else |
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
| ruby -e '(1..100).to_a.map{|i|i%15<1?"fizzbuzz":i}.map{|i|i%5==0?"fizz":i}.map{|i|i%3==0?"buzz":i}.tap{|i|puts i}' |
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 perl | |
| package Jyanken; | |
| use warnings; | |
| use strict; | |
| use 5.010; | |
| my @num_to_str = qw(g c p); | |
| my @num_to_handname = ("グー", "チョキ", "パー"); | |
| my %str_to_num = ( |
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
| `mkdir -p result` | |
| Dir.glob("#{ARGV[0]}/*.kif") do |fn| | |
| File.open(fn, "r") do |f| | |
| File.open("result/#{File.basename(fn)}","w") do |o| | |
| o.puts(f.read.gsub("\r\r\n","\r\n")) | |
| end | |
| end | |
| end | |
| `rm ARGV[0]/*` | |
| `cp result/* #{ARGV[0]}` |
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
| # -*- coding: utf-8 -*- | |
| ####################################### | |
| # 将棋の棋譜でーたべーすのidのリスト | |
| # を使って棋譜をぶっこぬくスクリプト | |
| ####################################### | |
| require 'open-uri' | |
| require 'nkf' | |
| require 'nokogiri' | |
| File.open("./kid.list","r") do |f| |
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
| # -*- coding: utf-8 -*- | |
| # CSA形式の棋譜を表すクラス | |
| class CsaRecord | |
| Sente = true | |
| Gote = false | |
| attr_accessor :file | |
| def initialize( *args ) | |
| option = args.pop | |
| case option |
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
| var http = require('http'); | |
| http.get( {host:"google.com"} ,function(res){ | |
| console.log(res.headers); | |
| }); | |
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
| var http = require('http'); | |
| // こうインデントさせたいのに | |
| var s1 = http.createServer(function(req, res){ | |
| res.end("hello world"); | |
| }); | |
| // こうなってしまう!! | |
| var s2 = http.createServer(function(req, res){ | |
| res.end("hello world"); |
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
| ;; インデントの関数の再設定 | |
| (add-hook 'js2-mode-hook | |
| #'(lambda () | |
| (require 'js) | |
| (setq js-indent-level 4 | |
| js-expr-indent-offset 4 | |
| indent-tabs-mode nil) | |
| (set (make-local-variable 'indent-line-function) 'js-indent-line))) |