Skip to content

Instantly share code, notes, and snippets.

@punchagan
punchagan / .gitignore
Last active Apr 27, 2020
Zoom Meetings Command Line
View .gitignore
/.mypy_cache/
/.envrc
@punchagan
punchagan / .gitignore
Last active Oct 17, 2019
Whatsapp Broadcast Export to Zulip
View .gitignore
*.zip
*.jpg
/*.txt
@punchagan
punchagan / upai-topscore.py
Created Aug 3, 2019
UPAI topscore request example
View upai-topscore.py
import requests
import json
# Obtain this from https://upai.usetopscore.com/u/oauth-key
client_id = 'XXX'
client_secret = 'YYY'
data = {
'grant_type': 'client_credentials',
@punchagan
punchagan / quidditch.clj
Created Mar 30, 2019
Quidditch simulation - ClojureBridge BLR workshop
View quidditch.clj
(ns teaching-clojure.quidditch)
(def game-at-start
{:gryffindor {:score 0
:players 7}
:slytherin {:score 0
:players 7}})
(def opposition {:gryffindor :slytherin
:slytherin :gryffindor})
@punchagan
punchagan / nikola-to-hugo.py
Last active Dec 7, 2019
Nikola to Hugo tools
View nikola-to-hugo.py
#!/usr/bin/env python3
""" Script to convert a Nikola blog to Hugo
Requirements:
- toml
Usage:
./nikola-to-hugo.py /path/to/nikola/blog
@punchagan
punchagan / kindle.js
Last active Aug 21, 2018
Readable view & Downloads for Kindle notebook (highlights) page
View kindle.js
// Visit https://read.amazon.com/notebook
(function(){
var highlights_markdown = function(){
var markdown = "";
for (var i=0; i < highlights.length; i++){
markdown += "> " + highlights[i] + "\n\n";
var note = notes[i];
if (note !== "") {
markdown += note + "\n\n";
}
@punchagan
punchagan / prepare-commit-msg.sh
Last active Apr 23, 2019 — forked from bartoszmajsak/prepare-commit-msg.sh
How to automatically prepend git commit with a branch name
View prepare-commit-msg.sh
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test release/candidate)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"
@punchagan
punchagan / *scratch*.el
Created Jun 21, 2016
Org drill related code
View *scratch*.el
(defun my/org-drill (tag)
(interactive "MTag: ")
(let ((org-drill-tag tag))
(call-interactively #'org-drill)))
@punchagan
punchagan / elfeed-url-bookmarklet.js
Created Jun 11, 2016
Elfeed org-capture bookmarklet
View elfeed-url-bookmarklet.js
javascript:(function(){
var url_element =
document.querySelector('link[type="application/rss+xml"]') ||
document.querySelector('link[type="application/atom+xml"]') ||
location;
var url = url_element.href;
location.href = 'org-protocol://capture://L/'+
encodeURIComponent(url)+'/'+
encodeURIComponent(document.title);
})();
View org-column-new-row.el
(org-defkey org-columns-map "N" 'pc/org-columns-new-row)
(defun pc/org-columns-new-row (&optional key)
"Allow adding a new row."
(interactive)
(save-excursion
(save-restriction
(org-beginning-of-line)
(org-with-silent-modifications
(org-insert-heading)