This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File | |
import play.api._ | |
import play.api.Application | |
import play.api.db.slick.Database | |
import scala.slick.model.codegen.SourceCodeGenerator | |
import scala.slick.jdbc.meta.createModel | |
/** | |
*/ | |
object PlaySlickCodeGenerator { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class C | |
case class C1() extends C | |
case class C2() extends C | |
trait Service[T <: C] { | |
def getFoo(): Option[T] | |
} | |
object Service { | |
// found : List[Option[Any]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 頭が慣れていないので、再帰むずい | |
case class Tree(id: Int, children: List[Tree]) | |
val n8 = Tree(8, Nil) | |
val n4 = Tree(4, Nil) | |
val n5 = Tree(5, Nil) | |
val n6 = Tree(6, List(n8)) | |
val n7 = Tree(7, Nil) | |
val n2 = Tree(2, List(n4, n5)) | |
val n3 = Tree(3, List(n6, n7)) | |
val n1 = Tree(1, List(n2, n3)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Based on this gist https://gist.github.com/mardix/3623562 | |
while read -r file; | |
do | |
if [[ $file = *.php ]]; | |
then | |
php-cs-fixer fix "$file" --fixers=-phpdoc_params,-psr0,-visibility | |
git add "$file" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright Kazuo KASHIMA 2011 | |
* k4200 [at] kazu [dot] tv | |
* Licensed under the same license as Lift framework (Apache 2.0) | |
*/ | |
package code.model | |
import net.liftweb._ | |
import mapper._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* コンパイル通りません。 | |
* | |
* やりたい事: | |
* 1. ProtoUserクラスを継承した任意のクラス(仮にUser)と、モデルクラス(Foo)の2つが存在。 | |
* 2. Fooには、どのユーザーがレコードを作成したかを表すフィールドがあり、Userテーブルへの外部キーとなっている。 | |
* 3. レコードの所有者のみがCRUDの機能を使えるよう。 | |
* 4. 2, 3の機能はtraitにして、Foo以外のクラスでも同様の機能を使えるようにしたい。 | |
* | |
* Liftのソースをにらめっこしながら頑張ったんだけど・・・ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright Kazuo KASHIMA 2011 | |
* k4200 [at] kazu [dot] tv | |
* Licensed under the same license as Lift framework (Apache 2.0) | |
*/ | |
// Some methods used here are private[mapper], so I need to put these traits | |
// under net.liftweb.mapper. | |
package net.liftweb { | |
package mapper { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):002:0> "1234567890".crypt("AA") | |
=> "AAOytELTtvgVU" | |
irb(main):003:0> "1234567809".crypt("AA") | |
=> "AAOytELTtvgVU" | |
irb(main):004:0> "1234567809".crypt("$1$AA") | |
=> "$1$AA$FGGqw9MVpWh4jOox/NNHk0" | |
irb(main):005:0> "1234567890".crypt("$1$AA") | |
=> "$1$AA$GpKPiWMTtFX2jcBN5zP7v1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// There's a class called MappedPassword in Lift. I wanted to create a class that | |
// holds the plain text when a password is set. | |
//------------------------------- | |
// This works, but I didn't like the idea for two reasons. | |
// 1. The class name is long. | |
// 2. Seems kinda ugly to me. | |
abstract class MappedPasswordWithPlainWhenSet[A<:Mapper[A]](override val fieldOwner: A) | |
extends MappedPassword[A](fieldOwner) { | |
var plain: String = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form name="aa" action="foo.php" method="POST"> | |
<input type='text' name='important_info' /> | |
<input type='hidden' name='token' value='<?php echo session_id(); ?>' /> | |
<input type='submit' name='submit' value='send it' /> | |
</form> | |
----- | |
<!-- 次のページ foo.php --> | |
<?php | |
session_start(); |
OlderNewer