Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / Presentation.ipynb
Created July 15, 2014 16:00
cinspect presentation IPython notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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 / gh-ipynb.user.js
Last active October 8, 2017 00:02
GitHub IPynb rendering
// ==UserScript==
// @name GitHub IPynb rendering
// @namespace ghipynb
// @version 0.3.1
// @description Renders raw IPython notebooks on GitHub using nbviewer and Frames!
// @license WTFPL
// @match *://*.github.com/*
// @match *://github.com/*
// @match *://gist.github.com/*
// @grant none
@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 / quidditch.clj
Created March 30, 2019 16:31
Quidditch simulation - ClojureBridge BLR workshop
(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 / 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 / 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
@punchagan
punchagan / upai-topscore.py
Created August 3, 2019 15:58
UPAI topscore request example
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',