Skip to content

Instantly share code, notes, and snippets.

View DavidMellul's full-sized avatar

David Mellul DavidMellul

View GitHub Profile
// Dependencies
const express = require('express');
const proxy = require('http-proxy-middleware');
// Config
const { routes } = require('./config.json');
const app = express();
for (route of routes) {
{
"routes": [
{
"route": "/project1",
"address": "http://localhost:1001"
},
{
"route": "/project2",
"address": "http://localhost:1002"
}
// Dependencies
const fs = require('fs');
const http = require('http');
const https = require('https');
const express = require('express');
const app = express();
// Certificate
const privateKey = fs.readFileSync('/etc/letsencrypt/live/yourdomain.com/privkey.pem', 'utf8');
// Dependencies
const express = require('express');
// Configure & Run the http server
const app = express();
app.use(express.static(__dirname, { dotfiles: 'allow' } ));
app.listen(80, () => {
console.log('HTTP server running on port 80');
// Dependencies
const express = require('express');
const bodyparser = require('body-parser');
// Configuration
const app = express();
app.use(bodyparser.json());
// Webhook route
app.post('/webhook', (req, res) => {
// Dependencies and stuff, who cares ?
// ES6 way
(async () => {
// Browser launched
const browser = await puppeteer.launch();
// New tab created
const tab = await browser.newPage();
<?php
// Could have broken request clauses line by line
// SELECT X FROM Y WHERE Z
// ->
// SELECT X
// FROM Y
// WHERE Z
final class RequestHolder {
// Query a list of users without ordering
<?php
// CodeIgniter coding style with plain queries, easy to read
$users = $this->db->query('SELECT * FROM Users')->result();
$cities = $this->db->query('SELECT * FROM Cities')->result();
$usersWithCity = $this->db->query('SELECT U.*, C.city_name FROM Users U LEFT JOIN Cities C ON U.id_user = C.id_user')->result();
// A dead-easy data structure representing a database
let ArticlesDatabase = {
content: [
{
'id': 1,
'title': 'Insane prank, I broke my leg watch this'
},
{
'id': 2,
'title': 'Cops arrested me, discover why'
// A dead-easy data structure representing a database
let ArticlesDatabase = {
articles: [
{
'id': 1,
'title': 'Insane prank, I broke my leg watch this'
},
{
'id': 2,
'title': 'Cops arrested me, discover why'