Skip to content

Instantly share code, notes, and snippets.

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

Shogo Watanabe nownabe

💪
Yeah!!
View GitHub Profile
@nownabe
nownabe / mkmf.patch
Created September 10, 2017 13:06
test-gems
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 7e40c2d..a6299a0 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -6,6 +6,61 @@
require 'rbconfig'
require 'fileutils'
require 'shellwords'
+require "pp"
+require "open3"
@nownabe
nownabe / test_gem.rb
Created September 1, 2017 11:44
Ruby Hack Challenge
# Usage:
# $ make
# $ make install
# $ ./ruby test_gem.rb test GEM_NAME
require "rbconfig"
require "rubygems"
require "rubygems/gem_runner"
require "rubygems/exceptions"
require "yaml"
@nownabe
nownabe / deploy
Last active June 27, 2017 15:01
Deploy GitHub Pages
#!/bin/bash
set -eux
cd out # deploy directory
git init .
git config --local user.name USER
git config --local user.email USER@example.com
git checkout -b gh-pages
@nownabe
nownabe / base64.html
Last active June 5, 2017 09:19
JavaScript Base64 Encoding Performance
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Base64 Encoding Performance</title>
</head>
<body>
<p id="counter"></p>
<input type="file" id="dialog" multiple>
@nownabe
nownabe / clustering.rb
Created December 13, 2016 06:51
ruby-mecab-kmeans
require "kmeans-clusterer"
require "natto"
class WordDic
class << self
def [](word)
dictionary[word] ||= next_index
end
def size
@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
@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 / 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":[]}
# 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(
# 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)