DIGITALREP

Update an Android SurfaceView using a ThreadAugust 26, 2016

The Activity

Firstly, you will want to launch the SurfaceView from an Activity:


package easyprogrammingexamples.com.surface;

import android.app.Activity;
import android.os.Bundle;

public class TheActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_layout);

        //Use this if you don't want to use XML layout files
        //surfaceView = new TheSurfaceView(this);
        //setContentView(surfaceView);

    }
}

Read more…

Category: Tutorials
Tags:  

CSS SpecificityApril 12, 2015

Sometimes you’ll inherit a project that has one or more CSS files that are thousands upon thousands of lines long. You’ll want to edit them, naturally, in order to update the styles of the website you’re working on. You’ll search through the CSS file for the properties you need to change and then change them, save the file, hit refresh…

And nothing happens. So you do another search and make sure that the property you just added or edited is the last instance of that property in the file. Then you make sure any preceding files aren’t overwriting your property. Then you want to make sure no one has used !important anywhere. But still…

You come up empty-handed. So what is going on?

Read more…

Category: Best Practices
Tags:  

Implement a RESTful web service using Symfony2June 27, 2014

Why a RESTful web service?

The case for REST is best illustrated by example.

Non RESTful Reading of Resources:
GET: http://www.mydomain.com/authors.php?author_name=Stephen_King
Response:


<h1>Stephen King</h1>
<p>Author of 'Misery', 'The Stand' and more recently 'The Dome', Stephen King is 
indeed a King of...</p>

RESTful Reading of Resources:
GET: http://www.mydomain.com/authors/Stephen_King/
Response:


{
    "author":
    {
        "name":"Stephen King",
        "intro":"Author of 'Misery', 'The Stand' and more recently 'The Dome', Stephen King is indeed a King of..."
    }
}

Read more…

Category: Tutorials
Tags:  

Symfony2 Console Commands CheatsheetJune 19, 2014

How to use console commands with Symfony2

To run any Symfony2 console command, open up a command prompt and navigate to your app’s directory, then run the console with a command:

C:\> cd htdocs/myappdirectory C:\htdocs\myappdirectory> php app/console list

‘List’ will give you a list of the commands.

Read more…

Category: Cheat Sheets
Tags:  

Using SASS (instead of just plain boring old CSS on its own)February 22, 2014

Because let’s face it – CSS3 on its own just wasn’t complex enough!

All jokes aside though, with compass and sass added to the mix we now have the ability to throw in variables, mix-ins, advanced nesting, the ability to sort our css into sections via imports and other various wonderful things. It almost makes css seem like a scripting language. So how do you add variables and stuff into plain old css? By writing it all up in a .scss file which is then parsed by Ruby which then creates valid css files that contain literal values for your variables, imports and mix-ins.

Read more…

Category: Tutorials
Tags:  

Using Composer to install PHP dependenciesJanuary 22, 2014

Sometimes you’ll want to install and use a project that depends on other projects in order to work properly. One example is the PHP framework Symfony, which uses other things developed by other people, such as the twig bundle (twig is a templating system) and the doctrine bundle (which includes an object relational mapper and a database abstraction layer).

Read more…

Category: Tutorials
Tags:  

How to make WordPress page templatesOctober 20, 2013

So you’ve decided to use WordPress as a content management system – well, you’re going to need custom WordPress page templates, then.

Custom page templates represent the pages of your website that aren’t related to blog posts – for example an about page, a contact page, or a custom homepage. You want them to look a little different than the rest of the site and you want them to be editable within the WordPress administration section in the same way that a post is.

To accomplish this, firstly you need to create a HTML template that defines how the page will look. Then, when you create a new ‘page’ from the WordPress administration section of your site you can identify its template as the HTML template you just created.

To define the content for a custom page template you can either

a) dynamically grab some content within the page template based on a custom post-type,

b) simply edit the page directly within WordPress or

c) hard-code it into your custom page template.

Read more…

Category: Tutorials
Tags:  

How to add WordPress custom post typesOctober 16, 2013

Add your WordPress custom post type to functions.php

Say we want to add a custom product post type. We first need to create an array of labels to be used in the administrative menu for the post type:

