Skip to content

Instantly share code, notes, and snippets.

@raghavio
raghavio / karabiner-config.json
Last active November 18, 2025 20:21
Keyboard config for Karabiner for setting command to caps lock etc.
{
"description": "Caps Lock to Command, Swap Command and Option",
"manipulators": [
{
"from": {
"key_code": "caps_lock",
"modifiers": { "optional": ["any"] }
},
"to": [{ "key_code": "left_command" }],
"to_if_alone": [{ "key_code": "escape" }],
@raghavio
raghavio / kanata-config.kbd
Created March 1, 2025 08:03
My Kanata config to treat caps lock key as control and escape. Along with tab + hjkl for arrow keys.
#|
This minimal config changes Caps Lock to act as Escape on quick tap, but
if held, it will act as Left Ctrl. It also changes the tab key to
act as tab on quick tap, but change hjkl keys to arrow keys on hold.
|#
(defcfg
#|
This configuration will process all keys pressed inside of kanata, even if
they are not mapped in defsrc. This is so that certain actions can activate
@raghavio
raghavio / karabiner-profile-switch.sh
Last active February 24, 2025 11:31
Switch Karabiner profiles on screen change using Deskflow/Syngery
echo '#!/bin/bash
tail -f /Users/raghav/deskflow.log | awk \'/leaving screen/{system("/Library/Application\\ Support/org.pqrs/Karabiner-Elements/bin/karabiner_cli --select-profile \"Disabled\"")} /entering screen/{system("/Library/Application\\ Support/org.pqrs/Karabiner-Elements/bin/karabiner_cli --select-profile \"Default profile\"")}\'' > ~/karabiner-profile-switch.sh
#|
This minimal config changes Caps Lock to act as Escape on quick tap, but
if held, it will act as Left Ctrl. It also changes the tab key to
act as tab on quick tap, but change hjkl keys to arrow keys on hold.
|#
(defcfg
#|
This configuration will process all keys pressed inside of kanata, even if
they are not mapped in defsrc. This is so that certain actions can activate
@raghavio
raghavio / mastermind.clj
Created January 15, 2024 04:00
A mastermind implementation in Clojure. Made at Recurse Center pairing workshop with Felix Caraballo.
(require '[clojure.string :as str])
(def colors ["red" "blue" "yellow" "green" "purple" "pink"])
(defn secret
[colors]
(mapv (fn [_] (rand-nth colors)) (range 4)))
(defn match
[secret color-input index]
(cond
@raghavio
raghavio / lisp_parser.clj
Created November 25, 2023 22:09
Lisp tokenizer in Clojure
(ns lisp_parser
(:require [clojure.string :as str]))
(declare tokenize-expression)
(defmulti ^:private parse-tokens
"Dispatches based on the first element in the token collection"
(fn [[token & _]]
(when (contains? #{"}" "]" ")"} token) ;; If code str is starting with ending brackets, throw error.
(throw (Exception. (str "Unmatched delimiter: " token))))
@raghavio
raghavio / cracklepop.clj
Created November 25, 2023 21:56
CracklePop in Clojure
(ns cracklepop)
(defn ^:private crackle-pop
"Accepts a number and checks if it meets the criteria for CracklePop.
If the number is divisible by 3, return 'Crackle'.
If the number is divisible by 5, return 'Pop'.
If the number is divisible by both 3 and 5, return 'CracklePop'.
If none of the above conditions meet, return the number."
[n]
(let [divisible? (comp zero? mod)]
@raghavio
raghavio / readme.txt
Created March 23, 2016 00:22
Socket webserver in Python with API support
Requirements:
Python 2.7
How to run:
python webserver.py
Test using cURL:
Create connection:
curl -i -X GET "http://localhost:8080/api/request?connId=1&timeout=5"
@raghavio
raghavio / amazonscraper.py
Created March 6, 2016 12:12
Scraps book details from Amazon.in
import requests
import re
import time
import csv
from urllib import urlretrieve
from bs4 import BeautifulSoup
bookURLs = []