Skip to content

Instantly share code, notes, and snippets.

View kazoo04's full-sized avatar

Kazuya Gokita kazoo04

  • Garm Inc.
  • Tokyo
View GitHub Profile
@kazoo04
kazoo04 / ginko.rb
Last active December 25, 2015 18:49
ぎんこさんワロタbotの精度向上
require 'rubygems'
require 'levenshtein'
require 'shellwords'
def similar(s1, s2, threshold = 2)
d = Levenshtein.distance(toKatakana(s1), toKatakana(s2))
d <= threshold
end
def toKatakana(str)
@kazoo04
kazoo04 / RandomChars.java
Last active December 26, 2015 00:49
@s0bc
import java.util.Random;
public class RandomChars
{
private final static String answer = "あいうえ";
public static int count = 0;
public static void main(String[] args)
{
char[] chars = answer.toCharArray();
@kazoo04
kazoo04 / braro.rb
Created October 20, 2013 11:41
@bra_ro_
answer = "ABABCD"
chars = answer.split('').uniq
str = ""
count = 0
while not str.end_with? answer
count += 1
c = chars.sample
print c
str += c
@kazoo04
kazoo04 / teraari.rb
Created October 24, 2013 05:04 — forked from sasamijp/teraari.rb
# -*- encoding: utf-8 -*-
for n in 0...gets.to_i
print "「てら#{"あり" * n}w」"
end
@kazoo04
kazoo04 / yukkuri.rb
Last active December 26, 2015 12:49
answer = "ABABCD"
str = ""
while not (print (str += answer.split('').uniq.sample)[-1] or str.end_with? answer) do end
puts "\ncount = #{str.length}
@kazoo04
kazoo04 / NextPalindrome.scala
Created January 10, 2014 16:55
Next Palindrome
package io.github.kazoo04.palindrome
import scala.annotation.tailrec
object NextPalindrome {
@tailrec
def next(num: Int): Int = {
val n = num + 1
@kazoo04
kazoo04 / detector.cpp
Last active October 15, 2020 09:17
メチャクチャわかりやすい cv::DenseFeatureDetector のサンプル
#include <iostream>
#include <fstream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/features2d/features2d.hpp>
#define IMAGE_SIZE 280
int main(int argc, char* argv[])
{
# encoding: utf-8
require 'date'
@dic = {'朝' => 'first', '昼' => 'second', '夜' => 'third'}
def meshi(str)
today = Date.today
# encoding: utf-8
dic = {'朝' => 'first', '昼' => 'second', '夜' => 'third'}
# キーから対応する値を取れる
# 逆(値からキーを取る)はできない
puts dic['朝'] # first
puts dic['昼'] # second
puts dic['夜'] # third
# encoding: utf-8
require 'date'
require './timer.rb'
@last_update = nil
def tweet
d = DateTime.now