Skip to content

Instantly share code, notes, and snippets.

Mark Ekisa ivermac

  • ona
Block or report user

Report or block ivermac

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ivermac
ivermac / resolve-and-call-symbol-derived-from-a-string.md
Created Sep 19, 2019
Resolve and Call symbol derived from a string
View resolve-and-call-symbol-derived-from-a-string.md
clj.user.main=> ((-> "clojure.string/blank?" symbol resolve) "")
true
clj.user.main=> ((-> "clojure.string/blank?" symbol resolve) "ivermac")
false

I used Clojure 1.8.0. The example above has been influenced by resolve clojure function

@ivermac
ivermac / 00_destructuring.md
Created Jun 28, 2019 — forked from john2x/00_destructuring.md
Clojure Destructuring Tutorial and Cheat Sheet
View 00_destructuring.md

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@ivermac
ivermac / java-vararg-in-clojure.md
Last active Sep 19, 2019
Calling Java vararg function in Clojure
View java-vararg-in-clojure.md

A colleague and I were using Jedis and wanted to delete multiple keys at once without using a loop. The version of Jedis we were using has 2 del functions and the one we wanted use is a java vararg function and can be found here. We understood a Java vararg function as a variadic function in Clojure which simply means a function with infinite arity. Assuming b1 and a1 are keys in redis, the following is what we attempted initially:

(.del jedis "a1" "b1")

The above failed with the following error: IllegalArgumentException No matching method found: del for class redis.clients.jedis.Jedis clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:80)

@ivermac
ivermac / redis-client-debugging-101.md
Last active Nov 26, 2018
Redis Client Debugging 101
View redis-client-debugging-101.md

If you are using redis and wanted to check how many open connections are there at the moment, use the client list command in your redis terminal.

127.0.0.1:6379> client list
id=936 addr=127.0.0.1:61277 fd=8 name= age=3 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client

This is a powerful debugging tool especially when you have an app that's using redis and seems to be opening connections without closing them, meaning you run out of memory in your redis host server.

Before getting to this stage, a colleague in the SRE team had used the following command to identify the redis problem

@ivermac
ivermac / my-python-2-tips-and-tricks.md
Last active Nov 2, 2018
My python 2 tips and tricks
View my-python-2-tips-and-tricks.md

To generate random values for secret keys

import os
os.urandom(24).encode('hex')

To view hidden attribute of an object

object._className__attrName
@ivermac
ivermac / input-rc.md
Last active Dec 1, 2018
Custom .input.rc file
View input-rc.md

Inspired by this url. From this page, the input.rc file is used to map the keyboard to specific situations.

"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char
@ivermac
ivermac / useful-commads-for-linux-osx.md
Last active Dec 19, 2018
Useful commands for linux and/or osx
View useful-commads-for-linux-osx.md

search for a file

find / -name <file-name>

search for a directory

find / -type d -name "<directory-name>"
@ivermac
ivermac / dont-include-non-cljs-dir-in-checkouts-dir.md
Created Oct 3, 2018
Dont include non cljs folder in checkouts folder of a cljs project as a symlink
View dont-include-non-cljs-dir-in-checkouts-dir.md

I included a non-Clojurescript directory in the checkout of a clojurescript project and started getting the following error:

Compiling ClojureScript...
WARNING: no :cljsbuild entry found in project definition.
--------------------------------------------------------------------------------
WARNING: your :cljsbuild configuration is in a deprecated format.  It has been
automatically converted it to the new format, which will be printed below.
It is recommended that you update your :cljsbuild configuration ASAP.
--------------------------------------------------------------------------------
:cljsbuild
@ivermac
ivermac / config.md
Created Sep 8, 2018 — forked from 0XDE57/config.md
Firefox about:config privacy settings
View config.md

ABOUT

about:config settings to harden the Firefox browser. Privacy and performance enhancements.
To change these settings type 'about:config' in the url bar. Then search the setting you would like to change and modify the value. Some settings may break certain websites from functioning and rendering normally. Some settings may also make firefox unstable.

I am not liable for any damages/loss of data.

Not all these changes are necessary and will be dependent upon your usage and hardware. Do some research on settings if you don't understand what they do. These settings are best combined with your standard privacy extensions (HTTPS Everywhere, NoScript/Request Policy, uBlock origin, agent spoofing, Privacy Badger etc), and all plugins set to "Ask To Activate".

@ivermac
ivermac / hash-map-to-query-param-string.md
Created Sep 7, 2018
Convert clojure hash-map to query param string
View hash-map-to-query-param-string.md
(defn get-query-params-str [query-params-map & [query-param-str]]
  "Converts a hash-map to a query param string containing the keys and values
   in the hash-map
   Note: this function assumes the values have already been url-encoded"
  (let [query-param-str (str query-param-str)
        query-param-str-blank? (string/blank? query-param-str)
        key (first (keys query-params-map))
        query-param-key (name (or key ""))
        query-param-val (and key (key query-params-map))]
You can’t perform that action at this time.