Skip to content

Instantly share code, notes, and snippets.

@mtgto
mtgto / proxy.rb
Last active December 20, 2015 05:49
ゴミHTTP Proxy (HEAD, GETのみ対応)
require 'socket'
require 'net/http'
require 'uri'
class Proxy
PORT = 8888
def initialize
@server_socket = TCPServer.open(nil, PORT)
end
@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 = {}
@mtgto
mtgto / garoond.rb
Created January 31, 2014 07:36
ガルーンから今月&来月分のiCalデータを取ってきてくれるプロキシ
require 'sinatra'
require 'net/https'
require 'uri'
require 'date'
=begin
ガルーンから今月&来月分のiCalデータを取ってきてくれるプロキシです。
sinatraが必要なので、入れてなければgem install sinatraしてね。
使い方はこのプログラムを起動してから、iCalでカレンダーメニューの照会を開き、"http://localhost:10999/ical"を指定すればいけるはず。
=end
@mtgto
mtgto / SampleSpec.scala
Created February 27, 2014 15:03
Specs2's mockito cannot mock the class which have the function returns AnyVal, but this example can be passes.
import org.specs2.mutable._
import org.specs2.mock._
trait Dummy extends Any
case class V(s: String) extends AnyVal with Dummy
class A {
def f: Dummy = new V("Hello")
}
@mtgto
mtgto / httpd.rb
Created May 8, 2014 05:47
simple HTTP server
require 'webrick'
include WEBrick
s = HTTPServer.new(:Port => 10080)
s.mount_proc('/') do |req, res| res.body = 'hogehoge' end
s.start
@mtgto
mtgto / run.sh
Created August 12, 2014 01:30
icon image generator for iOS. Before execute, you need to create 1024x1024 png.
#!/bin/sh
convert Icon.png -resize 29x -strip +set date:create +set date:modify Icon-29.png
convert Icon.png -resize 58x -strip +set date:create +set date:modify [email protected]
convert Icon.png -resize 80x -strip +set date:create +set date:modify [email protected]
convert Icon.png -resize 57x -strip +set date:create +set date:modify Icon-57.png
convert Icon.png -resize 114x -strip +set date:create +set date:modify [email protected]
convert Icon.png -resize 120x -strip +set date:create +set date:modify [email protected]
convert Icon.png -resize 29x -strip +set date:create +set date:modify Icon-29.png
convert Icon.png -resize 58x -strip +set date:create +set date:modify [email protected]
convert Icon.png -resize 40x -strip +set date:create +set date:modify Icon-40.png
curl -I http://search.yahoo.co.jp/
HTTP/1.1 500 Internal Server Error
Server: nginx
Date: Mon, 13 Oct 2014 11:50:27 GMT
Content-Type: text/html
Content-Length: 186
Connection: close
@mtgto
mtgto / uploader.rb
Created January 6, 2017 07:26
Idiot simple http file uploader written by ruby. It requires sinatra.
# WARNING: This script has an enormous vulnerability!!!!!!
require 'sinatra'
get '/' do
erb <<"HTML"
<form action="upload" method="POST" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" value="Upload" />
</form>
@mtgto
mtgto / ~|.sbt|repositories
Created December 26, 2017 08:47
Use Google Cloud Platform's Maven Central repository mirror for sbt
# http://www.scala-sbt.org/release/docs/Proxy-Repositories.html
# http://www.scala-sbt.org/release/docs/Launcher-Configuration.html
# https://storage-download.googleapis.com/maven-central/index.html
[repositories]
local
typesafe-ivy-releases: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
google-maven-central: https://maven-central-asia.storage-download.googleapis.com/repos/central/data/
maven-central
sonatype-snapshots: https://oss.sonatype.org/content/repositories/snapshots
@mtgto
mtgto / repositories
Created January 30, 2018 00:10
[~/.sbt/repositories] Use google's maven central mirror, prevent to redirect for lightbend repository.
# http://www.scala-sbt.org/1.x/docs/Launcher-Configuration.html
# https://storage-download.googleapis.com/maven-central/index.html
[repositories]
local
maven-central: https://maven-central-asia.storage-download.googleapis.com/repos/central/data/
lightbend-ivy-releases: https://dl.bintray.com/typesafe/ivy-releases/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
#typesafe-ivy-releases: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
sonatype-snapshots: https://oss.sonatype.org/content/repositories/snapshots