Skip to content

Instantly share code, notes, and snippets.

View ivermac's full-sized avatar
👋
Hi there!

Mark Ekisa ivermac

👋
Hi there!
View GitHub Profile
@ivermac
ivermac / gist:a895b28f3546686386f3ed41f61ca2f0
Created February 24, 2018 17:26 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@ivermac
ivermac / multi-line-chained-python-functions.md
Last active March 3, 2018 09:21
Multi-line chained python functions

From a stack overflow link

Before line break

subkeyword = Session.query(
    Subkeyword.subkeyword_id, Subkeyword.subkeyword_word
).filter_by(
    subkeyword_company_id=self.e_company_id
).filter_by(
 subkeyword_word=subkeyword_word
@ivermac
ivermac / nvm-compatiblity-issue.md
Last active March 7, 2018 09:41
nvm compatible issue

I noticed the following warning being triggered when launching the terminal in my Visual Studio app a couple of times but I had ignored it:

➜ nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local" 
  Run `npm config delete prefix` or `nvm use --delete-prefix v8.0.0 --silent` to unset it.

I got the exact same warning when launching tmux locally and that caught my attention. I use nvm locally to manage node versions so initially I thought that was the problem. A quick search on google and I found out that a couple of people had experienced the same problem. I found my solution here in a github

@ivermac
ivermac / url-encoding-and-decoding-python.md
Last active August 14, 2018 12:30
Url encoding and decoding in python

python 2.7

Use urlencode from urllib for encoding and parse_qs from urlparse for decoding. urlencode takes a dict while parse_qs takes a string. I learned from this awesome link.

python 3.6

Use urlencode from urllib.parse for encoding and parse_qs from urllib.parse for decoding. urlencode takes a dict while parse_qs takes a string.

compatibility in both python 2.7 and 3.6 com

Install future package version 0.16.0. Import urlencode and parse_qs from future.moves.urllib.parse.

@ivermac
ivermac / flatten-list-of-lists-in-python.md
Created August 16, 2018 15:43
Flatten list of lists in python

This worked in both python 2.7 and 3.6.4

sum([[1, 2, 3], [4, 5, 6]], [])
@ivermac
ivermac / postgres-cold-reboot-fix-osx.md
Last active September 1, 2018 12:45
Postgres Cold Reboot fix on OSX

I use brew's postgresql service and after cold reboot on the mac I was using, I got the following when I tried to access psql on the command line:

psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

I got my fix from here. In a nutshell, the postmaster.pid file already exists and has to be removed. Removing file that file fixed it for me i.e.

rm -f /usr/local/var/postgres/postmaster.pid

You might also want to to checkout the postgres log file (tail -n 10 /usr/local/var/log/postgres.log) for any errors and bugs.

@ivermac
ivermac / hash-map-to-query-param-string.md
Created September 7, 2018 03:15
Convert clojure hash-map to query param string
(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))]
@ivermac
ivermac / dont-include-non-cljs-dir-in-checkouts-dir.md
Created October 3, 2018 14:47
Dont include non cljs folder in checkouts folder of a cljs project as a symlink

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 / redis-client-debugging-101.md
Last active November 26, 2018 05:56
Redis Client Debugging 101

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 / input-rc.md
Last active December 1, 2018 18:51
Custom .input.rc file

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