This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"compilerOptions": { | |
"target": "es5", | |
"module": "commonjs", | |
"lib": ["es2017", "es7", "es6", "dom"], | |
"declaration": true, | |
"outDir": "dist", | |
"strict": true, | |
"esModuleInterop": true | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const axios = require('axios'); | |
const http = require('http'); | |
const https = require('https'); | |
module.exports = axios.create({ | |
//60 sec timeout | |
timeout: 60000, | |
//keepAlive pools and reuses TCP connections, so it's faster | |
httpAgent: new http.Agent({ keepAlive: true }), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EventEmitter { | |
constructor() { | |
this.target = new EventTarget(); | |
} | |
on(eventName, listener) { | |
return this.target.addEventListener(eventName, listener); | |
} | |
once(eventName, listener) { | |
return this.target.addEventListener(eventName, listener, { once: true }); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
target="${1:-/Applications}" | |
check() { | |
stat "$1/Contents/Frameworks/Electron Framework.framework" &> /dev/null | |
if [[ $? = 0 ]]; then | |
echo "$1 uses Electron" | |
fi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu -o pipefail | |
count=$(find . -depth 1 -name "*.HEIC" | wc -l | sed 's/[[:space:]]*//') | |
echo "converting $count files .HEIC files to .jpg" | |
magick mogrify -monitor -format jpg *.HEIC | |
echo "Remove .HEIC files? [y/n]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* takes a list of async functions and executes them one at a time | |
*/ | |
async function serial( | |
fnList: Array<() => Promise<void>>, | |
nextIndex?: number = 0, | |
) { | |
let current = fnList[nextIndex]; | |
if (!current) return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Observable } = require('rxjs/Observable'); | |
require('rxjs/add/observable/fromEvent'); | |
require('rxjs/add/operator/map'); | |
require('rxjs/add/observable/merge'); | |
function createOnline$() { | |
//merge several events into one | |
return Observable.merge( | |
//use .map() to transform the returned Event type into a true/false value | |
Observable.fromEvent(window, 'offline').map(() => false), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// These methods and getter/setters force layout/reflow in Chrome/WebKit | |
// From https://gist.github.com/paulirish/5d52fb081b3570c81e3a | |
const getterSetters = [ | |
'offsetLeft', | |
'offsetTop', | |
'offsetWidth', | |
'offsetHeight', | |
'offsetParent', | |
'clientLeft', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const electron = require('electron'); | |
const path = require('path'); | |
const fs = require('fs'); | |
class Store { | |
constructor(opts) { | |
// Renderer process has to get `app` module via `remote`, whereas the main process can get it directly | |
// app.getPath('userData') will return a string of the user's app data directory path. | |
const userDataPath = (electron.app || electron.remote.app).getPath('userData'); | |
// We'll use the `configName` property to set the file name and path.join to bring it all together as a string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -e | |
# function to grep for a dependency | |
grep_dep() { | |
# params: $1 = the string to grep for, $2 = directory to grep in | |
# [1] | |
grep --include="*.js" --exclude-dir="node_modules" -R --color -n "require\(.*$1.*\)" "$2" | |
# if grep returns 0 results, it has an exit code of 1. No results means dependency is not in use |
NewerOlder