Skip to content

Instantly share code, notes, and snippets.

require 'digest'
require 'base64'
WD = ARGV[0]
# sha256 sha384 sha512
HASH_ALGO = "sha384"
allow_file_type = [".css", ".js"]
short_hash_length = 7
@Coro365
Coro365 / esp32_am2320_sender.ino
Created August 2, 2021 01:48
Send temperature and humidity data of am2320 from EPS32 to your influxdb server.
#include <WiFi.h>
#include <HTTPClient.h>
#include <Ticker.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_AM2320.h>
// Network
const char* ssid = "YOUR_SSID"; // 2.4GHz ONLY
const char* password = "YOUR_PASS";
const char* influxdb_addr = "http://192.168.0.210:8086";
@Coro365
Coro365 / random_cake.rb
Created July 19, 2021 03:59
Randomly select a cut cake from Ginza Cozy.
# 銀座コージーのカットケーキをランダムに選ぶ
require 'open-uri'
require 'nokogiri'
def cakes
domain = 'https://www.cozycorner.co.jp/'
url = 'https://www.cozycorner.co.jp/product/cutcake/'
charset = nil
html = URI.open(url) do |f|
@Coro365
Coro365 / waifu2x-wrapper.rb
Last active March 10, 2021 12:25
This script can process multiple files and directories with waifu2x-converter-cpp
# 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 March 9, 2021 14:49
Display home environment from influxdb in macOS menu bar.
#!/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 November 22, 2020 08:09
Backup pleroma instance
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 11:21
Download afp video
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 11:20
Download reuters video
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 April 18, 2020 16:32
Rearrange arrays naturally
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 March 28, 2020 12:49
Add a file name to images.(ImageMagick)
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