Skip to content

Instantly share code, notes, and snippets.

View rakuishi's full-sized avatar
🏠
Working from home

OCHIISHI Koichiro rakuishi

🏠
Working from home
View GitHub Profile
@rakuishi
rakuishi / analytics.rb
Created February 18, 2016 06:28
Google Analytics API Client with ruby
# 参考
# * https://developers.google.com/google-apps/calendar/quickstart/ruby
# * https://github.com/google/google-api-ruby-client/blob/master/samples/cli/lib/samples/analytics.rb
# * https://gist.github.com/rakuishi/5010ee819260cdd32a15
# $ gem install google-api-client
require 'googleauth'
require 'googleauth/stores/file_token_store'
require 'google/apis/analytics_v3'
require 'fileutils'
git init
git remote add origin git@github.com:username/repo.git
git fetch
git branch master origin/master
git reset --mixed FETCH_HEAD
git branch -vv
#!/bin/sh
PROJECT=sample
DATABASE=sample
case $1 in
"start")
docker rm -f ${PROJECT}
docker build -t ${PROJECT} .
docker rmi $(docker images | awk '/^<none>/ { print $3 }')
@rakuishi
rakuishi / gist:a3d6d392f66220117eed
Last active March 23, 2016 08:26
Rails Command
./bin/rails s
./bin/bundle install --path vendor/bundle
./bin/bundle exec rails g rspec:install
./bin/bundle exec rspec
./bin/rails runner -e development SampleWorker.task
curl -H "X-Access-Token: eyJ..." http://localhost:3000/api/v1/goods
curl -H "X-Access-Token: eyJ..." -X POST -d "" http://localhost:3000/api/v1/goods/1
curl -H "X-Access-Token: eyJ..." -X POST -d count=1207 http://localhost:3000/api/v1/goods/1
php -S localhost:8080 -t public_html/
require 'sqlite3'
require 'fileutils'
require 'uri'
require 'net/http'
require 'json'
DIR = 'app/src/main/assets'
FILENAME = 'earthview.db'
def get_path(dir, filename)
@rakuishi
rakuishi / convert_html_to_markdown.php
Last active September 24, 2016 00:42
WordPress で書かれた記事を Markdown 変換する(物理)
<?php
$dir = './content/archives/';
$filenames = [];
if ($handle = opendir($dir)) {
while (false !== ($filename = readdir($handle))) {
if ($filename != "." && $filename != ".." && strtolower(substr($filename, strrpos($filename, '.') + 1)) == 'md') {
$filenames[] = $filename;
}
}
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open('http://www.onsen.ag'))
doc.xpath('//section[@id="movieList"]//div[@class="listWrap"]//ul[@class="clr"]//li').each do |node|
p node.xpath('h4[@class="listItem"]').inner_text
p node.xpath('p[@class="thumbnail listItem"]//img').attribute('src').text
break
end
@rakuishi
rakuishi / gist:c36a03fad75d96334856607d406a7020
Created June 8, 2016 01:20
Export wordpress's tags data to csv
$ mkdir backup
$ chmod 777 backup
$ mysql -u root
> USE [DATABASE_NAME];
> SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('post_tag') INTO OUTFILE "/backup/post_tag.csv" FIELDS TERMINATED BY "," ENCLOSED BY "\"" LINES TERMINATED BY "\n";
$ htpasswd -cb .htpasswd username password