Interactivity for Payment Forms

Interactivity for Payment Forms

A short while ago now I read an article by Michael Villar of Stripe on using animations when users are completing payment forms.

Villar put forward the argument that this improves the user experience.

Below is a demonstration of doing that.

Interactivity for Payment Forms A short while ago now I read an article by Michael Villar of Stripe on using animations when users are completing payment forms. Villar put forward the argument that this improves the user experience. Below is a demonstration of doing that. …

Read More

Laravel: Filter Every Array Element with a Closure

I always forget about how awesome Laravel Collection's are. I came across this gem when needing to run a filter on every element of an array. I think it may of been Dayle's book that first informed me of them. For example, if you have an array of fruits that you want to filter down, you can do the following:

// Create an array of fruits
$array = ["banana", "apple", "orange"];

// Transform the array into a Collection object
$collection = new Illuminate\Support\Collection($array);

// We don't like banana's anymore, so we're going to filter them out
$no_bananas = $collection->filter(function($element) {
    if ($element != "banana") return true;
});

// Dump out our array now, and we'll see the banana's are gone
dd($no_bananas);

I always forget about how awesome Laravel Collection's are. I came across this gem when needing to run a filter on every element of an array. I think it may of been Dayle's book that first informed me of them. For example, if you have an array of fruits that…

Read More

Laracon US 2014

If you haven't noticed yet, the Laracon US 2014 videos have been posted online for a short while now, you can grab them over on Userscape's website at http://userscape.com/laracon/2014/.

One talk of note, which I've recommended to a lot of people is by Greg Baugues, titled "Devs and Depression".

If you haven't noticed yet, the Laracon US 2014 videos have been posted online for a short while now, you can grab them over on Userscape's website at http://userscape.com/laracon/2014/. One talk of note, which I've recommended to a lot of people is by Greg Baugues, titled…

Read More

Adding Google Sitemap's to Ghost Blogging Platform

I recently wanted to replace my statically generated sitemap.xml file with a dynamically one generated by ghost. It ended up being pretty trivial to do, but the following two links helped immensely. At present, it's a hack to the core which you'll have to repeat if you upgrade - but that's a small price to pay for having your sitemap generated dynamically.

For adding sitemap support:
http://tstrimple.com/hacking-ghost-adding-dynamic-sitemap-xml/

For updating the format/count:
http://www.mathachew.com/blog/customizing-your-dynamic-sitemap-in-ghost/

I recently wanted to replace my statically generated sitemap.xml file with a dynamically one generated by ghost. It ended up being pretty trivial to do, but the following two links helped immensely. At present, it's a hack to the core which you'll have to repeat if you upgrade -…

Read More

A Love of Brasil

I've seen a lot of people unhappy with Brasil and their football team the past few days. There is a piece of me that deals with that unhappiness and disappointment of events in a way that allows me to deal with things.

If you've met me in person, played football with me or spoken to me about sports then I've probably at some point mentioned Brasil. I'll be travelling over to Brasil later this year and I'm sure that I'll love it. I have an incredible amounts of friends and people close to me there, it'll be good to finally spend time learning about the country and life in it.

Both Brasil as a country and the friendly nature of Brazilians has been a part of my admiration since I was a kid and this was mainly influenced by one person, an idol of mine: Ronaldo Luís Nazário de Lima.

I had a childhood that wasn't like most kids. I spent most of it in a wheelchair, unable to walk and dealing with the effects of Legg–Calvé–Perthes Disease which prevented me from walking normal until I was about 12 years old. When I started high school at 11, I was on crutches and then a walking stick. I missed out on the whole childhood adventure of climbing trees, playing football and doing the usual things that children do.

For my life and career, this served me well. I learned to program basic at this time and started to learn a lot about computing which has done me well considering that I'm now a programmer as a professional.

Football seemed to touch something deep inside my soul. As soon as I was able to walk, then run - I began to play football. This is now one of the most important parts of my life, I have been told that I will be unable to walk by doctors three times in my life so far. I still prove them wrong and will continue to do so, until I actually can't. I have no idea if I'll be walking by the time I am 40, 50, 60 or older. I hope that it will be longer, of course. I have no control over that though, it all depends on how well my hip manages to deal with life. My doctor would prefer me to have a hip replacement now, to which I object completely. I prefer to deal with the pain of having my 'real' hip and being able to play the sport that has given me so much.

