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
defmodule Product do | |
defstruct name: "", price: 0 | |
def fmap(func, %Product{ name: name, price: price }) do | |
{ n_name, n_price } = func.(name, price) | |
%Product{ name: n_name, price: n_price } | |
end | |
end | |
stones = %Product{ name: "大人気!その辺に落ちていた石の詰め合わせ", price: 2000 } | |
summer_sale = Product.fmap(fn name, price -> { "[SummerSale]: #{name}", price - 200 } end, stones) |
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
git branch | grep -ve " master$" | xargs git branch -D |
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 functools | |
class BloomFilter: | |
def __init__(self, filter_size): | |
self.filter_size = filter_size | |
self.bloom_filter = [0 for _ in range(filter_size)] | |
def exist_v(self, val): | |
indexes = self.n_hash(val) | |
for index in indexes: |
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 Iterator | |
def next | |
raise NotImplementedError.new("#{self.class}##{__method__} が実装されていません") | |
end | |
def has_next | |
raise NotImplementedError.new("#{self.class}##{__method__} が実装されていません") | |
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
# Adapte | |
module Adaoter | |
class Queue | |
attr_reader :queue | |
def initialize | |
@queue = [] | |
end | |
def enqueue(val) |
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 Sward | |
attr_reader :options | |
def initialize | |
@options = {} | |
end | |
def cost | |
raise NotImplementedError.new("#{self.class}##{__method__} が実装されていません") | |
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
# Your code here! | |
class Notify | |
def exec(*data) | |
raise NotImplementedError.new("#{self.class}##{__method__} が実装されていません") | |
end | |
end | |
class User< Notify | |
def exec(*data) | |
puts "send to User #{data}" |
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 StringArray | |
attr_reader :s_array | |
def initialize | |
@s_array = '' | |
end | |
def push(v) | |
@s_array += "#{v}SPLIT" | |
self | |
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
use std::collections::HashMap; | |
fn main(){ | |
let field_name = String::from("Favorite color"); | |
let field_value = String::from("Blue"); | |
let mut map = HashMap::new(); | |
map.insert(&field_name, field_value); | |
let score = map.get(&field_name); | |
match score { |
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
/* プレイヤー情報 */ | |
CREATE TABLE IF NOT EXISTS players ( | |
player_id SERIAL PRIMARY KEY, | |
name VARCHAR(50) NOT NULL, | |
created_at TIMESTAMP NOT NULL, | |
updated_at TIMESTAMP NOT NULL, | |
name_changed_at TIMESTAMP NOT NULL, | |
last_loggined_at TIMESTAMP NOT NULL | |
); |