目标
设计一个基于cookie的安全的自动登陆功能。 简单说就是不在cookie中保存密码,且token值在每次使用后都会更新 ( 类似lift那样 )
计划
package test.java; | |
import java.util.LinkedList; | |
import java.util.List; | |
class Listeners { | |
private List<Callback> listeners = new LinkedList<Callback>(); | |
public void register(Callback cb) { | |
listeners.add(cb); |
class PreferredPrompt(val preference: String) | |
object JoesPrefs { | |
implicit val prompt = new PreferredPrompt("Yes, master> ") | |
} | |
object Greeter { | |
def greet(name: String)(implicit prompt: PreferredPrompt) { | |
println("Welcome, " + name + ". The system is ready.") | |
println(prompt.preference) |
object A { | |
val loggerClass = LoggerFactory.getLogger(classOf[A]) | |
val logger = LoggerFactory.getLogger(A.getClass) | |
} | |
class A { | |
val logger = A.loggerClass | |
} |
def opt(paramA: Option[String], paramB: Option[Date], paramC: Option[Int]): Option[String] = { | |
for ( | |
a <- paramA; | |
b <- paramB; | |
c <- paramC) yield { | |
a + " | " + b + " | " + c | |
} | |
} | |
println(opt(Some("羊八井", Some(new Date), Some(26))) |
package demo | |
import org.scalatest.FlatSpec | |
import org.scalatest.BeforeAndAfter | |
import org.scalatest.matchers.ShouldMatchers | |
class T extends FlatSpec with ShouldMatchers { | |
it should ("SSSSSSS") in { | |
assert(succ("") == "") | |
assert(succ("R2D3") == "R2D4") |
package me.yangbajing.util | |
object TryUsingResources { | |
def optionNull[A](f: => A): Option[A] = { | |
val a = f | |
if (a == null) None | |
else Some(a) | |
} | |
def tryout[R](f: => R): Option[R] = try { |
package bootstrap.liftweb | |
import net.liftweb.common.{ Full } | |
import net.liftweb.http.InternalServerErrorResponse | |
import net.liftweb.http.{ XHtmlInHtml5OutProperties, LiftRules, Req } | |
import net.liftweb.mongodb.{ MongoDB, DefaultMongoIdentifier, MongoAddress, MongoHost, MongoIdentifier } | |
import net.liftweb.sitemap.{ SiteMap, Menu, ** } | |
import cst.lib.CstProps |
scala> Array(1, 6, 6, 4, 5, 6).groupBy(x => x).maxBy{ case (key, group) => group.size -> key } | |
res5: (Int, Array[Int]) = (6,Array(6, 6, 6)) | |
scala> Array(1, 6, 6, 4, 5, 5, 6, 5).groupBy(x => x).maxBy{ case (key, group) => group.size -> key } | |
res6: (Int, Array[Int]) = (6,Array(6, 6, 6)) | |
scala> Array(1, 6, 6, 4, 5, 5, 6, 5).groupBy(x => x).maxBy{ case (key, group) => group.size } | |
res7: (Int, Array[Int]) = (5,Array(5, 5, 5)) |
function areaSelect(areaContainer, selectedTxt, selectedVal) { | |
$('.area-sub label').click(function(e) { | |
var chkbox = $(this).find('input'); | |
var val = chkbox.val().trim(); | |
var txt = chkbox.parent().text().trim(); | |
var txtObj = $('#' + selectedTxt); | |
var valObj = $('#' + selectedVal); | |
if (chkbox.is(':checked')) { |