Skip to content

Instantly share code, notes, and snippets.

@OliverJAsh
OliverJAsh / main.scpt
Last active Mar 7, 2017
AppleScript to launch a network drive prior to launching an application. Useful if your iTunes or Aperture library is stored remotely.
View main.scpt
# 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 Dec 20, 2015
An example of currying and partial application
View currying.js
// 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 Dec 24, 2015
JS Bin Settings
View README.md

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 Dec 25, 2015
A script to select multiple history entries (in Chrome) that match against a given string — handy for bulk deletions
View chrome-history-select-bulk.js
// 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 Dec 27, 2015
Functional programming experiment
View foo.js
/**
* 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 Aug 29, 2015
`git stash pop` not merging
View foo.md

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 Aug 29, 2015
The Plumber equivalent of the Gruntfile from https://github.com/Mixd/frontend-framework
View Plumbing.js
// 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 Apr 12, 2014
Uncompress a HTTP response when needed
View foo.js
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
Generated by SassMeister.com.
View SassMeister-input-HTML.html
<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">
View a.rb
@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;