List Code

Total Items found in Code is 984.
This is a collection of various code tests and descriptions on how to use them. Primarily HTML, CSS, Javascript and PHP.
php
php countries array

country codes to country names array in php

11:09 pm, July 12, 2020
linux
add a user to a group

usermod -a -G examplegroup exampleusername

3:00 am, July 12, 2020
linux
loop through each directory in a target directory and compress them

this one loops through each of the target directory and also compresses each one

2:55 am, July 12, 2020
linux
loop through each directory in a target directory

i thought this would be useful for backing up all files in the /var/www/html/ directory rather than having to do each seperately, this loops through all of them

2:47 am, July 12, 2020
jquery
add a class or remove it based on window scroll location

if you inspect the header div you will see a class added to it when scrolled down, i have added additional margins to it so you can still see it even when scrolled. then you add a fixed property to m..

1:45 am, June 30, 2020
gimp
stretching an image to fit in a banner image with gimp

sometimes i need to get a square image to fit in a rectangle box this is a way to do it with GIMP get a square image, or pick any image (pexels) fit it in this box.. For this one we will be using ..

1:16 am, June 30, 2020
javascript
javascript window.onload

wait for the window to load and then run a function

11:32 pm, June 29, 2020
css
adding pulsating dots to your css ul li list

get rid of those boring dots in your list and add some pulsation! See the Pen Pulsate your <ul><li> list item dots! by Luke (@kruxor) on CodePen.

3:26 am, June 26, 2020
wordpress
wordpress adding post custom field meta and displaying it on you template

if you want to be able to add custom post fields into your pages in wordpress and display them in your template this is how you can do it, no plugin is required for this as post meta is available by d..

1:33 am, June 24, 2020
javascript
get element by class name with javascript and change it function

You may have seen the get element by id in javascript, which is great when there is only one element but what if you need to get the element using its class name The issue with classes is that they c..

1:59 am, June 17, 2020
html
hide parts of a form until the 1st item is selected

this code can be used when you just want to show the 1st field on a form then when it is selected it shows the rest of the form elements

1:26 am, June 17, 2020
css
css using perspective for transforms

just playing around with the perspective and transforms, it does weird and annoying things to the margins. I was interested in how this page worked, so i thought i would try and deconstruct it a bit. ..

5:57 am, June 16, 2020
wordpress
getting the site title vs the page name

this statement will check if the current page is the home page and show the get_bloginfo('name') if its another page in the site it will get that pages title using wp_title('')

5:07 am, June 16, 2020
wordpress
wordpress get home url

this uses the global wordpress variable to retrieve the home url

5:03 am, June 16, 2020
wordpress
add a tag to wordpress header from a plugin

when i googled this it just showed me plugins to add and remove things from the wordpress header. here is how you actually add your own tags to the wordpress header. This function will add the tag hi..

4:44 am, June 16, 2020
wordpress
list items matching a category title

this is just raw at the moment, not tested or working. this is matching a category number at the moment so would need an additional way to link that number to the category name, or know what the categ..

4:08 am, June 12, 2020
webdev
fixing the website footer and making it less ugly

Here i show you in a couple of steps how to make the footer on this site look nicer, while actually doing it. Here is what the footer currently looks like. Yep pretty average looking. Lets add a ..

3:43 am, June 6, 2020
javascript
loading content into fancybox modal using ajax

This loads content into a fancybox modal using an ajax request so you can specify a url to load into the modal when the button is clicked

4:30 am, June 5, 2020
javascript
inline fancybox modal testing

just testing to see if i can get a fancybox popup loading using an inline script rather than a document ready one, might be easier to implement. similar to this one, but without the need for documen..

6:12 am, June 3, 2020
css
simple linear gradient overlay for an image to make it darker or lighter

i use this one often if i have a background image and some text over the top, you can darken or lighten the linear gradient values to match the text content and make it readable.

11:07 pm, June 2, 2020
wordpress
wp register plugin settings admin

for usage in a wordpress plugin, this will register its settings

12:28 am, June 1, 2020
javascript
fancybox modal popup example

an example showing fancybox text modal window attached to a button to open it

6:59 am, May 29, 2020
css
wordpress main nav dropdown fix

this unsets the flex and allows the menu items to stack properly in a dropdown menu, not sure if this is reusable

3:47 am, May 27, 2020
linux
tar.gz to compress a directory in linux and then decompress it

a pretty common way to zip up contents in a directory into one (or technically two) archive(s). Add to tar.gz This will add the directory and all sub directories into the archive called the-archiv..

2:41 am, May 26, 2020
javascript
javascript isset equivalent

