Skip to content

Instantly share code, notes, and snippets.

View alea12's full-sized avatar
🏠

alea12 alea12

🏠
View GitHub Profile
require 'json'
require 'open-uri'
require 'slack-notifier'
url = ENV["ETHERMINE_API_URL"]
json = JSON.load(open url)
message = "Unpaid Balance: #{json['unpaid'] / 10.0 ** 18} ETH \n"
json['workers'].each do |worker, status|
message << "#{worker}: #{status['hashrate']} \n"
@alea12
alea12 / crontab
Created March 28, 2017 02:50
Nginx + Let's Encrypt + Rails5 + Puma
00 05 01 * * /home/alea12/letsencrypt/letsencrypt-auto certonly --webroot -w /var/www/html -d example.net --renew-by-default && nginx -t && nginx -s reload
@alea12
alea12 / test.rb
Last active September 4, 2016 03:40
# irb(main):001:0> load "test.rb"
# => true
# irb(main):002:0> is_kaibun?("あいうえお")
# => false
# irb(main):003:0> is_kaibun?("あいういあ")
# => true
# irb(main):004:0> is_kaibun?("わたしまけましたわ")
# => true
# irb(main):005:0> is_kaibun?("abc")
# => false
def is_kaibun?(str)
# 奇数長の文字列だった場合、真ん中の文字を削除
if (str.length % 2) == 1
str = str[0, (str.length/2)] + str[((str.length/2)+1), str.length]
end
str[0, (str.length/2)] === str[str.length/2, str.length].reverse
end
@alea12
alea12 / -
Created August 15, 2016 05:09
test
require 'google_drive'
require 'open-uri'
require 'nokogiri'
session = GoogleDrive::Session.from_config('config.json')
ws = session.spreadsheet_by_key('XXXXXXXXXXXXXXXXXXXXXXXXXX').worksheet_by_title('Sheet1')
urls = [
'http://hanabi.walkerplus.com/list/ar0313/',
'http://hanabi.walkerplus.com/list/ar0313/2.html',
@alea12
alea12 / gd.rb
Created February 12, 2016 00:06
gd
require "google/api_client"
require "google_drive"
session = GoogleDrive.saved_session("config.json")
ws = session.spreadsheet_by_key("pz7XtlQC-PYx-jrVMJErTcg").worksheets[0]
# Gets content of A2 cell.
p ws[2, 1] #==> "hoge"
# Changes content of cells.
# Changes are not sent to the server until you call ws.save().
@alea12
alea12 / setup.sh
Last active March 18, 2016 07:50
setup.sh
adduser alea12
usermod -G root alea12
# disable root login
# apt tools
sudo apt-get update
sudo apt-get install -y git nginx php5-fpm php5-cli libmysqld-dev mysql-server mysql-client php5-mysql php5-intl php5-mcrypt
sudo apt-get install -y zlib1g-dev build-essential libssl-dev libreadline-dev nodejs
@alea12
alea12 / puma.rb
Created January 26, 2016 11:08
puma.rb
# Change to match your CPU core count
workers 2
# Min and Max threads per worker
threads 1, 6
app_dir = File.expand_path("../..", __FILE__)
shared_dir = "#{app_dir}/shared"
# Default to production
@alea12
alea12 / HandbrakeQSVBatch.ps1
Last active January 21, 2016 21:29
HandbrakeQSVBatch.ps1
while (1) {
net use "\\192.168.xxx.xxx\share"
$filelist = Get-ChildItem \\192.168.xxx.xxx\share\video\ -filter *.m2ts
$num = $filelist | measure
$filecount = $num.count
$i = 0;
ForEach ($file in $filelist)
{
$i++;
$oldfile = $file.DirectoryName + "\" + $file.BaseName + $file.Extension;