Skip to content

Instantly share code, notes, and snippets.

@davidbanham
davidbanham / gist:1186032
Created September 1, 2011 12:02
Dynamically generate a file download in express without touching the filesystem
var express = require('express');
var app = require('express').createServer();
app.listen('3030');
app.get('/', function(req, res) {
res.contentType('text/plain');
res.send('This is the content', { 'Content-Disposition': 'attachment; filename=name.txt' });
});
<?php
function curl_setopt_custom_postfields($ch, $postfields, $headers = null) {
$algos = hash_algos();
$hashAlgo = null;
foreach ( array('sha1', 'md5') as $preferred ) {
if ( in_array($preferred, $algos) ) {
$hashAlgo = $preferred;
break;
}
}