Skip to content

Instantly share code, notes, and snippets.

View davidep87's full-sized avatar
๐Ÿ˜‡
Working remotely from Sardinia

Davide Polano davidep87

๐Ÿ˜‡
Working remotely from Sardinia
View GitHub Profile
Adding this to crontab enable you to pass the today date to an endpoint that you have to call sometimes
0 1 * * * wget https://api.example.com/example/`date +"\%Y-\%m-\%d"`
@davidep87
davidep87 / gist:46868c89002ac89802768b279a0689e9
Last active September 21, 2017 17:15
nginx http https reverse proxy server
#Replace /usr/local/etc/nginx/nginx.conf with this. This is the
# default location for Nginx according to 'nginx -h'
worker_processes 1;
error_log /etc/nginx/error.log;
events {
worker_connections 1024;
}
http {
0xb668cF16d6819bcf9Dc0998a7A01e8e195EBEed2
@davidep87
davidep87 / eth_addr
Created July 17, 2017 19:27
eth_addr
0xceE5F58dBe0b8Cc1ee8E453daafF413429bfbBc5
@davidep87
davidep87 / slugify.js
Last active June 17, 2017 18:15
return slug from a string
function slugify(text) {
return text.toString().toLowerCase()
.replace(/[\u00C0-\u00C5]/ig,'a')
.replace(/[\u00C8-\u00CB]/ig,'e')
.replace(/[\u00CC-\u00CF]/ig,'i')
.replace(/[\u00D2-\u00D6]/ig,'o')
.replace(/[\u00D9-\u00DC]/ig,'u')
.replace(/[\u00D1]/ig,'n')
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
@davidep87
davidep87 / nginx.conf
Created April 28, 2017 16:33
Nginx conf as reverse proxy for a nodejs app
#Replace /usr/local/etc/nginx/nginx.conf with this. This is the
# default location for Nginx according to 'nginx -h'
worker_processes 1;
error_log /usr/local/var/log/nginx/error.log;
events {
worker_connections 1024;
}
http {
function isInArray(value, array) {
return array.indexOf(value) > -1;
}
function deleteElement(elem, array){
let _array = [];
for (let i = 0; i < array.length; i++) {
if(array[i] != elem){
_array.push(array[i]);
}
}
return _array;
}
@davidep87
davidep87 / Stream a file from a directory
Created January 30, 2017 12:39
Stream a file from a private directory in NodeJS with KoaJS
const fs = require('fs');
const path = require('path');
/**
* @param ctx - Koa context (this) (required)
* @param file - contain file information (required)
* @param file.fileType - contain file type information such as application/pdf || image/jpg and so on..
* @param file.filePath - contain the private file path
*/
function pickReplace(obj, objPick){
let no = {};
for(let k of objPick){
if(k in obj){
no[k] = obj[k];
}
}
return no;
}