Skip to content

Instantly share code, notes, and snippets.

View 53ningen's full-sized avatar
🐰
Is the Order a Rabbit?

gomi_ningen 53ningen

🐰
Is the Order a Rabbit?
View GitHub Profile
@j5ik2o
j5ik2o / gist:2156447
Created March 22, 2012 05:41
Play framework 2.0でデーモン化する方法

commons-daemonの依存関係を追加する

次のようにproject/Build.scala を編集する。

object ApplicationBuild extends Build {
    // ...
    val appDependencies = Seq(
      "commons-daemon" % "commons-daemon" % "1.0.10"
    )

// ...

@raichoo
raichoo / gist:2345414
Created April 9, 2012 18:50
Monads vs. implicit values in Scala
case class Config(host: String, port: Int) {
def prettyPrint(prefix: String, msg: String): String =
List(prefix, ": ", msg, " on ", host, ":", port.toString).mkString
}
/**
* Passing a configuration with implicits is like
* working in the state monad. You can "put" a
* new configuration even though we don't want that
* to happen in this particular example. We don't
@mbinna
mbinna / hack.sh
Created April 11, 2012 05:57 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2357277/hack.sh | sh
#
def index(id:String) = Action {
getFirstData(id)
}
private def getFirstData(id:String) = {
Cache.get(id) match {
case Some(id2) => getSecondData(id2)
case None => NotFound
}
}
private def getSecondData(id2:String) = {
@andypiper
andypiper / nuget.sh
Created May 8, 2012 16:18
nuget for OS X
#!/bin/sh
# add a simple 'nuget' command to Mac OS X under Mono
# get NuGet.exe binary from http://nuget.codeplex.com/releases/view/58939
# get Microsoft.Build.dll from a Windows .NET 4.0 installation
# copy to /usr/local/bin and Robert is your father's brother....
#
PATH=/usr/local/bin:$PATH
mono --runtime=v4.0 /usr/local/bin/NuGet.exe $*
@pkukielka
pkukielka / Factorial.java
Created May 31, 2012 10:25
Factorial in java with trampolines
import java.math.BigInteger;
class Trampoline<T>
{
public T get() { return null; }
public Trampoline<T> run() { return null; }
T execute() {
Trampoline<T> trampoline = this;
@mala
mala / gist:5107120
Last active March 19, 2020 01:41
TwitterのOAuthの問題の補足とか

https://gist.github.com/mala/5062931

の続き。

Twitterの人に色々と問題点は伝えたんだけど、これからOAuthのサーバー書く人や、クライアント書く人が似たような問題を起こさないようにするために、どうすればいいのかについて簡単に書きます。既存の実装真似して作るとうっかりひどい目にあう。

自分は意図的に「Twitterの脆弱性」という表現を使わないように気を使っていて、それはクライアントアプリ側の責任もあるからなのだけれども、安全に実装するための方法がわかりにくかったり誤解を招きやすかったり、Twitterに買収されているTweetDeckにも問題があったりしたので、それはやっぱりTwitter側の責任の比重が大きいとは思う。とはいっても別に責任を追求したかったり◯◯はクソだといったことを言いたいわけではなく、誰が悪いとか言う以前に、複合的な要因によって問題が起きるときには原因を正しく理解する必要があると思う。

そもそも何を担保に安全性を保証しているのか

  • サーバー側で秘密の鍵を持っている(それが無いとアクセストークンを取得できない or 使えない)
@tattyamm
tattyamm / gist:5967602
Last active March 8, 2016 00:48
コップ本 15章 ケースクラスとパターンマッチ

15.1 ケースクラスとパターンマッチ

今回扱う例:算術式を扱うサンプル Expr (Expression)

abstract classの中身を実装していく 変数、数値、単項演算(-, ++, !, ...)、二項演算(+, - , <, &&)

abstract class Expr
case class Var(name:String) extends Expr
case class Number(num:Double) extends Expr
@eldesh
eldesh / banana.sml
Last active December 19, 2015 14:39
圏論勉強会 @ ワークスアプリケーションズ#8 http://nineties.github.io/category-seminar/8.html#/55 練習問題 回答
(**
* 圏論勉強会 @ ワークスアプリケーションズ#8
* http://nineties.github.io/category-seminar/8.html#/55
* 練習問題 回答
*
* 実行方法(for SML/NJ)
* $ cat banana.cm
* group
* is
* $/basis.cm
@shinyaohira
shinyaohira / App States and Multitasking.md
Last active October 5, 2023 07:57
アプリケーションの状態とマルチタスキング

全体的に簡略化し、必要と思われる部分を抜粋しました。

  • Not running

    アプリは起動されていないか、実行されていたけれどもシステムによって終了されています。

  • Inactive