Skip to content

Instantly share code, notes, and snippets.

View ywindish's full-sized avatar
🐈

Yamako ywindish

🐈
View GitHub Profile
@ywindish
ywindish / schedule.rb
Last active June 21, 2023 07:12
Mastodonに毎日ランダムな時間で予約投稿するbot
# crontab とかで 0:00 に実行するといい感じ
# encoding: utf-8
require 'mastodon'
require 'date'
message = "らんだむに投稿されるよ"
url = "https://mastodon.example.com"
token = 'xxxxxx'
@ywindish
ywindish / delete_scheduled_status.md
Created December 7, 2021 09:21
curl で Mastodon の予約投稿を削除する
  • mastodon.example は適当な Mastodon サーバ
  • xxxxx はAPIアクセストークン

予約投稿のリストを得る

curl https://mastodon.example/api/v1/scheduled_statuses -H 'Authorization: Bearer xxxxx`

指定したIDの予約投稿を消す (仮に 123 とする)

@ywindish
ywindish / keybase.md
Created January 4, 2021 14:13
for keybase

Keybase proof

I hereby claim:

  • I am ywindish on github.
  • I am yamako (https://keybase.io/yamako) on keybase.
  • I have a public key ASByHnN_BuC5uqi_ZuK2WcN6MDzLNuzt67VIBdKigyv3Qwo

To claim this, I am signing this object:

@ywindish
ywindish / image_post_at_random.rb
Last active February 9, 2021 02:20
Images in folder be posted to Mastodon instance at random
require 'mastodon' # https://github.com/tootsuite/mastodon-api
message = '#hashtag'
pattern = '/path/to/image_files/*.jpg'
path = Dir.glob(pattern).sample
client = Mastodon::REST::Client.new(base_url: 'https://fedibird.com', bearer_token: ENV['MASTODON_TOKEN'])
media = client.upload_media(File.new(path))
@ywindish
ywindish / gist:af8580973ca9487c25c78d338a4285bf
Created April 10, 2019 06:01
Perl one-liner: Unicode code point converted to a character
# perl -MEncode -e 'my $str="\x{4ee4}";print Encode::encode("utf-8", $str);print "\n"'
# => 令
# perl -MEncode -e 'my $str="\x{f9a8}";print Encode::encode("utf-8", $str);print "\n"'
# => 令
@ywindish
ywindish / 2file_unique.pl
Created July 13, 2017 03:01
2ファイルのうちお互いにしか無い行を抽出する
#!/usr/bin/env perl
# 2ファイルのうちお互いにしか無い行を抽出します。
#
use strict;
use warnings;
use utf8;
use feature 'say';
my $file_left = './left.txt';
my $file_right = './right.txt';
@ywindish
ywindish / line_notifiy_sample.pl
Last active May 7, 2018 08:59
LINE Notify sample code
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use LWP::UserAgent;
use Encode;
my $ua = LWP::UserAgent->new;
my $res = $ua->post(
'https://notify-api.line.me/api/notify',
@ywindish
ywindish / teian_reader.pl
Last active October 13, 2016 06:37
TeianReader
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use LWP::UserAgent;
use HTML::TreeBuilder;
use Encode;
use Data::Dumper;
my $url_base = 'http://hiroba.dqx.jp';
@ywindish
ywindish / geoip.pl
Created June 15, 2016 09:05
GeoIPをつかってIPアドレスから国コードを引く
#!/usr/bin/env perl
use strict;
use warnings;
use Geo::IP;
my $ipaddr = $ARGV[0] || die "usage: geoip.pl <ip_addr>";
my $gi = Geo::IP->open("/usr/local/share/GeoIP/GeoIP.dat", GEOIP_STANDARD);
my $country = $gi->country_code_by_addr($ipaddr);
print $ipaddr." 's country is ".$country."\n";
@ywindish
ywindish / gist:2d4ea86058c1511be482
Created September 20, 2015 14:12
index.html?hoge というファイル名を hoge に一括置換するPerlワンライナー
perl -e 'while(<index.html*>) { ($new = $_) =~ s/index\.html\?(.*)$/$1/; rename $_, $new }'