Skip to content

Instantly share code, notes, and snippets.

View nownabe's full-sized avatar
💪
Yeah!!

Shogo Watanabe nownabe

💪
Yeah!!
View GitHub Profile
yum install -y httpd mariadb-server mariadb-devel php-mysql php php-gd php-mbstring
curl -O https://ja.wordpress.org/wordpress-4.1.1-ja.tar.gz
tar zxf wordpress-4.1.1-ja.tar.gz -C /var/www/html
chown -R apache. /var/www/html/wordpress
systemctl start httpd
systemctl start mariadb
mysql -uroot -e 'create database wordpress'
@nownabe
nownabe / test_spec.rb
Created March 2, 2016 00:47
Defference between allow_any_instance_of and expect_any_instance_of
class SomeClass
def greet
"Hello."
end
end
describe "allow_any_instance_of" do
before { allow_any_instance_of(SomeClass).to receive(:greet).and_call_original }
context "when calling Command#greet" do
it "pass the test" do
@nownabe
nownabe / sleep_server.rb
Last active March 29, 2016 09:22
Simple Sleep Web Server
#!/usr/bin/env ruby
#
# Usage:
# ruby sleep_server.rb [options]
#
# Options:
# -p port (default: 80)
# -b bind_address (default: 0.0.0.0)
# -s sleep_seconds (default: 5)
@nownabe
nownabe / detect_invalid_certificate.rb
Created March 30, 2016 01:17
Detect valid or invalid certificate
require "openssl"
pem = DATA.read
begin
OpenSSL::X509::Certificate.new(pem)
puts "Valid!"
rescue
puts "Invalid!"
end
@nownabe
nownabe / .commit_template
Created July 5, 2016 06:54
Emojiで楽しく綺麗なコミットを手に入れる
# ==== Emojis ====
# 🐛 :bug: バグ修正
# 👍 :+1: 機能改善
# ✨ :sparkles: 部分的な機能追加
# 🎉 :tada: 盛大に祝うべき大きな機能追加
# ♻️ :recycle: リファクタリング
# 🚿 :shower: 不要な機能・使われなくなった機能の削除
# 💚 :green_heart: テストやCIの修正・改善
# frozen_string_literal: true
require 'google/apis/analytics_v3'
require 'google/api_client/auth/key_utils'
module GoogleServices
class Analytics
attr_reader :start_date, :end_date
def initialize(start_date: nil, end_date: nil)
# frozen_string_literal: true
require "sinatra"
module Sinatra
module Mount
def mount(app, path = "/#{app.name.downcase}")
%i(get post put delete patch options).each do |method|
self.send(method, "#{path}*") do
app.call(
@nownabe
nownabe / guess_bq_schema.rb
Last active November 25, 2016 02:48
Guess BigQuery Schema from JSON Lines
#!/usr/bin/env ruby
# frozen_string_literal: true
# Guess BigQuery table schema automatically from JSON Lines
#
# example:
# $ cat source.jsonl
# {"required":123,"optional":true,"nested":{"required":1234,"optional":"yes"},"array":[0,1,2,3,4]}
# {"required":456,"optional":false,"nested":{"required":1234,"optional":"yes","nested":{"prop":1}},"array":[5,6,7,8,9]}
# {"required":789,"nested":{"required":1234,"optional":"yes","additional":"added"},"array":[]}
@nownabe
nownabe / ikayaki
Last active October 24, 2016 03:25
Change Log生成
#!/usr/bin/env ruby
$LOAD_PATH.unshift("../../lib", __FILE__)
require "./runner"
Takoyaki::Runner.new(ARGV).run
@nownabe
nownabe / hello.c
Last active November 23, 2016 09:56
RubyでRubyVMを実装してちょっとだけRubyVMの気持ちになってみる
#include <stdio.h>
int main(void) {
printf("Hello, world!");
return 0;
}
/*
$ gcc -c hello.c
$ gobjdump -d -M intel hello.o