Skip to content

Instantly share code, notes, and snippets.

Coro Coro365

Block or report user

Report or block Coro365

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Coro365
Coro365 / afp_video.rb
Created May 21, 2020
Download afp video
View afp_video.rb
require 'open-uri'
require 'fileutils'
def add_log(recode)
recode = [Time.now, recode + "\n"].join(",\s")
File.write(File.join(__dir__, 'downlod.log'), recode, mode: 'a')
end
def load_log
File.open(File.join(__dir__, 'downlod.log')).read
@Coro365
Coro365 / reuters_video.rb
Last active May 21, 2020
Download reuters video
View reuters_video.rb
require 'open-uri'
require 'fileutils'
module Natural_sort
def natural_sort
zero_length = max_num_length_of(self)
number_formated_names = self.map do |data|
name_array = data.scan(/(\D*)(\d+)(\D*)/).flatten.reject(&:empty?)
name_array = [data] if name_array.empty?
@Coro365
Coro365 / add_filename.rb
Created Mar 28, 2020
Add a file name to images.(ImageMagick)
View add_filename.rb
def get_files_from_ARGV(recursive: true)
files = ARGV.map do |path|
path = File.expand_path(path)
if File.directory?(path)
if recursive
Dir.glob(File.join(path, '**', '*'))
else
Dir.glob(File.join(path, '*'))
end
@Coro365
Coro365 / add_margin_for_square.rb
Last active Mar 28, 2020
Adding margins to an image to make it square. (ImageMagick)
View add_margin_for_square.rb
def add_margin_for_square
images = get_files_from_ARGV
images.each_with_index do |file, i|
puts("[#{i}/#{images.size}]\t#{file}")
size = get_width_hight(file)
margin = margin(size)
if margin.first.zero?
puts("#{file} is square")
# TODO: create file-squre.jpg
@Coro365
Coro365 / hatena-fotolife-donwloder.rb
Created Mar 15, 2020
Download photos from f.hatena.ne.jp
View hatena-fotolife-donwloder.rb
require 'open-uri'
require 'fileutils'
def set_username
return ARGV[0] if ARGV[0]
raise('Specify the user name in the argument.')
end
def get_photo_urls
@Coro365
Coro365 / README.md
Last active Mar 7, 2020
Show current weather icon.
View README.md

Usage example DarkSky and Skycon

Show current weather icon.

Data Flow

  1. DarkSky API
  2. post_darksky_to_influxdb.rb
  3. influxdb
  4. current_weather.html

Usage

@Coro365
Coro365 / 2019_ncov_json.rb
Created Feb 6, 2020
Json format for 2019-nCoV from Google Spread Sheets
View 2019_ncov_json.rb
# 2019_ncov_json.rb create json format for 2019-nCoV from Google Spread Sheets
# Thanks
# https://docs.google.com/spreadsheets/d/1wQVypefm946ch4XDp37uZ-wartW4V7ILdg-qYiDXUHM/htmlview?usp=sharing&sle=true
# https://gisanddata.maps.arcgis.com/apps/opsdashboard/index.html#/bda7594740fd40299423467b48e9ecf6
require 'open-uri'
require 'json'
require 'pp'
module GoogleSpreadSheet
@Coro365
Coro365 / natural_sort.rb
Last active Apr 18, 2020
Rearrange arrays naturally
View natural_sort.rb
module Natural_sort
def natural_sort
zero_length = max_num_length_of(self)
number_formated_names = self.map do |data|
name_array = data.scan(/(\D*)(\d+)(\D*)/).flatten.reject(&:empty?)
name_array = [data] if name_array.empty?
number_formated_name_array = name_array.map do |e|
e.match(/\d/) ? format("%0#{zero_length}d", e.to_i) : e
@Coro365
Coro365 / aterm-router-reboot.sh
Created Dec 2, 2019
Reboot aterm router (ATERM-DD3B55)
View aterm-router-reboot.sh
#!/bin/sh
# @(#) Reboot aterm router.
# @(#) shell script version: 20191202
# @(#) Test router is ATERM-DD3B55 (FW: 1.8.56)
user=YOUR_USERNAME
pass=YOUR_PASSWORD
domain=http://192.168.0.1
path=index.cgi/reboot_main_set
@Coro365
Coro365 / chapter-for-youtube-setlist.rb
Created Sep 1, 2019
Generate chapter.ini file for youtube comment setlist
View chapter-for-youtube-setlist.rb
# How to
# Meke video file and comment file and video length
# ex. ~/video.mp4 and ~/video.txt
# Run `ruby chapter-for-youtube-setlist.rb 1:23:23 video.txt`
# Generated ~/video.ini
# Run `ffmpeg -i ふろうふしのうた-Zw4bukluYcI.mp4 -i ふろうふしのうた-Zw4bukluYcI.ini -map_metadata 1 -c copy /ふろうふしのうた-Zw4bukluYcI-add-cap.mp4`
def to_ms(time)
t = time.split(":").map { |e| e.to_i }
s, m, h = t.reverse
You can’t perform that action at this time.