Skip to content

Instantly share code, notes, and snippets.

@devrimbaris
devrimbaris / query.json
Last active January 23, 2018 06:59
[elasticsearch] scripted field query
{
"sort" : [
{"processing_end_time" : {"order" :"asc"}}
],
"query": {
"bool" : {
"must" :{
"range":{
"processing_end_time": {
@devrimbaris
devrimbaris / query.json
Created January 23, 2018 06:18
[elasticsearch] scripted field query
{
"sort" : [
{"processing_end_time" : {"order" :"asc"}}
],
"query": {
"bool" : {
"must" :{
"range":{
"ingestion_time": {
"gte": "now-1d/d"
@devrimbaris
devrimbaris / javascriptreduce.js
Created April 4, 2015 18:50
Javascript reduce example
<script>
var uyeler = [{
ad: "baris",
soyad: "acar",
g: "e"
}, {
ad: "esen",
soyad: "acar",
g: "k"
}, {
@devrimbaris
devrimbaris / gist:7ea9931c03934e97b898
Last active August 29, 2015 14:13
Git command generator for indexed filename renamer
;;Renames file by adding file numbers incrementally
;;To run, execute repl output in shell
(ns dba.core.utils
(:require [clojure.java.io :as io]
[clojure.string :as stri]))
(defn- pad-left [s p length]
(stri/replace (format
(str "%" length "s" )
@devrimbaris
devrimbaris / gist:1686eb292a3f08f77d92
Last active August 29, 2015 14:12
Various util functions...
(defn CAPITALIZE [x]
(let [parsed (clojure.string/split x #" ")]
(map
#(reduce str %)
(for [x parsed] (conj
(map #(clojure.string/lower-case %) (rest x))
(clojure.string/upper-case (first x)))))))
;-----------------------------------------------------------
;VERY VERY slow compared to java's shuffle for collections
(defn SHUFFLE [coll]
@devrimbaris
devrimbaris / Functions.clj
Last active August 29, 2015 14:12
How to define functions out of string...
(defn run-rule-one-argument
"Assumes rule is defined in string like "zero? b."
[rule-string & args]
(let [parsed (stri/split rule-string #" ")
rulefn (resolve (symbol (first parsed)))]
(apply rulefn args)))
(run-rule-one-argument "zero?" 7)
@devrimbaris
devrimbaris / gist:7654473
Created November 26, 2013 07:10
H2 Database connection with SQL Korma in Clojure
;;; load this file from
;;; path_to_project.clh>emacs src\emlak\korma.clj
;;; This will enable the classpath libraries to be seen
;;; I have installed h2 from setup program, I guess this installs the test database
;;; Users table with columns "first" and "last" should be prepared beforehand
;;; for in memory database the subname should be mem:dbName
;;; got the original gist from someone else...
(ns deneme.core
(:use [korma.db])