Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / *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 / 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 / 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 / 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 / hello.py
Last active December 21, 2023 23:36
A simple Flask sockets example
# Copy of http://stackoverflow.com/a/20104705
from flask import Flask, render_template
from flask_sockets import Sockets
app = Flask(__name__)
app.debug = True
sockets = Sockets(app)
@sockets.route('/echo')
@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 / video-loopback
Created March 29, 2014 18:05
Brighter video, thanks to video loopback and gstreamer
#!/bin/bash
MODULE=v4l2loopback
if grep -q $MODULE /proc/modules;
then
echo $MODULE already loaded
else
echo loading $MODULE
sudo modprobe $MODULE