Skip to content

Instantly share code, notes, and snippets.

[
{
"name": "faceAnnotations",
"type": "RECORD",
"mode": "REPEATED",
"fields": [
{
"name": "boundingPoly",
"type": "RECORD",
"mode": "NULLABLE",
@nagachika
nagachika / json-to-bigquery-schema.rb
Last active March 3, 2016 09:49
BigQuery Schema extract from JSON data
require "json"
require "yaml"
def type(value, key)
case value
when Float
"FLOAT"
when Integer
"INTEGER"
when String
@nagachika
nagachika / airplay.rb
Created November 26, 2015 08:04
play waveform transported via TCP with coreaudio.gem
require "coreaudio"
require "socket"
serv = TCPServer.new(9999)
sock = serv.accept
puts "accepted."
dev = CoreAudio.default_output_device
buf = dev.output_buffer(4096)
puts "output to device: #{dev.inspect}"
1. ruby extconf.rb
2. make
3. ruby test11328.rb
4. watch memory usage of 3. process
You should reproduce Makefile (step 1) if you try another version of ruby.
@nagachika
nagachika / .gitignore
Created May 29, 2015 02:57
picasa with OAuth 2.0
/.bundle
/vendor/bundle
/.envrc
@nagachika
nagachika / Gemfile
Created March 24, 2015 09:49
workaround for Google Cloud Pub/Sub via google-api-client.gem
source "https://rubygems.org"
gem "google-api-client", "0.8.3"
@nagachika
nagachika / reproduce.rb
Created January 22, 2015 04:54
weird behavior of psych with activesupport on 2.2.0/2.1.5
gem 'activesupport'
require "psych"
p Psych.respond_to?(:load_file) # => should print "true" but print "false" when psych-2.0.11.gem was installed
class A
Const = lambda{ p [ :in_lambda, self, @foo ] }
define_method(:meth) do
p [:in_method, self, @foo]
Const.call
end
def initialize
@foo = 72
% make prereq
making srcs under enc
make[1]: Nothing to be done for `srcs'.
generating transdb.h
transdb.h unchanged
generating ../ruby/ext/ripper/ripper.c
extracting ripper.y from ../../parse.y
id.h not found in ["../.."]
make[1]: *** [ripper.y] Error 1
make: *** [../ruby/ext/ripper/ripper.c] Error 2
@nagachika
nagachika / a.rb
Created July 7, 2014 14:50
ruby constant lookup
module A
class << self
def foo
p B
end
end
B = "A::B"
end