Skip to content

Instantly share code, notes, and snippets.

@Coro365
Coro365 / waifu2x-wrapper.rb
Last active Mar 10, 2021
This script can process multiple files and directories with waifu2x-converter-cpp
View waifu2x-wrapper.rb
# Dipendency waifu2x and imagemagic
require 'Open3'
require 'fileutils'
require 'ruby-progressbar'
require "#{__dir__}/get_files_from_ARGV.rb"
require "#{__dir__}/natural_sort.rb"
include Natural_sort
@Coro365
Coro365 / HomeEnv.1m.rb
Last active Mar 9, 2021
Display home environment from influxdb in macOS menu bar.
View HomeEnv.1m.rb
#!/usr/bin/env ruby
# coding: utf-8
# <bitbar.title>HomeEnv</bitbar.title>
# <bitbar.version>v0.1</bitbar.version>
# <bitbar.author>Coro365</bitbar.author>
# <bitbar.author.github>Coro365</bitbar.author.github>
# <bitbar.desc>Display home environment from influxdb</bitbar.desc>
# <bitbar.image></bitbar.image>
# <bitbar.dependencies>ruby, influxdb</bitbar.dependencies>
@Coro365
Coro365 / pleroma-backup.sh
Created Nov 22, 2020
Backup pleroma instance
View pleroma-backup.sh
local_path="/home/pi/Documents/pleroma-backup"
remote="zunda"
remote_path="/Users/coro/Documents/pleroma-backup"
today=`date "+%Y%m%d-%H%M%S"`
pgdp_path=""$local_path"/plbk-"$today".pgdump"
sftp_path=""$local_path"/sftp.bat"
echo "Backup pg"
@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 / 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 / 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