Skip to content

Instantly share code, notes, and snippets.

View samuelteixeiras's full-sized avatar

Samuel Teixeira samuelteixeiras

View GitHub Profile
@samuelteixeiras
samuelteixeiras / postal-codes.json
Created January 16, 2023 15:11 — forked from matthewbednarski/postal-codes.json
Global postal codes regex formats
[{ "Note": "The first two digits (ranging from 10–43) correspond to the province, while the last two digits correspond either to the city/delivery zone (range 01–50) or to the district/delivery zone (range 51–99). Afghanistan Postal code lookup", "Country": "Afghanistan", "ISO": "AF", "Format": "NNNN", "Regex": "^\\d{4}$" }, { "Note": "With Finland, first two numbers are 22.", "Country": "Åland Islands", "ISO": "AX", "Format": "NNNNN", "Regex": "^\\d{5}$" }, { "Note": "Introduced in 2006, gradually implemented throughout 2007.", "Country": "Albania", "ISO": "AL", "Format": "NNNN", "Regex": "^\\d{4}$" }, { "Note": "First two as in ISO 3166-2:DZ", "Country": "Algeria", "ISO": "DZ", "Format": "NNNNN", "Regex": "^\\d{5}$" }, { "Note": "U.S. ZIP codes (range 96799)", "Country": "American Samoa", "ISO": "AS", "Format": "NNNNN (optionally NNNNN-NNNN or NNNNN-NNNNNN)", "Regex": "^\\d{5}(-{1}\\d{4,6})$" }, { "Note":
@samuelteixeiras
samuelteixeiras / index.js
Created March 24, 2022 00:07
Index file
const express = require('express')
const app = express()
var http = require('http').Server(app);
var io = require('socket.io')(http,{
allowEIO3: true,
});
var bodyParser = require('body-parser');
var prettyHtml = require('json-pretty-html').default;
var port = process.env.PORT || 3000;
@samuelteixeiras
samuelteixeiras / curl.txt
Created March 24, 2022 00:06
failureNotification for docker
curl -X POST \
http://localhost:8080/failureNotification \
-H 'content-type: application/json' \
-H 'key: my_other_key' \
-d '{"samuel":"test"}'
@samuelteixeiras
samuelteixeiras / successfulNotification.txt
Last active March 24, 2022 00:04
successful Notification for docker
curl -X POST \
http://localhost:8080/successfulNotification \
-H 'content-type: application/json' \
-H 'key: my_secret_key_on_header' \
-d '{"samuel":"test"}'
FROM node:8
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
@samuelteixeiras
samuelteixeiras / curl.txt
Created March 23, 2022 23:54
failure Notification
curl -X POST \
http://localhost:3000/failureNotification \
-H 'content-type: application/json' \
-H 'key: my_other_key' \
-d '{"samuel":"test"}'
@samuelteixeiras
samuelteixeiras / curl.txt
Last active March 23, 2022 23:49
successfulNotification
curl -X POST \
http://localhost:3000/successfulNotification \
-H 'content-type: application/json' \
-H 'key: my_secret_key_on_header' \
-d '{"samuel":"test"}'
@samuelteixeiras
samuelteixeiras / index.js
Created March 23, 2022 23:34
prettyHtml
var htmlHeader = prettyHtml(req.headers, req.body.dimensions);
var htmlBody = prettyHtml(JSON.parse(req.body), req.body.dimensions);
@samuelteixeiras
samuelteixeiras / index.js
Created March 23, 2022 23:31
bodyParser
app.use(bodyParser.text({
type: function(req) {
return 'text';
}
}));
@samuelteixeiras
samuelteixeiras / index.js
Created March 23, 2022 23:19
failure Notification endpoint
app.post('/failureNotification', function (req, res) {
res = res.status(200);
res.send(req.body);
try {
var htmlHeader = prettyHtml(req.headers, req.body.dimensions);
var htmlBody = prettyHtml(JSON.parse(req.body), req.body.dimensions);
io.emit('chat message', '<div class="msg-header-failure">Failure Notification received at:'+ formatDate(new Date(), "dddd h:mm:sstt d MMM yyyy") +'</div>');
io.emit('chat message', '<div class="header-failure">Header</div>');