Skip to content

Instantly share code, notes, and snippets.

View ponkotuy's full-sized avatar
🗾

ponkotuy ponkotuy

🗾
View GitHub Profile
@ponkotuy
ponkotuy / md5jasypt.scala
Created February 11, 2014 18:10
MD5総当たりjasypt版
import scala.collection.GenSeq
import org.jasypt.util.digest.Digester
object Main {
val digester = new Digester("MD5")
def main(args: Array[String]): Unit = {
val salt = "hoge".getBytes("UTF8")
val digest = digester.digest(salt ++ toBytes(567890))
val single = timer { println(bruteForceSingle(salt, digest)) }
@ponkotuy
ponkotuy / Main.scala
Last active August 29, 2015 13:56
補助コンストラクタでなぜかcompileできないパターン
object Main extends App {
val hoge = new Hoge()
println((hoge.hoge, hoge.fuga))
}
class Hoge(val hoge: Int, val fuga: Int) {
import Hoge._
def this() = this(init, init) // Compile Erorr! not found init
}
@ponkotuy
ponkotuy / FinagleProxySample.scala
Created May 24, 2014 06:54
FinagleProxySample
package com.ponkotuy.proxy
import com.twitter.finagle.builder.ClientBuilder
import com.twitter.finagle.{Http, Service, http}
import org.jboss.netty.handler.codec.http.{HttpMethod, HttpResponse, HttpRequest}
import com.twitter.util.{Await, Future}
import com.github.theon.uri.Uri
class FinagleProxySample(hosts: String, port: Int, inter: Intercepter) {
val client = ClientBuilder().codec(http.Http()).hosts(hosts).build()
@ponkotuy
ponkotuy / Sample.scala
Created June 17, 2014 02:40
なんでこれがコンパイルエラーなのか良く分からんちん
type Key = Long
implicit def strToKey(str: String): Long = str.toLong
@ponkotuy
ponkotuy / main.org
Created June 27, 2014 23:58
Cocos2dx(Ver2)の闇な話

Cocos2dx(Ver2)が闇な話

@ponkotuy
ponkotuy / Main.scala
Created July 3, 2014 02:05
Scala for sample
for {
i <- 1 to 9
j <- 1 to 9
if i != j
result = s"($i, $j)"
} {
println(result)
}
@ponkotuy
ponkotuy / command.coffee
Created July 6, 2014 09:35
CommandWatcher
class CommandWatcher
constructor: (commands) ->
@keys = []
@length = commands.length
@command = commands.join ','
watch: (handler) =>
watcher = @
$(document).on 'keydown', (event) ->
watcher.keys.push event.which
# マッチしたら実行後、即return
@ponkotuy
ponkotuy / Ver.scala
Created September 26, 2014 09:40
Scala Ordering Sample
object Main extends App {
assert(Ver(1, 4) > Ver(1, 2))
assert(Ver(2, 1) < Ver(3, 0))
assert(Ver(4, 0) == Ver(4, 0))
assert(List(Ver(1, 2), Ver(1, 4), Ver(1, 6)).min == Ver(1, 2))
}
case class Ver(major: Int, minor: Int) extends Ordered[Ver] {
def compare(other: Ver) = {
@ponkotuy
ponkotuy / NettyProxy.scala
Created December 27, 2014 13:04
NettyProxySample
package com.ponkotuy.proxy
import java.nio.charset.StandardCharsets
import com.netaporter.uri.Uri
import io.netty.bootstrap.{Bootstrap, ServerBootstrap}
import io.netty.buffer.{ByteBuf, Unpooled, UnpooledByteBufAllocator}
import io.netty.channel._
import io.netty.channel.nio.NioEventLoopGroup
import io.netty.channel.socket.SocketChannel
@ponkotuy
ponkotuy / mariadb.cnf
Created March 19, 2015 17:11
MariaDB UTF-8
# MariaDB-specific config file.
# Read by /etc/mysql/my.cnf
[client]
# Default is Latin1, if you need UTF-8 set this (also in server section)
default-character-set = utf8
[mysqld]
#
# * Character sets