const os = require('os');
let interfaces = os.networkInterfaces();
Object.keys(interfaces).
forEach((interface) => {
interfaces[interface].forEach((interfaceRecord)=>{
if (interfaceRecord.family === 'IPv4') {
console.log(`${interface}: ${interfaceRecord.address}`);
}
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 fs = require('fs'); | |
const path = require('path'); | |
const packageJson = require('./package.json'); | |
let filePath = path.join(__dirname, '/build/index.html'); | |
let html = fs.readFileSync(filePath, 'utf8'); | |
html = html.replace('<head>', `<head><base href="${packageJson.homepage}">`); | |
fs.writeFileSync('build/index.html', html); |
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
export default (config, env, helpers) => { | |
config.target = 'electron-renderer'; | |
if (env.production) { | |
config.output.publicPath = env.pkg.homepage; | |
let {plugin} = helpers.getPluginsByName(config, 'DefinePlugin')[0]; | |
plugin.definitions['PUBLIC_PATH'] = env.pkg.homepage; | |
} | |
}; |
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 startUrl = process.env.ELECTRON_START_URL || url.format({ | |
pathname: path.join(__dirname, '/../build/index.html'), | |
protocol: 'file:', | |
slashes: true | |
}); | |
win.loadURL(startUrl); |
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 {app, BrowserWindow} = require('electron'); | |
const path = require('path'); | |
const url = require('url'); | |
// Keep a global reference of the window object, if you don't, the window will | |
// be closed automatically when the JavaScript object is garbage collected. | |
let win; | |
/** | |
* @name createWindow |
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 net = require('net'); | |
const port = process.env.PORT ? (process.env.PORT - 100) : 5000; | |
process.env.ELECTRON_START_URL = `http://localhost:${port}`; | |
const client = new net.Socket(); | |
let startedElectron = false; | |
const tryConnection = () => client.connect({port: port}, () => { | |
client.end(); |
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 | |
COUNTER=$1 | |
while [ $COUNTER -gt 1 ]; do | |
let COUNTER=COUNTER-1 | |
echo -ne "Seconds remaining: $COUNTER\033[0K\r" | |
sleep 1 | |
done | |
echo -ne "\033[0K\r" |
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
{ | |
"hydra": { | |
"serviceName": "caller", | |
"serviceDescription": "", | |
"serviceIP": "", | |
"servicePort": 0, | |
"serviceType": "", | |
"redis": { | |
"url": "redis://localhost:6379/15" | |
} |
Hydra is an open source project which provides a set of tools that faciliate building distributed applications such as microservices.
These source files are part of the Hydra Workshop, an introduction to Hydra presented at Node and JavaScript meetups. The presentation slides can be found at: https://speakerdeck.com/cjus/building-microservices-using-hydra
Find out more about Hydra at: https://github.com/flywheelsports
You can share this gist using: https://goo.gl/AVW0lG
The following shell script backups up the currrent node project by performing the following actions:
- Assumes that the back script is bundled with the actual NodeJS projecxt foler.
- Uses the current directory as the backup file name.
- Moves to the parent folder to create a tarball using the project name and the current date stamp and excludes the node_modules folder.
- Lists the backups created using the script.