$labels = array( 'name' => _x('Products', 'post type general name'), 'singular_name' => _x('Product', 'post type singular name'), 'add_new' => _x('Add New', 'Product'), 'add_new_item' => __('Add New Product'), 'edit_item' => __('Edit Product'), 'new_item' => __('New Product'), 'all_items' => __('All Products'), 'view_item' => __('View Product'), 'search_items' => __('Search Products'), 'not_found' => __('No products found'), 'not_found_in_trash' => __('No products found in the Trash'), 'parent_item_colon' => '', 'menu_name' => 'Products' );

Read more…

Category: Tutorials
Tags:  

SEO best practices – linksOctober 14, 2013

Sometimes Search Engine Optimisation best practices get pushed aside in favour of fancy form. This can potentially frustrate the hell out of your audience.

Read more…

Category: Best Practices
Tags:  

How to make a basic WordPress pluginOctober 14, 2013

The WordPress plugin we will develop in this tutorial will use custom HTML and CSS to display and style a tag cloud. It will also load a couple of jQuery libraries and a jQuery script that will override the default hover method of the links in our tag cloud so we can add some special effects.

Read more…

Category: Tutorials
Tags:  

How to make a basic WordPress templateOctober 13, 2013

So you’ve decided that this WordPress thing is pretty cool, but you really want to make your own WordPress template? Well, it all begins with index.php; at the bare minimum, index.php contains three php functions and ‘the loop’ (the loop that runs until it has grabbed all of the blog’s posts and displayed them on the front page). The other functions simply grab other parts of the template (the header, the sidebar and the footer) in order to glue them together with the loop on the front page.

Read more…

Category: Tutorials
Tags:  

Some basic Linux commandsOctober 12, 2013

On most modern Linux distributions you can use the graphical user interface to do just about everything. It is, however, sometimes easier to use the command line in a terminal and type the commands out. In these cases it’s good to have a handy reference that includes only the most common Linux commands and their options.

Read more…

Category: Cheat Sheets
Tags:  

Some basic Git commandsOctober 11, 2013

This is a quick-start guide that details some basic Git commands for version control

Using Git locally and then checking out branches, merging them and reverting changes

You can download Git for Windows here if you just want a version control system you can use to make changes to your own projects that you can easily merge or revert if disaster strikes. Once installed you will be able to use it via either a command-line interface or a graphical user interface.

Read more…

Category: Cheat SheetsTutorials
Tags:  

Beginning search engine optimisation – keywordsOctober 10, 2013

Whether you want to be at the top of the search engine results for your chosen subject or you just want to attract a certain type of person to your website, it all begins with some keyword research.

Keyword Discovery

To get a good idea of what works well, make a list of the keywords that your top ranking competitors use in the keyword meta tags in the source of their webpages (if they even have any!), i.e:

Read more…

Category: Tutorials
Tags:  

How to use the HTML5 shim in websitesOctober 09, 2013

Developers everywhere got mega excited about HTML5 and CSS3, until they realised with some measure of disappointment that older browsers won’t support the newer HTML5 elements such as article, section, aside, etc.

Read more…

Category: Tutorials
Tags:  

How to use modernizr in websitesOctober 08, 2013

Modernizr allows you to support newer features in newer browsers whilst also providing an alternative implementation of features for older browsers so you get the best of both worlds.

Read more…

Category: Tutorials
Tags:  

A quick look at the PHP MySQLi objectOctober 07, 2013

MySQLi – or improved MySQL – is for use with PHP 4.1 and above and provides improved security over MySQL.

Using the MySQLi object constructor to connect to a database:

$dbconn = new mysqli(‘localhost’, ‘user’, ‘pass’, dbname’);

Read more…

Category: Cheat Sheets
Tags:  

How to add Facebook meta tags to your webpageOctober 06, 2013

So you want to add facebook meta tags to your webpage and officially join the new age of social media? Good for you! By doing this you are turning your webpage into a self-hosted open graph object.

Read more…

Category: Tutorials
Tags:  

A quick look at MySQL regular expressionsOctober 05, 2013

This is a cheat sheet detailing MySQL’s particular flavour of regular expressions. All of the examples use a database table called Shades that contains the fields Red, Green, Blue, Yellow, Purple, Black, and Mother of Pearl.

Read more…

Category: Cheat Sheets
Tags: