Skip to content

Instantly share code, notes, and snippets.

@rainyjonne
rainyjonne / fizz_buzz.rb
Last active September 24, 2020 09:07
fizz_buzz excercise 109078513
# frozen_string_literal: true
## write your fizzbuzz method in this file
# see http://en.wikipedia.org/wiki/Fizz_buzz for details on FizzBuzz game
def fizzbuzz(size, &decorate)
arr = Array.new(size) { |i| i + 1 }
fizz_buzz_arr = arr.map do |item|
if (item % 15).zero? then 'FizzBuzz'
@rainyjonne
rainyjonne / tsv_to_yml.rb
Last active October 5, 2020 02:18
tsv_to_yml.rb 109078513
# frozen_string_literal: true
require 'csv'
require 'yaml'
# check file is tsv or not
def tsv?(filename)
return raise('File not exist!') unless File.exist?(filename.to_s) # No file!
content = File.read(filename.to_s, encoding: 'utf-8')
@rainyjonne
rainyjonne / yml_to_tsv.rb
Last active October 5, 2020 02:18
yml_to_tsv.rb 109078513
# frozen_string_literal: true
require 'csv'
require 'yaml'
# check file is tsv or not
def yml?(filename)
return raise('File not exist!') unless File.exist?(filename.to_s) # No file!
content = File.read(filename.to_s, encoding: 'utf-8')
@rainyjonne
rainyjonne / short_string_packer.rb
Last active March 7, 2021 13:56
short_string_packer.rb
# frozen_string_literal: true
# Packs/Unpacks a String to and from an Integer
class ShortStringPacker
## Packs a short string into a Integer
# Arguments:
# str - String object
# Returns: a Integer object
def self.pack(str)
# IMPLEMENT THIS METHOD