Skip to content

Instantly share code, notes, and snippets.

@felipehummel
felipehummel / ESslowlog.log
Created October 21, 2012 00:22
ES slowlog
[2012-10-19 19:59:54,085][INFO ][index.search.slowlog.query] [Elastic Search 4] [busk_prod_0310][0] took[566.9ms], took_millis[566], search_type[QUERY_THEN_FETCH], total_shards[8], source[...], extra_source[],
[2012-10-19 19:59:54,102][INFO ][index.search.slowlog.query] [Elastic Search 4] [busk_prod_0310][5] took[612.5ms], took_millis[612], search_type[QUERY_THEN_FETCH], total_shards[8], source[...], extra_source[],
[2012-10-19 20:02:21,702][INFO ][index.search.slowlog.query] [Elastic Search 4] [busk_prod_0310][0] took[745.8ms], took_millis[745], search_type[QUERY_THEN_FETCH], total_shards[8], source[...], extra_source[],
[2012-10-19 20:02:21,809][INFO ][index.search.slowlog.query] [Elastic Search 4] [busk_prod_0310][5] took[832.9ms], took_millis[832], search_type[QUERY_THEN_FETCH], total_shards[8], source[...], extra_source[],
[2012-10-19 20:08:27,309][WARN ][index.search.slowlog.fetch] [Elastic Search 4] [busk_prod_0310][5] took[54.3s], took_millis[54399], search_type[QUERY_THEN_FETCH], total_shards[8], sou
@felipehummel
felipehummel / crawler.scala
Created October 18, 2012 16:26
crawler problem
class CrawlRoundSender(master: ActorRef, scheduler: CrawlScheduler) extends Actor {
def receive = {
case CrawlRound => {
scheduler.next() match {
case Some(crawlFeed) => {
master ! crawlFeed
self ! CrawlRound
}
case None => context.system.scheduler.scheduleOnce(100.millis, self, CrawlRound)
}
@felipehummel
felipehummel / PerfTests.scala
Created October 18, 2012 02:44
jedis vs scala-redis in mget
package com.redis
import redis.clients.jedis._
object PerfTests {
def keys = (0 until 20000) map { "somekey:" + _ }
def populate() {
val jedis = new Jedis("localhost")
keys foreach { n =>
jedis.set("somekey:"+n, n.toString)
}
@felipehummel
felipehummel / build.sbt
Created October 4, 2012 17:05
build sbt
organization := "com.busk"
name := "SearchServer"
version := "0.1.0-SNAPSHOT"
scalaVersion := "2.9.1"
seq(webSettings :_*)
@felipehummel
felipehummel / updateESdoc.scala
Created October 3, 2012 17:40
update es doc
final def updateClusterSize(docId: String, newClusterSize: Int) : ListenableActionFuture[UpdateResponse] = {
val fields = client.prepareGet(indexName, typeName, docId)
.setFields("_timestamp")
.execute().actionGet().fields()
val oldTimestamp = if (fields == null)
(new Date()).getTime
else
fields.get("_timestamp").value()
client.prepareUpdate(indexName, typeName, docId)
.setScript("""
{
"query" : {
"constant_score": {
"filter": {
"terms": {
"_id": [ "44554814", "44506463", "44504729", "44506997", "44524881", "44509720", "44511458", "44522991", "44516257", "44504696", "44510314", "44543302", "44511529", "44508846", "44553660", "44513106", "44523403", "44550041", "44546073", "44506741", "44510843", "44559504", "44546960", "44511807", "44511889", "44516652", "44508535", "44542304", "44548172", "44504430", "44560101", "44545461", "44505070", "44524517", "44512248", "44505853", "44510579", "44510031", "44545932", "44511065", "44504916", "44515151", "44505492" ]
}
}
}
},
mysql> SELECT category_id, categories.name, count(*) as count FROM article_categories LEFT JOIN categories ON categories.id = category_id WHERE article_id in (select article_id from article_categories where category_id = 2179) AND category_id <> 2179 GROUP BY category_id ORDER BY count DESC LIMIT 100;
+-------------+------------------------+-------+
| category_id | name | count |
+-------------+------------------------+-------+
| 334 | olympics | 2806 |
| 280214 | olympícs | 2243 |
| 123916 | commentid=sports | 754 |
| 8023 | mlb | 530 |
| 36 | news | 435 |
| 199103 | london-olympics | 344 |
high-thread-dispatcher {
# Dispatcher is the name of the event-based dispatcher
type = Dispatcher
# What kind of ExecutionService to use
executor = "fork-join-executor"
# Configuration for the fork join pool
fork-join-executor {
# Min number of threads to cap factor-based parallelism number to
parallelism-min = 200
# Parallelism (threads) ... ceil(available processors * factor)
@felipehummel
felipehummel / gist:2144395
Created March 21, 2012 04:35 — forked from axelav/gist:1839777
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@felipehummel
felipehummel / gist:2144394
Created March 21, 2012 04:35
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after