Skip to content

Instantly share code, notes, and snippets.

View dfgonzalez's full-sized avatar

Diego Gonzalez Marignac dfgonzalez

View GitHub Profile
@drewjoh
drewjoh / example.php
Last active January 11, 2021 18:06 — forked from mloberg/example.php
A Simple Postmark PHP Class with Attachments
<?php
require("postmark.php");
$postmark = new Postmark("your-api-key","from-email","optional-reply-to-address");
$result = $postmark->to("reciver@example.com")
->subject("Email Subject")
->plain_message("This is a plain text message.")
->attachment('File.pdf', base64_encode(file_get_contents('sample.pdf')), 'application/pdf')
@kentbrew
kentbrew / how-i-got-ssl-working-with-node.js
Created January 13, 2011 02:08
How I got SSL working on Node
// works with node-0.2.4, not node-0.3.6; be SURE you got node to build with OpenSSL
//
// you will need working SSL key and cert, otherwise:
// openssl genrsa -out privatekey.pem 1024
// openssl req -new -key privatekey.pem -out certrequest.csr
// openssl x509 -req -in certrequest.csr -signkey privatekey.pem -out certificate.pem
//
// map port 8443 to 443 and 8080 to 80; see gist 776580 to do this on EC2
var http = require('http'), crypto = require('crypto'), fs = require("fs");
@kentbrew
kentbrew / node-on-ec2-port-80.md
Last active February 4, 2024 19:14
How I Got Node.js Talking on EC2's Port 80

The Problem

Standard practices say no non-root process gets to talk to the Internet on a port less than 1024. How, then, could I get Node talking on port 80 on EC2? (I wanted it to go as fast as possible and use the smallest possible share of my teeny tiny little micro-instance's resources, so proxying through nginx or Apache seemed suboptimal.)

The temptingly easy but ultimately wrong solution:

Alter the port the script talks to from 8000 to 80:

}).listen(80);