Skip to content

Instantly share code, notes, and snippets.

View odaillyjp's full-sized avatar

Suguru Odai odaillyjp

View GitHub Profile
@odaillyjp
odaillyjp / hunting_monsters.rb
Last active August 29, 2015 13:57
オフラインリアルタイムどう書く #14 の問題を解いた http://nabetani.sakura.ne.jp/hena/ord14linedung/
require 'rspec'
module HuntingMonsters
class Player
attr_reader :weapons
def initialize
@weapons = []
end
@odaillyjp
odaillyjp / xy_sort.rb
Created March 13, 2014 04:05
オフラインリアルタイムどう書く #7 の問題を解いた http://nabetani.sakura.ne.jp/hena/ord7xysort/
def sort_with_other_row(table, idx)
row = table[idx]
# [ソート前のカラムのインデックス値, ...]
ex_sort_idxs = row.map
.with_index { |e, idx| [e, idx] }
.sort_by
.with_index { |cell, idx| [cell.first, idx] }
.map(&:last)
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>カレーのレシピ</title>
<meta name="description" content="誰でもできる、美味しいカレーの作り方です。旦那も息子もこのカレーが大好物。">
</head>
<body>
<header>
<h1>カレーのレシピ</h1>
@odaillyjp
odaillyjp / odai.md
Created June 14, 2014 12:01
よちよち.rb 過去の宿題

思い入れのある Git コマンド

  • git diff
  • git grep

定番!

宿題のおまけ

よく使っているコマンドを調べてみました。(とりあえず トップ20 だけ抜き出し)

$ egrep -o ';g(?:it)?\s\w*' ~/.zsh_history | cut -f 2 -d ' ' | sed -e "s/^co$/checkout/" -e "s/^st$/status/" -e "s/^lg/log/" | sort | uniq -c | sort -r
require 'minitest'
require 'minitest/autorun'
require 'pry'
MAX_WIDTH = 5
MAX_HEIGHT = 5
SENTINEL_CHER = -1
def solve(str)
init_numbers_field(str)
@odaillyjp
odaillyjp / remi.rb
Last active August 29, 2015 14:04
remi リポジトリを入れるレシピ
include_recipe 'yum'
yum_repository 'remi' do
baseurl "http://rpms.famillecollet.com/enterprise/#{node[:platform_version].to_i}/remi/#{node[:kernel][:machine]}/"
enabled false
gpgkey 'http://rpms.famillecollet.com/RPM-GPG-KEY-remi'
action :create
end
@odaillyjp
odaillyjp / nginx.rb
Last active August 29, 2015 14:04
CentOS に Nginx の最新安定版を入れるレシピ
include_recipe 'yum'
# リポジトリは http://wiki.nginx.org/Install#Official_Red_Hat.2FCentOS_packages を参考
yum_repository 'nginx' do
baseurl "http://nginx.org/packages/centos/#{node[:platform_version].to_i}/#{node[:kernel][:machine]}/"
gpgcheck false
enabled false
action :create
end
@odaillyjp
odaillyjp / yochiyochi.md
Last active August 29, 2015 14:25
よち合宿

2015/09/04(金)〜2015/09/06(日)の期間でよちよち.rb開発合宿を開催します。 普段は忙しくてなかなか取り込むことができなかったことを各自持ち寄って、いつもとは違う環境でもくもくと取り組みに行きませんか?

よちよち.rbとは

詳細

2015/09/04(金)〜 2015/09/06(日)

集合場所: 20:30 JR品川駅

@odaillyjp
odaillyjp / intersection.rb
Created January 9, 2013 11:45
オフラインリアルタイムどう書く#6 参考問題を解いた。 http://nabetani.sakura.ne.jp/hena/ord6lintersection/
#coding: utf-8
class Intersection
def to_square(p, q)
xs = [p[0], q[0]].min.to_i
xe = [p[0], q[0]].max.to_i
ys = [p[1], q[1]].min.to_i
ye = [p[1], q[1]].max.to_i
pos = Array.new(10, 0)
line = (xs..xe).inject(0) {|a, i| a + (2**i)}
(ys..ye).each {|y| pos[y] = line}
{-# OPTIONS -Wall #-}
-- Not,And,Or,Xor を独自実装
myAnd :: Bool -> Bool -> Bool
myAnd True True = True
myAnd _ _ = False
myNot :: Bool -> Bool
myNot False = True
myNot _ = False