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 / config.md
Created September 8, 2018 16:17 — forked from 0XDE57/config.md
Firefox about:config privacy settings

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 / fetch-basic-auth.md
Created August 1, 2018 14:45
Using fetch with basic auth
let username = 'john';
let password = 'doe';
let url = `https://httpbin.org/basic-auth/${username}/${password}`
let authString = `${username}:${password}`
let headers = new Headers();
headers.set('Authorization', 'Basic ' + btoa(authString))
fetch(url,{method: 'GET', headers: headers})
    .then(function (response) {
 console.log (response)
@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 / my-python-tips-and-tricks.md
Last active May 5, 2020 04:43
My python tips and tricks

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 / 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-type-reflection.md
Created September 1, 2018 12:55
Clojure Type Reflection

Found clojure type reflection useful when using java objects in clojure. Especially in the repl

(use 'clojure.pprint 'clojure.reflect)
(def object-members (:members (reflect <object>)))
(print-table [:name :type :flags] (sort-by :name object-members))

The official documentation is here