Skip to content

Instantly share code, notes, and snippets.

View adeolaawoyemi's full-sized avatar
🏠
Working from home

Adeola Awoyemi adeolaawoyemi

🏠
Working from home
  • Yahoo
  • San Jose, CA
View GitHub Profile
@adeolaawoyemi
adeolaawoyemi / gist:2955082
Created June 19, 2012 16:23
add header to apache response (enable CORS)
# Enable CORS
Header append Access-Control-Allow-Origin *
@adeolaawoyemi
adeolaawoyemi / gist:2955101
Created June 19, 2012 16:26
Force IE9 to use IE9 Standard mode, ALWAYS
X-UA-Compatible: IE=edge,chrome=1
@adeolaawoyemi
adeolaawoyemi / gist:3014238
Created June 28, 2012 21:58
iPhone Mobile Safari HTML5 Video access log
192.168.0.105 - - [28/Jun/2012:22:48:07 +0100] "GET /html5video HTTP/1.1" 301 323
192.168.0.105 - - [28/Jun/2012:22:48:07 +0100] "GET /html5video/ HTTP/1.1" 200 1100
192.168.0.105 - - [28/Jun/2012:22:48:08 +0100] "GET /html5video/chrome_japan.mp4 HTTP/1.1" 206 2
192.168.0.105 - - [28/Jun/2012:22:48:08 +0100] "GET /html5video/chrome_japan.mp4 HTTP/1.1" 200 9407755
192.168.0.105 - - [28/Jun/2012:22:48:09 +0100] "GET /html5video/chrome_japan.mp4 HTTP/1.1" 304 -
192.168.0.105 - - [28/Jun/2012:22:48:17 +0100] "GET /html5video/chrome_japan.mp4 HTTP/1.1" 206 2
192.168.0.105 - - [28/Jun/2012:22:48:17 +0100] "GET /html5video/chrome_japan.mp4 HTTP/1.1" 200 9407755
192.168.0.105 - - [28/Jun/2012:22:48:18 +0100] "GET /html5video/chrome_japan.mp4 HTTP/1.1" 206 65536
192.168.0.105 - - [28/Jun/2012:22:48:19 +0100] "GET /html5video/chrome_japan.mp4 HTTP/1.1" 206 65536
192.168.0.105 - - [28/Jun/2012:22:48:17 +0100] "GET /html5video/chrome_japan.mp4 HTTP/1.1" 206 9325219
@adeolaawoyemi
adeolaawoyemi / gist:3016923
Created June 29, 2012 09:35
parse list of videoIDs (and sanitise)
var playlist = "-123 ,456-, x789";
var videos = playlist.split(',');
var videos_count = videos.length;
for( var i = 0; i < videos_count; i++ ) {
// sanitise and remove non-numeric characters
var video_id = Number(videos[i].replace(/\D/g, ''));
// test
trace('videoID: [' + video_id + ']');
}
@adeolaawoyemi
adeolaawoyemi / gist:3040782
Created July 3, 2012 16:18
Batch-import databases
for d in *.sql; do echo "Database ${d/.sql/} will be created" && mysql -uroot -e "create database ${d/.sql/};" && mysql -uroot ${d/.sql/} < $d && echo "Done creating and populating ${d/.sql/}"; done
@adeolaawoyemi
adeolaawoyemi / gist:3859479
Created October 9, 2012 15:21
parse JSON object in AS3
private function parseJSON(o:*, spaces:int = 1):String {
var str:String = "";
if(getTypeof(o) == "object") {
str += "{\n";
for(var i:* in o) {
str += getSpaces(spaces) + i + "=";
if(getTypeof(o[i]) == "object" || getTypeof(o[i]) == "array") {
str += parseJSON(o[i], spaces + 1) + "\n";
} else {
var type:String = getTypeof(o[i]);
@adeolaawoyemi
adeolaawoyemi / switch_protocol.js
Created November 7, 2012 10:50
Javascript protocol (SSL) resource switch
script.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://my.url.com/file.ext';
@adeolaawoyemi
adeolaawoyemi / gist:4075859
Created November 15, 2012 00:37
String.inArray() method
String.prototype.inArray = function(arr) {
for (var i = arr.length - 1; i >= 0; i--) {
if (arr[i] == this.toString()) return true;
};
return false;
};
"dick".inArray(["tom", "dick", "harry"]); // true
<?xml version="1.0"?>
<cross-domain-policy>
<site-control permitted-cross-domain-policies="master-only"/>
<allow-access-from domain="*" />
</cross-domain-policy>
@adeolaawoyemi
adeolaawoyemi / konami-debug.js
Last active December 20, 2015 01:59
Debugger opened using the Konami code
/* -----------------------------*/
/* Debugging */
// Show d(ebug)alerts only when in DEBUG mode
window.dalert = function (a, b, c, d) {
if (window.ALLOW_DEBUG) window.alert(a, b, c, d);
};
window.dtitle = function (a) {
if (window.ALLOW_DEBUG) document.title=a;
};
$(function () {