Skip to content

Instantly share code, notes, and snippets.

@sironekotoro
sironekotoro / remove_file.sh
Created July 22, 2019 06:11
40文字のファイル名を守るファイルを削除するワンライナー
ls | perl -nlE'say $_ if length $_ == 40' | xargs rm
@sironekotoro
sironekotoro / mojo_livedoor_weather.pl
Created August 4, 2019 09:25
東京と大阪の天気情報を取る
#!/usr/bin/env perl
use Mojolicious::Lite;
use HTTP::Tiny;
use JSON::PP;
my $json;
my $location_list = [ [ '東京' => '130010' ], [ '大阪' => '270000' ] ];
get '/' => sub {
my $c = shift;
@sironekotoro
sironekotoro / gcp_language_analyze_sentiment.pl
Last active August 26, 2019 04:44
Google Cloud Natural Language API をPerlで使う
use strict;
use warnings;
use utf8;
use JSON;
use HTTP::Tiny;
# Goolge Cloud Natural Language API analyzeSentiment
my $GOOGLE_API_URL
= 'https://language.googleapis.com/v1/documents:analyzeSentiment';
@sironekotoro
sironekotoro / Calc.pm
Created August 30, 2019 14:46
Mojolicious::Liteのテンプレートにオブジェクトを渡す
package Calc;
use strict;
use warnings;
sub new {
my $class = shift;
my @argv = @_;
my $self = bless { nums => \@argv }, $class;
return $self;
}
#!/usr/bin/env perl
use Mojolicious::Lite;
use HTTP::Tiny;
use JSON;
# ピザ会課題
# mojoliciousから、IFTTTのwebhookに経由でLINEを送る
# IFTTT経由でLINEにメッセージを送る処理
# IFTTT側での準備が必要
@sironekotoro
sironekotoro / get_file_over_basic_auth_http_tiny.pl
Last active September 16, 2019 13:49
HTTP::TinyでBasic認証を超える
#! /usr/bin/env perl
use strict;
use warnings;
use HTTP::Tiny;
use MIME::Base64 qw/encode_base64/;
my $url = 'BASIC認証越しにあるファイルのURL';
my $user = 'user';
my $password = 'password';
@sironekotoro
sironekotoro / fizzbuzz.go
Created September 21, 2019 07:24
GoでFizzBuzz
package main
import "fmt"
func main() {
for i := 1; i <= 100; i++ {
if i%15 == 0 {
fmt.Println("fizzbuzz")
} else if i%3 == 0 {
fmt.Println("fizz")
@sironekotoro
sironekotoro / fizzbuzz-use-switch.go
Created September 22, 2019 03:33
Goのswitch文でfizzbuzz
package main
import "fmt"
func main() {
for i := 1; i <= 100; i++ {
switch {
case i%15 == 0:
fmt.Println("fizzbuzz")
case i%3 == 0:
@sironekotoro
sironekotoro / myapp.pl
Created October 21, 2019 02:02
Mojoliciousのgetで呼ぶサブルーチンリファレンスを分解してみる
#!/usr/bin/env perl
use Mojolicious::Lite;
# 本来の書き方
# get '/' => sub {
# my $c = shift;
# $c->render(template => 'index');
# };
# サブルーチンリファレンスを作る
// ==UserScript==
// @name Hello, World(Yahoo)
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.yahoo.co.jp/
// @grant none
// ==/UserScript==