Create a standalone desktop app with puppeteer example.
- Run
npm i
- Run
node app
For run this example without installation, run in console:
npx https://gist.github.com/ilio/6f4239b60b84a918ab500e2e0528c094
FROM debian | |
RUN apt update && apt install -y tzdata; \ | |
apt clean; | |
# sshd | |
RUN mkdir /var/run/sshd; \ | |
apt install -y openssh-server; \ | |
sed -i 's/^#\(PermitRootLogin\) .*/\1 yes/' /etc/ssh/sshd_config; \ | |
sed -i 's/^\(UsePAM yes\)/# \1/' /etc/ssh/sshd_config; \ | |
apt clean; |
{ | |
"scripts": { | |
"build": "babel src/ -d bin", | |
"build watch": "babel src/ -d bin --watch" | |
}, | |
"devDependencies": { | |
"@babel/preset-env": "^7.2.0", | |
"@babel/cli": "^7.2.0", | |
"@babel/core": "^7.2.0" | |
}, |
Create a standalone desktop app with puppeteer example.
npm i
node app
For run this example without installation, run in console:
npx https://gist.github.com/ilio/6f4239b60b84a918ab500e2e0528c094
#!/usr/bin/env node | |
console.log('v6', process.argv, process.cwd(), __dirname); | |
const {exec} = require('child_process'); | |
const path = require('path'); | |
exec('npm bin', {cwd: __dirname}, (err, stdout, stderr) => { | |
if (err) { | |
console.error(err); | |
} else { |
const Day = ({value, className})=> ( | |
<div className={"day"+(className? ' ' + className: '')}> | |
<div className="selected" /> | |
<div className="secondary" /> | |
<div className="value">{value}</div> | |
</div> | |
); | |
class Calendar extends React.Component { | |
state = { |
function runNpmInstall() { | |
return new Promise((resolve, reject) => { | |
let cmd = 'npm'; | |
if (os.platform() === 'win32') { | |
cmd += '.cmd'; | |
} | |
npmProcess = spawn(cmd, ['install'], {cwd: path.join(__dirname, 'service_')}); | |
npmProcess.on('error', e => { | |
npmProcess = null; |
awaitable = (func, ...args) => { | |
return new Promise(resolve => { | |
func.apply(this, [...args, (...a) => { | |
if(a.length === 1){ | |
return resolve(a[0]); | |
} | |
if(a.length === 2){ | |
return resolve(a[1]); | |
} | |
return resolve(a); |
// based on https://github.com/baalexander/node-portscanner/blob/master/lib/portscanner.js | |
const {Socket} = require('net'); | |
function connect(port, host, timeout, callback) { | |
let connectionRefused = false; | |
const socket = new Socket(); | |
let status = null; | |
let error = null; |
es6/js snippets
sudo su -l |