Skip to content

Instantly share code, notes, and snippets.

View masahitojp's full-sized avatar
🎯
Focusing

Masato Nakamura masahitojp

🎯
Focusing
View GitHub Profile
object Simirality {
def j[T](a:Set[T], b:Set[T]):Double = (a intersect b).size.toDouble / (a | b).size
}
$ echo -e "10.11.3" | sed 's/^\(.*\)\.\(.*\)/\1/'
10.11
@masahitojp
masahitojp / Wo
Created May 23, 2016 05:27
countWords
object WordCounter {
def countWords(line: List[String]): Map[String, Int] =
line.flatMap(x=>x.split(" ")).groupBy(x => x).mapValues(x=>x.length)
}
def range(a: Int,b: Int, l:List[Int] = List.empty[Int]):List[Int] = {
if (a >= b) l.reverse
else range((a+1), b, a ::l)
}
import scala.annotation.tailrec
import scala.util.Random
object ZDK {
val Z = "Z"
val D = "D"
val K = "K"
@tailrec
def zundoko(zd: List[String] = Nil): List[String] = zd match {
case D :: Z :: Z :: Z :: Z :: _ => zd.reverse
@masahitojp
masahitojp / PingHandlers.kt
Last active February 16, 2016 08:34
botan handler for Kotlin v1.0.0
package handlers
import com.github.masahitojp.botan.Robot
import com.github.masahitojp.botan.handler.BotanMessageHandlers
import com.github.masahitojp.botan.message.BotanMessage
class PingHandlers : BotanMessageHandlers {
override fun register(robot: Robot?) {
robot?.respond(
"ping\\z",
package handlers.alias;
import com.github.masahitojp.botan.Robot;
import com.github.masahitojp.botan.handler.BotanMessageHandlers;
import com.github.masahitojp.botan.message.BotanMessageSimple;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@masahitojp
masahitojp / heartToSushiOnTwitter.user.css
Last active November 4, 2015 06:52
change flowert to sushi (original : http://pastebin.com/x4U2bLu2) for stylish
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document url("https://twitter.com/") {
.HeartAnimationContainer {
visibility: hidden;
}
.HeartAnimationContainer:after {
content: '🍣';
visibility: visible;
display: block;
@masahitojp
masahitojp / palindrome.cr
Last active November 3, 2015 00:37
parindrome(DELL XPS 13 2015)
$ crystal version
Crystal 0.9.1 [b3b1223] (Fri Oct 30 03:48:35 UTC 2015)
$ ruby -v
ruby 2.1.2p95 (2014-05-08) [x86_64-linux-gnu]
$ crystal build parindrome.cr
$ time ./parindrome
real 0m0.548s
user 0m0.560s
@masahitojp
masahitojp / java
Created October 26, 2015 12:29
create google image
package handlers.google.image.pojo;
import java.util.List;
public class GoogleImageResponse {
public class Result {
public String unescapedUrl;
}
public class ResponseData {