Posts

How to change the Wordpress database table prefix

Image
A simple guide, to explain how to change the Wordpress database table prefix of your WordPress installation from its 'wp_' into something else . It is recommended that you change this because all your login details are stored in this database, making it a popular target for hackers. Changing the prefix will make it harder for them to break in. Step 1: Change the table prefix in wp-config.php This is done via the CPanel > File Manager: In file manager, navigate to the root folder and identify the wp-config.php file. Right-click on and select edit or select Edit in the menu bar at the top of your screen. Locate the following entry: [code language="text"] $table_prefix = 'wp_'; [/code] Replace 'wp_' with something else; in this case, we replaced it with 'xyz_': [code language="text"] $table_prefix = 'xyz_'; [/code] Step 2: Change the table prefix in the database Open your database in PhpMyAdmin: Se...

Getting started with Chocolatey packages

Image
Simple example Taken from chocolatey.org documentation that shows you how to create a basic package to install Notepad++. Open a command prompt and navigate to a preferred location and enter 'choco new notepadplusplus' to create the package files etc: This will create the basic structure as shown: notepadplusplus.nuspec Edit the notepadplusplus.nuspec file as follows (modify the version number according to what Notepad++ version yuo are installing) [code lang="xml"] <?xml version="1.0" encoding="utf-8"?> <package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd"> <metadata> <id>notepadplusplus</id> <title>Notepad++ (Install)</title> <version>7.0</version> <authors>Don Ho</authors> <owners>my company</owners> <!-- also known as package mantainers --> <description>Notepad++ is a free (as ...

Using Regex to find and replace text in Notepad++

Image
A quick cheat sheet for using Notepad++ to find and replace text in Notepad++. In all examples, use select Find and Replace (Ctrl + H) to replace all the matches with the desired string or (no string). And also ensure the 'Regular expression' radio button is set. [caption id="attachment_9278" align="alignnone" width="573"] Using Regex to find and replace text[/caption]

Using flex to layout items in css

Image
Some recipes for using flex to reliably align items in your html files. The collection of recipes can also be found as a collection my CodePen site . 1. Make a div box occupy available height, fixed footer HTML [code language="html"] <div class="outer"> <div class="inner_remaining"> I take up the remaining height </div> <div class="footer"> Fixed footer </div> </div> [/code] CSS [code language="css"] html, body { height: 100%; width: 100%; margin: 0; } .outer { display: flex; flex-flow: column; height: 100%; } .footer { height: 100px; background-color: grey; } .inner_remaining { background-color: #DDDDDD; flex-grow : 1; } [/code] 2. Fixed / sticky footer example HTML [code language="html"] <div class="box"> <h2>Fixed/Sticky Footer</h2> <p>The footer is placed at the bottom of the page.<...

Dragging shapes with the mouse in WPF / MVVM

Image
In a recent project I was interested in Dragging shapes with the mouse in a WPF / MVVM Visual Studio project. This post contains an example on how to drag a rectangle from from one canvas location to another using the WPF / MVVM architecture. This project uses Microsoft Visual Studio Community 2019. Step 1: Create a new WPF project: [caption id="attachment_9221" align="alignnone" width="900"] Dragging shapes with the mouse[/caption] Step 2: Add event-handling and event-raising infrastructure Just add the following classes to your project: EventArgs.cs [code language="csharp"] using System; namespace Canvas1 { public class EventArgs<T> : EventArgs { public EventArgs(T value) { Value = value; } public T Value { get; private set; } } } [/code] EventRaiser.cs [code language="csharp"] using System; namespace Canvas1 { public static class EventRaise...

A JavaScript cheat sheet

1. slice() The splice() method adds/removes items to/from an array, and returns the removed item(s). [code language="js"] const words: string[] = ['abc', 'xyz', '123', 'the', 'cat', 'sat', 'on', 'the', 'mat']; const splicedWords = words.splice(3); console.log('Spliced array: ' + splicedWords); console.log('Original array: ' + words); [/code] Output: [code language="text"] Spliced array: the,cat,sat,on,the,mat Original array: abc,xyz,123 [/code] Note that on using splice() the original array is impacted. The contents of the original array can be modified by adding or removing elements too, such as in the following example. Remove the word 'the' from the selected index index in the list and insert the words ['this', 'other'] instead: [code language="js"] const words: string[] = ['the', 'cat', 'sat', 'o...

A git stash cheat sheet

A summary of usages of git stash commands: 1. List current stashes [code language="xml"] &gt; git stash list [/code] 2. Deleting stashes Delete all stashes: [code language="xml"] &gt; git stash clear [/code] Delete specific stash (stash id in quotes on PowerShell): [code language="xml"] &gt; git stash drop &lt;stashId&gt; [/code] 3. Save stash(es), annotated with a message [code language="xml"] &gt; git stash save my message... [/code] 4. Apply the most recent stash [code language="xml"] &gt; git stash apply [/code] 5. Apply a specific stash [code language="xml"] &gt; git stash apply --index 2 [/code] or use stash{0}: [code language="xml"] &gt; git stash apply stash@{1} [/code] If you are using a Powershell-based command line, it won't like the curly braces, so enclose it in quotes and it should work: [code language="xml"] &gt; git...