Skip to content

Instantly share code, notes, and snippets.

@bdargan
bdargan / elasticsearch_ngram_settings
Created March 15, 2011 12:45
configure index and analyzers for ngram indexing
curl -XDELETE localhost:9200/twitter
curl -XPOST localhost:9200/twitter -d '
{"index":
{ "number_of_shards": 1,
"analysis": {
"filter": {
"mynGram" : {"type": "nGram", "min_gram": 2, "max_gram": 10}
},
"analyzer": { "a1" : {
@bdargan
bdargan / elasticsearch_snowball_example
Created March 15, 2011 13:31
Elastic Search snowball Sample
curl -XDELETE localhost:9200/twitter
curl -XPOST localhost:9200/twitter -d '
{"index":
{ "number_of_shards": 1,
"analysis": {
"filter": {
"snowball": {
"type" : "snowball",
"language" : "English"

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods
@bdargan
bdargan / pom.xml
Created June 28, 2012 05:50 — forked from technoweenie/pom.xml
the finished pom.xml after going through the DropWizard tutorial
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.helloworld</groupId>
<artifactId>hello-world</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
@bdargan
bdargan / gist:3167793
Created July 24, 2012 03:13 — forked from lucasfais/gist:1207002
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
@bdargan
bdargan / gist:4334057
Created December 19, 2012 03:09
Select top N records from various databases
Returning only the first N records in a SQL query differs quite a bit between database platforms. Here's some samples:
Microsoft SQL Server
SELECT TOP 10 column FROM table
PostgreSQL and MySQL
SELECT column FROM table
LIMIT 10
Oracle
@bdargan
bdargan / gist:4334059
Created December 19, 2012 03:10
select random rows from various databases
There are lots of ways to select a random record or row from a database table. Here are some example SQL statements that don't require additional application logic, but each database server requires different SQL syntax.
Select a random row with MySQL:
SELECT column FROM table
ORDER BY RAND()
LIMIT 1
Select a random row with PostgreSQL:
SELECT column FROM table
@bdargan
bdargan / gist:4536616
Created January 15, 2013 06:16
send some syslog from bash
echo "<133>Dec 3 16:00:00 host1 webapp1: learning something new" > /dev/udp/10.0.0.111/514
@bdargan
bdargan / bash loop sending udp syslog
Last active December 11, 2015 04:18
shell bash loop with iso8601 date format
export ip="127.0.0.1"; export COUNTER=0; while [ $COUNTER -lt 100 ]; do dt=`date "+%Y-%m-%dT%H:%M:%S"`"+10:00";echo "<165>1 $dt host1:Knock, Knock..." > /dev/udp/$ip/514; let COUNTER=COUNTER+1; done
@bdargan
bdargan / jq_tips.rst
Created January 18, 2013 05:29
jq command line json query processor tips. from stedolan/jq

cat tmp.results| ~/bin/jq '.hits.hits[]._source | select(.address) |.address'

"192.168.1.1"

cat tmp.results| ~/bin/jq '.hits.hits[]._source | select(.address) |{address,name}'

{
"name": "some name", "address": "192.168.1.1"

}