As a human, I think I've overcome quite a lot to get to where I am now. The inspiration for that and the never giving up came from years of watching and learning about Ronaldo. This is a professional sports player that has had career threatening injuries more times than people care to remember. There is an image that sticks into my mind of Ronaldo while he was playing for Inter Milan on 21 November 1999 against Lecce felt his knee buckle, he was out for a long period of time.

I sat watching the moment I'd waited for, on the 12th April 2000 Ronaldo was named a substitute for the game against Lazio in the Copa Italia final. Ronaldo played seven minutes in total. He took the ball on the edge of the D and collapsed. His knee had given way again. There is a now famous photo of Ronaldo laying on the pitch in anguish.

Ronaldo Injury

This image has stayed with me for life. I've had serious knee injuries myself and serious ankle injuries too. I never gave up hope that I would play again and always believe that I would be able to recover from them. In Ronaldo's case, he not only came back from these awful injuries, he resumed his career after them. The attitude and commitment to do that is amazing to me and part of the reason why he has remained my idol throughout life.

If you ever wondered how severe Ronaldo's knee injuries have been, look at the photo below.

Ronaldo's Knee

I read an interesting post a few days ago, which talks about what Ronaldo could have been which I'd recommend reading.

Always remember, that no matter how bad things may be at present, they can always get better.

I've seen a lot of people unhappy with Brasil and their football team the past few days. There is a piece of me that deals with that unhappiness and disappointment of events in a way that allows me to deal with things. If you've met me in person, played football…

Read More

MariaDB: Set Maximum Server Connections via Query

If you're a MariaDB user and need to set the max_connections variable a little higher while the server is running, you can use the following SQL query:

# This will give you the current mac_connections setting
select @@max_connections;

# Set the maximum connections allow for MariaDB
set global max_connections = 200;

# To see that the variable has been changed, run the following query again:  
select @@max_connections;

If you're a MariaDB user and need to set the max_connections variable a little higher while the server is running, you can use the following SQL query: # This will give you the current mac_connections setting select @@max_connections; # Set the maximum connections allow for MariaDB set global max…

Read More

ncftp: Recursive File Get

A while ago I wrote a post about using the basic ftp command to recursively fetch remote FTP files, it seems this doesn't completely fetch them recursively. A great little program called NCFTP will do this accurate and pretty quickly. Install NCFTP if you haven't already, then run the program:

ncftp

This will give you a prompt, at which type the following:

set save-passwords yes

Which will allow the program to save your password while its working and transferring files. Open a connection to your FTP server by using the following at the command prompt:

open -u ftp_username ftp_host

It'll ask for a password, enter it and then it'll go away and connect. To then download your files recursively, enter the command:

bgget -r file/path

and once you've finished queuing files, type:

bgstart

to begin the transfer and NCFTP will go ahead and download all your queued files.

A while ago I wrote a post about using the basic ftp command to recursively fetch remote FTP files, it seems this doesn't completely fetch them recursively. A great little program called NCFTP will do this accurate and pretty quickly. Install NCFTP if you haven't already, then run the program…

Read More

Titanium: Remove All Children of View

I picked up this function somewhere a while ago, it's useful when you want to remove all the children elements of a view in Titanium.

function removeAllChildren(obj) {
    var c = obj.children.slice(0);
    for (var i = 0; i < c.length; ++i) {
        obj.remove(c[i]);
    }
}

I picked up this function somewhere a while ago, it's useful when you want to remove all the children elements of a view in Titanium. function removeAllChildren(obj) { var c = obj.children.slice(0); for (var i = 0; i < c.length; ++i) { obj.remove(c[i]); } } …

Read More

Apple Swift Programming Language Manual Download

After Apple's impressive WWDC keynote earlier, you can download the reference manual for the Swift programming language for iBooks using the following URL:

https://itunes.apple.com/gb/book/swift-programming-language/id881256329?mt=11

