Skip to content

Instantly share code, notes, and snippets.

@masarakki
masarakki / gist:807d55d67771b912979a
Last active March 15, 2016 17:47
cuda unknown error
masaki@desktop:~/ $ cat main.cu
#include <stdio.h>

int main() {
    int count = 0;
    cudaError_t error;

 error = cudaGetDeviceCount(&amp;count);
@masarakki
masarakki / Caverna.md
Last active December 29, 2015 02:59
Caverna ルール翻訳

Caverna

コンポーネント 名前と特徴と原文の対応

立体物(グッズ)

  • 犬(Dog ライトブラウン) x20
  • 羊(Sheep 白) x35
  • ロバ(Donky グレイ) x30
  • イノシシ(Wild boar 黒) x30
@masarakki
masarakki / jasmine_helper.rb
Created April 21, 2013 19:31
enable to include javascript sources by url in jasmine for using api.googleapis.com
module Jasmine
class UrlMapper
def initialize(config)
@config = config
end
def map_url_paths(paths)
paths.map{|path| path}
end
end
#include <stdio.h>
int main() {
int answer = 20;
char input[10];
while(1) {
printf("input: ");
scanf("%s", input);
if ( answer == atoi(input)) {
@masarakki
masarakki / slg.md
Last active December 9, 2015 04:58

n! のケツの0を全部抜いて下から9桁出力しろという問題

通らない

n = gets.to_i
x = 2
3.upto(n) do |i|
  x *= i                                                                        
  x = x.to_s.gsub(/0+$/, '').to_i % 1_000_000_000                           
end
@masarakki
masarakki / gist:4016711
Created November 5, 2012 11:17
solrのなぞい動作

おかしいレスポンス

q=とあるクエリ&start=0&rows=1
  • 検索結果の 「イラストレーター」 がなぜか 「イラストレーターー」になる
    • 元データを 「イラストレータア」 にすると 「イラストレータアア」
    • 元データを 「イラストレータ」 にすると 「イラストレータ」
    • 元データを 「イラストレー」 にすると 「イラストレー」
    • 元データを 「イラストレーターー」 にすると 「イラストレーターー」
  • 元データを 「イラストレーターーー」 にすると 「イラストレーターーーー」
@masarakki
masarakki / aabbcc.rb
Created September 21, 2012 12:31
aabbcc
str = "aabbcc"
str.chars.to_a.permutation(str.size).select{|x| 1.upto(x.size).all? { |i| x[i] != x[i-1] } }.uniq.count
@masarakki
masarakki / rails_conf_of_hide_part_of_json.rb
Created September 19, 2012 20:49
hide parameter of json in rails log
config.filter_parameters += [:password, lambda {|k, v|
if k.to_sym == :json
json = JSON.parse(v).symbolize_keys
json[:password] = "[FILTERED]" if json.has_key?(:password)
v.replace json.to_s
end
}]
@masarakki
masarakki / gist:3726909
Created September 15, 2012 08:03
linuxで棒読み的なこと
#!/bin/sh
voice=/usr/share/hts-voice/mei_normal
dic=/var/lib/mecab/dic/open-jtalk/naist-jdic
open_jtalk -x $dic -td $voice/tree-dur.inf -tm $voice/tree-mgc.inf -tf $voice/tree-lf0.inf -md $voice/dur.pdf\
-mm $voice/mgc.pdf -mf $voice/lf0.pdf -dm $voice/mgc.win1 -dm $voice/mgc.win2 -dm $voice/mgc.win3\
-df $voice/lf0.win1 -df $voice/lf0.win2 -df $voice/lf0.win3 -ow out.wav -em $voice/tree-gv-mgc.inf\
-ef $voice/tree-gv-lf0.inf -cm $voice/gv-mgc.pdf -cf $voice/gv-lf0.pdf -k $voice/gv-switch.inf\
-s 48000 -p 480 -a 0.55 -u 0.1 -jm 1.0 -jf 0.5 -z 6000 -ow /dev/stdout \
@masarakki
masarakki / self_product_with_length.rb
Created September 4, 2012 11:57
ある集合の長さnの直積集合を求める
class Array
def **(num)
args = []
(num - 1).times { args << self }
product(*args)
end
end
[0,1] ** 3 #=> [[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]