Skip to content

Instantly share code, notes, and snippets.

View mtgto's full-sized avatar

Satoshi Goto mtgto

  • Japan
  • 00:26 (UTC +09:00)
  • X @mtgto
View GitHub Profile
before
def fib(n) {
if (n < 3) {
return 1;
}
return fib(n-1) + fib(n-2);
}
var a = readInt();
printInt fib(a);
import math._
import collection.mutable._
object Main {
def main(args: Array[String]) {
val sc = new java.util.Scanner(System.in)
val T = sc.nextInt()
for (t <- 1 to T) {
val H = sc.nextInt()
val W = sc.nextInt()
#include <dispatch/dispatch.h>
int main() {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{puts("gcd! gcd!");});
sleep(1);
}
import java.util.Random
object HelloWorld extends App {
println(randomString(748171626L) +" "+ randomString(31718954746L))
println(randomString2(748171626L) +" "+ randomString2(31718954746L))
def randomString(i :Long) :String = {
val rand = new Random(i)
val sb = new StringBuilder()
rs(rand.nextInt(27))
@mtgto
mtgto / CompilerPluginSample.scala
Created March 22, 2013 16:58
Scalaコンパイラを使ってクラスやメソッドの行数をチェックしてみようのテスト
/**
* Scalaコンパイラを使ってクラスやメソッドの行数をチェックしてみようのテスト
*
* コンパイラプラグインの使い方は以下のサイトを参考にしています。
* http://www.ne.jp/asahi/hishidama/home/tech/scala/cplugin/index.html
*
* 使い方
* 1. scalac-plugin.xmlをclassesに置く
* 2. コンパイル
* scalac -d classes CompilerPluginSample.scala
// clang hoge.m -o hoge -framework Foundation -fobjc-arc
#import <Foundation/Foundation.h>
@interface A : NSObject {
double dummy;
}
@property (strong, nonatomic, setter=setDummyNumber:, getter=dummyNumber) NSNumber *number;
@end
@mtgto
mtgto / gist:5331366
Created April 7, 2013 17:13
直近2日間のgitのブランチに対して変更した行数とファイル数を表示する
git log --shortstat --since "2 days ago" | grep "files changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed", files, "lines inserted:", inserted, "lines deleted:", deleted}'
@mtgto
mtgto / Build.scala
Created April 8, 2013 16:15
lazy valを使わないとヌルポ (Play 2.1.1)
import sbt._
import Keys._
import play.Project._
object ApplicationBuild extends Build {
val appName = "test"
val appVersion = "1.0-SNAPSHOT"
/*lazy*/val main = play.Project(appName, appVersion, appDependencies).settings() // cause NullPointerException!
@mtgto
mtgto / HogeSpec.scala
Last active December 16, 2015 15:49
Specs2でinのネストができなくなってた!
import org.specs2.mutable.Specification
class HogeSpec extends Specification {
"One" should {
"Two test" in {
2 === 2
}
"Two" in {
"Three test" in {
3 === 3
@mtgto
mtgto / gist:5554562
Last active December 17, 2015 04:59
puzzle
00101100110001101010101010101100011011001011001001101100000111001010101010101100100111000000101000101100100001101100101001101100100111000001001011101100000011001011001010101100100111000101101010101100111011000001001000101100110011001110101010101100100001101001101000101100001011001010101010101100111011001010101000101100011011001110001001101100111011001011001001101100001001101110101010101100101011000011001010101100011011001110101001101100000111000000101010101100100111000011001000101100100001100100101001101100100111000100101010101100100011000001001001101100100111000011001010101100100011001001101000101100111011001010101000101100010011000110101001101100111011000100101000101100110011001110001001101100111011000101001011001100001001100000101011001100001001100001001000001100100001101100101001010000