i was just looking for an equivalent to the isset in php for javascript, i was initially using .length but this can still cause errors so i found this solution. if (typeof my_var !== 'undefined') {}

6:39 am, May 19, 2020
wordpress
wordpress show the parent page title with fallback to title

in wordpress either show the parent page title, or if it does not have a parent then show the page title. tags: get parent page title wordpress

1:03 am, May 18, 2020
jquery
find and replace hrefs in existing page links using jquery

sometimes i have to do these things when you cant change the source files for some reason, usually due to old code. Its kind of a patch, but it works. The reason i had to add a delay in running the fu..

12:03 am, May 8, 2020
javascript
Use Sweet Alert rather than alert!

i love this script, it make the default alert look so much nicer, and its very easy to install. Just add the one script to your site, and then use Swal.fire rather than alert. simple usage Swal.fire..

11:35 pm, May 7, 2020
jquery
get the href value using jquery

this uses the jquery attr function to get the value of the href. this example targets the first a in the card div, so running the demo should alert you with https://kruxor.com Rather than using alert..

11:22 pm, May 7, 2020
php
check if a timestamp is older than one hour

this will check if the timestamp string is less or more than one hour old.

1:24 pm, May 4, 2020
wordpress
Add a post date to your custom wordpress post listing

this is an example using: get_the_date: this one gets the post date the_excerpt: which gets the .. excerpt or summary text from the post and get_the_post_thumbnail_url which gets the image from th..

5:49 am, May 4, 2020
php
making var_dump look nice

i was var_dumping an array the other day, and it comes out like a massive string you cant read. a fast way to make this readable is just to add some pre tags to it.

4:16 am, May 4, 2020
javascript
use javascript to open a link in a new tab or window

im not sure why you would use this rather than using the html target="_blank" but it could be useful if you needed to open a new tab in a javascript function.

3:59 am, May 1, 2020
javascript
force existing link to open in a new window with javascript

here is some javascript that grabs an existing link and then forces it to open in a new tab when clicked.

3:49 am, May 1, 2020
linux
Find Disk Space Usage using DU

The easiest way to check the space used in a directory in linux is this command: du -h This will do the current directory and all its sub directories. if you want to see a specific one type this d..

11:30 pm, April 28, 2020
javascript
Load and Unload TinyMCE editor from a button

Enable TinyMCE Disable TinyMCE Some Content function load_tinymce(idclass) { tinymce.init({ selector: idclass, plugins: [ "spellchecker code aut..

2:53 am, April 17, 2020
nginx
Nginx Server Block with Rewrite

Nginx Server Block with Rewrite Here is a basic nginx server block with rewrite to the index.php file. So it takes all the parameters and passes them into the index, into the variable $p or $_GE..

11:16 pm, March 29, 2020
css
pulsating dots - glow glowing

a column of pulsing dots using css keyframes animation

5:47 am, March 13, 2020
html
load a youtube video in a fancybox modal

With just a couple of lines of js and html you can load your video links in a modal lightbox. Get the latest version of the fancybox scripts (just the links) from here: https://cdnjs.com/libraries/fa..

10:46 pm, March 2, 2020
css
using css linear gradient for background overlays

a few examples using css linear gradient for the background

12:34 am, February 17, 2020
wordpress
wordpress get page content to display on template page

gets the page content and displays it on a template, this must use the post loop as shown in the code.

11:11 pm, February 3, 2020
javascript
ES6 Nested Object Example

extracting variables from a nested object with new variable names

1:09 am, February 3, 2020
javascript
ES5 vs ES6 Object Example

here you can see the syntax changes between ES5 vs ES6 Object declaration, you can still access the values in the same way.

12:41 am, February 3, 2020
javascript
Use Recursion to Return a Range Array

using recursion to return a range array between the two numbers added

11:38 pm, February 2, 2020
javascript
Use Recursion to Count Down

just a slight change to the count up version of this, using unshift rather than push to the array.

10:29 pm, February 2, 2020
javascript
Use Recursion to Count Up

10:20 pm, February 2, 2020
javascript
Get the documentURI with JS

This function gets the current document URI assigns it to the variable documentURI so it can be reused and shows it in the result area once you click on run function.

10:06 pm, January 28, 2020
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote


Random CSS Property

border-inline-end-width

The border-inline-end-width CSS property defines the width of the logical inline-end border of an element, which maps to a physical border width depending on the element's writing mode, directionality, and text orientation. It corresponds to the border-top-width, border-right-width, border-bottom-width, or border-left-width property depending on the values defined for writing-mode, direction, and text-orientation.
border-inline-end-width css reference