Skip to content

Instantly share code, notes, and snippets.

@kizashi1122
kizashi1122 / default.rb
Last active Feb 6, 2020
chef file to attach role to itself
View default.rb
ey_aws_key = "retrieved from dna.json"
ey_aws_secret = "retrieved from dna.json"
bash "add engine yard user to credentials" do
user 'deploy'
code <<-"EOH"
echo '[engineyard]' >> /home/deploy/.aws/credentials
echo 'aws_access_key_id=#{ey_aws_key}' >> /home/deploy/.aws/credentials
echo 'aws_secret_access_key=#{ey_aws_secret}' >> /home/deploy/.aws/credentials
EOH
View pop3_xoauth2_use_module.pl
#!/usr/bin/env perl
use v5.28;
use utf8;
use Net::POP3;
use Net::POP3::XOAuth2;
my $user = 'myaccount@example.com';
my $token = 'ya29.GltdBxoUGp4......'; # retrieve with OAuth2
@kizashi1122
kizashi1122 / pop3_xoauth.pl
Created Aug 19, 2019
pop3 xoauth2 authentication with Net::POP3
View pop3_xoauth.pl
#!/usr/bin/env perl
use v5.28;
use utf8;
use Net::POP3;
use MIME::Base64;
my $user = 'myaccount@example.com';
my $token = 'ya29.GltdBxoUGp4......'; # retrieve with OAuth2
View smtp.py
# https://www.python.ambitious-engineer.com/archives/2034
import smtplib
from email.mime.text import MIMEText
# 送受信先
to_email = "xxxxx@gmail.com"
from_email = "xxxxx@s3.spaaqs.ne.jp"
# MIMETextを作成
@kizashi1122
kizashi1122 / enum_behavior.rb
Last active Apr 27, 2019
Understanding Enumerator class of Ruby.
View enum_behavior.rb
class Response
def response_body=(enum)
enum.each {|e| puts "res: #{e}" }
end
end
def gen_stream
Enumerator.new do |yielder|
10.times do |num|
puts "stream: #{num}"
@kizashi1122
kizashi1122 / imap-client.pl
Created Feb 25, 2019
IMAP経由でメール(eml)をアップロードするスクリプト
View imap-client.pl
use v5.18;
use Mail::IMAPClient;
use File::Slurp;
# nohup perl imap-client.pl imap.example.com username password eml_dir 1> importx.log &
my $imap_host = $ARGV[0] or die $!;
my $user = $ARGV[1] or die $!;
my $pass = $ARGV[2] or die $!;
my $eml_dir = $ARGV[3] or die $!;
View parse_release.pl
use v5.18;
use Net::GitHub;
use Encode qw/encode_utf8/;
use DDP;
my @files = glob "release-*";
my %hash = ();
for my $f (@files) {
my %release = ();
View github_release.pl
use v5.18;
use Net::GitHub;
use Encode qw/encode_utf8/;
my $github = Net::GitHub->new( # Net::GitHub::V3
access_token => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
);
my $repos = $github->repos;
View rename_timestamp_part_to_its_dateheader.pl
use DateTime;
use MIME::Parser;
my $dir = shift || Cwd::getcwd();
my $count = 0;
my @array = ();
touch_emls($dir);
View split_file_evenly.pl
#!/usr/bin/env perl
#
# split data file as evenly as possible for n-fold cross validation
#
# Usage:
# ./split_file_evenly.pl data_file 10
#
# In this case, 10 training and test sets are generated.
#