Skip to content

Instantly share code, notes, and snippets.

View dbani-dev's full-sized avatar
🔨
Working...

David Bani dbani-dev

🔨
Working...
  • Shell Energy
  • Perth, Western Australia
View GitHub Profile
class PollingBase {
poll = async ({ fn, validate, interval, maxAttempts = 10 }) => {
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
for (let attempts = 0; attempts < maxAttempts; attempts++) {
try {
const result = await fn()
if (validate(result)) {
return result
@dbani-dev
dbani-dev / gist:3da1c44c33e4688d12027c8cc4ff186f
Created January 2, 2018 00:15 — forked from scottious/gist:0d99ea77daa041b28929
__git_ps1 command not found issue.

I've been having an issue with the following error appear in the prompt after upgrading to Yosemite. The solution was to source the git bash completion and prompt files from a local copy.

    curl -o ~/.git-completion.bash https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
    curl -o ~/.git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh

Then in:

    vi ~/bash_profile

Add:

@dbani-dev
dbani-dev / interval.js
Created August 19, 2016 02:33 — forked from bendc/interval.js
Better setInterval
const interval = (callback, delay) => {
const tick = now => {
if (now - start >= delay) {
start = now;
callback();
}
requestAnimationFrame(tick);
};
let start = performance.now();
requestAnimationFrame(tick);
@dbani-dev
dbani-dev / merge.js
Created July 22, 2016 03:54 — forked from bendc/merge.js
Deep merge of JSON-like objects
const merge = (() => {
const duplicate = object => JSON.parse(JSON.stringify(object));
return (...objects) => Object.assign(...objects.map(duplicate));
})();
@dbani-dev
dbani-dev / define.js
Created July 10, 2016 13:54 — forked from bendc/define.js
Friendlier object definition
const define = (object, ...pairs) =>
(Array.isArray(pairs[0]) ? pairs : [pairs]).reduce((accumulator, pair) => {
const [ key, value ] = pair;
return Object.defineProperty(accumulator, key, { value, enumerable: true });
}, object);
@dbani-dev
dbani-dev / cli.bash
Created December 6, 2015 04:37 — forked from ryanseddon/cli.bash
Mocha compiler for css-module support in tests using sass
mocha --compilers js:babel/register,js:./test/css-modules-compiler.js --recursive -w
@dbani-dev
dbani-dev / es6
Last active August 29, 2015 14:27 — forked from dvidsilva/es6
es6 and recursion, examples from http://raganwald.com/2015/02/02/destructuring.html
const length = ([first, ...rest]) =>
first === undefined
? 0
: 1 + length(rest);
const flatten = ([first, ...rest]) => {
if (first === undefined) {
return [];
}
@dbani-dev
dbani-dev / .vimrc
Last active August 29, 2015 14:26 — forked from anonymous/.vimrc
"---------------------------------------------------"
" Author: Karl Brightman "
" Homepage: http://karlbrig.ht "
" Source: http://github.com/karlbright/vimrc "
"---------------------------------------------------"
" vim:set ts=2 sts=2 sw=2 expandtab:
autocmd!
filetype off "Turn off file type detection. Required for Vundle
// array utils
// =================================================================================================
const combine = (...arrays) => [].concat(...arrays);
const compact = arr => arr.filter(Boolean);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)

###Expose IIS or IISExpress running in a Parallels Windows 7/8 VM to your OS X host

####Rename your virtual machine In your Windows 7/8 VM, go to Control Panel > System > Advanced system settings > Computer Name and click Change. Name this whatever you like, e.g. windows. Restart your VM.

####Add an ACL rule Open CMD or Powershell as administrator. Add a URL ACL entry for your new name on the port of your choice, e.g.
netsh http add urlacl url=http://windows:8080/ user=everyone

####Add a firewall rule