Skip to content

Instantly share code, notes, and snippets.

View jweaver's full-sized avatar

Jack Weaver jweaver

  • ~/
View GitHub Profile
@jweaver
jweaver / app.js
Created August 25, 2012 21:43
Wrapping Repojs as an Angularjs Directive
var myApp = angular.module('myApp', []);
myApp.directive('repository', function() {
return {
restrict: 'C',
scope: {
owner: '@repoOwner',
name: '@repoName'
},
link: function(scope, element, attrs, controller) {
//attach to 'repoOwner' due to ordering of attributes in element. TODO: Is there a better way?
@jweaver
jweaver / proxy-example
Created August 10, 2013 23:54
How to use a Proxy (example). Useful for debugging, as logging can be done as the object under proxy is changed for any value(s).
var engineer = { name: 'Joe Sixpack', salary: 50 };
var interceptor = {
set: function (receiver, property, value) {
console.log(property, 'is changed to', value);
receiver[property] = value;
}
};
engineer = Proxy(engineer, interceptor);
@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' *
@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 / 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 / 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 / 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-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 / 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 / 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)