Skip to content

Instantly share code, notes, and snippets.

View andrei-tofan's full-sized avatar

Andrei Tofan andrei-tofan

View GitHub Profile
@andrei-tofan
andrei-tofan / express_app.js
Created May 13, 2017 09:58
Run node.js express app under a low privilege user
var express = require('express')
var app = express()
/**
* After app starts, demote the app to a low privilege user
*/
function demote() {
if(process.platform != 'linux') {
return false;
@andrei-tofan
andrei-tofan / example.js
Last active February 29, 2024 23:59
node.js writable buffer stream (pdfkit example)
/**
* Convert PDFDocument to Base64
*/
const PDFDocument = require('pdfkit');
const stream = require('./stream');
// crate document and write stream
let doc = new PDFDocument();
let writeStream = new stream.WritableBufferStream();
@andrei-tofan
andrei-tofan / test_imap.php
Created July 17, 2017 08:40
Test local IMAP server
<?php
// To connect to an IMAP server running on port 993 on the local machine,
// do the following:
$mbox = imap_open("{mailmoka.com:993/imap/ssl/novalidate-cert}INBOX", "delivery", "Ahgn8WKqyQGqgpeXiInh");
echo "<h1>Mailboxes</h1>\n";
$folders = imap_listmailbox($mbox, "{mailmoka.com:993}", "*");
if ($folders == false) {
echo "Call failed<br />\n";