Skip to content

Instantly share code, notes, and snippets.

View writingdeveloper's full-sized avatar
🏠
Working from home

Si Hyeong Lee writingdeveloper

🏠
Working from home
View GitHub Profile
@writingdeveloper
writingdeveloper / index.js
Created February 8, 2021 01:01
PowerShell Handling Node.js App
const express = require('express');
const bodyParser = require("body-parser");
const path = require("path");
const Base64 = require('js-base64');
const {
exec
} = require('child_process');
const router = express.Router();
router.use(bodyParser.urlencoded({
@writingdeveloper
writingdeveloper / index.js
Last active February 5, 2021 08:13
Part of 'Windows Local User Management' code
const express = require('express');
const bodyParser = require("body-parser");
const path = require("path");
const Base64 = require('js-base64');
// const Shell = require('node-powershell');
// var spawn = require("child_process").spawn,
// child;
const router = express.Router();
/* PowerShell Constructor */
const express = require('express');
const bodyParser = require("body-parser");
const path = require("path");
const {
base64,
Base64
} = require('js-base64');
const {
Shell,
PSCommand

Handling Errors

Express.js makes it a breeze to handle errors in your routes.

Express lets you centralizes your error-handling through middleware.

Let's look at patterns for how to get the most out of your error-handling.

First, our error-handling middleware looks like this:

@writingdeveloper
writingdeveloper / clien.js
Created March 11, 2019 01:25
Puppeteer Auto Clien Screencapture App
const puppeteer = require('puppeteer');
let prevNumber;
function again() {
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
// Adjustments particular to this page to ensure we hit desktop breakpoint.
page.setViewport({
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
app.get('/topic', function(req,res){
res.send(req.query.id+' , '+req.query.name);
});
html
head
title= title
body
h1 Hello Jade
ul
-for(var i=0; i<5; i++)
li coding
div= time
var express = require('express');
var path = require('path');
var app = express();
app.locals.pretty = true;
app.set('view engine', 'pug');
app.set('views', path.join(__dirname, 'views'));
app.use(express.static(path.join(__dirname, 'public')));
app.get('/template', function(req, res) {
var express = require('express');
var app = express();
var path = require('path');
app.use(express.static(path.join(__dirname, 'public')));
app.get('/', function(req, res) {
res.send('Hello home page');
});
app.get('/dynamic', function(req, res) {
var lis = '';