Skip to content

Instantly share code, notes, and snippets.

View nikukyugamer's full-sized avatar
🍣
🍻

Osamu Takiya nikukyugamer

🍣
🍻
View GitHub Profile
@nikukyugamer
nikukyugamer / get_twitter_favorite_list.rb
Created February 19, 2017 13:54
Get someone's Twitter favorite list
require "twitter"
client = Twitter::REST::Client.new do |config|
config.consumer_key = "YOUR_CONSUMER_KEY"
config.consumer_secret = "YOUR_CONSUMER_SECRET"
config.access_token = "YOUR_ACCESS_TOKEN"
config.access_token_secret = "YOUR_ACCESS_SECRET"
end
screen_name = target_screen_name
@nikukyugamer
nikukyugamer / Vagrantfile
Created April 30, 2017 08:07
my default Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@nikukyugamer
nikukyugamer / ruboty_original_class.rb
Last active December 9, 2017 22:44
ruboty original class
module Ruboty
module Handlers
class Whoami < Base
on(
/who am i\?/i,
name: "whoami",
description: "Answer who you are",
)
def whoami(message)
@nikukyugamer
nikukyugamer / yaml_to_json.rb
Last active December 9, 2017 22:42
YAML to JSON by Ruby
require 'yaml'
require 'json'
yaml = YAML.load_file('abstract.yml')
json = JSON.pretty_generate(yaml)
@nikukyugamer
nikukyugamer / search_bocchan.rb
Created October 19, 2017 02:45
search specific image parts in entire image by ruby-opencv
require 'opencv'
include OpenCV
target_image = CvMat.load('search_target.png')
original_image = CvMat.load('original.jpg')
matching_result = original_image.match_template(target_image, :sqdiff)
puts "マッチング画像の元画像での座標の始点は次のとおりです"
puts "x: #{matching_result.min_max_loc[2].x}, y: #{matching_result.min_max_loc[2].y}"
@nikukyugamer
nikukyugamer / apache2_config.conf
Last active October 29, 2017 12:05
mount any directory on Apache 2
# place /etc/apache2/sites-enabled/config_name_as_you_like.conf
# in this case, public directory is /mnt/hogehoge/apache2
# and invalidate -> /etc/apache2/sites-available/000-default.conf
<VirtualHost *:20080> # set any port number
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
@nikukyugamer
nikukyugamer / check_last_modified_at.rb
Created November 1, 2017 04:30
check last modified datetime about web server object
require 'mechanize'
def last_modified_at
agent = Mechanize.new
page = agent.get('http://img.amiami.jp/images/b/used_h.jpg') # TODO: SHOULD NOT BE HARD CORDING
last_modified_gmt = page.header['last-modified']
last_modified_jst = Time.parse(last_modified_gmt).getlocal
end
puts last_modified_at #=> 2017-10-27 17:27:14 +0900
@nikukyugamer
nikukyugamer / convert_pdf_to_sexy_format.sh
Last active December 9, 2017 22:41
Convert PDF file to PNG, JPEG, TEXT and HTML file
#!/bin/bash
pdftoppm -png pdf_file.pdf output_filename
pdftoppm -jpeg pdf_file.pdf output_filename
pdftotext -layout pdf_file.pdf output_filename.txt
pdftotext -htmlmeta -layout pdf_file.pdf output_filename.html
# cf. pdf2htmlex https://github.com/coolwanglu/pdf2htmlex
@nikukyugamer
nikukyugamer / create_wifi_access_point.sh
Last active December 25, 2017 16:27
change Ubuntu client machine with wired LAN to Wi-Fi child machine by using create_ap and hostapd
#!/bin/bash
# https://github.com/oblique/create_ap
create_ap --ieee80211n wlx8857ee9a2350 eno1 106F3F0CC924_G SECRET_KEY &
@nikukyugamer
nikukyugamer / git_clone_with_ssh_key_directly.rb
Last active November 21, 2017 01:46
git clone with ssh key
#!/bin/bash
GIT_SSH_COMMAND="ssh -i ~/.ssh/my_key -F /dev/null" git clone [email protected]:foobar/hogehoge.git