Skip to content

Instantly share code, notes, and snippets.

View missingno15's full-sized avatar

Kenneth Uy missingno15

  • Tokyo
  • 02:21 (UTC +09:00)
View GitHub Profile
@missingno15
missingno15 / reduce.rb
Created April 22, 2019 09:53
reduceのいろんな使い方
# require "pry"
puts [1, 2, 3].inspect
result_1 = [1, 2, 3].reduce do |sum, n|
sum + n
end
puts result_1.inspect
puts
require "csv"
require "base64"
require "typhoeus" # HTTP toolkit that is backed by CuRL
require "pry" # debugger
require "json" # JSON parser that comes with standard Ruby library
require "oj" # JSON parser but uses C extensions
keywords = []
# {
@missingno15
missingno15 / article.cc
Created November 26, 2017 14:54
Demonstration of Dynamic Binding through Strategy Pattern in C++
#include <iostream>
#include <string>
#include <vector>
#include "article.h"
#include "formattable.h"
Article::Article(std::string t, std::vector<std::string> te) {
title = t;
text = te;
};
@missingno15
missingno15 / showroom-watch
Created October 9, 2017 18:05
script that i use to record showroom streams
#!/usr/bin/env ruby
abort("This script requires Ruby 2.4 or higher") if RUBY_VERSION.to_f < 2.4
# Expects command to be run like
# `showroom-watch https://www.showroom-live.com/48_Orin_Mutou`
if ARGV[0] && /^https:\/\/www\.showroom-live\.com\/.*$/.match?(ARGV[0])
url = ARGV[0]
else
abort("You must give a url as an argument (e.g. `./showroom-watch https://www.showroom-live.com/48_NAKAI_RIKA`)")
@missingno15
missingno15 / muteaudio.rb
Created June 8, 2017 02:11
Mute the audio of certain parts of a video with ffmpeg via Ruby CLI script
require "optparse"
require "active_support/all"
options = []
input = nil
output = nil
has_two_timestamps= ->(arg) {
if arg.split(",").count == 2
nil
@missingno15
missingno15 / showroom_bot.rb
Created February 5, 2017 22:18
showroom bot
require "active_support/core_ext/numeric/time"
require "capybara"
require "capybara/poltergeist"
require "dotenv"
require "logger"
require "json"
require "pry"
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, {js_errors: false})
@missingno15
missingno15 / parse_album_id.rb
Created June 4, 2015 08:46
parse album ids from attachments
def parse_album_id(type, url)
if type == "photo"
album_id = url.split('/')[-2]
elsif type == "album"
album_id = url.split('/')[-1].split('?')[0]
else
raise "The type, \"#{type}\" is not supported, #{}"
end
end
@missingno15
missingno15 / nothing_is_something.rb
Last active August 29, 2015 14:20
Code you can run which mimics the "external framework API" that Sandi Metz talks about in her BathRuby 2015 - Nothing is Something talk https://youtu.be/9lv2lBq6x4A
class Animal
DATABASE = [
{ id: 1, name: "Mockingbird" },
{ id: 2, name: "Pheasant" },
{ id: 3, name: "Duck" },
{ id: 4, name: "Platypus" },
{ id: 5, name: "Penguin" },
{ id: 6, name: "Peacock" },
{ id: 7, name: "Hummingbird" },
{ id: 8, name: "Owl" }
module ModuleA
class ClassInsideModule
end
end
class ClassA
class ClassInsideClass
end
end
require 'csv'
require 'pry'
// external csv file has headers: name_eng, name_jpn, team
// EXAMPLE:
// name_jpn | name_eng | team
// 宮脇咲良 | Miyawaki Sakura | KIV
module Janken