Skip to content

Instantly share code, notes, and snippets.

Avatar

Rogério Chaves rogeriochaves

View GitHub Profile
@davidbanham
davidbanham / gist:1186032
Created Sep 1, 2011
Dynamically generate a file download in express without touching the filesystem
View gist:1186032
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' });
});
View gist:288242
<?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;
}
}