Skip to content

Instantly share code, notes, and snippets.

View jweaver's full-sized avatar

Jack Weaver jweaver

  • ~/
View GitHub Profile
@jweaver
jweaver / steps.md
Created April 4, 2018 23:17 — forked from fredRos/steps.md
Setup emacs with github markdown and pandoc offline rendering

Based on this blog.

This guide shows you how to setup emacs to render a README.md very similarly to how github will do it; except it also works offline. There are no dependencies that can't be easily installed via the package manager on ubuntu.

  1. Install emacs24, the markdown mode, and pandoc. You may need the packages emacs, emacs-goodies-el, and pandoc.
  2. Get a style sheet that resembles the github style from this gist and store it. I put it in ~/emacs.d/github-pandoc.css.
@jweaver
jweaver / new_gist_file.el
Last active February 8, 2018 22:35
Emacs function to insert a random UUID on-demand.From http://ergoemacs.org/emacs/elisp_generate_uuid.html
(random t)
(defun insert-random-uuid ()
"Insert a random UUID.
Example of a UUID: 1df63142-a513-c850-31a3-535fc3520c3d
WARNING: this is a simple implementation. The chance of generating the same UUID is much higher than a robust algorithm.."
(interactive)
(insert
(format "%04x%04x-%04x-%04x-%04x-%06x%06x"
@jweaver
jweaver / disable-plantuml-code-prompt_org-mode.el
Last active March 31, 2022 10:49
Disable the prompt during org-mode export to execute code blocks for plantuml
;; Disable every prompt during an org-mode export, when using plantuml.
;; Useful when you have multiple UML diagrams in an org doc, and you don't
;; want to type 'y' on every export prompt.
(defun my-org-confirm-babel-evaluate (lang body)
(not (string= lang "plantuml")))
(setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate)
@jweaver
jweaver / versioning.gradle
Last active June 2, 2017 15:55
Version Scheme for Android Applications. This bridges the gap between a "version name" and Google's "version code" (a single integer). Using this along with your gradle build, you can convert a typical SNAPSHOT or RC based semantic version string into a monotonically increasing version code, guaranteeing that when an updated APK is installed, it…
ext {
/**
* Builds an Android version code from the version of the project.
* This is designed to handle the -SNAPSHOT and -RC format.
*
* I.e. during development the version ends with -SNAPSHOT. As the code stabilizes and release nears
* one or many Release Candidates are tagged. These all end with "-RC1", "-RC2" etc.
* And the final release is without any suffix.
*/
buildVersionCode = {
@jweaver
jweaver / get-version.sh
Created January 27, 2017 00:05
Maven commands to get and set version
mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec
@jweaver
jweaver / org-mode hot tips.md
Last active August 15, 2016 19:57
Useful org-mode tips pulled from orgmode.org/manual

Jump around within an org-mode file

C-c %     (org-mark-ring-push) Push the current position onto the mark ring, to be able to return easily. Commands following an internal link do this automatically

C-c &     (org-mark-ring-goto) Jump back to a recorded position. A position is recorded by the commands following internal links, and by C-c %. Using this command several times in direct succession moves through a ring of previously recorded positions.

Link to sections within the org-mode document

Headings produce sections, and you want to link (hotlink) to this section elsewhere in the document, and even have that produce a valid URL/anchor link on the HTML export.

For this, use a custom section ID heading:

@jweaver
jweaver / get_mileage.js
Created February 16, 2016 22:54
Use the google matrix API to get the distance in miles from one location to another. This requires the google API Key somewhere in the spreadsheet.
/**
* @OnlyCurrentDoc Limits the script to only accessing the current spreadsheet.
*/
/**
* Take two string addresses, and use the google matrix distance API to
* fetch the mileage (distance) between the two.
*
* @param {String} origin An Address that resolves in Google Maps. The Origin.
* @param {String} destination Another address that varies from the first and
@jweaver
jweaver / keybase.md
Created September 30, 2014 05:12
keybase.io identity verification

Keybase proof

I hereby claim:

  • I am jweaver on github.
  • I am jweaver (https://keybase.io/jweaver) on keybase.
  • I have a public key whose fingerprint is 6B9C 40C2 1408 97F2 2588 93EC E924 F32C 8AA4 6955

To claim this, I am signing this object:

@jweaver
jweaver / gpg encrypt example
Created October 10, 2013 05:56
Encrypt a file on disk, creating an ascii armored version that is "emailable" to a person whose pgp key you have already. The pgp-email-address-here field should auto-complete (tab-complete) with potential recipients from your local keyring.
gpg -ea -r {pgp-email-address-here} -o {encrypted-file-name-output} {input-file-to-encrypt}
@jweaver
jweaver / example-perl-pie
Last active December 21, 2015 21:39
Perl pie. Replace strings across files.
$ perl -pi -e '<some replacement regular expression>' <file or files>
# Example
$ perl -pi -e 's/src/build/g' *