Skip to content

Instantly share code, notes, and snippets.

@kurain
kurain / vector_search.py
Created January 3, 2024 14:34
お手軽ベクトル検索
import mlx.core as mx
import numpy as np
import faiss
import time
class MLXVecSearch():
def __init__(self, stream=mx.gpu):
self._stream = stream
@kurain
kurain / thumbturn_detection.py
Created October 17, 2019 11:55
detecting thumbturn status
import io
import picamera
import sys
from time import sleep
from tensorflow.contrib import predictor
from picamera import PiCamera
import signal
import slacker
#!/bin/bash
if [ -n "$SESSION_NAME" ];then
session=$SESSION_NAME
else
session=multi-ssh-`date +%s`
fi
window=multi-ssh
### tmuxのセッションを作成
@kurain
kurain / compare.rb
Created July 17, 2013 15:27
Comper ruby's log and math.h log
require 'benchmark'
require 'inline'
class Test
include Math
inline do |builder|
builder.include('<math.h>')
builder.c <<-EOF
double
log_c(int i)
@kurain
kurain / gist:5858160
Created June 25, 2013 12:43
TAOCP 7.2.1.1
def function_f(tuple, m)
c = [-1, -1, 0]
if tuple.all? {|digit| digit == 0}
return c[0].abs
elsif tuple[0] == 1 and tuple[1..-1].all? {|digit| digit == 0}
return 0
else
sum = 0
tuple.each_index{|i| sum += c[i] * tuple[i] }
return sum % m
@kurain
kurain / gist:4161525
Created November 28, 2012 14:04
doRuby Service
on run {input, parameters}
set output to do shell script "echo " & quoted form of (input as Unicode text) & " | ruby -Ku"
if output is "" then
display dialog "No output"
end if
return output
end run
@kurain
kurain / gist:1458407
Created December 11, 2011 04:47
speak_stdin
#!/usr/bin/env perl
use warnings;
use strict;
use Text::MeCab;
my $mecab = Text::MeCab->new;
while(<>){
chomp;
@kurain
kurain / yukkuri_irc.pl
Created November 21, 2011 10:02
To listen the IRC log
use warnings;
use strict;
use Text::MeCab;
use Perl6::Say;
my $mecab = Text::MeCab->new;
while(<>){
chomp;
my (undef,undef, @elms) = split ' ', $_;
@kurain
kurain / build.pl
Created July 20, 2011 11:03 — forked from hakobe/build.pl
use strict;
use warnings;
use AnyEvent;
use AnyEvent::HTTPD;
use AnyEvent::Util qw(run_cmd);
use Cwd;
my $httpd = AnyEvent::HTTPD->new (port => 9090);
my $last_pid = undef;
http://maps.google.co.jp/maps?q=%E4%BA%AC%E9%83%BD%E5%BA%9C%E4%BA%AC%E9%83%BD%E5%B8%82%E5%B7%A6%E4%BA%AC%E5%8C%BA%E5%90%89%E7%94%B0%E7%A5%9E%E6%A5%BD%E5%B2%A1%E7%94%BA4&oe=utf-8&hl=ja&client=firefox-a&ie=UTF8&hq=&hnear=%E4%BA%AC%E9%83%BD%E5%BA%9C%E4%BA%AC%E9%83%BD%E5%B8%82%E5%B7%A6%E4%BA%AC%E5%8C%BA%E5%90%89%E7%94%B0%E7%A5%9E%E6%A5%BD%E5%B2%A1%E7%94%BA%EF%BC%94&gl=jp&brcurrent=3,0x600108fee5e22dff:0xc7efeeb4261205e,0&layer=c&cbll=35.024289,135.788347&panoid=taZtJIfdd0Nvj5DvsQEIaQ&cbp=12,264.31,,0,-10.83&ll=35.02429,135.78835&spn=0.001524,0.002653&z=19