Skip to content

Instantly share code, notes, and snippets.

View dainiusjocas's full-sized avatar
:octocat:
editing status

Dainius Jocas dainiusjocas

:octocat:
editing status
View GitHub Profile
@dainiusjocas
dainiusjocas / gist:7f4ff4480274fcaab22d
Created November 25, 2014 09:11
Clojure map function with default parameters
(map #(+ 2 %) (range 0 5))
@dainiusjocas
dainiusjocas / centos-7-firewall
Created May 19, 2015 20:00
CentOS 7 open firewall for port 80
# Long description of the situation can be found here:
# http://ask.xmodulo.com/open-port-firewall-centos-rhel.html
# Following two lines get the job done.
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
@dainiusjocas
dainiusjocas / gist:a389e3232931622caff2
Created June 16, 2015 12:08
lithuanian-characters-in-remote-shell
# For using Lithuanian characters in the remote shell
LC_CTYPE=en_US.UTF-8
@dainiusjocas
dainiusjocas / gist:6ecbe8ef0ce6dcd5cf11
Created June 22, 2015 13:21
snowball stemmer clojure
/*
* This fixes some strance method overloading error:
* NoSuchMethodError org.tartarus.snowball.ext.LithuanianStemmer.slice_from(Ljava/lang/CharSequence;)V
*/
protected void slice_from(String cs) {
super.slice_check();
String current = super.getCurrent();
StringBuilder sb = new StringBuilder(current);
sb.replace(this.bra, this.ket, cs);
this.setCurrent(sb.toString());
@dainiusjocas
dainiusjocas / gist:5ef737e620b702526023
Created July 1, 2015 09:25
clojure-liquibase-logging-level
(defn- get-liquibase
"Creates Liquibase instance for given connection and sets logging level."
[connection]
(let [liq-conn (JdbcConnection. connection)
liq-db-factory (DatabaseFactory/getInstance)
liq-database (.findCorrectDatabaseImplementation liq-db-factory liq-conn)]
(.setLogLevel (LogFactory/getLogger) (LogLevel/SEVERE))
(Liquibase. "db/changelog.xml" (ClassLoaderResourceAccessor.) liq-database)))
@dainiusjocas
dainiusjocas / midje-json-test
Created August 20, 2015 08:00
Midje JSON body request
(ns project.ns-test
(:require [ring.mock.request :as rr]))
(rr/body
(rr/content-type
(rr/request :post "/do")
"application/json")
(ch/generate-string [{:name "Name"
:countryCode "US"}]))
mysqldump -P [port] -h [host] -u [username] -p [password] > [file]
@dainiusjocas
dainiusjocas / cljs set background
Created November 18, 2015 15:53
CLJS set background color
(set! (.. js/document -body -style -backgroundColor) "red")
@dainiusjocas
dainiusjocas / destructuring
Created December 9, 2015 08:23
Multi-level clojure map destructuring
(def contact
{:firstname "John"
:lastname "Smith"
:age 25
:contacts {:phone "+44.123.456.789"
:emails {:work "jsmith@company.com"
:personal "jsmith@some-email.com"}}})
;; Just the top level
(let [{lastname :lastname} contact]
@dainiusjocas
dainiusjocas / enlive-attr-select
Created December 9, 2015 10:17
clojure enlive select node by value of custom attribute
[[:input (h/attr= :name "host")]]