Skip to content

Instantly share code, notes, and snippets.

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;
require 'twitter'
require 'active_record'
ActiveRecord::Base.establish_connection(
adapter: 'mysql2',
host: 'localhost',
username: 'root',
database: 'twitter',
# For emoji
charset: 'utf8mb4',
@alea12
alea12 / deleted_tweets.rb
Created December 27, 2015 08:55
deleted_tweets.rb
require 'twitter'
require 'big_query'
# Twitter Gem のバグを回避
class HTTP::URI
def port
443 if self.https?
end
end
@alea12
alea12 / test.rb
Created December 27, 2015 07:10
test.rb
require 'big_query'
require 'twitter'
require 'pp'
class HTTP::URI
def port
443 if self.https?
end
end