Skip to content

Instantly share code, notes, and snippets.

@adeel
adeel / arXiv-download.js
Created October 16, 2022 01:18
bookmarklet for downloading pdf from arXiv (with filename: "Author1-Author2 - Title.pdf")
var title = $$("h1.title")[0].innerText;
var authors = $$(".authors a").map(a => a.innerText.split(" ").pop()).join("-");
var link = $$("a.download-pdf")[0];
link.download = authors + " - " + title + ".pdf";
link.click();
@adeel
adeel / push-notifications.clj
Created July 26, 2011 01:03
Example of sending Apple push notifications with Clojure.
; Depends on [com.notnoop.apns/apns "0.1.6"].
(:import ('com.notnoop.apns APNS))
(defn send-push-notification [device-token message]
(let [service (.build (.withSandboxDestination
(.withCert (APNS/newService) "resources/apns-dev-cert.p12" "password")))
payload (.build (.alertBody (APNS/newPayload) message))]
(.push service device-token payload)))
@adeel
adeel / roam-mathjax.js
Created September 9, 2020 12:40
Enable MathJax in Roam (this goes in roam/js).
window.MathJax = {
tex: {
inlineMath: [["$","$"]],
displayMath: [["\\[","\\]"]],
processEscapes: true,
}
};
(function() {
var script = document.createElement("script");
@adeel
adeel / gist:ba01e1ca611b4ea455b94628ac09bbd4
Created February 22, 2019 04:41
CompilerException when running `lein ring server-headless`
❯ lein ring server-headless
clojure.lang.Compiler$CompilerException: Syntax error macroexpanding clojure.core/fn at (clojure/core/unify.clj:83:18).
#:clojure.error{:phase :macro-syntax-check, :line 83, :column 18, :source "clojure/core/unify.clj", :symbol clojure.core/fn}
at clojure.lang.Compiler.checkSpecs (Compiler.java:6971)
clojure.lang.Compiler.macroexpand1 (Compiler.java:6987)
clojure.lang.Compiler.analyzeSeq (Compiler.java:7092)
clojure.lang.Compiler.analyze (Compiler.java:6789)
clojure.lang.Compiler.analyzeSeq (Compiler.java:7094)
clojure.lang.Compiler.analyze (Compiler.java:6789)
clojure.lang.Compiler.access$300 (Compiler.java:38)
@adeel
adeel / arXiv_citation.js
Last active October 20, 2018 07:50
arXiv citation bookmarklet
// Save the following as a bookmark:
// javascript:(function()%7Bfunction%20callback()%7B(function(%24)%7Bvar%20jQuery%3D%24%3Bvar%20authors%20%3D%20%24(%22.authors%20a%22).map(function()%20%7Breturn%20%22%5B%5B%22%20%2B%20%24.trim(%24(this).html())%20%2B%20%22%5D%5D%22%3B%7D).get().join(%22%2C%20%22)%3B%24(%22.title%20.descriptor%22).remove()%3Bvar%20title%20%3D%20%24.trim(%24(%22.title%22).html())%3Bvar%20arxivId%20%3D%20%24(%22.arxivid%20a%22).html()%3Bvar%20URL%20%3D%20location.href%3Bvar%20citation%20%3D%20%22*%20%22%20%2B%20authors%20%2B%20%22%2C%20_%22%20%2B%20title%20%2B%20%22_%2C%20%5B%22%20%2B%20arxivId%20%2B%20%22%5D(%22%20%2B%20URL%20%2B%20%22).%22%3Bwindow.prompt(%22Copy%20to%20clipboard%3A%20Ctrl%2BC%2C%20Enter%22%2C%20citation)%7D)(jQuery.noConflict(true))%7Dvar%20s%3Ddocument.createElement(%22script%22)%3Bs.src%3D%22https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fjquery%2F2.1.3%2Fjquery.min.js%22%3Bif(s.addEventListener)%7Bs.addEventListener(%22load%22%2Ccallback%2Cfalse)%7Delse%20if(s.ready
@adeel
adeel / instiki_to_mediawiki.py
Last active December 6, 2017 14:54
conversion script from instiki to mediawiki (in progress)
# instiki_to_mediawiki.py
from optparse import OptionParser
import os.path
import re
import cgi
import sys
import subprocess
category_regex = re.compile(r"(:)?category\s*:(.*)", re.IGNORECASE)

Keybase proof

I hereby claim:

  • I am adeel on github.
  • I am preschema (https://keybase.io/preschema) on keybase.
  • I have a public key ASAxeUXSSO0Q6cuYqAiQ2-XCbBlF3ZMOZXAewxfkzMMwWgo

To claim this, I am signing this object:

@adeel
adeel / mplayer.py
Created August 24, 2009 04:09
mplayer wrapper
import os
import time
import subprocess
import threading
import Queue
# c.f.: http://is.gd/2T1p
path = '/usr/bin/mplayer'
@adeel
adeel / plainnat-aky.bst
Last active December 23, 2015 15:59
a modification of the bibliography style `plainnat` provided by the package `natbib`, which uses a hyphen to separate multiple author names instead of " and ".
%% File: `plainnat-aky.bst'
%% A modification of `plainnat.bst' to use hyphens to separate
%% multiple author names instead of " and ".
%% See http://tex.stackexchange.com/questions/134512/using-an-en-dash-for-multiple-author-citations-with-natbib
%%
%% Modified on 22.9.2013 by AKY. The original author's comments
%% follow.
%%%%
%% File: `plainnat.bst'
%% A modification of `plain.bst' for use with natbib package
@adeel
adeel / aak-layout.sty
Created April 3, 2013 03:48
new latex style files
\ProvidesPackage{aak-layout}
\usepackage[colorlinks=true,linkcolor=blue]{hyperref}
\RequirePackage[
textheight=0.7\paperheight,
textwidth =0.7\paperwidth,
top =0.1\paperheight,
bottom =0.2\paperheight,
left =0.1\paperwidth,