Skip to content

Instantly share code, notes, and snippets.

@harizvi
harizvi / gist:405b1b0531111a6c3bf70ed05056001f
Last active September 13, 2021 21:57 — forked from philc/gist:e849b48e6c5f32592d62
A script to copy Chrome's search engine settings into Vimium's settings format
#!/bin/sh
# This script lists user defined search engines in Chromium.
# It replaces {inputEncoding}, which appears in some search engine definitions, with
# UTF-8, {google:baseURL} with the Google URL, and omits other such tokens.
# can take browser name as first argument.
# 'Google Chrome', Chromium, BraveSoftware/Brave-Browser
browser=${1:-Vivaldi}
;; discussion in reddit about clipping from browser.
(defun hr/paste-html-to-org ()
"Takes the contents of the system clip/paste-board, and uses
`pandoc' to convert it to the org-mode format."
(interactive)
(let* ((clip (if (eq system-type 'darwin)
"pbv public.html"
"xclip -out -selection 'clipboard' -t text/html"))
(format (if (eq major-mode 'org-mode) "org" "markdown"))
(pandoc (concat "pandoc -f html -t " format))
@harizvi
harizvi / misc_fn.lua
Created May 27, 2021 21:37
Hammerspoon code to extract a caller's number and issue a ddg search.
local char_to_hex = function(c)
return string.format("%%%02X", string.byte(c))
end
local function urlencode(url)
if url == nil then
return
end
url = url:gsub("\n", "\r\n")
url = url:gsub("([^%w ])", char_to_hex)
@harizvi
harizvi / .gnus.el
Last active January 10, 2019 18:49
Gnus setup for opening urls from nntp headers added by various RSS feeds / mailing lists.
;; user Return key to pull up the page in browser
(defun browse-nnrss-url( arg )
(interactive "p")
(let ((url (assq nnrss-url-field
(mail-header-extra
(gnus-data-header
(assq (gnus-summary-article-number)
gnus-newsgroup-data))))))
(if url
@harizvi
harizvi / # pdf-tools - 2018-11-29_14-59-05.txt
Created November 29, 2018 22:01
pdf-tools (dunn/emacs/pdf-tools) on macOS 10.13.6 - Homebrew build logs
Homebrew build logs for dunn/emacs/pdf-tools on macOS 10.13.6
Build date: 2018-11-29 14:59:05
// only keep E, R and T from Surfingkeys for gmail.com and twitter.com
unmapAllExcept(['E','R','T'], /gmail.com|twitter.com|yahoo.com/);
// an example to create a new mapping `ctrl-y`
mapkey('<Ctrl-y>', 'Show me the money', function() {
Front.showPopup('a well-known phrase uttered by characters in the 1996 film Jerry Maguire (Escape to close).');
});
// an example to replace `T` with `gt`, click `Default mappings` to see how `T` works.
map('gt', 'T');
@harizvi
harizvi / init.lua
Created October 22, 2014 19:47
Config for hydra
--
-- Configuration for Hydra <https:--github.com/sdegutis/Hydra>
--
-- Haider Rizvi <harizvi@gmail.com>
-- Started: Friday, July 25, 2014 6:22 PM
-- Update Time-stamp: <2014-09-22 08:56:10 haider>
--
notify.show("Hydra", "Started!","","")
@harizvi
harizvi / smartlyplacewindow
Created July 27, 2014 02:44
Place windows based on window app or title
function ext.utilfns.smartlyPlaceWindow()
local win = window.focusedwindow()
local winName = win:title()
local appName = win:application():title()
if (string.match(winName, "started: ")) then -- sametime messaging window
positioncurrentwindow(win,{0.01,0.15,0.45,0.65})
elseif (string.match(winName, "IBM Sametime Connect")) then
positioncurrentwindow(win,{0,0,0.2,0.9})
elseif (appName == "Adium" and string.match(winName, "Contacts")) then -- Adium contacts window