多くの開発者はSQLをうまく書けるわけではないから、DBを簡単に操作するインタフェースを Table Data Gateway で用意する。
# ex.
# Items
# id integer primary key
require 'sinatra' | |
require 'jwt' | |
require 'json' | |
def get_iap_key(kid) | |
@key_table ||= begin | |
require 'open-uri' | |
resp = open('https://www.gstatic.com/iap/verify/public_key', &:read) | |
JSON.parse(resp) | |
end |
$><<(%<><<(%$%(/</<=)<%~~~/%>>>~<>)/>>)=)/(>%()<>~~~()<=%/=<=>)=(%=<~>(~/><<~)//)</)=$=~/$/)<<(%$<)>><%(>/()(//(=>%~<=((<=((=%/%~(((>//=<=)/=/<>(>~~<)~>~/~=~)~==%)><%=<=~(=/~//>)><%<>((<)/~)<<=>/%=<$=~/$/)<<(%$</)>(=%))%(<)=></<)~<<))/~/<<~/)//=/>~%~)((()>)/=(%)>>~/~<<()(((()<)~>%<)%%~~<%><==(()((/((><%%=%)=<%%=(%~~)$=~/$/)<<(%$=>~~>>/>>><)=<>=~=<(/%>(~%~()(~<>%)()>)(=<%)=%<>()(%==%<>/(>%~=<//%/(~)/<(%(><)>(>=%)>/~(%><=>)>~>))(<<((~%>$=~/$/)<<(%$</=(~>%~~><=~=<))/~()/(~=%(=<()/=/(~)~~~=/><)<<>>>~///=>))=(>>/(())<>/%<<<==/%(<~<~>/(%<()(/=%=))~%~(/%>==)/~>/$=~/$/)) |
# https://github.com/google/google-api-ruby-client/blob/master/samples/cli/lib/samples/bigquery.rb | |
require 'google/apis/bigquery_v2' | |
require 'googleauth' | |
require 'securerandom' | |
# CHANGEME | |
project_id = 'myproject' | |
dataset_id = 'mydataset' | |
table_id = 'mytable' |
#!/usr/bin/env ruby | |
require 'csv' | |
firstline = true | |
io = $stdout | |
while line = ARGF.gets | |
data = line.chomp.split(/\t/).map{|item| item.split(/:/,2) }.to_h | |
if firstline |
#!/bin/sh | |
# set ft=sh | |
set -e | |
# available variables: | |
# | |
# SLACKSAY_WEBHOOKURL | |
# SLACKSAY_CHANNEL | |
# SLACKSAY_USERNAME |
#!/bin/sh | |
rm -rf "~/Library/Application Support/Skype" | |
open "/Applications/Skype.app" |
module BQSchema | |
# conversion AR to BQ | |
# http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/TableDefinition.html#method-i-column | |
# https://cloud.google.com/bigquery/data-types | |
def to_bq_schema | |
self.columns.map{|c| | |
# FIXME decimal and time type conversion | |
type = \ | |
case c.type | |
when :integer, :primary_key |
require 'slack-notifier' | |
require 'tweetstream' | |
SLACK_WEBHOOK_URL = 'https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX' | |
TweetStream.configure do |config| | |
config.consumer_key = 'XXXXXXXXXXXXXXXXXXXXXXXXX' | |
config.consumer_secret = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | |
config.oauth_token = 'XXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' |
#!/usr/bin/env ruby | |
require 'shellwords' | |
require 'niconico' | |
token = ENV['NICO_TOKEN'] | |
id = ARGV[0] | |
# monkey patch |