Skip to content

Instantly share code, notes, and snippets.

View OliverJAsh's full-sized avatar

Oliver Joseph Ash OliverJAsh

View GitHub Profile
@OliverJAsh
OliverJAsh / main.scpt
Last active March 7, 2017 13:10
AppleScript to launch a network drive prior to launching an application. Useful if your iTunes or Aperture library is stored remotely.
# Options
set networks to {"YOUR_SSID"}
set diskName to "YOUR_DISK_NAME"
set mountPath to "afp://192.168.0.2/" & diskName
set applicationName to "YOUR_APPLICATION_NAME"
# Get wireless network SSID
set SSID to do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk '/ SSID: / {print $2}'"
# Test if we are connected to the right network(s)
@OliverJAsh
OliverJAsh / currying.js
Last active December 20, 2015 21:58
An example of currying and partial application
// Manual currying (no abstraction; right to left)
function prop(key) {
return function (object) {
return object[key]
};
}
var nameProp = prop('name');
[ { name: 'Bob' } ].map(nameProp);
@OliverJAsh
OliverJAsh / README.md
Last active December 24, 2015 09:39
JS Bin Settings

JS Bin Settings

JSBin internally uses the CodeMirror library for it's HTML, JavaScript, and CSS code editors. JSBin exposes the Configuration Settings of CodeMirror and allows you to set them yourself. The settings are stored in localStorage so they are available the next time you use JSBin. CodeMirror supports a whole suite of settings, but the following are the ones that I am most interested in:

  • theme - Color scheme that will be used for the editor. Currently the following themes exist: solarized-light, solarized-dark, monokai, vibrant-ink, cobalt, blackboard, ambiance, & jsbin (default)
  • indentUnit - The number of spaces inside a block of code
  • smartIndent - Automatically indent based on the context of what you are doing
  • tabSize - This defines the width of the tab character
  • indentWithTabs - Determines if you want to use tabs instead of spaces when you intent
  • autoClearEmptyLines - Clears lines that only have whitespace
@OliverJAsh
OliverJAsh / chrome-history-select-bulk.js
Last active December 25, 2015 14:28
A script to select multiple history entries (in Chrome) that match against a given string — handy for bulk deletions
// Go to chrome://history-frame and run the following script from the console:
var url = window.prompt('Enter a URL to match');
var entries = document.querySelectorAll('.entry');
Array.prototype.forEach.call(entries, function (entry) {
var test = new RegExp(url)
if (test.exec(entry.querySelector('.title a').attributes.getNamedItem('href').value)) {
entry.querySelector('input[type="checkbox"]').checked = true;
}
});
@OliverJAsh
OliverJAsh / foo.js
Last active December 27, 2015 21:29
Functional programming experiment
/**
* Goal: add 10 to each persons age using functions from Lodash and curry only.
*
* I have provided a custom version of curry, instead of using _.curry, as
* the one in Lodash sadly doesn't play nicely here.
*
* Transform:
* [ { name: 'Foo', age: 20 }, { name: 'Baz', age: 21 } ]
* into:
* [ { name: 'Foo', age: 30 }, { name: 'Baz', age: 31 } ]
@OliverJAsh
OliverJAsh / foo.md
Last active August 29, 2015 13:57
`git stash pop` not merging

If you’re trying to pop a stash and Git won’t merge for you because you have changes in your index to the same file(s) (Git needs to use the index to do a merge at all), i.e.:

❯ gsp
error: Your local changes to the following files would be overwritten by merge:
	index.html
Please, commit your changes or stash them before you can merge.
Aborting
@OliverJAsh
OliverJAsh / Plumbing.js
Last active August 29, 2015 13:57
The Plumber equivalent of the Gruntfile from https://github.com/Mixd/frontend-framework
// https://github.com/plumberjs/plumber
var all = require('plumber-all');
var glob = require('plumber-glob');
var bower = require('plumber-bower');
var uglifyjs = require('plumber-uglifyjs')();
var concat = require('plumber-concat');
var filter = require('plumber-filter');
var mincss = require('plumber-mincss');
var rename = require('plumber-rename');
@OliverJAsh
OliverJAsh / foo.js
Created April 12, 2014 14:21
Uncompress a HTTP response when needed
var request = require('request');
var stream = require('stream');
var zlib = require('zlib');
var websiteRequest = request('http://oliverjash.me/', {
headers: {
'Accept-Encoding': 'gzip,deflate'
}
});
@OliverJAsh
OliverJAsh / SassMeister-input-HTML.html
Created May 9, 2014 16:11
Generated by SassMeister.com.
<div class="l-row l-desktop-row">
<div class="l-desktop-row__item flex-2">
<section class="island">
<h1>We build in pursuit of a cause that is greater than ourselves.</h1>
<div class="l-row l-tablet-row l-tablet-row--max-2">
<div class="l-tablet-row__item">
<section class="island">
<h1 class="h3">Empowering journalists</h1>
<p>We build products that make it easier for journalists to publish informative and delightful stories.</p>
<div class="l-row l-default-row l-default-row--max-2">
@mixin font-size($percent, $min-font-size, $max-font-size) {
// Min
font-size: $min-font-size;
@include breakpoint($min-font-size/$percent * 100) {
font-size: #{$percent}vw;
}
@include breakpoint($max-font-size/$percent * 100) {
font-size: $max-font-size;