Skip to content

Instantly share code, notes, and snippets.

View danielef's full-sized avatar

Daniel Estévez danielef

  • Ontario, Canada
  • 06:12 (UTC -04:00)
  • X @danielef
View GitHub Profile
@danielef
danielef / colores.clj
Created October 6, 2017 22:33
Colores Hexadecimal
(def COLORS ["#f44336" "#E91E63" "#9C27B0" "#673AB7" "#3F51B5" "#2196F3" "#03A9F4" "#00BCD4" "#009688" "#4CAF50" "#8BC34A" "#CDDC39" "#FFEB3B" "#FFC107" "#FF9800" "#FF5722" "#795548" "#9E9E9E" "#607D8B" "#ffebee" "#FCE4EC" "#F3E5F5" "#EDE7F6" "#E8EAF6" "#E3F2FD" "#E1F5FE" "#E0F7FA" "#E0F2F1" "#E8F5E9" "#F1F8E9" "#F9FBE7" "#FFFDE7" "#FFF8E1" "#FFF3E0" "#FBE9E7" "#EFEBE9" "#FAFAFA" "#ECEFF1" "#ffcdd2" "#F8BBD0" "#E1BEE7" "#D1C4E9" "#C5CAE9" "#BBDEFB" "#B3E5FC" "#B2EBF2" "#B2DFDB" "#C8E6C9" "#DCEDC8" "#F0F4C3" "#FFF9C4" "#FFECB3" "#FFE0B2" "#FFCCBC" "#D7CCC8" "#F5F5F5" "#CFD8DC" "#ef9a9a" "#F48FB1" "#CE93D8" "#B39DDB" "#9FA8DA" "#90CAF9" "#81D4FA" "#80DEEA" "#80CBC4" "#A5D6A7" "#C5E1A5" "#E6EE9C" "#FFF59D" "#FFE082" "#FFCC80" "#FFAB91" "#BCAAA4" "#EEEEEE" "#B0BEC5" "#e57373" "#F06292" "#BA68C8" "#9575CD" "#7986CB" "#64B5F6" "#4FC3F7" "#4DD0E1" "#4DB6AC" "#81C784" "#AED581" "#DCE775" "#FFF176" "#FFD54F" "#FFB74D" "#FF8A65" "#A1887F" "#E0E0E0" "#90A4AE" "#ef5350" "#EC407A" "#AB47BC" "#7E57C2" "#5C6BC0" "#42A5F5" "
@danielef
danielef / gist:69630854bd7013797e375d60f137875c
Last active August 30, 2017 16:07
ImageMagick : Turn color to transparent
# From http://www.imagemagick.org/discourse-server/viewtopic.php?t=12619
# Turn white background image to transparent
convert image-old.png -transparent white image-new.png
# not perfectly white (aliasing) with fuzz percentage
convert image-old.png -fuzz 95% -transparent white image-new.png
@danielef
danielef / config.clj
Last active August 18, 2017 18:49
caudal/example-mapping
(let [es-url "http://localhost:9200"
es-mapping-name "caudal-mapping"
es-index-name "caudal-index"
es-mapping {es-mapping-name {:properties {:TYPE {:type "string" :index "not_analyzed"}
:COUNTRY {:type "string" :index "not_analyzed"}
:HOST_ORIGIN {:type "string" :index "not_analyzed"}
:ACTION {:type "string" :index "not_analyzed"}
:NAME_OF_QUALIFIER {:type "string" :index "not_analyzed"}
:AUTHORIZATION_RULE_ID {:type "string" :index "not_analyzed"}
:AUTHORIZATION_INDICATOR {:type "string" :index "not_analyzed"}
@danielef
danielef / delete-all-docker-images-and-containers.bash
Created April 18, 2017 23:39
Docker delete all images containers
#!/bin/bash
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
@danielef
danielef / files-recur.clj
Last active March 3, 2017 19:15
Clojure Walk `path` recursivelly (with recur) and retrieves a vector with all regular files
(defn files-in-depth
"Walk `path` recursivelly and retrieves a vector with all regular files"
[path]
(loop [files [] acums [path]]
(if-not (empty? acums)
(if (Files/isDirectory (peek acums) (into-array (LinkOption/values)))
(let [stream (Files/newDirectoryStream (peek acums))]
(recur files (into (pop acums) (iterator-seq (.iterator stream)))))
(recur (conj files (peek acums)) (pop acums)))
files)))
@danielef
danielef / rename.clj
Created February 18, 2017 00:45
Clojure Renaming a file using java.nio
(defn rename [path-file new-name]
(try
(Files/move path-file (.resolveSibling path-file new-name) (into-array [StandardCopyOption/ATOMIC_MOVE]))
(catch Exception e
(.printStackTrace e)
nil)))
@danielef
danielef / month-text-to-number.clj
Created January 26, 2017 13:30
Clojure Month to Number
(defn month-text-to-number [text & [locale]]
(let [loc (if locale locale java.util.Locale/ENGLISH)
dfmt (java.text.SimpleDateFormat. "MMM" loc)
date (.parse dfmt text)
cal (doto (java.util.Calendar/getInstance)
(.setTime date))]
(.get cal java.util.Calendar/MONTH)))
@danielef
danielef / netcheck-instance.log
Created November 1, 2016 04:04
AWK gets a log with specified line starts and write a CSV
;; Query time: 13 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Thu Oct 27 14:05:26 2016
;; MSG SIZE rcvd: 53
size inuse free pin virtual mmode
memory 4030464 3606573 423891 821507 2071729 Ded
pg space 4325376 28186
@danielef
danielef / rename.sh
Created October 17, 2016 15:33
Elasticsearch rename index
curl -X POST http://localhost:9200/_reindex -d '{
"source": {
"index": "twitter"
},
"dest": {
"index": "new_twitter"
}
}'
curl -X DELETE http://localhost:9200/twitter
@danielef
danielef / jmx.level
Created October 15, 2016 00:07
JMX SOAP-Version 5.3.0.GA (with authentication)
guest readonly
admin readwrite