Skip to content

Instantly share code, notes, and snippets.

View ponkotuy's full-sized avatar
🗾

ponkotuy ponkotuy

🗾
View GitHub Profile
@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
@ponkotuy
ponkotuy / Main.scala
Created March 24, 2015 16:33
LittleProxyによる艦これProxyサンプル
package com.ponkotuy
import java.nio.charset.Charset
import io.netty.channel.ChannelHandlerContext
import io.netty.handler.codec.http._
import org.littleshoot.proxy.impl.DefaultHttpProxyServer
import org.littleshoot.proxy.{HttpFilters, HttpFiltersAdapter, HttpFiltersSourceAdapter}
@ponkotuy
ponkotuy / slow.sql
Last active August 29, 2015 14:21
SlowQueryとcreate table
# Time: 150513 9:34:49
# User@Host: myfleet[myfleet] @ localhost [127.0.0.1]
# Thread_id: 63 Schema: myfleet QC_hit: No
# Query_time: 8.689849 Lock_time: 0.000136 Rows_sent: 2096 Rows_examined: 3635960
# Full_scan: Yes Full_join: No Tmp_table: Yes Tmp_table_on_disk: No
# Filesort: Yes Filesort_on_disk: No Merge_passes: 0 Priority_queue: No
SET timestamp=1431477289;
select br.area_id, br.info_no, br.cell, br.win_rank, ci.alphabet, count(1) as cnt from battle_result br left join cell_info ci on br.area_id = ci.area_id and br.info_no = ci.info_no and br.cell = ci.cell where br.created > 1396278000000 and br.created < 1431442800000 group by br.area_id, br.info_no, br.cell, br.win_rank order by br.area_id, br.info_no, br.cell, br.win_rank;
# 以下のように書き換えたら3倍ぐらい早くなった
@ponkotuy
ponkotuy / Main.scala
Created June 27, 2015 16:56
jpexsのffdecからFlashのimageを取ってくるScala Sample
import java.io._
import com.jpexs.decompiler.flash.SWF
object Main {
def main(args: Array[String]) {
val path = "/home/yosuke/01_01.swf"
val is = new FileInputStream(new File(path))
val swf = new SWF(is, path, "KanColle1_1", false)