Skip to content

Instantly share code, notes, and snippets.

View nmatsui's full-sized avatar

Nobuyuki Matsui nmatsui

  • TIS Inc.
  • Japan
View GitHub Profile
@nmatsui
nmatsui / bonjovi.go
Created November 11, 2014 05:29
bonjovi generator
package main
import (
"fmt"
"math/rand"
"time"
)
type Stream chan string
@nmatsui
nmatsui / bonjovi.scala
Last active August 29, 2015 14:08
bonjovi generator
def bonjovi:Unit = {
import util.Random.nextInt
val elements = List("ボ", "ン", "ジョ", "ヴィ")
val badname = "ジョンボンジョヴィ"
Stream.continually(elements(nextInt(elements.length))).grouped(6).toStream.takeWhile(_.mkString != badname).foreach(name => println(name.mkString))
println(s"$badname, You Give Love A Bad Name!!")
}
@nmatsui
nmatsui / MD5FindPassword.c
Created February 15, 2014 12:51
「数字6桁パスワードのMD5ハッシュ値の総当たり」OpenMPを使うと0.70秒までキタ ref: http://qiita.com/nmatsui/items/8a33941072668f3ac55b
#include <stdio.h>
#include <string.h>
#include "md5.h"
#define MD5_DIGEST_LENGTH 16
int main(int argc, char* argv[])
{
char origin[256];
char hex[3];
@nmatsui
nmatsui / FindPassword_Single.scala
Created February 15, 2014 10:56
「数字6桁パスワードのMD5ハッシュ値の総当たり」Scalaは1.70秒だった ref: http://qiita.com/nmatsui/items/dd70fd57d81bdd935f79
import java.security.{MessageDigest => MD}
object MD5FindPassword_Single_WithFormatter {
def findPassword(salt:String, pw:String):Option[Int] = {
def hexdigest(s:String):String = {
val digester = MD.getInstance("MD5")
digester.update(s.getBytes)
digester.digest.toList.map(_&0xff).map("%02x".format(_)).mkString
}
(0 to 1000000)
@nmatsui
nmatsui / gist:2626826
Created May 7, 2012 09:05
arduinoのソース
#define R_PIN 8
#define G_PIN 3
#define B_PIN 2
#define F_R_PIN 11
#define F_G_PIN 9
#define F_B_PIN 10
#define F_C_PIN 12
#define F_R_TH 180
#define F_G_TH 230
@nmatsui
nmatsui / gist:2494675
Created April 26, 2012 00:16
Arduino操作用スクリプト
#!/usr/bin/env ruby
require 'serialport'
port = "/dev/tty.usbmodemfa131"
sp = SerialPort.new(port, 9600, 8, 1, SerialPort::NONE)
loop do
c = gets.chomp
break if c == "Q"
sp.putc c.to_i.chr