This file contains hidden or 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 scala.xml.NodeSeq | |
| import net.liftweb.http.js._ | |
| import net.liftweb.http.js.jquery._ | |
| def $(exp: String): jQuery = $(JE.Str(exp)) | |
| def $(exp: JsExp): jQuery = jQuery(exp) | |
| case class jQuery(exp: JsExp) { |
This file contains hidden or 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
| (ns collect.core | |
| (:require [clojure.java.io :as io])) | |
| (defn fromRoot [rootDir] | |
| (doseq | |
| [f (->> (io/file rootDir) | |
| .listFiles | |
| (filter #(.endsWith (.getName %) ".jar")) | |
| (map #(str "lib/" (.getName %))))] |
This file contains hidden or 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
| object IDCard { | |
| case class IDCard(raw: String) { | |
| def verification(data: String) = { | |
| val first17 = data.substring(0, 17) | |
| val seq = for (ch <- first17; weight <- IDCard.WEIGHT) yield ch.getNumericValue * weight | |
| IDCard.VERIFICATION_CODE(seq.sum % 11) | |
| } | |
| val normalized = raw.length match { | |
| case 15 => raw.splitAt(6) match { |
This file contains hidden or 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 javafx.application.Application; | |
| import javafx.scene.Scene; | |
| import javafx.scene.control.Label; | |
| import javafx.scene.control.TextAreaBuilder; | |
| import javafx.scene.control.TreeView; | |
| import javafx.scene.layout.BorderPaneBuilder; | |
| import javafx.stage.Stage; | |
| import javafx.scene.layout.BorderPane; | |
| public class Main extends Application { |
This file contains hidden or 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
| trait CanContain[T <: CanContain[T]]{ | |
| def contains(v: T):Boolean | |
| } | |
| trait Searchable[T <: CanContain[T]]{ | |
| val data: T | |
| def contains(v: T):Boolean = this.data.contains(v) | |
| } | |
| case class Image(bytes: Array[Int]) extends CanContain[Image]{ |
This file contains hidden or 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
| package net.oschina.oldpig | |
| import javafx.scene.{Node, Parent} | |
| object InheritParent { | |
| implicit class SParent[T <: Parent](parent: T) extends Parent { | |
| // override protected def getChildren = parent.getChildren | |
| def apply(children: Seq[Node]) = { | |
| println(children) |
This file contains hidden or 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
| trait Tree | |
| case object Empty extends Tree | |
| case class Node(i: Int, left:Tree, right:Tree) extends Tree | |
| def show(tree: Tree) : String // implement this method | |
| /* Test Cases |
This file contains hidden or 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 akka.actor._ | |
| import scala.concurrent.duration.Duration | |
| trait CommonReceive extends Actor { | |
| def commonReceive: Receive = { | |
| case "Mesage" => // | |
| } | |
| abstract override def receive = super.receive orElse commonReceive |
This file contains hidden or 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
| package com.cipinvestment | |
| import spray.routing.{HttpService, Route} | |
| import akka.actor.{ActorRefFactory, Actor} | |
| trait ServiceCombiner extends HttpService { | |
| val combinedRoute: List[Route] = Nil | |
| } | |
| trait Service1 extends ServiceCombiner { |
This file contains hidden or 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
| path("login") { | |
| post { | |
| formFields('username, 'password) { (username, password) => | |
| val queryResult = (db ? Admin(username, password).find).mapTo[QueryResult] | |
| onSuccess(queryResult) { qr => | |
| qr.rows match { | |
| case Some(Seq(single: RowData)) => | |
| onSuccess(createSession(single)) { session_id => | |
| setCookie(HttpCookie(identity_cookie_name, session_id)) { | |
| redirect("/admin/index", StatusCodes.SeeOther) |