After Apple's impressive WWDC keynote earlier, you can download the reference manual for the Swift programming language for iBooks using the following URL: https://itunes.apple.com/gb/book/swift-programming-language/id881256329?mt=11…

Read More

Linux: Find All Modified Files in Last X Days

Nifty linux command to remember:

$ find . -mtime -3 -ls /

This will display all the files modified in the last 3 days. You can change 3 to suit as many days as you require.

Nifty linux command to remember: $ find . -mtime -3 -ls / This will display all the files modified in the last 3 days. You can change 3 to suit as many days as you require.…

Read More

How to Detect Version of CS Cart Websites

Quick tip, if you need to find the version of a CS Cart based website, simply append ?version to the query string, so for example if you shop name is mysupershop.co.uk, point your browser at:

http://www.mysupershop.co.uk/index.php?version

You'll be presented with a page that notifies you which version of CS Cart is installed and running, similar to:

CS-CART: version 2.1.4 PROFESSIONAL

Quick tip, if you need to find the version of a CS Cart based website, simply append ?version to the query string, so for example if you shop name is mysupershop.co.uk, point your browser at: http://www.mysupershop.co.uk/index.php?version You'll be presented with a…

Read More

Laravel Homestead: Add Enviroment Variables to Nginx

If you wish to set your enviroment by using server enviromental variables with the new Laravel Homestead you can do the following:

Edit the website configuration name, by running the following command within the VM:

$ sudo nano /etc/nginx/sites-available/local.dev

Within the location ~ \.php$ { block, update your configuration to resemble this:

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;

    fastcgi_param LARAVEL_ENVIROMENT "dev";

    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}

Now restart Nginx

$ sudo /etc/init.d/nginx restart

Next, edit your bootstrap/start.php file and update the method to detect enviroment:

$env = $app->detectEnvironment(function(){
    return getenv("LARAVEL_ENVIROMENT");
});

Now you can set your enviroments per server.

