Skip to content

Instantly share code, notes, and snippets.

View troyp's full-sized avatar

Troy Pracy troyp

  • Lismore, NSW, Australia
View GitHub Profile
@troyp
troyp / vim-style-key-binding.el
Last active April 14, 2016 21:40
Vim-style keybinding in Emacs/Evil-mode.
(defun kbd+ (keyrep &optional need-vector)
(if (vectorp keyrep) keyrep (edmacro-parse-keys keyrep need-vector)))
(defun gmap (keyrep defstr)
"Vim-style global keybinding. Uses the `global-set-key' binding function."
(global-set-key (kbd+ keyrep) (edmacro-parse-keys defstr t)))
(defun fmap (keybind-fn keyrep defstr)
"Vim-style keybinding using the key binding function KEYBIND-FN."
(call keybind-fn (kbd+ keyrep) (edmacro-parse-keys defstr t)))
@troyp
troyp / describe-symbol.el
Last active June 24, 2016 03:11
describe-symbol command for Emacs 24 (code taken from Emacs 25 sources)
;; Code taken from Emacs 25 source. GPL3.
;; http://repo.or.cz/emacs.git
(global-set-key (kbd "C-h o") 'describe-symbol)
;;;###autoload
(defun describe-symbol (symbol &optional buffer frame)
"Display the full documentation of SYMBOL.
Will show the info of SYMBOL as a function, variable, and/or face."
(interactive
@troyp
troyp / close_all_to_right_or_left.penta
Last active April 29, 2017 09:00
Pentadactyl code to add `:closealltoright` and `:closealltoleft` commands (and corresponding keybindings). Add to `~/.pentadactylrc`. Vimperator versions in https://gist.github.com/troyp/20e4b1f744c5e799f1df
command! closetabstoleft
\ -description "Close all tabs to the left of the current tab"
\ -js
\ var firstTab = tabs.getTab(0);
\ var numToClose = tabs.getTab().dactylOrdinal - 1;
\ tabs.remove(firstTab, numToClose);
command! closetabstoright
\ -description "Close all tabs to the right of the current tab"
\ -js
\ tabIndex = tabs.getTab().dactylOrdinal - 1;
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
//
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it)
//
// Permission is hereby granted, free of charge, to any person
map h previousTab
map l nextTab
map <C-d> scrollPageDown
map <C-u> scrollPageUp
map b :buffer<Space>
map sk<Space> :bookmarks<Space>
map skk :bookmarks /Bookmarks bar/
imap <C-p> backwardLine
imap <C-n> forwardLine
@troyp
troyp / onepiece
Last active January 12, 2021 23:40
One Piece scripts for scraping and caching anime and manga data
onepiece-episode-title: Get an episode title in english, romaji &/or japanese, or print a title according to a format string
prerequisites:
gnu tools: bash, sed, tr
curl
pup (https://github.com/ericchiang/pup)
xmlstarlet (unesc)
onepiece-episode-chapters: List the manga chapters adapted by an episode
prerequisites:
gnu tools: bash, sed, tr
curl
@troyp
troyp / .gitignore
Last active November 12, 2017 00:35 — forked from unbracketed/export_repo_issues_to_csv.py
Export Issues from Github repo to CSV (API v3)
user_data.sh
@troyp
troyp / colours.sh
Created November 12, 2017 21:21
Display colours used for different file types
#!/bin/bash
# Script to show the colours used for different file types
# Taken from https://github.com/gkotian/gautam_linux/blob/master/scripts/colours.sh
# This is just a more readable version of the 'eval' code at:
# http://askubuntu.com/a/17300/309899
# A nice description of the colour codes is here:
@troyp
troyp / xreadkeys.c
Created January 18, 2018 01:03 — forked from javiercantero/xreadkeys.c
A X11/Xlib program that reads the KeyPress and KeyRelease events from the window and prints them to the standard output. Used to debug the keyboard within X.
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
Display *display;
Window window;
XEvent event;
int s;
@troyp
troyp / jono.csv
Last active August 16, 2019 02:06
manga onomatopeia
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 4 columns, instead of 3. in line 1.
kana,equivalent,meaning,examples
ウキ,kee;screech,monkey cry
ウン,groan;mmm;hmmm,groaning sound,One Piece ch788p16
が,chatter,background voices
ガガ,bam bam;pow pow;rattattat,sound of multiple closely-spaced impacts or explosions,One Piece ch788p12
ガギ,clang,clanging,One Piece ch788p13
カツン,clomp,sound of (esp. heavy) footfalls,One Piece ch788p13
ギャ,eek!,shriek (often girlish)
ギャアー,aargh!,screaming;extreme shock;terror,One Piece ch779 (vol78p70)
キラキラ,sparkle;twinkle,twinkling of a star;sparkle of jewellery;sparkling with excitement