Skip to content

Instantly share code, notes, and snippets.

View wnda's full-sized avatar

A. M. Douglas wnda

View GitHub Profile
@wnda
wnda / Fn.ptype.bind-quick-polyfill.js
Created January 29, 2017 05:17
Function.prototype.bind quick polyfill
if (!('bind' in Function.prototype)) {
Function.prototype.bind = function (context) {
var fn, args, i;
if (typeof this !== 'function') { throw new TypeError('fn not callable'); }
fn = this; args = []; i = 0;
for (; i < arguments.length; ++i) { args[i] = arguments[i]; }
return function() { fn.apply(context, args) };
};
}
@wnda
wnda / nginx-latest.sh
Created February 3, 2016 12:10 — forked from Globegitter/nginx-latest.sh
Install the latest nginx from source for Ubuntu 14.04
# Automatically instal the latest nginx
wget -O - http://nginx.org/keys/nginx_signing.key | sudo apt-key add -
#Make a backup copy of your current sources.list file
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
#Now copy the following repositories to the end of ` /etc/apt/sources.list`
echo "deb http://nginx.org/packages/mainline/ubuntu/ trusty nginx" | sudo tee -a /etc/apt/sources.list
echo "deb-src http://nginx.org/packages/mainline/ubuntu/ trusty nginx" | sudo tee -a /etc/apt/sources.list
@wnda
wnda / NginxRedirect.md
Created January 8, 2016 14:03 — forked from esfand/NginxRedirect.md
Nginx Redirect

Redirect: Temporary and Permanent

Source

What is an HTTP Redirect?

HTTP redirection, or URL redirection, is a technique of pointing one domain or address to another. There are many uses for redirection, and a few different kinds of redirection to consider.

As you create content and administrate servers, you will often find the need to redirect traffic from one place to another. This guide will discuss the different use-cases for these techniques, and how to accomplish them in Apache and Nginx.

<script>(function(){var fadeEl=document.getElementsByTagName('section');var i;for(i=0;i<fadeEl.length;i++){fadeIn(fadeEl[i]);}})();function fadeIn(el){el.style.opacity=0;var last= +new Date();var tick=function(){el.style.opacity= +el.style.opacity+(new Date()-last)/400;last= +new Date();if(+el.style.opacity<1){(window.requestAnimationFrame && requestAnimationFrame(tick))||setTimeout(tick,16);}};tick();}</script>
@wnda
wnda / gist:e4dbd50d57f4894ccb07
Created October 22, 2015 16:19
inject a good browser into old IE
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.1.7/es5-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/classlist/2014.01.31/classList.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/selectivizr/1.0.2/selectivizr-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/flexie/1.0.3/flexie.min.js"></script>
<script src="/assets/js/calc.min.js"></script>
<![endif]-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="keywords" content="">
@wnda
wnda / mail-handler-attachment.php
Created July 8, 2015 02:59
A PHP script that can send a POSTed form as an email, with an attachment
<?php
if(isset($_POST['submit']))
{
$to = 'info@hil.org.uk';
$namefrom = strip_tags($_POST['name']);
$emailfrom = strip_tags($_POST['email']);
$enquirytype = strip_tags($_POST['enquirytype']);
$textarea = strip_tags($_POST['textarea']);
$message = strip_tags($_POST['message']);
$attachment = chunk_split(base64_encode(file_get_contents($_FILES['attachment']['tmp_name'])));
@wnda
wnda / .htaccess
Last active August 29, 2015 14:23 — forked from darcyliu/.htaccess
# BEGIN GZIP
# http://httpd.apache.org/docs/2.2/mod/mod_deflate.html
<IfModule mod_deflate.c>
# Enabling Compression
SetOutputFilter DEFLATE
# Insert filters
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
OS: Ubuntu 14.04 LTS, Apache 2.4.7, OpenSSL 1.0.1f
SSL Labs: A+ (RSA2048, SHA256 certificate)
Certificate: 100%
Protocol Support: 95%
Key Exchange: 90%
Cipher Strength: 90%
#### In the SSL.CONF file
SSLCipherSuite AES256+EECDH:AES256+EDH:AES128+EECDH:AES128+EDH
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<link rel="stylesheet" type="text/css" href="http://dl.dropbox.com/u/32029178/logo.css" />
<link rel="stylesheet" type="text/css" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"/>
</head>
<body>
<div class="square">