Skip to content

Instantly share code, notes, and snippets.

View tobius's full-sized avatar

Toby Miller tobius

View GitHub Profile
@tobius
tobius / MACOS-SETUP.md
Last active April 20, 2020 12:43
How to setup a macOS development machine

How to setup a macOS development machine

By default macOS environments are configured to execute lots of different types of applications, but executing things and compiling things are two very different activities that require totally different libraries and system configurations. The following steps will change those default behaviors to make setting up and maintaining development projects a whole lot easier. IOW, this is how to setup a macOS development environment from scratch.

Every project is different and every Developer understands that in order to be effective in today's modern world of programming tools you have to be able, and willing, to wear a lot of hats. This phenomena is often referred to as "polyglot programming". But before you can do that effectively you need to understand your machine and how to turn it into a swiss army knife.

— Tobius

We will be setting up seven specific technology capabilities (in this order):

@tobius
tobius / promise-all-bug.js
Created March 14, 2019 21:27
Promise.all Chaining Bug?
class Foo {
async run() {
setTimeout(() => {
console.log('long wait');
}, 5000);
this.start()
@tobius
tobius / gitrepos
Created July 11, 2018 22:52
Find and show all uncommitted Git repo files in $HOME
#!/usr/bin/env node
/**
* Find and show all uncommitted Git repo files in $HOME
*
* @author Toby Miller <tobius@tobius.co>
* @license MIT
*/
// import
@tobius
tobius / promise-all-map_sync-vs-async.js
Created March 1, 2018 18:51
An example of how differently `Promise.all(arr.map(iteratee))` behaves when iteratee returns a synchronous result (value) versus an asynchronous result (promise).
const chalk = require('chalk');
/**
* sleep given number of milliseconds
*
* @param {Integer} ms
* @return {Void}
*/
function sleep(ms) {
const start = new Date().getTime();
@tobius
tobius / index.js
Created March 1, 2018 14:22
`async.mapLimit` as a `promise`
const Promise = require('bluebird');
/**
* Produce a new collection of values by asynchronously mapping each value in
* `collection` through the `iteratee` function, but running a maximum of
* `limit` operations at a time.
*
* __Inspired by `async.mapLimit`__
*
* @param {Array} collection
@tobius
tobius / findurls.js
Created July 6, 2017 17:56
Find URLs inside SQL Dumps
/**
* [~] npm install chalk lodash
* [~] node thisfile.js yourfile.sql
*/
var _ = require('lodash');
var chalk = require('chalk');
var fs = require('fs');
var path = process.argv.length > 1 ? process.argv[process.argv.length - 1] : null;
@tobius
tobius / vagrant-output.txt
Created December 2, 2016 16:55
Vagrant Error Output
/Users/tobius/.vagrant.d/gems/gems/vagrant-aws-0.7.2/lib/vagrant-aws/config.rb:537:in `read_aws_files': undefined method `[]' for nil:NilClass (NoMethodError)
from /Users/tobius/.vagrant.d/gems/gems/vagrant-aws-0.7.2/lib/vagrant-aws/config.rb:513:in `get_aws_info'
from /Users/tobius/.vagrant.d/gems/gems/vagrant-aws-0.7.2/lib/vagrant-aws/config.rb:326:in `finalize!'
from /opt/vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/kernel_v2/config/vm.rb:490:in `block in finalize!'
from /opt/vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/kernel_v2/config/vm.rb:455:in `each'
from /opt/vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/kernel_v2/config/vm.rb:455:in `finalize!'
from /opt/vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/config/v2/root.rb:50:in `block in finalize!'
from /opt/vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/config/v2/root.rb:49:in `each'
from /opt/vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/config/v2/root.rb:49:in `finalize!'
from /opt/vagrant/embedded/gems/gems/va
@tobius
tobius / userAndRole.js
Created June 26, 2014 16:26
example of user and role associations in sails.js
// user.js
module.exports = {
schema: true,
attributes: {
name: {
type: 'string',
required: true
},
@tobius
tobius / reciprocal_package_installs.md
Created February 27, 2014 14:43
Just to see what would happen.

Reciprocal Package Repository Tests

Just to see what would happen.

NPM

http://npmjs.org/

@tobius
tobius / batchpdftotext
Last active August 29, 2015 13:56
Convert a batch of pdf files into a single text dump
#!/bin/bash
##---------------------------------------------------------------------##
## Convert a batch of pdf files into a single text dump ##
## @author Toby Miller <tobius.miller@gmail.com> ##
## ##
## setup: brew install xpdf ##
## usage: cd pdffolder && batchpdftotext [out.txt] ##
##---------------------------------------------------------------------##