Skip to content

Instantly share code, notes, and snippets.

Avatar

ponkotuy ponkotuy

View GitHub Profile
@ponkotuy
ponkotuy / Downloader.scala
Created Mar 22, 2017
Parallel Downloader per hostname
View Downloader.scala
package actors
import java.net.URI
import akka.actor.{Actor, ActorRef, Props}
import akka.pattern.{ask, pipe}
import akka.util.Timeout
import skinny.http.HTTP
import scala.collection.mutable
View DiagramArea.scala
import scala.io.StdIn
object Main extends App {
val input = StdIn.readLine()
val heights = input.foldLeft(Seq(0)) { case (hs, x) =>
val add = x match {
case '\\' => hs.last - 1
case '/' => hs.last + 1
case '_' => hs.last
}
View InsertionSort.scala
object InsertionSort {
def sort[A](ary: Array[A])(implicit ord: math.Ordering[A]): Unit = {
if(2 <= ary.length) {
ary.indices.tail.foreach { i =>
val j = (0 until i).indexWhere { j => ord.lt(ary(i), ary(j)) }
if(0 <= j) insert(ary, i, j)
println(ary.mkString("(", ", ", ")"))
}
}
@ponkotuy
ponkotuy / point.c
Last active Jul 21, 2016
点を移動したりまわしたり
View point.c
#include <stdio.h>
#include <math.h>
typedef struct {
double x;
double y;
} point_t;
typedef struct {
point_t* center;
@ponkotuy
ponkotuy / ImageIOTest.scala
Created Jan 5, 2016
ImageIOのサンプル
View ImageIOTest.scala
import java.io.File
import javax.imageio.ImageIO
object Main extends App {
assert(args.nonEmpty)
val image = ImageIO.read(new File(args.head))
println(image.getWidth, image.getHeight)
}
@ponkotuy
ponkotuy / scalas
Created Dec 22, 2015
scalasスクリプト(sbt-extraユーザ向け)
View scalas
#!/bin/sh
java -jar $HOME/.sbt/launchers/0.13.9/sbt-launch.jar -Dsbt.main.class=sbt.ScriptMain -Dsbt.boot.directory=$HOME/.sbt/boot "$@"
@ponkotuy
ponkotuy / Main.scala
Created Dec 22, 2015
SkinnyMicroScalas サンプル
View Main.scala
#!/usr/bin/env scalas
/***
scalaVersion := "2.11.7"
resolvers += "sonatype releases" at "https://oss.sonatype.org/content/repositories/releases"
libraryDependencies += "org.skinny-framework" %% "skinny-micro-server" % "1.0.+"
*/
import skinny.micro._
@ponkotuy
ponkotuy / Main.scala
Last active Dec 8, 2015
Compare Changing Date to yyyymmddhh(Int)
View Main.scala
import java.text.SimpleDateFormat
import java.util.{Calendar, Date}
import com.github.nscala_time.time.Imports._
object Main extends App {
def timer[A](name: String)(f: => A): A = {
val start = System.currentTimeMillis()
val result = f
println(s"${name}: ${System.currentTimeMillis() - start}ms")
View hero_tower_bot.sh
#!/bin/sh
# 勇者の塔を自動プレイする簡易スクリプト
# ただしNexus6(1440x2560)に限る
# 必要なもの: adb
# 条件: 兵士タブを開いた状態にし、スクロールを一番上にしておくこと
while :
do