Skip to content

Instantly share code, notes, and snippets.

@mark-up
mark-up / regex-domain-validator
Created June 5, 2013 04:33
A regex to validate domain names.
# http://www.shauninman.com/archive/2006/05/08/validating_domain_names
/^([a-z0-9]([-a-z0-9]*[a-z0-9])?\\.)+((a[cdefgilmnoqrstuwxz]|aero|arpa)|(b[abdefghijmnorstvwyz]|biz)|(c[acdfghiklmnorsuvxyz]|cat|com|coop)|d[ejkmoz]|(e[ceghrstu]|edu)|f[ijkmor]|(g[abdefghilmnpqrstuwy]|gov)|h[kmnrtu]|(i[delmnoqrst]|info|int)|(j[emop]|jobs)|k[eghimnprwyz]|l[abcikrstuvy]|(m[acdghklmnopqrstuvwxyz]|mil|mobi|museum)|(n[acefgilopruz]|name|net)|(om|org)|(p[aefghklmnrstwy]|pro)|qa|r[eouw]|s[abcdeghijklmnortvyz]|(t[cdfghjklmnoprtvwz]|travel)|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw])$/i
@mark-up
mark-up / bmi.js
Created April 3, 2013 01:52
This is the code Vodafone Fiji is injecting into its users web traffic.
function bmi_44107_getInternetExplorerVersion(){var e=-1;if(navigator.appName=="Microsoft Internet Explorer"){var t=navigator.userAgent;var n=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");if(n.exec(t)!=null)e=parseFloat(RegExp.$1)}return e}function bmi_44107_addReadyEvent(e){function t(){for(var e=0;e<bmi_44107_readyList.length;e++){bmi_44107_readyList[e]()}}if(!bmi_44107_readyList.length){bmi_44107_bindReady(t)}bmi_44107_readyList.push(e)}function bmi_44107_bindReady(e){function n(){if(t)return;t=true;e()}var t=false;if(document.addEventListener){document.addEventListener("DOMContentLoaded",n,false)}else if(document.attachEvent){try{var r=window.frameElement!=null}catch(i){}if(document.documentElement.doScroll&&!r){function s(){if(t)return;try{document.documentElement.doScroll("left");n()}catch(e){setTimeout(s,10)}}s()}document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){n()}})}if(window.addEventListener)window.addEventListener("load",n,false);else if(window.attachEvent)window
@mark-up
mark-up / grayscale-filter
Created October 1, 2012 03:24
Cross-browser CSS Grayscale Filter
/*
* First create a file filters.svg with the following contents
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg">
<filter id="grayscale">
<feColorMatrix type="matrix" values="0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0"/>
</filter>
</svg>
@mark-up
mark-up / gist:3261247
Created August 5, 2012 02:50 — forked from nixhope/gist:3261241
js_footer
{% block js_footer_source %}
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
window.jQuery || document.write('<script src="{{ STATIC_DIR }}js/jquery-1.7.1.min.js"><\/script>')
</script>
{% endblock js_footer_source %}
{% block js_footer %}
<script>