Skip to content

Instantly share code, notes, and snippets.

var connect = require('connect')
var csp = require('helmet-csp')
var app = connect()
app.use(csp({
directives: {
mediaSrc: ['media.example.com']
}
}))
@EvanHahn
EvanHahn / apm_remove_versions.rb
Created January 8, 2015 21:41
A Ruby script to remove versions from the output of `apm list --installed --bare`.
#!/usr/bin/env ruby
IO.foreach(ARGV.first) do |line|
puts line.split('@').first
end
# Licensed under the Unlicense. <http://unlicense.org/>
@EvanHahn
EvanHahn / gist:99edd459a4f08bb6fd6c
Created October 23, 2014 18:49
Simple app to set CSP.
var express = require('express');
var path = require('path');
var HEADER_VALUE = "default-src 'self';";
var HEADERS = [
'Content-Security-Policy',
'X-Content-Security-Policy',
'X-Webkit-CSP'
];

Keybase proof

I hereby claim:

  • I am EvanHahn on github.
  • I am evanhahn (https://keybase.io/evanhahn) on keybase.
  • I have a public key whose fingerprint is C3AB 6FA7 DC98 0294 2D89 C540 4329 0CC8 681B 62EB

To claim this, I am signing this object:

@EvanHahn
EvanHahn / gist:38f08f40a23e0cb9f4b0
Created September 5, 2014 19:20
Disabling some headers set by Express's static middleware.
var express = require("express");
var onHeaders = require("on-headers");
var path = require("path");
var app = express();
// ...
app.use(function(req, res, next) {
onHeaders(res, function() {
@EvanHahn
EvanHahn / brochure.css
Created July 21, 2014 16:57
showing the difference in the brochure for website issue #18230
@charset "UTF-8";
/* ======================================================
v 0.1.0
Versioned according to http://semver.org/spec/v2.0.0.html
Primary Maintainer: @albert
Contributors:
====================================================== */
@EvanHahn
EvanHahn / .gitignore
Last active August 29, 2015 14:03
Working on Helmet issue #57.
.DS_Store
*.swp
node_modules
*.log
@EvanHahn
EvanHahn / app.js
Created June 24, 2014 20:58
Dealing with Helmet issue #55.
var path = require("path");
var connect = require("connect");
var favicon = require("serve-favicon");
var helmet = require("helmet");
var app = connect();
app.use(helmet.defaults());
var faviconPath = path.resolve(__dirname, "favicon.ico");
var iframesLoaded = 0;
$("form").each(function() {
var $form = $(this);
var $iframe = $("<iframe name='temporary-iframe'></iframe>");
var oldTarget = $form.prop("target");
$form.prop("target", "temporary-iframe");
@EvanHahn
EvanHahn / 158.bf
Created April 15, 2014 02:20
Daily programmer #158, in Brainfuck
first digit
,------------------------------------------------
[>++++++++++<-]
second digit
,------------------------------------------------
>>
third digit
,------------------------------------------------