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:471bced069c3928e4033c4c7522b57c1
Last active March 31, 2024 03:58
Renaming user in ubuntu when using WSL2

Recently (well a couple of hours ago 😆) I installed Ubuntu 22.04 on my WSL2 but I misspelled my username and I had to ( wanted to is more accurate 😆) change to my preferred username. I got all my insights from here and here.

 wsl -d ubuntu-22.04 -u root usermod -l <new-username> <old-username>
 wsl -d ubuntu-22.04 -u root groupmod -n <new-groupname> <old-groupname>
 wsl -d ubuntu-22.04 -u root usermod -d /home/<new-home-directory> -m <new-username>

I got excited this worked the first time and I wanted to write about it 😄

@ivermac
ivermac / shell-utility-commands.md
Last active November 19, 2020 14:14
Shell utility commands

check diskspace ubuntu

sudo fdisk -l

sudo lsblk

check files and directories size in a directory in ubuntu

ll --block-size=M

du -hc | sort -rh | head -20

@ivermac
ivermac / ansbile_tips.yml
Created September 18, 2020 17:51 — forked from bmwant/ansbile_tips.yml
ansible quick tips for some modules
# Check existing
- name: Ansible check file exists.
stat:
path: /etc/filename
register: file_status
- debug:
msg: "File exists..."
when: file_status.stat.exists
- debug:
msg: "File not found"
@ivermac
ivermac / gpg_helper.md
Last active July 18, 2020 14:51
GPG helper

List gpg keys:

gpg --list-keys --keyid-format LONG

Search key in key server:

gpg --search <email>

I'm a mac user and I use crontab -e to render the crone job editor. I added comments that help me remember the cron job pattern/format.

# |minute (0 - 59)
# |
# | |hour (0 - 23)
# | |
# | | |day of month (1 - 31)
# | | |
@ivermac
ivermac / kill-pm2-god-daemon.md
Created March 20, 2020 05:24
Kill pm2 god daemon

Killing pm2 god daemon

ps aux | grep -i pm2 | grep <user> | grep -v grep | awk '{print $2}' | xargs kill -9

A small alteration from the github solution given here

@ivermac
ivermac / clojure-load-and-check-namespace.md
Last active November 23, 2019 16:35
Load and check if a namespace exists
(defn namespace-exists?
  "check that a namespace has been loaded"
  [str-val]
  (-> str-val
      symbol
      find-ns
      nil?
      not))
 
@ivermac
ivermac / javascript-filename-in-resources-directory.md
Last active November 23, 2019 16:07
Using Clojure to retrieve javascript file names in resources directory
(:require [clojure.java.io :as io])

(defn get-file-names [directory-object files-path]
  (let [full-directory-path (.getPath directory-object)
        get-js-file-path (fn [file]
                           (str files-path (.getName file)))]
    (->> full-directory-path
         io/file
 file-seq
@ivermac
ivermac / resolve-and-call-symbol-derived-from-a-string.md
Created September 19, 2019 08:21
Resolve and Call symbol derived from a string
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 June 28, 2019 12:42 — forked from john2x/00_destructuring.md
Clojure Destructuring Tutorial and Cheat Sheet

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