Skip to content

Instantly share code, notes, and snippets.

@punchagan
punchagan / install.sh
Last active August 29, 2015 14:04
A columned LEDStrip module for RPi
set -e
# Defaults to install where install.sh is located
INSTALL_DIR="$( cd "$(dirname "$0")" ; pwd -P )"
BUILD_DIR=${INSTALL_DIR}/BUILD
mkdir -p $BUILD_DIR
pushd $BUILD_DIR
@punchagan
punchagan / pygmentize.el
Created November 9, 2014 15:12
Pygmentize code for Nikola
;; Use pygments highlighting for code
(defun pygmentize (lang code)
"Use Pygments to highlight the given code and return the output"
(with-temp-buffer
(insert code)
(let ((lang (or (cdr (assoc lang org-pygments-language-alist)) "text")))
;; A crazy hack!! Why src-block have no info?!@!@#
(let* ((file-name (format "%s.png" (sha1 code)))
(output-path (format "%s" file-name))
(url (format "%s" file-name)))
@punchagan
punchagan / search_github_users.py
Last active June 1, 2017 15:51
GitHub users search
""" A simple script to search for GitHub users. """
from __future__ import print_function
import json
from os.path import abspath, dirname, exists, join
import requests
from requests.utils import quote
@punchagan
punchagan / *clocking*.el
Last active June 1, 2017 15:45
Org clock demo code
(if (org-clocking-p)
(message (concat "I am currently clocking into " org-clock-heading))
(message "I am slacking off!"))
@punchagan
punchagan / org-column-new-row.el
Last active June 2, 2016 05:43
org-columns add row
(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)
@punchagan
punchagan / elfeed-url-bookmarklet.js
Created June 11, 2016 13:25
Elfeed org-capture bookmarklet
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);
})();
@punchagan
punchagan / *scratch*.el
Created June 21, 2016 20:54
Org drill related code
(defun my/org-drill (tag)
(interactive "MTag: ")
(let ((org-drill-tag tag))
(call-interactively #'org-drill)))
@punchagan
punchagan / prepare-commit-msg.sh
Last active April 23, 2019 04:01 — forked from bartoszmajsak/prepare-commit-msg.sh
How to automatically prepend git commit with a branch name
#!/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 / kindle.js
Last active August 21, 2018 03:48
Readable view & Downloads for Kindle notebook (highlights) page
// 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 / nikola-to-hugo.py
Last active December 7, 2019 05:53
Nikola to Hugo tools
#!/usr/bin/env python3
""" Script to convert a Nikola blog to Hugo
Requirements:
- toml
Usage:
./nikola-to-hugo.py /path/to/nikola/blog