Skip to content

Instantly share code, notes, and snippets.

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

Arnaud Buchholz ArnaudBuchholz

🏠
Working from home
View GitHub Profile
@ArnaudBuchholz
ArnaudBuchholz / gist:8668033
Created January 28, 2014 13:52
[ExtJS] Control Ext.data.Batch start for multiple stores serialization
var batch = new Ext.data.Batch();
batch.start = function () {};
// Sync your stores
myStore.sync({
batch: batch
});
// When done
delete batch.start;
batch.start();
@ArnaudBuchholz
ArnaudBuchholz / gist:01f8d6152735384c2ae5
Created January 13, 2015 20:56
Clone a function definition
function cloneFunction(functionToClone) {
functionToClone = functionToClone.toString();
var paramStart = functionToClone.indexOf('('),
paramEnd = functionToClone.indexOf(')'),
paramList = functionToClone.substr(paramStart + 1, paramEnd - paramStart - 1).split(','),
bodyStart = functionToClone.indexOf('{'),
bodyEnd = functionToClone.lastIndexOf('}'),
body = functionToClone.substr(bodyStart + 1, bodyEnd - bodyStart - 1),
len,
idx,
@ArnaudBuchholz
ArnaudBuchholz / serve with express.js
Created February 29, 2020 05:33
An example of a web server publishing static files using express
const path = require('path')
const express = require('express')
const app = express()
const port = 8081
const wwwRoot = path.join(__dirname, '../www')
app.use(express.static(wwwRoot))
app.get('/', (req, res) => res.sendFile(path.join(wwwRoot, 'static.html')))
app.listen(port, () => console.log(`Listening on port ${port}!`))
@ArnaudBuchholz
ArnaudBuchholz / package.json
Last active February 29, 2020 22:18
Example of package.json that executes serve through npm start
{
"name": "your-project",
"version": "1.0.0",
"scripts": {
"start": "serve"
},
"dependencies": {
"serve": "11.3.0"
}
}
@ArnaudBuchholz
ArnaudBuchholz / reserve.json
Created March 1, 2020 15:31
An example of a web server publishing static files using REserve
{
"port": 8080,
"mappings": [{
"match": "^/$",
"file": "../www/static.html"
}, {
"match": "^/(.*)",
"file": "../www/$1"
}]
}
{
"match": "^/(.*)",
"file": "../www/$1"
}
const { read } = require('reserve')
read('reserve.json').then(configuration => /* ... */)
const { check } = require('reserve')
check({
port: 8080,
mappings: [{
/* ... */
}]
}).then(configuration => /* ... */)
const { serve } = require('reserve')
serve({ /* configuration */ })
.on('ready', ({ url }) => {
console.log(`Server running at ${url}`)
})
{
"match": "^/proxy/(https?)/(.*)",
"url": "$1://$2"
}