Skip to content

Instantly share code, notes, and snippets.

Text is always inserting before cursor
Delete character -> x
Appending text to end of line -> A
d [number] motion -> Deleting
dw -> Delete until the start of next word (More penatration forward)
de -> Delete to end of word
Accesss menu bar -> CTRL + F2

Keybase proof

I hereby claim:

  • I am chamoda on github.
  • I am chamoda (https://keybase.io/chamoda) on keybase.
  • I have a public key whose fingerprint is 632E 804B 0EC9 9042 F264 FF5F 30D0 DB31 2CD8 AB0A

To claim this, I am signing this object:

@chamoda
chamoda / rename.py
Created January 16, 2017 07:38
Script to convert CamelCase filenames to snake_case
import os
import re
files = [f for f in os.listdir('.') if os.path.isfile(f)]
def convert(name):
s = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s).lower()
for file in files:
@chamoda
chamoda / butter_knife_auto.py
Created January 17, 2017 09:34
Autogenerate android butterknife binding code from xml
#! /usr/bin/python
#
# Chamoda Panthage
# chamodac@gmail.com
#
import fileinput
from bs4 import BeautifulSoup
@chamoda
chamoda / tree.py
Created September 5, 2019 13:07
Convert a tree to tabular structure.
from anytree import AnyNode, RenderTree, PreOrderIter
from pandas import DataFrame
root = AnyNode(id=1, name="Parent", children=[
AnyNode(id=2, name="Child1", children=[
AnyNode(id=4, name="GrandChild1"),
AnyNode(id=5, name="GrandChild2"),
]),
AnyNode(id=3, name="Child2", children=[
AnyNode(id=6, name="GrandChild1"),
@chamoda
chamoda / tree.py
Last active September 8, 2019 13:26
Convert tabular data to a forest.
# First row is child, second row is parent.
rows = [
('h', 'd'),
('f', 'c'),
('e', 'b'),
('b', 'a'),
('d', 'b'),
('c', 'a'),
('g', 'c'),
('i', 'd'),
from datetime import date, timedelta
from aiohttp import ClientSession
from aiofiles import open
import asyncio
BASE_URL = "http://documents.gov.lk"
YEAR = 2022
def get_fridays(year) -> list[date]:
@chamoda
chamoda / script.sh
Created March 31, 2024 13:51
Check if your server is vulnerable to xz backdoor
#! /bin/bash
set -eu
# find path to liblzma used by sshd
path="$(ldd $(which sshd) | grep liblzma | grep -o '/[^ ]*')"
# does it even exist?
if [ "$path" == "" ]
then