Skip to content

Instantly share code, notes, and snippets.

View mocyuto's full-sized avatar
🏠
Working from home

Yuto Suzuki mocyuto

🏠
Working from home
View GitHub Profile
@mocyuto
mocyuto / build.sbt
Created February 5, 2016 10:52
command line task
lazy val hello = taskKey[Unit]("say hello to you")
lazy val root = (project in file("."))
.settings(
hello := {Hello.say}
)
lazy val hello = inputKey[Unit]("say hello to you")
import complete.DefaultParsers._
lazy val root = (project in file("."))
.settings(
hello := {
val args: Seq[String] = spaceDelimited("<arg>").parsed
println(args)
}
)
@mocyuto
mocyuto / Hello.scala
Created February 5, 2016 00:37
hello
object Hello {
def say = println("Hello")
}
@mocyuto
mocyuto / Bower.scala
Last active January 12, 2016 17:29
bower update by Process
import java.io.File
object Bower {
def update = {
Process(Seq("bower","update"), new File("frontBuildTools")).!
}
}
@mocyuto
mocyuto / manifest.json
Created November 15, 2015 08:02
Page Redder
{
"name": "Page Redder",
"description": "Make the current page red",
"version": "2.0",
"permissions": [
"activeTab"
],
"applications": {
"gecko": {
"id": "redder@mozilla.org"
@mocyuto
mocyuto / sql2case_v2.py
Last active November 26, 2015 03:03
script "sql to case class" for slick
# -*- coding:utf-8 -*-
import re
import sys
from argparse import ArgumentParser
r_table = re.compile("CREATE TABLE `?([\w_]+)`? \((.*)\)(.*?);$")
caseSuffix = "Dto"
class Table:
def __init__(self, query):
@mocyuto
mocyuto / BaseTransaction.scala
Last active August 29, 2015 14:16
It can create transaction over multi DB schema by Slick
package com.cyberz.foxapi.dao
import scala.slick.jdbc.JdbcBackend._
/**
* Created by Yuto Suzuki on 15/03/06.
*/
object BaseTransaction {
/**
@mocyuto
mocyuto / IconGetter.scala
Created February 15, 2015 01:25
GooglePlayからIcon画像のURLを引っ張ってくる
def googlePlayIconUrl(appIdentifier: String): Option[String] = {
val googleImgTag = "div.cover-container img.cover-image"
def googlePlayUrl(appIdentifier: String): String = s"https://play.google.com/store/apps/details?id=$appIdentifier"
try {
val doc = Jsoup.connect(googlePlayUrl(appIdentifier)).get
Option(doc.select(googleImgTag).first.attr("src"))
} catch {
case e: HttpStatusException => {
// loggerに関しては、適当なものを定義してください。
logger.error(s"GooglePlayにアクセスできません。$appIdentifier")
@mocyuto
mocyuto / dbTest.py
Last active August 29, 2015 14:14
MySQLとinfluxDBの比較スクリプト
# coding: utf-8
import doctest
import MySQLdb
from influxdb import InfluxDBClient as ifdb
from datetime import datetime
DATA = "123456789012345678901234567890123456789012345678901234567890"
COUNT = 10000 * 1
@mocyuto
mocyuto / sshDao.scala
Created December 27, 2014 00:25
ssh-scalaで画像をscpするコード
import java.io.File
import com.decodified.scalassh._
import com.typesafe.config.ConfigFactory
import org.slf4j.LoggerFactory
import spray.http.StatusCodes
import scala.io.Source
/**
* Created by Yuto Suzuki on 2014/12/24.
*/
object SshDao {