Skip to content

Instantly share code, notes, and snippets.

@nagachika
nagachika / .gitignore
Created May 29, 2015 02:57
picasa with OAuth 2.0
/.bundle
/vendor/bundle
/.envrc
@nagachika
nagachika / google-cloud-speech-api-bigquery-schema.json
Created September 27, 2016 07:40
BigQuery schema for Google Cloud Speech API result
[
{
"name": "results",
"type": "RECORD",
"mode": "REPEATED",
"fields": [
{
"name": "alternatives",
"type": "RECORD",
"mode": "REPEATED",
@nagachika
nagachika / sine.cpp
Created August 10, 2009 15:23
RtAudio example - Sine Wave Tone (440Hz)
// RtAudio exsample - Sine Wave (440Hz)
#include <math.h>
#include <RtAudio/RtAudio.h>
#if defined(__cplusplus)
extern "C" {
#endif
@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 / 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 / gist:8018565
Last active December 31, 2015 17:09
diff of generated Makefile between r44256 and r44257
68,69c68,69
< CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I/usr/local/include $(DEFS) ${cppflags} $(INCFLAGS)
< LDFLAGS = $(CFLAGS) -L. -fstack-protector -L/usr/local/lib
---
> CPPFLAGS = -Idummy/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT $(DEFS) ${cppflags} $(INCFLAGS)
> LDFLAGS = $(CFLAGS) -L. -fstack-protector
76c76
< DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/usr/local/lib $(XLDFLAGS) $(ARCH_FLAG)
---
> DLDFLAGS = $(XLDFLAGS) $(ARCH_FLAG)
@nagachika
nagachika / gist:6549187
Last active December 22, 2015 23:49
reproduce code for Refinements bug.
module M
refine(Fixnum) do
def foo
:foo
end
end
end
using M
p([0].map{|i| i.foo})
function echo_and_exec() {
echo $*
$*
ST=$?
if [ $ST -ne 0 ];
then
echo "エラー: exitstatus: ${ST}"
return 1
fi
}
diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb
index 25a4608..fcf89bf 100644
--- a/test/ruby/test_fiber.rb
+++ b/test/ruby/test_fiber.rb
@@ -52,6 +52,7 @@ class TestFiber < Test::Unit::TestCase
(1..100).map{|ti|
Thread.new{
max.times{|i|
+IO.select([$stdin], nil, nil, 0) # print "" でも可。Thread.pass ではタイムアウト
Fiber.new{
@nagachika
nagachika / svn.rb
Created June 25, 2013 18:01
svn.rb
#!/usr/bin/env ruby
module Svn
class Revision
def initialize(str)
unless /r(\d+) \| (\S+) \| (\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} \S+)/ =~ str
raise "unrecognized svn log message #{str}"
end
@revision = Regexp.last_match(1)
@developer = Regexp.last_match(2)