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 / automation_bath.rb
Last active Nov 8, 2018
Automatically operate the bath light and fan
View automation_bath.rb
require "influxdb"
def current_value(field,location,device="none")
host = 'hostname.local'
database = 'home-sensor'
influxdb = InfluxDB::Client.new database,:host => host
# query
result = influxdb.query "select value from #{field} where location='#{location}' order by desc limit 1 tz('Japan')"
@Coro365
Coro365 / iTunes.sh
Last active Nov 16, 2019
This script iTunes(Music.app) play, pause, next track, back track and return state.
View iTunes.sh
#!/bin/sh
# @(#) This script Music.app play, pause, next track, back track and return state.
# @(#) Support macOS Catalina version.20191116
if [ -z "$1" ]; then
echo "Argument is missing!"
exit 1
elif [ "$1" == "play" ]; then
music_run=`osascript -e 'application "Music" is running'`
@Coro365
Coro365 / screen.sh
Created Nov 5, 2018
This script will turn on / off the screen of the Mac or run the screen saver and return screen status
View screen.sh
#!/bin/sh
# @(#) This script will turn on / off the screen of the Mac or run the screen saver.
# @(#) Argument:on, off, saver and display_status. Support macOS Mojave version.20181016
if [ -z "$1" ]; then
echo "Argument is missing!"
exit 1
elif [ "$1" == "on" ]; then
caffeinate -u -t 1
@Coro365
Coro365 / image_trim.rb
Created Nov 5, 2018
Delete the lower 14 pixels of the image
View image_trim.rb
path = ARGV[0]
Dir.glob("#{path}/*") do |file|
next unless file.index(/jpeg$|jpg$|png$/)
# get image pixel size
width, hight = `identify -format "%w %h" #{file}`.split(" ")
new_file = File.basename(file) + "-trimed" + File.extname(file)
# trim
@Coro365
Coro365 / button.rb
Last active Nov 5, 2018
Emit IR signal when button is pushed
View button.rb
require "influxdb"
require "open3"
READ_SW_1_PIN = 1
SW_1_PIN = 2
LED_1_PIN = 3
INFLUXDB_ADRR = "http://hostname.local:8086/write?db=home-sensor"
LOCATION = 3
@Coro365
Coro365 / nas_status.sh
Created Aug 17, 2018
Send readynas cpu temperature, fan speed, disk temperature to influxdb
View nas_status.sh
# initialize
INFLUXDBADRR="http://hostname.local:8086/write?db=server"
hostname=`hostname | tr '[:upper:]' '[:lower:]'`
cpu_name="Marvell\ Armada\ 370/XP"
fan_name="main\ fan"
# get cpu temperature and fan RPM
cpu_temp=`sensors | grep CPU | sed -r "s/CPU.*?\+([0-9\.]*?)°C/\1/" | sed -e "s/[ \t]*$//"`
fan_rpm=`sensors | grep System | sed -r "s/System.*?\s([0-9]+)\ RPM.*?$/\1/"`
@Coro365
Coro365 / waifu2x.rb
Last active Jul 14, 2018
This script can process multiple files and directories with waifu2x-converter-cpp
View waifu2x.rb
require "ruby-progressbar"
require "shellwords"
require "find"
include Find
WAIF2X_CONVERTER_CPP_DIR = __dir__
WAIF2X_CONVERTER_CPP = WAIF2X_CONVERTER_CPP_DIR + "/waifu2x-converter-cpp"
def waifu2x
files = get_file_list(ARGV, ["jpeg","jpg"])
@Coro365
Coro365 / animetick_counter.rb
Created Nov 10, 2017
watch anime count in animetick.net
View animetick_counter.rb
require "pp"
require "open-uri"
require "nokogiri"
@userid = "Coro365"
@crawl_page_number = 26
@animetick_subscribes = Array.new
def animetick_crawl(page_number)
url = "http://animetick.net/users/#{@userid}?page=#{page_number}"
@Coro365
Coro365 / auto_encode.rb
Last active Oct 25, 2017
Encode the recorded m2ts file
View auto_encode.rb
require 'fileutils'
require 'shellwords'
WD = File.dirname(File.expand_path(__FILE__))
TSDIR = "path"
MP4DIR = "path"
def recodeing? (ts)
s1 = File.size(ts)
sleep 1
@Coro365
Coro365 / reg_rename.rb
Last active Aug 24, 2016
file name edit in regular expression
View reg_rename.rb
require "find"
Dir[File.dirname(__FILE__) + "/com_lib/*.rb"].each {|file| require file}
def yesno?(ms = "")
blue "#{ms}\nPlease press y/n\n> "
i = STDIN.gets
if /^y$|^Y$|^yes$|^Yes$|^YES$/ =~ i
return true
elsif /^n$|^N$|^no$|^No$|^NO$/ =~ i
You can’t perform that action at this time.