Skip to content

Instantly share code, notes, and snippets.

View tototoshi's full-sized avatar

Toshiyuki Takahashi tototoshi

View GitHub Profile
@eamelink
eamelink / transformers.scala
Last active November 26, 2021 15:36
Working with Eithers in Futures
import scala.concurrent.Future
object either {
// Scala standard library Either is sometimes used to distinguish between 'failure' and 'success' state. Like these two methods:
def getUser(id: String): Either[String, User] = ???
def getPreferences(user: User): Either[String, Preferences] = ???
// The Right side contains the success value by convention, because right is right, right?
var casper = require('casper').create();
casper.cli.drop("cli");
casper.cli.drop("casper-path");
if (casper.cli.args.length === 0 && Object.keys(casper.cli.options).length === 0) {
casper.echo('Usage: phantomjs download-java.js <name of file to download>');
casper.echo('Example: phantomjs download-java.js jdk-7u45-linux-x64.rpm');
casper.exit(1);
}
@mtgto
mtgto / proxy.rb
Created September 25, 2013 03:02
対sbt用proxy (ruby製。typoあり)
require 'socket'
require 'net/http'
require 'uri'
class Proxy
PORT = 8888
def initialize
@server_socket = TCPServer.open(nil, PORT)
@responses = {}
@cb372
cb372 / pom-vbump.py
Last active November 1, 2019 10:07
Version-bump script for Maven projects. Reads pom.xml, parses the version, increments it and either updates pom.xml or writes an updated pom to stdout.
#! /usr/bin/env python
#
# coding: utf-8
"""
Version-bump script for Maven projects.
Reads pom.xml, parses the version, increments it and writes an updated pom to stdout.
Usage:
pom-vbump.py [-i] [-v <new version number>] [path to pom.xml]
@cb372
cb372 / x-in-xs.txt
Last active December 18, 2015 16:39
Python-style "x in xs" testing in Scala using implicit conversion and duck typing. Sinful but convenient.
scala> implicit class WithInMethod(obj: Any) {
| def in(a: {def contains(e: Any): Boolean}): Boolean = a.contains(obj)
| }
warning: there were 1 feature warnings; re-run with -feature for details
defined class WithInMethod
scala> "foo" in List("1", "2")
res3: Boolean = false
scala> "foo" in List("foo", "bar")
@gakuzzzz
gakuzzzz / gist:5632577
Last active December 17, 2015 15:29
色んなSQLをScalikeJDBCで書くと?
@drexin
drexin / Macros.scala
Last active October 27, 2016 09:41
macros to get current file and line, inspired by ruby's __FILE__ and __LINE__
import java.io.File
import language.experimental.macros
import scala.reflect.macros.Context
object Macros {
def LINE: Int = macro lineImpl
def lineImpl(c: Context): c.Expr[Int] = {
import c.universe._
@lyricallogical
lyricallogical / rpscala88
Created September 26, 2012 09:50
rpscala88
!SLIDE
Play 2.0 の Action と BodyParser について学ぼう
----------------
!SLIDE
自己紹介
----------------
* 望月 慎也
* @lyrical_logical
* 株式会社レピダム
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

fizz = function f() {
fizz = function () {
fizz = function () {
fizz = f
return "Fizz"
}
}
}
buzz = function f() {