Skip to content

Instantly share code, notes, and snippets.

View vool's full-sized avatar

Keith Phelan vool

View GitHub Profile
@vool
vool / ternary_else_if
Created November 30, 2010 00:12
js ternary operators
/* js else if with ternary operators
* http://verens.com/2010/07/21/javascript-compression-tip/#comments
*/
function getValueFor(data){
return firstCondition(data)
?1
:secondCondition(data)
?2
:thirdCondition(data)
@vool
vool / http_error_array.php
Created September 7, 2011 17:30
http error codes in a php array
<?php
$error = array (
//4xx: Client Error
400 => array("title" => "Bad Request", "desc" => "The server did not understand the request"),
401 => array("title" => "Unauthorized", "desc" => "The requested page needs a username and a password"),
402 => array("title" => "Payment Required", "desc" => "You can not use this code yet"),
403 => array("title" => "Forbidden", "desc" => "Access is forbidden to the requested page"),
404 => array("title" => "Not Found", "desc" => "The server can not find the requested page"),
@vool
vool / Issue with Turn.html
Created March 23, 2012 19:44
updated with suggested edits
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="https://raw.github.com/blasten/turn.js/master/turn.min.js"></script>
<style>
body{
background:#ccc;
}
@vool
vool / radio.xml
Created March 24, 2012 14:05
Radio Stations
<entry type="iradio">
<title>Radio Kerry</title>
<genre>Varied</genre>
<artist></artist>
<album></album>
<location>http://www.radiokerry.ie/RK_MP3HQ1.asx</location>
<play-count>46</play-count>
<last-played>1330551764</last-played>
<bitrate>128</bitrate>
<date>0</date>
//Strip out the generator meta
function remove_generator() {
return '';
}
add_filter('the_generator', 'remove_generator');
@vool
vool / ajaxify-html5.js
Last active December 10, 2015 22:59 — forked from balupton/README.md
// History.js It!
// v1.0.1 - 30 September, 2012
//
// fork of https://gist.github.com/854622 with the scrollto functionality removed
(function(window,undefined){
// Prepare our Variables
var
History = window.History,
@vool
vool / prevent-script-execution.htaccess
Last active December 11, 2015 06:08
.htaccess rules
#########################################
prevent script execution in directory
useful when access permissions and to be lax
IndexIgnore *
Options All -Indexes
# Secure directory by disabling script execution, add any extentions required
AddHandler cgi-script .php .php2 .php3 .php4 .php5 .php6 .php7 .php8 .pl .py .jsp .asp .htm .html .shtml .sh .cgi
<html contenteditable spellcheck="true" id="f" style="font-size:2rem;line-height:1.4;max-width:60rem;margin:0 auto;padding:4rem;"><title>Skratch Pad</title><script>window.onload=function(){var f=document.getElementById('f');f.innerHTML=r(localStorage.f)};onkeyup=function(){localStorage.f=f.innerHTML};function r(f){var e =/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;return f.replace(e,"<a href='$1' style='cursor:pointer' onclick='window.open(this.href);return false'>$1</a>")}</script><style>body{color:#242424; background-color:#fffff2; padding:10px;border-radius:4px;box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.2);} #f{background-color:#eee;}</style>
@vool
vool / handy_js_functions.js
Last active December 19, 2015 21:59
Handy js functions
function map_range(value, low1, high1, low2, high2) {
return low2 + (high2 - low2) * (value - low1) / (high1 - low1);
}
@vool
vool / site_archiver.md
Last active January 9, 2020 20:24
wget command to archive sites

kbf

wget -q --mirror -p --html-extension --base=./ --exclude-directories=2008/,2009/,2010/,2011/,2012/,news/ -k -P ./ http://kerrybicyclefestival.org

wildmind

wget -q --mirror -p --html-extension --base=./ --exclude-directories=blog -nc -k -P ./ http://wildmind.ie