Skip to content

Instantly share code, notes, and snippets.

@fmpwizard
fmpwizard / lift-json.scala
Created November 13, 2012 02:20
Lift-json parseOpt , nice to know it;s there
scala> import net.liftweb.json._
import net.liftweb.json._
scala> val json = parse("""{"a": 1} """)
json: net.liftweb.json.package.JValue = JObject(List(JField(a,JInt(1))))
scala> val json = parseOpt("""{"a": 1} """)
json: Option[net.liftweb.json.package.JValue] = Some(JObject(List(JField(a,JInt(1)))))
scala> val json = parseOpt("""{"a": 1"} """)
[info] FlexMenuBuilder should
[error] x Link to Self
[error] 'No Navigation Defined.' is not equal to '' (FlexMenuBuilderSpec.scala:47)
[error] Expected:
[error] Actual: No Navigation Defined.
[info]
val xml: NodeSeq = <div class="main" id="wall">
<div class="row innerRow" id="mainRow">
<img src="/static/assets/logos/basf.png" class="logo" alt="" />
<p>
<span class="supplierName"><strong>BASF North America Order Management</strong></span>
<span class="right textSuccess supplierStatus">New</span><br/>
<span class="actions"><a href="#">Upload Partners</a></span>
<span class="actions clearable"><a href="#">Edit Program Details</a></span>
</p>
@fmpwizard
fmpwizard / description-search.sh
Created October 18, 2012 04:06
search on description
# ========================================
# Testing n-gram analysis in ElasticSearch
# ========================================
# The goal is to search for terms like
# key
# keyboard
# 8
# 8 cell
# 8x DVD
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_35).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import net.liftweb.util.Helpers._
import net.liftweb.util.Helpers._
scala> case class Musicians(graduation_year: Int, last_name: String, first_name: String)
defined class Musicians
@fmpwizard
fmpwizard / edgeNgram.sh
Created October 15, 2012 03:52
search on description field
# ========================================
# Testing n-gram analysis in ElasticSearch
# ========================================
curl -X DELETE localhost:9200/test
curl -X PUT localhost:9200/test -d '
{
"settings" : {
"index" : {
"analysis" : {
@fmpwizard
fmpwizard / file.sh
Created September 29, 2012 05:10
Snowball analyzer for ElasticSearch
curl -X DELETE localhost:9200/inventory
curl -X PUT localhost:9200/inventory -d '
{
"settings" : {
"index" : {
"analysis" : {
"analyzer" : {
"my_analyzer" : {
"type" : "snowball",
"language" : "English"
# ========================================
# Testing n-gram analysis in ElasticSearch
# ========================================
curl -X DELETE localhost:9200/test
curl -X PUT localhost:9200/test -d '
{
"settings" : {
"index" : {
"analysis" : {
#!/bin/bash
#It is called unsafe so most people stay away from this
#But this script is safe to use if you are trying to publish Lift Framework to sonatype
#as a release version (including Milestones and RC's
## This scripts runs on mac's bash terminal
# Exit on any errors and on unbound vars to be safe
set -o errexit
package com.fmpwizard
import bootstrap.liftweb.Boot
import net.liftweb.common.Full
import net.liftweb.http.S
import net.liftweb.mocks.MockHttpServletRequest
import net.liftweb.mockweb.MockWeb
import net.liftweb.json.JsonDSL._
import net.liftweb.json.JsonAST._
import com.fmpwizard.snippet.Result