This file contains 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
searchArcanas = (query, path, component, callback) -> | |
component.setState(showError: false) | |
$("#loading-modal").modal('show') | |
query ?= {} | |
query.ver = $("#data-ver").val() | |
url = $("#app-path").val() + path | |
callbacks = | |
done: (as) -> | |
callback(as, component) | |
$("#loading-modal").modal('hide') |
This file contains 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
class Fibonacci | |
class << self | |
include Enumerable | |
def each | |
(1..Float::INFINITY).lazy.each do |i| | |
yield fib(i) | |
end | |
end |
This file contains 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
https://paiza.jp/poh/enkoi | |
Ruby / CoffeeScript |
This file contains 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
# 再帰的探査 | |
def search(list, i, need, nco, maxind, mincost, limit_mem) | |
c = list[i] | |
nmem = need - c[0] | |
cost = nco + c[1] | |
return mincost if cost > mincost # すでにわかっている答えより大きいので無駄 | |
return cost if nmem <= 0 # メンバーが埋まった | |
return mincost if i >= maxind # 終端までいったが、メンバーが埋まらない | |
# 自身の効率*残り人数+現在のcostがmincostを超える |
This file contains 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
height, width = gets.split(' ').map(&:to_i) | |
# bitとして扱う | |
lines = [] | |
(1..height).each do |h| | |
lines << gets.chomp.to_i(2) | |
end | |
# 対象を解析 | |
targets = {} |
This file contains 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 | |
def read_data(count) | |
c = count.to_i | |
return if c < 0 | |
ret = [] | |
count.times do | |
s = gets | |
next unless s | |
ret << s.to_i | |
end |
This file contains 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
# encoding: utf-8 | |
require 'mail' | |
MAIL_ENCODING = 'ISO-2022-JP' | |
MYADDR = "hogehoge" | |
def send_message | |
mes = "mini来た!!" | |
m = Mail.new |
This file contains 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 | |
module Geolocation | |
def distance_to(lat, lon, mode = nil) | |
return unless (lat && lon) | |
return unless (self.respond_to?(:latitude) && self.respond_to?(:longitude)) | |
earth_distance(self.latitude, self.longitude, lat, lon, mode) | |
end | |
def distance_between(point, mode = nil) |
This file contains 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 scala.annotation.tailrec | |
object BF { | |
class Parser(val str: String) { | |
val cmap = Map( | |
">" -> 'pinc, | |
"<" -> 'pdec, | |
"+" -> 'inc, | |
"-" -> 'dec, |
This file contains 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 | |
(1..100).each do |n| | |
puts case | |
when n % 15 == 0 | |
'FizzBuzz' | |
when n % 3 == 0 | |
'Fizz' | |
when n % 5 == 0 | |
'Buzz' | |
else |