Unlimited Bandwidth & Unlimited Diskspace

My host are now offering Unlimited Bandwidth & Unlimited Diskspace so head
over there and get some hosting for cheap!

AJAX phpMyAdmin Greasemonkey Script

I’ve been working on something recently in which the testing has involved modiyfing 2 or 3 fields in a database very regularly, I was fed-up of going into phpMyAdmin clicking edit on the row, finding the field (1 of 100 odd), editing it and then going to the save button.

I decided that I would write a Greasemonkey script to turn all of the fields into an AJAX editing form.

Basically all you have to do now is double click the field value, edit the value and hit enter to save!

It has only been tested on phpMyAdmin 3.1.2 so I have no idea if it’ll work on other versions.

This script uses jQuery (www.jquery.com).

// ==UserScript==
// @name           Ajax PHPMyAdmin
// @namespace      All
// @description    Ajaxify PHPMyAdmin By Joel Day http://blog.dayjo.org/
// @include        http://localhost/phpmyadmin/sql.php*
// ==/UserScript==

// Add jQuery
var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://jquery.com/src/jquery-latest.js'; // Or specify one on the local server for a quicker load
GM_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);

// Check if jQuery's loaded
function GM_wait() {
    if (typeof unsafeWindow.jQuery == 'undefined') {
        window.setTimeout(GM_wait, 100);
    }
    else {
        $ = unsafeWindow.jQuery;
        letsJQuery();
    }
}
GM_wait();

// All your GM code must be inside this function
function letsJQuery() {

    var i = 0, j = 0;

    // Assign the th's id for later so we can grab the field name
    $('#table_results').find('th:not([colspan])').each(function() {

    	// i represents a column id
        i++; $(this).attr('id', i);

    });

// Loop through the field values and re-make the
 into our input box and div
    $('#table_results').find('td:not([align="center"])').each(function() {

        // Assign it a column id
        if (j == i) {
            j = 0;
        }
        j++;

    	// Current value of the field
        var value = $(this).html();
        var field = $('#' + j + ' a').html();

        // Set the html
        $(this).html("<div name='fielddiv'>" + value + "</div>\
        	<input style='display: none; text-align: right;' type='text' title='" + field + "' value='" + value + "' />");
    });

// Set the dblclick event of the div
$('#table_results div[name="fielddiv"]').dblclick(function(){

// Show the input and hide the div
$(this).siblings("input").show();
$(this).hide();

});

// Loop through and set the ENTER keypress event for save
    $('#table_results').find('td:not([align="center"]) input').keypress(function(ev) {
        if (ev.keyCode == 13) {
        	// Get the info for the query.
            var db = $('input[name="db"]').val();
            var table = $('input[name="table"]').val();
            var token = $('input[name="token"]').val();
            var field = $(this).attr('title');
            var value = $(this).val();
            var ID = $(this).parent().siblings().children('input[title="ID"]').val();

// Post the query
            $.post("sql.php?db=" + db + "&table=" + table + "&sql_query=UPDATE+" + table + "+SET+" + field + "='" + value + "'+WHERE+`ID`='" + ID + "'&token=" + token);

            // Now set the div to the new value, show it and hide the input
            $(this).siblings('div').html($(this).val()).show();
            $(this).hide();

// Return false as not to post any forms or click any selected links
            return false;
        }
    });
}

ExpertsExchange Greasemonkey Script

This is an edit of the following script: http://userscripts.org/scripts/show/46022

It removes all the junk, adverts and sign up links from experts exchange and gives you just the question and the solution.

I modified it to remove some more junk such as the Related Solutions box, and there will now be a link directly under the question for you to jump straight to the accepted solution.

The script uses jQuery.

// ==UserScript==
// @name           Clean Up ExpertsExchange
// @namespace   All
// @include        http://www.experts-exchange.com/*
// @include        http://experts-exchange.com/*
// ==/UserScript==

// Add jQuery
    var GM_JQ = document.createElement('script');
    GM_JQ.src = 'http://jquery.com/src/jquery-latest.js';
    GM_JQ.type = 'text/javascript';
    document.getElementsByTagName('head')[0].appendChild(GM_JQ);

// Check if jQuery's loaded
    function GM_wait() {
        if(typeof unsafeWindow.jQuery == 'undefined') { window.setTimeout(GM_wait,100); }
        else { $ = unsafeWindow.jQuery; letsJQuery(); }
    }
    GM_wait();

// All your GM code must be inside this function
    function letsJQuery() {
        $(".blurredAnswer, .relatedSolutions, .allZonesMain, .qStats, .lightImage, .ontopBanner, .adSense, .startFreeTrial, div#pageRight, #relatedSolutions20X6").remove();

        $(".sectionTwo:first").after('<h2><a style="color: #ee6600;" href="#theanswer">Skip To The Accepted Solution &gt;&gt;</a></h2><br />');
        $(".acceptedHeader").before('<a id="theanswer" name="theanswer"></a>');

    }

Les Arcs Pictures – Part 1


More Pictures Coming Soon :)

Snowboarding in Les Arcs

I’m off this evening… well 4am Sunday morning actually, to Gatwick and then on to Grenoble!

I’ll be away Snowboarding until next Sunday so there will probably be a lack of bloggage, unless of course there’s wifi in the chalet, and then I’ll try and upload some photos from my phone (although that never seems to work).

Hopefully, I won’t break anything that I require to do my new job (which is going well by the way). But maybe I’ll improve on my boarding skills which are somewhat limited as I’ve only really been once … well ok I did a whole season in New Zealand but I’m still not that great.

Anywho, I’ll be back in a week.

Glype Proxy – Content Filtering

So again with the Glype Proxy, I needed to filter some content on all pages, so I had to write a little mod, it’s quick simple, and unreliable so yay!

To begin, Open up /includes/parser.php … and insert the following code (I put it around line 48):

// Dayjo - Filter Modification	  
// Open the filters file and filter all of the results.
$filename =   "filters.txt";
$fp = @fopen($filename, 'r');
if ($fp) {
  $array = explode("\n", fread($fp, filesize($filename)));
  foreach($array as $key => $val){
    list($before,$after) = split("~",$val);
    $input = preg_replace($before,$after,$input);
  }
}

Then, in the main Glype directory (/), create a text file called “filters.txt“.

Now, in this file you can provide text filters using regular expressions, separating with the tilde symbol ( ~ ), for instance, if you wanted to filter out swear words you would put the following into the file:

/shit/~****
/twat/~****

etc…

Somebody wished to modify page titles, so to do that you will need to something like:

/<title>(.+)</title>/~<title>$1 - PROXIFIED BY DAYJO</title>

Which would add ” – PROXIFIED BY DAYJO” to the original title. (Remove the $1 to get rid of the original title).

This modification could be used for a variety of reasons, removing images or ads, replacing content with your own, or making pages look funny by replacing the with teh… whatever takes your fancy.

Glype Proxy Theme – Clouds

I decided to design a little theme for Glype Proxy (www.glype.com).

As far as I can tell, it is fully compatible with;

  • Firefox 3.0.6
  • Google Chrome
  • Opera 9.63
  • Safari(PC) 3.2.1

So yes, that leaves out Internet Explorer. I may adjust it to be IE compatible, but for now, you’ll just have to use a better browser.


Preview

Download Now (clouds.zip 70kb)

CSS – Pretty Buttons

So I’ve had the need to create some buttons for a web project I’m working on.

I wanted them to be entirely CSS based, and pretty flexible with the option to add icon images.

Read the rest of this entry »