List Code

Showing page 4 of 10 in latest. Total Items: 517
A Collection of Code
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.

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
wordpress
get the stylesheet directory in wordpress theme
...

9:55 pm, December 16, 2019
jquery
jquery document ready with foundation init as well
...

here is a jquery document ready that also loads the foundation js library. im not sure if the document foundation needs to be loaded in the document ready, but this way seems to work.

1:20 am, December 16, 2019
css
center something with css not using flex
...

This is how you can center something in another element if you dont want to use the flex method.  You will need the relative position on the outer element, and the absolute on the center one unl..

12:56 am, December 13, 2019
linux
how to unzip in linux
...

How to easily unzip in linux sudo apt install unzip unzip myzip.zip done.

11:51 pm, December 5, 2019
php
php mysql table exists function
...

this checks if a mysql table already exists in the selected database and returns true or false

4:25 am, December 2, 2019
php
how to display a php file as html with php
...

you can use the following function to show a php source file as html

3:50 am, December 2, 2019
jquery
jquery add a click function if the window size is greater than target_width
...

this function will add a click event to the target if the window size is greater than the target_width

2:03 am, December 2, 2019
jquery
jquery enable and disable attribute
...

enable and disable an element

12:12 am, December 2, 2019
javascript
js using recursion to create a range of numbers
...

in this we will create a function that calls its self to add to an array a range of numbers

4:25 am, November 25, 2019
php
php convert date now into a sql timestamp
...

an easy way to get the current date from php into a mysql or sql timestamp format, this uses the server time

12:43 am, November 25, 2019
html
add google captcha to enable and disable a form button
...

This will check if the google checkbox is checked and then enable or disable the form button depending on the outcome. This is just a basic version of this check, you should also check that the captu..

12:14 am, November 12, 2019
php
Generate a Random User Name
...

a function that will generate a random user name from a list of user names

11:33 pm, November 11, 2019
windows
Using Node to get a Web Dev Environment with livereload up and running
...

this is how i get a live reloading dev environment up and running on my windows pc's using node , npm and browsersync.

12:38 am, November 11, 2019
javascript
Using the Spread Operator to Evaluate Arrays In-Place Tests
...

My tests using the Spread Operator rather than the apply function. In the 1st function show_max_array i use the apply operator to convert the array into comma seperated values. In the show_max_array..

1:02 am, October 14, 2019
javascript
Using the rest operator to pass in a variable amount of arguments
...

If you don't know how many parameters you will need in your function you can use the rest operator to pass them in. ...

5:49 am, October 1, 2019
javascript
Default Parameters for Functions
...

You can pass in default parameters for functions so that if the function is used with no parameter it will use the default one.

5:23 am, October 1, 2019
javascript
Complex Arrow Function Example
...

Here is an example using a Complex or Higher Order arrow function, which slightly reduces the amount of code lines used. This should return the square root of all positive integers passed into it.

5:14 am, October 1, 2019
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

โค๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ•น

Random Quote
For a long time it had seemed to me that life was about to begin - real life. But there was always some obstacle in the way, something to be gotten through first, some unfinished business, time still to be served, or a debt to be paid. Then life would begin. At last it dawned on me that these obstacles were my life.
Alfred D. Souza