If you wish to set your enviroment by using server enviromental variables with the new Laravel Homestead you can do the following: Edit the website configuration name, by running the following command within the VM: $ sudo nano /etc/nginx/sites-available/local.dev Within the location ~ \.php$ { block, update your configuration…

Read More

MySQL Procedure: Drop All Tables in Database

If you ever need a progmatic way to drop all tables in a database, you can use the following stored procedure:

DELIMITER $$

DROP PROCEDURE IF EXISTS `drop_all_tables_from` $$

CREATE PROCEDURE `drop_all_tables_from`(IN schema_target VARCHAR(128))
BEGIN
    DECLARE table_list TEXT;

    SELECT
        GROUP_CONCAT(`TABLE_NAME`)
    INTO
        table_list

    FROM `information_schema`.`TABLES`
    WHERE
          `TABLE_SCHEMA` = schema_target;

    IF table_list IS NOT NULL THEN
        SET @drop_tables = CONCAT("DROP TABLE ", table_list);

        PREPARE stmt FROM @drop_tables;
        EXECUTE stmt;
        DEALLOCATE PREPARE stmt;
    END IF;

END $$

DELIMITER ;

To use, simply call the procedure with the database name as the parameter:

CALL drop_all_tables_from("database_name"); 

Note: This will drop all tables, without confirmation for the database name provided.

If you ever need a progmatic way to drop all tables in a database, you can use the following stored procedure: DELIMITER $$ DROP PROCEDURE IF EXISTS `drop_all_tables_from` $$ CREATE PROCEDURE `drop_all_tables_from`(IN schema_target VARCHAR(128)) BEGIN DECLARE table_list TEXT; SELECT GROUP_CONCAT(`TABLE…

Read More

Laravel: Prevent Sessions for Routes via a Filter

I needed to prevent Laravel from using sessions for a few API endpoints in an app, this is how I did it:

Route::filter('session.remove', function()
{
    return Config::set('session.driver', 'array');
});

This can be used quite easily with a route or route group:

Route::group(array(
    "prefix" => "api/v1",
    "before" => array("session.remove")
), function() {
    Route::get('/search', 'SearchController@getPerformSearch');
});

I needed to prevent Laravel from using sessions for a few API endpoints in an app, this is how I did it: Route::filter('session.remove', function() { return Config::set('session.driver', 'array'); }); This can be used quite easily with a route or route group: Route::group(array( "prefix" =>…

Read More

Company Unable to Fulful Your Order? Aquire It.

I absolutely love data and robots.

I came across a story this morning while reading Reddit. An Amazon warehouse staff member had taken part in AMA sessions which you can read here.

One on the questions posed was about how much automation is present in the warehouse. The person replied with a detailed answer which included the fact that Amazon placed an order for a Kiva automation system that Kiva was unable to fulfil.

Instead of going to find alternatives, Amazon purchased Kiva and now gets their orders fulfilled first and Kiva's other customers afterwards.

These Kiva robots are absolutely awesome and it turns the pickers work into a doddle.

I absolutely love data and robots. I came across a story this morning while reading Reddit. An Amazon warehouse staff member had taken part in AMA sessions which you can read here. One on the questions posed was about how much automation is present in the warehouse. The person replied…

Read More

Laravel London Meetup

On the 15th May, a work colleague and I attended Laravel London for a couple of talks by Aussie Kirk Bushell and Maks Surguy. Both were great presentations, Kirk spoke about abstracting validation away to use across your application and Maks spoke about the pitfalls of ajax file uploads.

Laravel London Meetup

If you're interested in attending one of the meetups you can find the group on Meetup.com at London Laravel which is created by the fantastic Jonty Behr.

On the 15th May, a work colleague and I attended Laravel London for a couple of talks by Aussie Kirk Bushell and Maks Surguy. Both were great presentations, Kirk spoke about abstracting validation away to use across your application and Maks spoke about the pitfalls of ajax file uploads. If…

Read More

FOI: Vacant Commercial Properties in Newcastle under Lyme

A recent Freedom of Information request that I had placed at the local council has been returned. There were a few noteable buildings currently vacant which I will document further soon.

Below is a map detailing the currently vacant commerical properties that are owned by Newcastle under Lyme Borough Council.

Map was produced with the useful jHERE mapping library that I've been wanting to use for a while now. You can find the code used to produce the map on Github at github.com/ssx/data-foi-nulbc-4332 where you can fork/use it as required.

A recent Freedom of Information request that I had placed at the local council has been returned. There were a few noteable buildings currently vacant which I will document further soon. Below is a map detailing the currently vacant commerical properties that are owned by Newcastle under Lyme Borough Council…

Read More

Laravel: Validate an Uploaded File is an Image

One thing I've seen asked often in the Laravel forums is how to validate that an uploaded file is an image. The quick couple of snippets below detail how to perform this common task.

Create a view called form.blade.php and place the following contents:

<!doctype html>
<html lang="en">
<head>
    <title>File Upload</title>
</head>
<body>
@if (Session::has("message"))
    {{ Session::get("message") }}
@endif
<hr />
{{ Form::open(array('url' => '/', 'files' => true)) }}
{{ Form::file('image'); }}
{{ Form::submit('Upload File'); }}
</body>
</html>

The code below should be placed in a controller, or quickness I've just dropped it into a route.

You can use the following logic with the Laravel validator to check the file is an image:

Route::get('/', function()
{
    // Return our basic form view
    return View::make("form");
});

Route::post('/', function()
{
    // Build the input for our validation
    $input = array('image' => Input::file('image'));

    // Within the ruleset, make sure we let the validator know that this
    // file should be an image
    $rules = array(
        'image' => 'image'
    );

    // Now pass the input and rules into the validator
    $validator = Validator::make($input, $rules);

    // Check to see if validation fails or passes
    if ($validator->fails())
    {
        // Redirect with a helpful message to inform the user that 
        // the provided file was not an adequate type
        return Redirect::to('/')->with('message', 'Error: The provided file was not an image');
    } else
    {
        // Actually go and store the file now, then inform 
        // the user we successfully uploaded the file they chose
        return Redirect::to('/')->with('message', 'Success: File upload was successful');
    }
});

One thing I've seen asked often in the Laravel forums is how to validate that an uploaded file is an image. The quick couple of snippets below detail how to perform this common task. Create a view called form.blade.php and place the following contents: <!doctype html>…

Read More