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
def ingestAllFromDatabase() { | |
solrIngester.clear | |
personRepository.foreach(solrIngester.addDocument(_)) | |
solrIngester.commit() | |
} |
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
class IngestionManager | |
def initialize(solrIngester, personRepository) | |
@solrIngester = solrIngester | |
@personRepository = personRepository | |
end | |
def ingestAllFromDatabase | |
@solrIngester.clear | |
@personRepository.each do |doc| | |
@solrIngester.addDocument(doc) | |
end |
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
(defmethod update-response URL | |
[request response url] | |
(assoc response :body (.openStream url))) | |
(defmethod update-response Integer | |
[request response status] | |
(assoc response :status status)) |
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
curl http://npmjs.org/install.sh | sh | |
% Total % Received % Xferd Average Speed Time Time Time Current | |
Dload Upload Total Spent Left Speed | |
100 3874 100 3874 0 0 2650 0 0:00:01 0:00:01 --:--:-- 7393 | |
fetching: http://registry.npmjs.org/npm/-/npm-1.0.6.tgz | |
node.js:63 | |
throw e; | |
^ | |
Error: Cannot find module 'semver' |
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
; 8a | |
(reduce min [14, 35, -7, 46, 98]) | |
; 8b | |
(min 14 35 -7 46 98) | |
; 8c | |
(apply min [14, 35, -7, 46, 98]) |
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 bugchk.core | |
(:use compojure.core | |
[compojure.response :only [resource]] | |
ring.middleware.json-params | |
ring.middleware.session | |
sandbar.stateful-session | |
[ring.adapter.jetty :only [run-jetty]]) | |
(:require [compojure.route :as route] | |
[compojure.handler :as handler] | |
[clojure.java.io :as io] |
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 my-mongo-app | |
(:use somnium.congomongo)) | |
(mongo! | |
:db "camellia") | |
(insert! :people | |
{:firstName "Fred", :lastName "Bloggs", :ssid 8675309} ) | |
(def fred (fetch-one | |
:people |
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
db = Mongo::Connection.new.db("camellia") | |
people = db["people"] | |
people.insert({ :firstName => "Fred", :lastName => "Bloggs", :ssid => 8675309}) | |
fred = people.find_one(:firstName => "Fred", :lastName => "Bloggs"); | |
# or using Mongoid: | |
class Person | |
include Mongoid::Document |
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
val mongoConn = MongoConnection("camellia") | |
val people = mongoConn("people") | |
val fred = MongoDBObject("firstName" -> "Fred", | |
"lastName" -> "Bloggs", | |
"ssid" -> 8675309) | |
people += fred | |
val possiblyFred = people.findOne("firstName" -> "Fred", | |
"lastName" -> "Bloggs") |
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 org.apache.solr.client.solrj.SolrQuery | |
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer | |
def build(fullName: String, maxRows: Int): SolrQuery = { | |
val (firstInitial, firstName, bits, lastName) = split(fullName) | |
val queryString = | |
"{!type=dismax mm=-1 qf='name^100.0 name_phonetic^10.0 name_synonym^10.0'} %s %s %s %s" | |
.format(firstInitial, firstName, bits, "+" + lastName) | |
val query = new SolrQuery(queryString) |