Search
Search Code
Search Code by entering your search text above.
wordpress
css
Left Fixed nav with right fluid content

left fixed nav section with right fluid section css and html using flexbox

12:43 am, March 15, 2024
wordpress
add a page template in a wordpress theme

duplicate the page.php to a new php file usually with the template name as the file name with no spaces file in wordpress theme and add the following line to the top.

12:31 am, March 15, 2024
js
jqueryui date selector with examples and code with custom date formatting

Datepicker using jquery ui with current date and date formatting. as dd-mm-yy Example Date formatting with selector  

6:12 am, February 27, 2024
css
css cursor types testing

testing all (most) of the available css cursor types, you can mouse over to test how the cursors react depending on your browser type and operating system.  refs https://developer.mozilla.org/e..

5:44 am, February 27, 2024
css
CSS Object Fit for Image fill rather than using background image on a div

CSS Object Fit can crop off the sides of an image, while also preserving its aspect ratio, and then fill in the space to fit any size.  Object Fit You can use: object-fit: With the following ..

3:47 am, February 23, 2024
css
flip card animation 3d front and back css html

3d flipping card with front and back content and animation

11:15 pm, February 15, 2024
css
six box grid css html custom no gap

re-usable four box grid with no gap, plus stack on responsive 1024px

12:38 am, February 7, 2024
css
four box grid css html custom

re-usable four box grid with gap calculations

12:37 am, February 7, 2024
templates
4 box custom grid with responsive

simple 4 box 25% grid with a responsive break at 1024px to stack the boxes in the grid

2:50 am, February 5, 2024
css
use an image in your list items ol ul li

replacing the default ul li list with an image prefix

12:02 am, January 15, 2024
windows
How to Enable Linux Subsystem in Windows

Enabling the linux subsystem in windows allows you to use linux within windows.  To enable linux sub system in windows you can do the following.  In the start menu type "Windows features..

11:35 pm, January 8, 2024
css
css grid container with 4 auto columns

12:58 am, December 22, 2023
html
Using the HTML tag details for easy accordions

Using the HTML Tag ` ` for automatic accordions.

12:32 am, October 27, 2023
css
select something with custom data attribute css

selecting something by its custom data attribute and value in css

2:00 am, June 27, 2023
js
fancybox youtube showing video links in a lightbox - updated with fixed code parts

do people still use lightboxes, it seems yes in some cases. ;) if you feel the urge to use lightboxes and need to link to some youtube videos this is how you can do it. you will need jquery and fanc..

6:43 am, June 26, 2023
SQLite
How To Install SQLite on Ubuntu 20.04

  Bash sudo apt install sqlite3 and to get it working with php, pick your version of php and change the following Bash sudo apt-get install php7.4-sqlite3

7:36 am, June 14, 2023
javascript functions
make clickable element with clickable class open link in new window

makes an element with a link into a clickable element. This finds the 1st a tag in the target element and then opens the link in a _blank tab. Then if you have an element that you want to be clickabl..

2:58 am, May 2, 2023
php function
function causing slow load time

i had this function matching a uid using a binary select query. The sites were loading in about 8 full seconds according to my load timer, sometimes up to 12 seconds! So this was running on old site ..

2:46 am, April 13, 2023
php errors
error Warning: getimagesize(uploads/583517f49099a.jpg): failed to open stream: No such file or directory in SimpleImage.php on line 1198

i think this error is just caused by a missing file. But there should be some kind of error checking here to not crash the whole site just due to a missing image file. this error is quite hard to fin..

7:07 am, April 11, 2023
php
Deprecated: parse_str(): Calling parse_str() without the result argument is deprecated

I had this error on a function that i was not even sure i was calling. This was on some old code i was testing for an old site, i must have fixed this error on a never version of the function.  ..

6:39 am, April 11, 2023
php functions
Return a file extention from a string

This php function returns a file extention from a string.  I think it will only work if the string does not have any additional . in it.  I think a better way to do this function would be ..

5:45 am, April 7, 2023
charts
Simple Line chart with Chart.js

a nice simple line chart example with fill using chart.js

11:58 pm, April 3, 2023
html
Boots Widget change from widget to cat head and click function

Moving this from the widget area to the bottom, to make it less obvious but still there if needed.   

4:26 am, March 27, 2023
slick slider
Slick slider code testing with slower slides and auto play on videos

additional testing with changes for slick slider videos and auto play

4:28 am, March 1, 2023
Sliders
Flickity - autoPlay with Loop

Flickity slider with auto play

11:46 pm, November 19, 2022
Windows Apps
windows robocopy /? help and usage

Reference for the windows robocopy command ------------------------------------------------------------------------------- ROBOCOPY :: Robust File Copy for Windows ..

10:54 pm, November 15, 2022
image formatting
can you set all image heights to match with css no stretching

Short Answer: Yes with object-fit: cover; on the css of the image properties.  object-fit: cover; You might also need:  object-position: right bottom; ..

4:32 am, November 9, 2022
html
pulse map dots

bunch of pulsing dots for a map or image. allows overlaying of clickable dots on an image, you can change the colors with the css below.  modified from here: e.g: 

12:14 am, November 8, 2022
javascript
find a text string and replace it in javascript

There is a function in javascript called replace. You can just give it some text and it should replace it with your target text.  For example #1 this just runs and replaces the first instance o..

11:48 pm, October 27, 2022
sections
sections
four box section template in foundation with classes find and replace (4 box)

this section uses the large-auto classes so you can add or remove boxes easily.  find and replace the name "boxsection" to rename your new classes for the section I have layed this one out a ..

11:08 pm, October 24, 2022
javascript
check if an item id exists in javascript

checks if 2 ids exist in one function and console logs the status here is the result in console log

12:28 am, October 19, 2022
php functions
shorten string php, string length php, clip string length php

I'm pretty sure i have done this function before but i cant find it due to the keywords being wrong! Here is a function that takes a string and shortens it and adds .. to the end, with the rest of th..

2:38 am, October 3, 2022
php functions
imgur upload from php

function that takes an image and uploads it to imgur using a client api id, and then returns all the data. i did this one ages ago and did not make it into a function, but this version should work as..

12:45 am, September 30, 2022
php functions
simplepie error : XML or PCRE extensions not loaded!

using simplepie it does not load the target feed, and does not display any errors. Just nothing.  if your feed is init'd with $feed check for feed errors with:        $feed ..

4:01 am, September 29, 2022
sections
four box responsive section with all classes find and replace boxsection title foundation grid (4 box)

four box responsive grid, find and replace the word... boxsection with your new section name to generate all class names and section names to match for rapid section creation. Demo Codepen

12:29 am, September 27, 2022
cookies
cookie consent quick install script js html css vanilla

Found this super slick looking cookie consent script here, looks awesome, and its easy to install (i hope). https://github.com/orestbida/cookieconsent  CDN Links https://cdn.jsdelivr.net/gh/or..

12:19 am, September 20, 2022
windows 11
How to switch desktops in windows 11 with keyboard

this is just a quick one as i could not see the option, which you would think they would add to the new desktop switching screen.. Anyway here is how you can switch desktops in windows 11 and create n..

12:24 am, September 13, 2022
Font Awesome
Add font awesome icons as placeholder text in inputs

An old one i found on codepen, works with only the old version of font awesome i think. Not tested on the later versions.

12:43 am, September 12, 2022
sections
two box responsive section with all classes find and replace boxsection title foundation grid (2 box)

easy copy and paste section and find replace the word boxsection with your new class names, using foundation grid.

7:01 am, September 9, 2022
sections
basic section item with foundation wrap and grid - single item in section

section with inner and outer css selectors for reuse and basic layout formatting. you can then search for "section-name" and replace it with your own section name.  section-name section-name..

4:36 am, September 6, 2022
jquery
wrap an iframe with another div inside another div

so lets say you had an iframe within another div and that div had the class called content. you cant actually edit the page content but you can add some jquery to the page can you add a wrapper to t..

12:35 am, September 5, 2022
javascript
Twitter Post Fetcher v18.0.4 - javascript twitter feed fetcher

A few queries showing how to get latest tweets and post likes using the Twitter Post Fetcher v18.0.4 script.

12:42 am, August 31, 2022
CSS
Map Image with Easy Dots and Titles using only CSS

I had to quickly add some dot points with names to a map the other day, so i thought i should probably look for a jquery library for tool tips or something similar. But then i thought why not just add..

12:44 am, August 24, 2022
regex
Regex replace or find anything in brackets

Search for anything within brackets ( find this ) and the bracket its self.  REGEX \((.*?)\)

12:27 am, August 15, 2022
fonts
Quick Embed Import and Code Samples for Google Font Roboto

quick embed codes and code examples for the google font Roboto. Roboto Font Preview

5:30 am, July 20, 2022
css
rainbow text background clip with linear gradient

testing using background clip with a linear gradient background colour to make the text appear rainbow colours 🌈 

2:02 am, July 6, 2022
html
codemirror with auto preview window

this should auto preview html code into the preview area using code mirror

7:15 am, July 5, 2022
php
using preg_match to extract text from elements

using preg_match to extract specified text from elements I also tried this search "if you have the start and end of a string extract the middle with php" as thats really all i need it to do, i have t..

1:41 am, June 24, 2022
html
using figcaption and figure for your images

So i usually add images in a <p> tag with just an <img> tag and then <br> and the image caption, but there is actually a tag for this that i should get used to using. The <figcapt..

12:40 am, June 24, 2022
Apps
Robocopy Options /? help

My usual backup command is now robocopy source destination *.* /M robocopy d:\ f:\ *.* /M Update: actually scrap that, its /E not /M, i used to use the /MIR option, but as deleting files in the des..

1:34 am, June 21, 2022
php
encode spaces in items passed to url to %20 not +

I was using urlencode in php and it was encoding words with spaces into word+space rather than word%20space This can be resolved by using the function rawurlencode rather than urlencode.

5:04 am, June 20, 2022
php functions
php validate email function

php function that can be used to validate an email address string

1:59 am, June 12, 2022
Site Updates
Welcome Widget Card - Toggle

Testing the welcome widget with a more or less toggle.  This version seems to work, with a jquery slide toggle. 

5:07 am, June 10, 2022
php
get json with php from a url and display it

yep its that easy. this code shows getting the contents from a json request api. var dumping all of the results and extracting one single item by its array key and showing it. 

1:39 am, June 1, 2022
linux
Install PHP without Apache on Ubuntu

I was actually about to do some coding and then i got distracted with this annoying error on vscode. I keep getting this error on vscode: I had been ignoring it, but i thought fine, ill fix it and..

12:30 am, June 1, 2022
html
a google font like muli - mulish and embed code

mulish font embed codes and styles with example

4:41 am, May 30, 2022
css
content-visibility and contain-intrinsic-size for page load rendering speed increase

interested to see if this makes any difference content-visibility The content-visibility CSS property controls whether or not an element renders its contents at all, along with forcin..

1:06 am, May 30, 2022
php
php convert number with k on the end to full number

I have a function that converts raw numbers into shorthand or human readable numbers, but was wondering how to convert these back if they are stored in that format, and also makes it better if you are..

9:16 am, May 29, 2022
html
basic radio checklist - check and item and get its value in a textarea

a basic radio input type checklist, where you can only select one of the items in the list.  Ok so no longer so basic.  This script allows you to fil the value of a text area with the valu..

2:06 am, May 25, 2022
Site Bugs
Search Duplicating Bugs

Still having issues with the word above duplicating, not sure why.  Search Page PHP - Get Search Value $search_value_encoded = htmlentities($search_value); Check for Search value, and then ..

6:39 am, May 20, 2022
linux
add a user and add the user to sudo group

basic adding of a user in linux and then adding the user to the sudo group to allow it to run super user commands like apt update or other potentially system breaking commands. Note: replace "usern..

2:23 am, May 19, 2022
javascript
floating message box on bottom right of screen with close button

A floating fixed message box on the bottom right hand side of the screen with a close button. 

12:00 am, May 17, 2022
docker
unable to write to a sqlite database with docker

turns out this was not a docker specific problem, i was getting the readonly database error.  even if the database has full write permissions, the directory also needs to have write permissions ..

1:46 am, May 8, 2022
javascript
share to linked in current url button with javascript

Share the current page url to linked in with a button and javascript

5:16 am, May 4, 2022
javascript
Get current URL and add a share to facebook share button with it

Combines this Facebook HTML for Sharing a Link and encode url with javascript this to make captan planet! Or... makes a share this post to facebook button. 

5:02 am, May 4, 2022
javascript
encode url with javascript

get the current url, encode it and log the encoded result to console

5:00 am, May 4, 2022
html
Facebook HTML for Sharing a Link

just the html for the link, that is all. Replace kruxor.com with your url to share E.g: share to facebook

4:55 am, May 4, 2022
css
truncate text with line clamp allow a certain number of lines

This shows how you can truncate text to a certain number of lines using the css property line-clamp.   -webkit-line-clamp: 3;  line-clamp:3;

1:32 am, May 4, 2022
javascript
Twitter Post Fetcher Script

Uses javascript to fetch a twitter feed from a user screen name. Totally stylable alternative to using the twitter embed code. Your Welcome... 

12:43 am, May 3, 2022
git
git basics - git init, git commit, git all, git *

create a new repository git init the following code can be typed in a terminal window, once you have installed git for your OS. This will create a directory called git-test assuming you already hav..

3:23 am, April 22, 2022
fonts
font similar to century gothic questrial google font quick install

I found this font to be closely related to the paid font "Century Gothic" the only issue i found with this font is that it only comes in regular weight.  But Questrial is free to use, so that is..

4:32 am, April 4, 2022
sections
html and css hoizontal simple timeline section in foundation

a horizontal simple timeline section example done in foundation grid with some custom styles. This also uses the Lato Font quick install! So Quick!..  :P Also works on responsive and mobile dev..

3:33 am, March 29, 2022
javascript
Javascript Objects Notes

As javascript objects are used so often in javascript i thought i would write an overview and some notes on how they work, well how they work for me anyway. I guess how they work for me should be simi..

2:37 am, March 28, 2022
javascript
javascript add class to element

how to add a class to an element in raw javascript I wrote a quick demo here showing how you can add a class to an element with an id on a button click

3:35 am, March 15, 2022
javascript
best way to write html into an existing page javascript

this probably isnt the "best way" but it is a way that works. say you want to add some elements to a page with javascript this is a method to do it.  Add an element, before including the script..

3:21 am, March 11, 2022
core
Core Function : list_search_by_class_return_links - List Searches by Class Type and Return Links

Function that list's the latest and top searches by the class name and return a list of links, with the search totals on them.  I wanted to extract the top searches and the latest searches by da..

2:35 am, March 10, 2022
php
Fatal error: Uncaught Exception: Required extension GD is not loaded.

How to resolve the error: Fatal error: Uncaught Exception: Required extension GD is not loaded. This Error is ususally due to a php library or script requiring the GD php extention.  On ubuntu ..

1:04 am, March 9, 2022
php
php check if a class exists

check if a class exists in php. this can be used rather than assuming the class exists and then causing an error You can run the class_exists function on the class before loading it with the followi..

12:47 am, March 9, 2022
javascript
check url hash using javascript

What is a url hash? This is a URL Hash. You can add the # symbol on the end of a url and content after it, and this will not effect the content usually, unless the browser is intructed to do somet..

3:59 am, March 7, 2022
javascript
submit form with javascript

if you have a form with an id, you can submit it with the following javascript. usually this will be attached to an event or something similar like a button click.  If i run this on the demo, it..

3:55 am, March 4, 2022
css
highlight a button with an animation css

While i was downloading the latest AdoptJDK i noticed this button, and thought it was a nice effect.  I wondered how hard it would be to replicate this. Copy the link html Check each class..

12:48 am, March 4, 2022
html
Regions of New Zealand - In Dropdown Form

Split into north and south island lists Also added a combined list, with a disabled options for north and south. /your welcome! :)

3:18 am, February 25, 2022
javascript
javascript get content from element

gets the content from a target element with javascript using its id sets the target with the content from element 1 using its innerHTML attribute

12:48 am, February 20, 2022
javascript
convert characters to entities using javascript replace

takes a html string and replaces the html elements into their equivalent characters. e.g: replaces < with &lt;

12:05 am, February 20, 2022
php functions
convert a string into its html entitles using php htmlentities function

this takes a html string such as the following example and converts it into its html entities. it will take a character such as < and convert it into &lt; so that the string is not parsed as h..

8:48 am, February 19, 2022
php
Uncaught Error: Call to undefined function mb_convert_encoding()

I was getting this error when calling a function in the readability php class, on a new server for code that worked on the old server. Uncaught Error: Call to undefined function mb_convert_encoding()..

11:45 am, February 15, 2022
javascript
Auto Create HTML Code Snippets

make anything within a <code> tag into a nice looking code snippit with highlighting via prism. To get this code to make a snippit, you need to: Give an element a .make-snippet class and it's ..

4:17 am, February 14, 2022
CSS
CSS Only Table Stacking Solution

11:24 pm, February 8, 2022
jquery
add a toggle with jquery and change the class

With this code I just wanted a quick bit of inline code that could add a toggle to an element or multiple and also switch its class to make it show that the item is toggled on or off.  Here is t..

12:00 am, February 8, 2022
node
Testing Playwrite on for Node

I came across this library on y news, and thought id give it a bit of a test.  I managed to get it working but not really sure what tests it can do.  I set it to take a screen shot of a we..

4:00 am, January 28, 2022
html
content editable p tag with spell check enabled

im not sure how this is useful, but you can set a p element to content editable so you can change its contents and then also set the spellcheck to true so the browser knows that it should run its spel..

12:01 pm, January 18, 2022
bootstrap templates
card.html template

a card template with title, content and a mb-3 for bottom margin for usage with the php template system.

4:52 am, January 18, 2022
php
fixing error Call to undefined function simplexml_load_string

usually the error "Call to undefined function simplexml_load_string" happens when the php xml library is missing from your server. You can install the xml php library with the following command, repl..

4:00 am, January 18, 2022
bootstrap
bootstrap form basic

a nice simple bootstrap form layout example template

11:49 pm, January 17, 2022
images
center image preview with lightbox and caption

I just wanted a thumbnail or preview of the image, where if clicked it would load into a lightbox, but the preview just shows the center of whatever image is added to it.  Note: I just picked ra..

2:54 am, January 12, 2022
javascript
get tomorrows date with javascript

Same as the get yesterdays date except with a +1 rather than a -1 let tomorrow = new Date(new Date().setDate(new Date().getDate()+1));  

11:03 pm, January 10, 2022
javascript
get yesterdays date with javascript

This gets todays date and minuses one day from it to be ... yesterday.  let yesterday = new Date(new Date().setDate(new Date().getDate()-1));console.log(yesterday); This format is the full da..

10:39 pm, January 10, 2022
css
hide the first h3 tag on the page with css

in case you want to target the first item on a page and hide it or change it with css. 

2:29 am, January 10, 2022
php functions
make a nice readable date using a timestamp string function make_nice_date

handy if you have a timestamp like this: 2022-01-10 00:12:42 and want it to look a bit nicer. like this... 12:19 am, January 10, 2022

12:12 am, January 10, 2022
javascript
add new random image with button

this appends a new random image from picsum.photos to the div with the id app

10:56 pm, December 30, 2021
javascript
Create Strings using Template Literals

if you use the backtick to enclose your strings you no longer have to use \n for a new line.  For example: `this is a multiline ...string!!` Console Example

5:55 am, December 29, 2021
php
get the content of a url get the content of a link with php and test if the result is empty

Where $import_url is the target URL. 

2:24 am, December 20, 2021
php simple html dom
extract meta attributes with simple html dom

pass in the url as import_url and it will search for the meta keywords tag and echo the result.

1:11 am, December 20, 2021
php
php check if url is valid with filter_var

check if url is valid using filter_var and return a message if the url is invalid rather than continuing

12:55 am, December 20, 2021
html
Common and Uncommon Meta Tag's and Social Meta Tags

I am writing an api that checks for meta tags so i thought i would add a list here of some of the common meta tag names that i found.  The ones prefixed with og: are facebook and linked in and s..

3:46 am, December 19, 2021
javascript
Darkmode JS - Add darkmode to your site with one script

This library looks really nice! It drops in ok, but maybe with more complex layouts or coloring, it seems to break a little bit.  Darkmode JS Example Source Links https://darkmodejs.learn.un..

12:47 am, December 17, 2021
javascript
Use destructuring assignment within the argument to the function half to send only max and min inside the function.

this seems like a tricky one, can be resolved with removing the stats array reference. Im not sure how it still knows to access the stats array. I dont know how that is correct as the console just lo..

12:34 am, December 17, 2021
css
center align vertical 2 items in a container flex

i had this issue and i was pretty sure that flex center could fix it but it was causing the two items in the div to sit next to each other, which was annoying as it was a header and content, but i sti..

11:26 pm, December 14, 2021
css
simple javascript no library accordion

a simple button and div based accordion with a toggled indicator

4:07 am, December 14, 2021
javascript
Using Destructuring and the Rest Parameter to Reassign Array Elements

Use destructuring assignment with the rest parameter to perform an effective Array.prototype.slice() so that arr is a sub-array of the original array source with the firs..

11:26 am, December 13, 2021
javascript
Use destructuring assignment to swap the values of a and b

Use destructuring assignment to swap the values of a and b so that a receives the value stored in b, and b receives the value stored in a. I was havi..

5:58 am, December 13, 2021
C
Hello world in C and seeing what it is actually doing

One of the most simple C applications, how to compile it and how to objdump it.  C #include int main() { int i; for(i=0;i < 10; i++) { puts("Hello Mac\n"); } return ..

12:25 pm, December 12, 2021
javascript
Sweet Alert 2 Methods and Examples

I love this alert replacement so i thought i would just add some of the examples here to show how awesome it is! You can check out the official sweet alert documents here if you want to browse throug..

5:39 am, December 8, 2021
css grid
Using CSS Grid instead of Float's for a 3 column simple list

I have been in the habit of just using float:left and then width 31% with margin 1% for list items, and it seems to work fine usually.  But i thought i probably should update the defaults in by ..

12:37 am, December 7, 2021
javascript
Slick Slider Carousel with Custom Next and Prev Buttons

I had a slider the other day where i needed to attach some detached buttons, so added the following click events to control the next and previous events on the slider.  Note the class names: sli..

4:52 am, December 6, 2021
html
Input Suggestions using a datalist

I found this cool piece of code here, looks very handy. Basically you can add the input and then provide it a data list with suggestions, which then will allow you to start typing the item and it wil..

12:58 am, December 6, 2021
php functions
get php to validate its self with php check syntax

Did you know that php has a syntax checking function built into it? Well it does and this is how you can use it to check your php files for errors, rather than just running them and hoping for the be..

5:45 am, December 1, 2021
mac
how to copy the folder path in finder

Moving from windows to mac is quite a shock, especially when you go from explorer which shows the file and folder path on every window in file explorer. Then we go to mac finder, which is nice, but h..

4:42 am, November 23, 2021
php functions
Spam IP Database and delete button

The Background and Reason for the SPAM IP Database and Delete I actually wrote up half of this article and was still testing the function and lost the whole post, which will teach me for adding it st..

12:24 pm, November 22, 2021
mac
install cmatrix on mac m1

For some reason i thought the mac would have apt or apt-get to install packages, but apparently not.  Here is how you can install cmatrix a matrix emulator or other unix type terminal apps on ma..

2:31 am, November 19, 2021
icons
how to embed google fonts icons

For some reason when i go to embed a google font icon, they dont seems to have any obvious way to actually use it, i can find the icons ok here. But then when i go and use it it links to a how to embe..

12:21 am, November 17, 2021
css
button zoom effect with expanding background

Just playing around with zoom and background size effects on a promo button, if you change the background to 110% and then zoom to 1.1 you can see how the background appears to zoom out while the butt..

8:21 am, November 11, 2021
virtual box
allow internal networking connection from virtual box vm

This will allows you to access a shared folder on a Windows 10 Virtual box from Windows 11. Probably also works with other windows versions, but only tested with the host OS beinf windows 11 and the V..

2:26 am, November 8, 2021
php functions
youtube search api request function

This function requests a search from the youtube search api, and searches the text in the snippet for the seearch string. You can get your own API key for this from the google developers console. They..

2:04 am, November 4, 2021
javascript
javascript random string to put on url for cache

I was having a bit of a cache issue with a external css file, so i thought i might fix this by appending a random query string to the file name. This should force the browser to recheck the file each ..

11:22 pm, November 1, 2021
javascript
javascript try catch example function

try catch is a good way to stop errors breaking your javascript. here is the example from the firefox mozilla with a basic try catch logging the error to your console, rather than just breaking all t..

2:01 am, October 29, 2021
php
Fix for PHP Warning Trying to get property '*name*' of non-object

i was getting this error when checking parts of an object that were sometimes set and sometimes they did not exist depending on the values.  Warning / Error : Warning Trying to get property '*na..

8:53 am, October 28, 2021
php
write the contents of a url into a file with php

save the content of a url into a file with php using the following command. This grabs the $url and saves the content into the file my_file.html  

8:43 am, October 27, 2021
javascript
load json data url or api with javascript

this loads a target json url or api using raw javascript so no jquery required with this one then logs the data returned to the console. 

4:43 am, October 26, 2021
jquery
load json data url with jquery

loads a api or json url or endpoint using jquery and console logs the result Tested working on my test json file, check the console and it should be there. 

4:36 am, October 26, 2021
php
sqlite fetchArray into another array

was having an issue when trying to return a multi array using sqlite over multiple rows. Stack Overflow Inspiration  I tried a few of these but it was not incrementing key, and also it was only..

2:55 am, October 25, 2021
php functions
php post data back to a url with a function

this function uses curl to post back data to a url, this acts like a _POST form request from within a function. Function usage: $url the url to post the data back to e.g: $url = "https://kruxor.co..

3:11 am, October 24, 2021
php functions
generate random username function in php

a function that takes several random words and creates a user name from them. This will generate a user name with between one to three words and a prefix if prefix_show is set to true. usage generat..

5:04 am, October 23, 2021
jquery
validate email address from string with jquery working function

Here is a working example of this post validate email address from string. This has very basic checking of an email address by checking that the string has an @ and a . in it. Note: this is still no..

12:31 am, October 22, 2021
react
Using props with Stateless Functional Components in React

Here is an example of a Stateless Functional Component but i cant get the PropTypes working correctly in my demo, not sure what im doing wrong here, but the code seems to work in the compiler just not..

5:30 am, October 19, 2021
react
How to Access Props Using this.props in React

If you would like to access a class component prop within its self you can do this using the this keyword.

5:15 am, October 19, 2021
react
How to Use PropTypes to Define Props in React

React allows you to define the types of props given to your components to make sure that invalid data is not sent as the prop to the element.  To do this you can define propTypes. You can defin..

4:40 am, October 19, 2021
javascript
log the console log output to a div

I do a lot of console logging so i thought it would be nice to be able to see this on my test pages. Apparently you can grab this quite easily with the following code.  I had to modify this a b..

4:03 am, October 19, 2021
javascript
javascript basic test array and loop

Here is just a basic test array and a loop to show a basic loop through the test array.  With the loop i use the length of the array as the max variable, so the loop stops when it hits the array..

3:05 am, October 19, 2021
react
How to use default props in React

If you dont want to specify props every time you use an element, you can also specify defaults for these items. This can also be useful to remember which props are needed per component. This can be a..

2:24 am, October 19, 2021
javascript
how to join an array in javascript using the join method

This example shows how we can join an array into a string using the join method. Its a nice quick way to convert your array into a string with a delimiter such as , or ; Here we can see the test arr..

2:01 am, October 19, 2021
php
replace singular variable assignment with an array loop and variable variables

I found this useful when passing in an array to a function, rather than assigning all the variables in the function manually from the array just loop through each item in the array and asign them that..

11:58 pm, October 17, 2021
site bugs
category listing not working on categories with spaces [not fixed]

for some reason the site bugs category and potentially other categories that have spaces in their names are not listing properly. Test URL: https://kruxor.com/category/code/site+bugs/  Probab..

2:52 am, October 16, 2021
javascript
show the current date in javascript

Returns the current date and time and sets the value in a div.  Also added a demo with setinterval to update the time and date in the div every second. 

2:17 am, October 16, 2021
react
How to Pass Props to a Stateless Functional Component in React

Props are like properties that you can pass into a component in react. A prop would be something like this in your component.  JSX <div>  <MyProp id="1234" /></div> The..

12:24 am, October 16, 2021
javascript
get element by id with javascript

gets an element using its id using javascript

5:21 am, October 15, 2021
foundation
foundation three boxes with text align links to the bottom of element

For some reason i had the request to align the links in three boxes with different height text, not sure why they wanted them aligned, but i guess my task is not too question that but to fix it. ..

11:51 pm, October 14, 2021
react
How to Compose React Components in React

In this code we nest the components NonCitrus and Citrus into the Fruits Component. Then nest the Fruits within the TypesOfFood component.  Also added the additional components, Vegetables, Non..

11:29 pm, October 14, 2021
react
How to Use React to Render Nested Components

It can be useful to take components and render them inside other components while still making them into seperate items. This shows how you can take each component and nest it within another one and ..

3:10 am, October 14, 2021
react
How to Create a Component with Composition in React

This shows how you can compose multiple React components together. In this example we return the parent component which has within it the child component, you can add as many child components as requ..

2:56 am, October 14, 2021
css
using css counter-increment to add numbering to elements

i just found this element in css where you can add numbering to elements, very handy to add counters and things.  This uses the counter-increment: section; in the main element and then adds the ..

12:17 am, October 14, 2021
templates
foundation base html template - foundation template

just a basic html template with foundation and the required javascripts, good for a starter html page using foundation framework.

4:17 am, October 12, 2021
react
What is a Stateless Functional Component in React

What is a Stateless Functional Component? A stateless component is one that can recive data and render it, but it does not manage the provided data or track changes to it.  This method creates ..

12:24 am, October 12, 2021
react
How do Self-Closing JSX Tags Work?

So in JSX all the tags must be closed, other wise it can break the element. for example: <div> must have a closing </div> and also for elements like <br> and <hr> must include..

12:10 am, October 12, 2021
react
How to Render HTML Elements to the DOM with React

Once you have a JSX element defined you can write it to the page with ReactDOM.render(componentToRender, targetNode),  In this example we are targeting the div with the id challenge-node. JSX ..

11:43 pm, October 11, 2021
react
Create a Complex JSX Element

JSX must return a single element, so you must wrap your items in a div element you cant just return a bunch of p tags.  Define a new constant JSX that renders a div which con..

11:28 pm, October 11, 2021
react
Create a Simple JSX Element

The current code uses JSX to assign a div element to the constant JSX. Replace the div with an h1 element and add the text Hello JSX! inside it.

11:19 pm, October 11, 2021
react
adding react with JSX using babel

just wanted to see how JSX would work with react and babel, so this way you can write JSX and babel compiles it for use with react.  This is apparently not a good way to do things and can be qui..

9:18 am, October 11, 2021
react
adding react to a website in 3 steps

i was just researching how to add react to a website, and i thought i would need babel to translate or compile the JSX code, but apparently you do not need this...  So ill test this here and see..

8:49 am, October 11, 2021
react
using babel for react compiling in browser

this is currently just an idea, as i saw that codepen uses babel to run react i was wondering i can do the same thing here and then just write normal react script and have babel compile it.  so ..

8:41 am, October 11, 2021
react
react hello world with time and date updating

here is a react hello world with the date and time updating on setInterval 1000 miliseconds.  Again with react it has to be compiled from JSX for it to work, so i have included the original and ..

4:12 am, October 11, 2021
react
react hello world with variable name

i was just testing some of the hello world examples on the react site, and as they use JSX they cant be directly entered into your code, so you need to run a pre compiler (not sure of the exact term f..

4:00 am, October 11, 2021
templates
bootstrap alert template

here is a templated bootstrap alert where you can switch the alert type with the @alert_type variable. Here are the different alerts: primary secondary success danger warning info light dar..

12:53 am, October 8, 2021
templates
bootstrap list group card with footer

a list group within a card and also a footer on the card for additional links. 

12:13 am, October 8, 2021
templates
list group bootstrap template

this generates a bootstrap list group basic template layout, nice option for lists with links in them rather than using a ul li style list, this makes them into neater looking elements so rather than ..

11:43 pm, October 7, 2021
templates
list group card item template

this is a list group item for usage with the template list group or list group card template.

11:40 pm, October 7, 2021
php
php html template class system

just a simple php templating system to extract your html files from within the php code into external files, makes things (or your code) a bit neater.

11:31 pm, October 7, 2021
templates
list group card template

list group card template for usage with the php template class

11:29 pm, October 7, 2021
php
views list function for checking what views have been made on the current week

this is related to the views class that i added with monthly week number and yearly views, this is the function that i use to extract the top viewed pages for the week num, month num and year num. I ..

8:54 am, October 7, 2021
php
load array load all items from an array while in a sqlite load sql loop

i find this useful when loading a bunch of items in a class while looping through data, rather than assigning variables manually i just add the array of item names into the class to begin with and the..

8:36 am, October 7, 2021
ideas
Idea: Google Font Dropdown Selector Code

just an idea at the moment, a dropdown list of google fonts and when selected it loads that selected font using the @import css tag.  Loading the fonts Gist : not tested https://gist.github.com..

8:55 am, October 6, 2021
html
twitter social sharing meta tags

I had done this one so many times on client sites I actually forgot that i had not applied it to my own site! Doh! Anyway this is the tag setup i use for adding the title, url, author and featured im..

11:51 am, October 5, 2021
sections
responsive three box section with tabular data or table data

here is a section in foundation with 3 hero boxes with images on top, and then a title and some tabular (is that the same as table?) data in each box, so could be good for some kinda products and then..

5:50 am, October 1, 2021
sections
stackable bio or biography list with portrait image title and text

a nice easily stackable bio or biography list done in foundation, just duplicate the bio-item and switch out the content and you have a nice responsive bio layout.  As its in foundation here is ..

1:13 am, October 1, 2021
wordpress
using wp_nav_menu to show a custom menu in wordpress

found this quick code snippit here, its not working just for reference of what the array items do.  Here is how you would display the menu called "Projects" PHP         $..

4:28 am, September 29, 2021
images
document placeholder for a4 in portrait

a nice document placeholder image with dropshadow and transparency

2:19 am, September 29, 2021
images
landscape image document placeholder

A nice landscape image of a blank presentation format, in landscape mode with drop shadow.

2:10 am, September 29, 2021
wordpress
link to a custom style sheet in your theme directory wordpress

this is how you can include a manual link in your wordpress header file with a link to a stylesheet called theme.css then if you change theme names or something it will still link correctly, rather t..

2:35 am, September 28, 2021
wordpress
wordpress add a template file to your theme

this is the basic layout of adding a wordpress template php file to your wordpress theme. good for custom theme pages This is a really basic template with just the header, but once added wordpress w..

1:13 am, September 28, 2021
svg
down chevron and styles

a down chevron and the class to style it, default this is 16x16px but you can zoom it in or out easily, just change the height and width of it target with the class bi-chevron-down

2:43 am, September 24, 2021
php
How to record your own page views with PHP, and make them into weekly monthly and yearly charts

Building a better Simple Page View Counter Currently this site has a very basic view counter on it.  Here is how it currently works. Load the page, function checks if the page has a existing r..

2:01 am, September 23, 2021
css
using a radial gradient for background overlay

usually i just use linear gradients for my background elements but i noticed this one the other day, a radial gradient. you can actually specify multiple colours and also opacity levels to overlay a ..

3:51 am, September 22, 2021
css
change selected color on input elements css

this can be useful if you are using darker form elements and they happen to have white on white text, so you can target the :focus on the input. here is the text input before the colour change, the c..

2:47 am, September 22, 2021
javascript
video not auto playing issue in chrome and brave

i had this error the other day when i was adding an auto play video to a page. the error was: Javascript Uncaught (in promise) DOMException: play() failed because the user didn't interact with the ..

2:34 am, September 20, 2021
javascript
change the box-shadow of an element with javascript boxShadow

changes the box shadow of test_div using the javascript object(?) boxShadow

4:39 am, September 18, 2021
javascript
change the background color of an element with javascript

gets the element by its id and changes the background color style css value the following example: gets the element by its id "my_bg" changes the style.backgroundColor to #123456

4:03 am, September 18, 2021
javascript
adding a new line in javascript

i was writing a function where i needed to for ease of readability add a new line to the code, you can do this with the \n for the new line and then if you need the string to go to the next line then ..

6:53 am, September 17, 2021
javascript
change padding of element with javascript

change the padding of an element with javascript only

1:27 pm, September 15, 2021
javascript
get the value from a range input field with javascript

this script will retrieve the current value from a range slider html input if you want the value to only update when the slider interaction has been stopped change the oninput to onchange then it w..

12:39 pm, September 15, 2021
php
get the current week as a number with php

retrieves the current week as a number from 1 to 52.

9:57 am, September 14, 2021
javascript
twitter json feed testing

just testing using the Twitter Post Fetcher script, seems to be working well.

9:33 am, September 10, 2021
site documentation
function to load one latest item with a start val load_latest_single_num

This is the same as load oldest item based on insdate then update the insdate to now - load_latest_single_update but it allows you to add a start number to the range, so allows you to access the 2nd, ..

4:06 am, September 2, 2021
site documentation
make the view number zoom when mouse over or active

Lets make the view number in the header widget area a bit more exciting... Zoom on mouse over with css.  Lets add this effect here: Using Transform Scale In Css To Zoom On Hover Over Simpl..

1:24 am, September 2, 2021
php
creating embedded php code from a database field

i actually dont know why i didnt think of doing this earlier, i already have the php code field in these code articles. I thought why not embed this code into an actual file and then run it as a test..

4:23 am, August 26, 2021
php
check if a file exists with php

checks if a file exists in php returns true of false

9:33 am, August 23, 2021
php
create directory with php create folder with php

i thought i had already done this somewhere but i guess i didnt. Anyway here is how you can create a directory with PHP. PHP mkdir("directory_name") yep its that easy just make sure you are in the..

6:48 am, August 23, 2021
jquery
simulate a click on an element with jquery

you can actually use jquery to simulate a click event using the following .click() so as soon as the document is ready and you have jquery loaded it will run the click event for you, and should pop ..

3:41 am, August 23, 2021
css
how to bundle css files together using windows or mac

so i was wondering how to do this the other day using some modern end tools, and i found this way just do it straight from mac or windows.  lets say i have these css files main.css style.css..

9:52 am, August 16, 2021
javascript
center mode slick zoom testing

update : this is a tricky one to get working! I have done a lot of testing on this one, and got a demo working from a combination of the following links. the demo is still not 100% styled, but its..

5:17 am, August 10, 2021
css
button with separated chevron

I have come across this kind of button format a few times now in various designs and the html and css for it is a bit different to normal button formats I have found.  Chevron Detached Button Ex..

5:48 am, August 9, 2021
site bugs
still more comment spam

this is getting annoying now. so much spam. i already have the google recapture, but spam is still getting through. who runs this stuff, bots i guess. annoying.  update: 10 August 2021 Still..

6:16 am, August 6, 2021
php
split a string into links using the comma

this is a common function for some field data, lets say you have a string like this. category one, category two, another category in one field or string but i want it to display like this category ..

5:48 am, August 6, 2021
foundation
add some foundation tabs working example

they show the tabs here on the example page, but there is no full working code... for some reason. So i thought i would add one here. Hmm foundation makes this site look weird, and very bright! :P ..

5:01 am, August 3, 2021
css
vertically align text within a fixed height div using flex

this can be used to make text align nicely while still keeping the same layout. the example below shows how you can set the height of the containing element and still have the text aligned center to ..

9:55 am, July 29, 2021
css
how to view a web page in its printer format

if you have to check a website in its print or @media print format this is how you can emulate it in browser if you are using chrome or edge.  Open the Dev Tools (usually F12) Click the menu ..

6:26 am, July 28, 2021
css
white space break word css

controlling the white space of an element with break word, this can be handy if you need to fit something into a fix but the item has no spaces, otherwise usually by default this will overflow out of ..

5:36 am, July 27, 2021
javascript
old browser check with javascript

modified from this script i console logged all the items available so you can do what you need with them these are the avilable variables Javascript console.log(browser.agent);console.log(browser...

2:56 am, July 26, 2021
css
roboto and poppins fonts include quick code

css import for poppins and roboto google fonts with the common font weights

12:10 am, July 23, 2021
html
set the amount of lines to show in a textarea field

using the rows will allow you to add the specified amount of rows to the textarea you can also specify the cols which does the amount of characters width  

1:01 am, July 16, 2021
site bugs
weird search results being recorded

i noticed some weird search results being recorded like this: the search function should only be recording a result if it finds a result, so this should not be added unless it can actually find thi..

4:04 am, July 10, 2021
foundation
foundation grid for 6.6x - also known as the foundation xy grid

some foundation grid demos for 6.6x foundation you can get foundation here: https://get.foundation/ or here https://cdnjs.com/libraries/foundation  more docs on this here: https://get.foundatio..

5:00 am, July 9, 2021
jquery
append a #link to the end of all href urls on a target

good for if you need to append target links with a # link

1:07 am, July 9, 2021
php
get last month as a number with php

this will get last month and last month as a text month e.g: 06 and June

12:58 pm, July 5, 2021
css
hide the third row in a table with css

just wondered how hard it is to hide the third column in a table with css, rather than deleting it in the html here is the test table cell 1a cell 2a cell 3a cell 4a cell 5a cell 1b ..

5:15 am, June 30, 2021
css
how to make a transparent logo white with css

lets say you have a logo and its dark on a black background, how annoying is that, you still want the dark background but also want to see the logo.  well with this css trick you can just make t..

3:07 am, June 29, 2021
php
verify the google recapture server php

i was still getting quite a bit of spam even after using google recapture v2 and i think this is just as i was using the javascript only version, which disables the submit button if the capture is not..

12:45 am, June 25, 2021
jquery
scroll down the page using a button click

scrolling down 600px from where you currently are on the screen demo vid

12:25 am, June 23, 2021
javascript
using clamp js to clamp lines of text

there is a css version of this as well but this version works in a greater range of browsers (i think) this one is not working for me... i think the overflow elipsis is still a better option than thi..

11:17 pm, June 22, 2021
site bugs
this is a weird one table underline appearing and dissapearing on mouse over

very strange that also reminds me that i have to get rid of these random searches idea: i was thinking of adding a more detailed hit system where it can record the month and also the year of the..

12:52 pm, June 21, 2021
jquery
check if a ul contains a ul li

i could not find a way to do this with just raw css so i had to use jquery /sad

4:25 am, June 21, 2021
css
target last item css with :last-of-type

the :last-of-type selector allows you to select the last item of that type in the target container. in the following example i can target the last <p> tag and make the text bold and red.

4:22 am, June 21, 2021
css
target first item css with :first-of-type

the :first-of-type selector allows you to select the 1st item of that type in the target container. in the following example i can target the 1st <p> tag and make the text bold.

3:48 am, June 21, 2021
site documentation
for auto filled fields, need to change the text and background colours

for some reason bootstrap or the browser is doing this to auto filled fields.  according to my searching there is a pseudo class added to auto filled fields CSS input:-webkit-autofill { col..

12:11 am, June 17, 2021
site documentation
use a list group for listing by category page [todo]

change this to a list group, should make it neater. Page to update: https://kruxor.com/list-category/code/  so for some reason this is listed using this function PHP $list_wiki_menu = $clas..

12:02 am, June 17, 2021
jquery
jquery check if a sub element exists

this can be done with .length

4:22 am, June 15, 2021
javascript
ajax callback to delete with sweet alert confirmation to make it cool! 😎

I recently wanted to to an ajax call back on a list of items just to make it easier to move around the place, rather than it reloading the page every time. So i thought why not also use sweet alert on..

4:29 am, June 11, 2021
site documentation
hero widget header - creates a nice looking hero item from a target uid and class

this creates a "nice" looking hero widget, just wanted to create something that looked decent and had an attached background image, surprizingly annoying to link items together. For some reason i kee..

12:10 am, June 11, 2021
javascript
show the browsers name in javascript

This function will show you an alert box with the name of your browser, however im using brave at the moment and it shows as Netscape, so i guess you cant trust the result.  Also i just discover..

3:49 am, June 4, 2021
php
counting the occurrence of words in a multidimensional array

array sorting example The array Array ( [0] => Array ( [0] => Some [1] => great-looking [2] => special [3] => editio..

4:19 am, June 3, 2021
css
target 1st td in a table with css

this css will allow you to target the 1st td in a table

4:06 am, June 2, 2021
php
write string contents to a file with php

this will create a file called my_file_name.txt in the current php working directory usually this is the same one that the script is running in and write the text yay! into that file if the file al..

12:48 pm, May 26, 2021
css
backdrop-filter: blur(10px);

just testing this filter

11:34 pm, May 25, 2021
javascript
json test objects (or arrays)

here is a couple of test objects in external js files just in case you need to test some ajax loading functions or need external objects, i mostly use them in my testing. Basic JSON Object with 3 ite..

12:22 pm, May 25, 2021
javascript
loop through a complex object json javascript

just a note to say that a complex object is an object with more than one nested object in it for example just kinda playing around with this one to get the handle on objects and how to access them C..

12:19 pm, May 25, 2021
javascript
load json with vanilla javascript no jquery

this basically does the same thing that a jquery .getJSON does but without the need for jquery.

9:57 am, May 25, 2021
jquery
json load from jquery and loop through the results

this is the same as this post but i have added the object to an external test file. so rather than already having the object data on the page we have to load it somehow Note: you can test that the o..

6:48 am, May 25, 2021
php
show all methods (functions) in a class

this will show all available methods or functions within a class, once they are in a class they are called methods for some reason. print functions, show all functions, methods in a class, show met..

4:07 am, May 13, 2021
php
adding an item to an array with php

how to add items to an array in php here is a working sandbox version of this code: sandbox. 

3:10 am, May 13, 2021
css
allow a title to be in the foreground while still having a before overlay for the background

i came across this issue recently, where a title was within an element and it needed to have a background overlay while still allowing the title to be on top of the overlay.  I found the fix was..

2:03 am, May 11, 2021
php
passing in arrays to your functions rather than using variables

this is probably an old technique, but i discovered it the other day when i was playing around, and i thought wow i should do this to all my functions, i cant see the downside, apart from having to re..

1:11 am, May 11, 2021
css
css responsive max and min targets @media

showing how you can target elements within a max and min screen width demo:

1:39 am, May 7, 2021
php
Remove background image php with image magic

untested research on removing background and making it transparent with php

12:12 am, May 3, 2021
javascript
check if a checkbox is checked with javascript

checks if the box is checked and returns true or false reusable function that can check if a checkbox is checked or not just pass it the id of the checkbox Javascript Usage check_my_box('check1');

6:06 am, April 30, 2021
javascript
form submit override with javascript

if you need to run some additional checks on a form before submitting it

5:48 am, April 30, 2021
javascript
submit a form with javascript onclick

submit a form with javascript, good if you want to submit a form with a button that is not within that form. the form will require an id

1:05 am, April 26, 2021
php
get current url with php

this checks is $_SERVER['HTTPS'] is set and $_SERVER['HTTP_HOST'] $_SERVER['REQUEST_URI'] to construct the current url

11:54 am, April 21, 2021
javascript
Slick Slider Carousel with Fade Transition

here is a working example of slick carousel with a fade transition between elements rather than a slide transition

5:01 am, April 21, 2021
php
list a functions variables or arguments

i think this has to be used within the function to get its arguments, i have not tested this one yet.

12:12 am, April 21, 2021
php
add a toast alert when logging in with half moon

example of adding a document dom ready wait and then the script that launches a new toast message just adapting a php cms using halfmoon as the ui, its quite nice.  a bit bright in non dark mod..

6:19 am, April 7, 2021
html
a page with two images

a page with two images for testing

7:03 am, April 4, 2021
python
python url to text with beautiful soup

python using beautiful soup to convert a url into text Python from bs4 import BeautifulSoupfrom urllib.request import urlopenurl = "https://kruxor.com"page = urlopen(url)html = page.read().decode("u..

2:08 am, April 4, 2021
python
python import and print url

here is an example script that imports html from a url and prints it add it to a .py file and then run it with python3 filename.py Python from urllib.request import urlopenurl = "http://olympus.rea..

1:11 am, April 4, 2021
php
php basic page router

this php page router while pretty basic does the job for this site. it takes all the query string and splits it with the / into $p variables you will also need the following nginx or similar page rew..

12:29 am, April 4, 2021
css
css double page document preview with shadow

two div elements that look like blank documents with drop shadows

11:55 pm, March 30, 2021
css
background image greyscale filter while foreground is still in colour

i had an issue the other day using a css filter which was causing all items within the element to also have that filter. using the ::before psudo class solves this issue

4:58 am, March 26, 2021
javascript
javascript page redirect

this one i cant add a working demo for, due to its nature, but it is working if you remove the comment. combine this with this: https://kruxor.com/view/code/wQUDM/do-something-later-with-settimeout-..

3:18 am, March 26, 2021
css
zoom background of element when active

I just wanted to see if something like this zoom was possible but just using the background image and leaving the foreground content in the element with no zoom.  https://kruxor.com/view/code/kM..

4:53 am, March 19, 2021
css
rounded click me button with icon

just a rounded button with a font awesome icon

3:28 am, March 19, 2021
linux
Creating a chart about charts.css with charts.css from the command line

Creating a chart about charts.css with charts.css from the command line: BASH (      echo "<table class='charts-css bar show-labels show-heading'>"      echo "&l..

8:33 am, March 18, 2021
javascript
add years as options to select dropdown

add the years as dropdown items between a range of years with javascript document ready js only version

11:35 pm, March 16, 2021
jquery
json jquery ajax request

get json data with jquery using getJSON

3:34 am, March 15, 2021
css
logo tickers marquee slow scrolling

logo tickers with a slide animation

12:07 am, March 14, 2021
linux
linux mount a drive manually

this is how you can mount a drive in linux first list the drives available with:  BASH sudo lsblk -o UUID,NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,MODEL or this BASH sudo blkid ok once we have th..

4:24 am, March 12, 2021
jquery
add click event to multiple link items and load the link content into a target div ajax

this will get a group of links with existing href targets and load them dynamically with an ajax callback you will need to also include the full jquery script as the slim one does not include the aja..

3:51 am, March 9, 2021
jquery
add click event to multiple link items

this allows you to get every a element in a-div class and stop the link from loading, so you can do other things with it like run a function or something else Functions used: Javascript Wait for th..

3:24 am, March 9, 2021
css
inline form field padding

I noticed this when doing this demo (get the value of an input form element).  Looks like inline form elements look pretty average when a button is added to the same line. i think this should..

12:21 am, March 8, 2021
javascript
get the value of an input form element (input value)

add how to get the value of an input form element with javascript for some reason i can get this working with: Javascript console.log(document.getElementById("my_input").value); but when trying to..

11:56 pm, March 7, 2021
javascript
check if a certain query string is set then apply it to all url's on the page

this script will check if a query string is already set, and if it matches it will append the same query string to all url's on the page Here is the test link with the field, and all url's on this pa..

8:22 am, March 1, 2021
javascript
check if a query string item is set in the current url

this will check and console log if a query string on this page is set to test=anything example url is:  Test is not set: https://kruxor.com/view/code/XzLaT/  Test is set using & : htt..

5:49 am, March 1, 2021
css
adding background blur to an image using css fill screen

I had noticed this cool looking effect used on places like google, and other sites that display portrait images, i think i saw it on the google home as well or maybe google photos.  Its basicall..

5:23 am, February 19, 2021
css
using the nth-of-type selector to target a class with the same name

using the nth-of-type css selector you can target a class with the same name, using a number. I guess this can make your code a bit neater not having to add a sub class

2:44 am, February 19, 2021
linux
how to check the temperature of the pi using command line

to get the temperature of the pi in shell or command line type the following: BASH vcgencmd measure_temp This measures the GPU temperature. Which should generate something like this: To get the..

11:39 pm, February 17, 2021
linux
how to find what version pi you are using

So i was wondering the other day how to show what raberry pi i had, rather than opening it up. you can install lshw and it can list all your hardware Install it with BASH uname -r which should gi..

2:19 am, February 17, 2021
jquery
Uncaught TypeError: $(...).slideToggle is not a function

Uncaught TypeError: $(...).slideToggle is not a function at toggle ((index):226) at HTMLAnchorElement.onclick ((index):239) I noticed this one today when looking up this post:https://kruxor.com/view/..

12:11 am, February 17, 2021
php
checking for spam comments function

with this function, you can scan through your incoming comments and check them for keywords the function will scan through the comment text and then provide you with a score as you get more spam com..

5:27 am, February 10, 2021
css
animated rings expanding with delay ripple water effects

just testing this one

5:00 am, February 10, 2021
linux
change file permissions to -rw-rw-r--

When adding a new php template file, it adds it under the www-data user with the file permissions set to -rw-r--r-- so its not remotely editable. Use chmod 664 to change it to -rw-rw-r-- chmod 664 ca..

8:39 am, February 6, 2021
javascript
Adding HTML Templates into TinyMCE Editor

This can be very useful if you are using the tinymce editor on your site and want to be able to add simple or complex html templates. Here is how to do it: Add this to your tinymce init Javascrip..

12:14 am, February 5, 2021
javascript
How to set a cookie and expire it in 30 days

Here is some basic usage for the js cookie library. Include the following script. Or you can grab the latest version at the cdnjs website. HTML <script src="https://cdnjs.cloudflare.com/ajax/lib..

9:51 am, February 2, 2021
linux
Enabling SSH on Ubuntu

To enable SSH connection via putty or another terminal app on ubuntu, do the following. Open a terminal with Ctrl+Alt+T sudo apt update sudo apt install openssh-server Check if its runningsudo syst..

5:16 am, January 24, 2021
css
using multiple text shadow

sometimes you want to use more than one text shadow, like if you want one with 2px on the bottom left and then one with 2px on the top right, so you can get a full outline or a more even shadow on you..

3:37 am, January 22, 2021
css
box shadow example(s) - drop shadow

I realised just now, that i dont have a box shadow example! How does that happen, its one of those css elements that i just use so much that i guess i forgot about it.  Related Pages: https:/..

2:27 am, January 22, 2021
javascript
darkmode toggle switch with local storage to remember the last selection

Here is a darkmode toggle switch, that swaps out the body class so you can target dark-mode or light-mode on all your elements! It saves to local storage the last selection so if you come back to the..

8:49 am, January 21, 2021
site bugs
add a youtube video preloader function, lazy load youtube [fixed]

I noticed that this list page: https://kruxor.com/list/rs3_efficient_skill/ Loads about 29 (well exactly 29) youtube video embeds and was wondering if there was an easy way to replace these iframes w..

2:58 am, January 21, 2021
css
@import and html link to Montserrat font family google font

includes the Montserrat font family as @import in your css or add as a link in html with preconnect. also has basic usage as the .montserrat class.

11:58 pm, January 19, 2021
site bugs
add a comment recording system for posts [idea]

add a custom comment system for code and posts with google recapcha

3:02 am, January 14, 2021
site bugs
fix view page for search links [reported]

its still showing raw data on these view pages e.g https://kruxor.com/view/search_links/KJYU0/mt-maunganui/  Looks like that example is already out of date, here is a new one: https://kruxor..

3:00 am, January 14, 2021
site bugs
linking search results to view pages [finished] 🤣

I was thinking it might be useful to link the search term to the page, so that it can be found more easily using that search. For example, Link this search text (somehow) to the post page and display..

2:44 am, January 12, 2021
javascript
set maxHeight of element by id with javascript

sets the max height value of an element with javascript demo pending

3:59 am, January 1, 2021
site bugs
top bar overflow issues [fixed]

So i was just browsing throught the site checking for random errors, which there are quite a lot. And noticed this one. Quite a large bug caused by overflow issues in the main header, i think this ..

2:36 am, January 1, 2021
css
make labels or badges look better

How to make these look better. The labels are used in the list items to show a small version of the category or sometimes the view count for a list item. How they look currently Dark Mode Ligh..

6:09 am, December 31, 2020
php
include tinymce only if a user is logged into the site

For google page speed i had an issue when every page was loading tinymce, which is quite a large script. I only actually use this script when editing pages, so this is the change i made to only inser..

5:44 am, December 23, 2020
html
test page for the custom css 12 grid used on this site

This is my testing page for the grid used on this site, it shows elements and other things for use on the grid and other general formatting.

5:38 am, December 23, 2020
css
make an image white with css using filter brightness and invert

If you have an icon or something with transparency this can be useful if you dont want to have to edit the image and create another copy of it you can apply the filter brightness and invert. You can ..

5:16 am, December 22, 2020
jquery
add a jquery date picker to your text box

This JQuery UI Date picker is good if you want to add a nice dropdown date selector to your input box, rather than having to type in the date manually. Requires: JQuery  JQuery UI Documen..

12:56 am, December 22, 2020
css
background image on 3 boxes not scaling correctly fix

So i had this weird task the other day, where there was three boxes with a background image set. When the screen changed size the image would go out of wack. The fix?  Pixels rather than Perce..

1:43 am, December 11, 2020
framework
CSS Grid Frame Work

8 Dec 2020 Yes i dont have an cool names for it, I just wanted something fairly light that can replace the bootstrap and foundation grid and basic components that i use so often, some of these framew..

10:56 pm, December 7, 2020
javascript
bootstrap
bootstrap toggle element collapse

the example code for toggling elements, show and hide

1:34 am, December 4, 2020
svg
download icon svg

a simple download icon in svg format, also added button example usage so you can use the svg within the button as an icon and change the fill colour on mouse over, plus it scales nicely on mobile devi..

10:28 pm, December 3, 2020
wordpress
add paging to wp list query

this is a raw template with list query for specific category names and also includes paging, if the post number is greater than 8 posts in the included categories. 

11:37 pm, December 1, 2020
jquery
using jquery appear for checking if an element is visible on screen

Yes.. sometimes i like using jquery as well, as it can make things so easy! :) Here is a quick demo using the JQuery Appear plugin so make an element change if it on or off screen.  Plugin Link..

12:24 am, December 1, 2020
javascript
Monitoring Visible Objects on Screen

i found this one when researching how to detect visible objects on screen, and then doing something with them. This one does not use any external scripts to change the box colour as it becomes visible..

12:07 am, December 1, 2020
css
using attr in css to get content from html

im not sure (yet) how this would be useful, but it shows that you can get title attribute content from a div with css

1:11 am, November 30, 2020
javascript
how to install js socials for social media share buttons and make them rounded

This should be a nice quick one on how to install js socials which add social media sharing buttons on your pages.  Yeah i always just ignore these as well, but hey some people may use them?? H..

5:42 am, November 23, 2020
css
css perspective and transform css properties testing

i wanted to see what i could do using the perspective and transform css properties. i dont really get how the perspective one works, but you can tweak it so it doesent look too weird.  with the ..

2:51 am, November 23, 2020
bootstrap
Fix Hover Over color on list group dark mode in bootstrap

How to fix the problem when switching to dark mode, the list group item text disappears when active. Here is what it currently looks like. To fix this we need to target the element and force the..

12:31 am, November 23, 2020
wordpress
list items from blog and filter by category name

this is a bit raw, but shows the $args = array('category_name' => 'Categy Name 1','Categy Name 2','Categy Name 3' => 8, 'paged' => $paged ); for querying the category_name to do multiple pro..

3:03 am, November 18, 2020
php
Quick tool to convert time into decimal

I needed a quick tool that can convert say 20 minutes into decimal, as im doing this a lot these days. Here is what i come up with, well you can google it as well and that works, but this form is a bi..

12:55 am, November 16, 2020
design elements
hero box with title sub title logos and call to action buttons

Here is a basic hero box section that contains: Title Sub Title 6 Logos (could replace with carousel logos) 2 call to action buttons I think it can be made more responsive, by replacing the..

2:43 am, November 9, 2020
css
using linear gradient background on text css

If you want to have a background gradient on your foreground text you can use this css.  I think currently this only works on webkit enabled browsers, but it looks pretty cool.

12:02 am, October 26, 2020
css
drop shadow text class easy drop shadow

makes it a bit easier to read light text on a dark background or vice versa

12:33 am, September 28, 2020
css
center everything in a div with flex-center (centre)

i usually add this to my base css styles, as a way to easily center something in the middle of an element.  then you just add this flex-center class and everything will be horizontally and verti..

12:07 am, September 28, 2020
php
generating all css colours with php?

I was looking at doing this just to generate all css colours, i think the only issue is there is a lot! You can do this with rgb(0,0,0) all the way up to rgb(255,255,255) how many seperate colours is..

12:13 am, September 25, 2020
javascript
country select javascript check which option is selected

this is an example of how you can get the selected country value with javascript from a html countries dropdown

1:54 am, September 22, 2020
js
fix for Uncaught (in promise) Error: reCAPTCHA placeholder element must be empty

This is usually caused by something being inside the element used to render the reCAPTCHA. In this case tinymce was adding a &nbsp; or a <p> tag to the element Removed the space and this f..

5:43 am, September 18, 2020
windows
search a zip file with windows command prompt and 7zip

if you ever need to search for a file in a zip file this is how to do it (in windows). Also you will need to install 7zip Open a command prompt CTRL+R and type cmd cd C:\Program Files\7-Zip 7z l c..

1:09 pm, September 8, 2020
bootstrap
extracting the useful bits of bootstrap

Back in the early instances of bootstrap they used to provide a build system for the individual components. It seems that these days its all or nothing, or use some kind of build tool to include the b..

5:14 am, August 31, 2020
linux
renew all SSL certificates with certbot

just issue the following command in bash

6:45 am, August 26, 2020
js
enable tinymce on a target textarea by id

this is useful if you have multiple textareas on a page and want to enable tinymce on, also included are buttons to enable and disable on all textareas on the page

12:15 am, August 19, 2020
bootstrap
Bootstrap Darkmode Switch

I have tried this before without success but i googled "Bootstrap Darkmode Switch" and found this repo at the top of the list. So i thought i would give it a try on here and see how it looks. Demo pag..

11:54 pm, August 18, 2020
javascript
stop tinymce replacing urls with relative url's

If you have been using tiny mce for your content editing, you will sometimes find that it replaces your full url strings with its relative ones. This can be annoying so this is how you can disable it..

12:55 am, August 18, 2020
core
What is Core?

17 Aug 20 core is php content management system where the content is editable from the front end of the site, so there is no real back end to this system. i designed it to be easily extended so every..

6:52 am, August 17, 2020
sql
Create a UTF8 General MySQL Database with Command

This will create a UTF8 database with the character encoding utf8_general_ci replacing the with your database name. I was manually doing this in adminer before this and selecting the encoding, this i..

4:05 am, August 13, 2020
jquery
fix for Uncaught TypeError: e.indexOf is not a function

fix for depreciated window load Uncaught TypeError: e.indexOf is not a function at S.fn.init.S.fn.load (jquery-3.5.1.min.js:2) at default.aspx:993 I found this error when upgrading from a..

12:20 am, August 3, 2020
css
switching stack order of floats with flex

responsive stacking, changing the order of how they stack. so by default they should stack in order they are listed in, like if the pink box is 1st then it should stack on top of the blue box when it ..

11:55 pm, July 28, 2020
php
change string to capital words ucwords

This will change an upper case or lower case, or mixed case string to uc words. Example with this page title

6:08 am, July 21, 2020
html
scroll to top html css and js

add a button to your website that allows scrolling to the top of the page css add scroll behavior smooth to your html, to allow the page to scroll nicely rather than just jumping to the top, in supp..

1:13 am, July 21, 2020
php
convert a string to uppercase with php

use this function to convert a lower case or sentence case string into its uppercase form

12:31 am, July 14, 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
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
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
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
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
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
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
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
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
javascript
ES6 Nested Object Example

extracting variables from a nested object with new variable names

1:09 am, February 3, 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
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
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
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
Writing Arrow Functions with Parameters

you can pass parameters to arrow functions as well as shown in the following demo, these functions are only meant to be used once where normal functions can be re-used.

12:36 am, October 1, 2019
javascript
Changing an array declared with const

a const means that you cannot re-declare the variable name, but you can still mutate an array content that is declared as a const. so you can see in the following example that even though the array is..

6:17 am, September 30, 2019
javascript
using let and const example

This example uses let and const rather than just vars, let can only be declaired once rather than overwritten like vars and const is a read only variable so it cant be changed. 

4:55 am, September 27, 2019
javascript
Use the parseInt Function with a Radix

This is the same as the parseint function, but you can also specify a base for the number which can be between 2 - 36. 2 is binary. Zeros and Ones. I think base 10 is the normal numbering system, but ..

6:14 am, September 24, 2019
javascript
Generate Random Whole Numbers within a Range

My testing for generating a random whole number within a range... 🤞 While the solution here works, it just loops until it gets a random number that is lower than the max, so not sure if this is th..

5:15 am, September 24, 2019
css
Custom 12 Grid using CSS Grid

For a while i have been using frameworks for their easy grid systems, like foundation and bootstrap. I guess this is a bit lazy and very bloated as you are loading the full css library and using about..

2:19 am, September 6, 2019
css
Radial Click Effect

shows the radial click effect like in the material design, so when you click a button it will show a click at that area with a nice animation. Uses CSS and javascript to generate this effect.

1:13 am, September 4, 2019
js
Generate Random Whole Numbers with JavaScript Function

generate a random whole number function with test buttons

6:20 am, August 26, 2019
js
Generate Random Fractions with JavaScript

generate a random fraction and add it to result when clicking a button

6:09 am, August 26, 2019
javascript
FCC - Basic: Profile Lookup

my solution to the FCC Basic js Profile Lookup, with added results area and button to run the function. json, array

5:38 am, August 26, 2019
bat
copy a file when the date of the source is newer than the destination

using xcopy and a loop i found this is a good way to make sure that changes in one file make their way across to another location using a windows batch file. this one loops every 5 seconds, i think yo..

3:27 am, August 26, 2019
javascript
for loop through an array with javascript

looping through an array with javascript using a basic for loop

12:18 am, August 23, 2019
javascript
get the dimensions of an image with javascript

this will show the height and width of an image using javascript

5:55 am, August 13, 2019
css
target data attribute with css

you can add a data attribite and target it with css using the following demo

11:52 pm, August 12, 2019
html
toggle div function with chevron up down toggle

showing an example of chevron toggles kinda like a manual accordion

1:19 am, August 9, 2019
css
form checkbox replacement with large tick using label

this is good if you want to change a form checkbox with the default and show a fancy tick or something else, this will still check the checkbox so will work normally as the form element

2:15 am, August 7, 2019
css
keyframe animations css

moving a background with css keyframes

12:27 am, August 6, 2019
javascript
basic for loop odd numbers

a basic for loop with odd numbers adding to an array

6:20 am, July 31, 2019
javascript
Objects in javascript

creating and using an object in javascript, the full version of this testing is on codepen

11:25 pm, July 29, 2019
javascript
using switch with multiple identical cases

this can be used if you have several outcomes where the return value will be the same by omitting the break from the cases before the final

1:32 am, July 29, 2019
javascript
using switch in a function

This shows an example using the switch to select multiple options in a function, you can return from the switch with break, or you can end the whole function with return.

11:19 pm, July 28, 2019
javascript
JS Using typeof to check on string types

you can use the typeof operator to check what kind of variables you have.

2:38 am, July 23, 2019
javascript
defining a variable inside a function without using var will create a global variable

here is an example showing a variable defined within a function showing how it becomes a global variable if not defined with var

5:15 am, July 22, 2019
javascript
add something to the start of an array with unshift

unshift is the opposite of push where push adds to the end of an array unshift will add to the start of the array.

2:40 am, July 19, 2019
javascript
remove the first element in an array with shift

like pop but shift does the 1st element in an array

2:37 am, July 19, 2019
javascript
add a class to a div with an id javascript

a one liner to add a class name to an element with a specific id, for this to run it seems to need a document ready.

1:11 am, July 17, 2019
javascript
remove something from the end of an array with pop

pop is the opposite of push and will remove the last item in an array, it also returns the value so you can assign it to a variable

5:58 am, July 16, 2019
javascript
add something to the end of an array with push

you can easily add to the end of a javascript array with the .push function.

5:49 am, July 16, 2019
html
Bootstrap Card Formatting HTML and CSS - Header and Footer

just a bootstrap card format with header and footer elements, makes a piece of content neat easily

2:38 am, July 10, 2019
css
Move any element with css offsets

Make any element moveable without moving other items around by making it position: relative;

2:31 am, July 9, 2019
css
CSS Improve Compatibility with Browser Fallbacks

when using css variables to increase compatibility you should also include a normal color as a default.

2:04 am, July 9, 2019
php
PHP Finding the position of a string in another string using strpos

$dot_location = strpos($my_string,"."); The first version of this does not seem to work in all cases, so i have updated this with a working version here.

12:00 am, July 9, 2019
jquery
jquery click function

Bind something to a click event on an element using jquery. Needs to be combined with a document ready.

5:33 am, July 3, 2019
css
using a css grid area template

here we can specify areas for the grid. using grid-template-areas. once the areas are defined we can add the items into each area with grid-area: header in each element Use grid-area Without Creatin..

2:26 am, July 3, 2019
css
CSS Grid - Basic Columns

Here is a basic demo showing the usage for css grid columns. You just need to add the display:grid property and then add the grid-template-columns: adding the size of each column, adding a value for e..

5:59 am, July 2, 2019
css
using flexbox to align elements in a row

flexbox is so good at aligning elements, yes i used to use float left and then percentages and overflow auto or hidden the surrounding div, but now with flex you can just do something like this.

1:37 am, July 2, 2019
html
Applied Accessibility - Tab Index

using the tabindex property on elements allows you to press the tab key while on the page and tab through the elements depending on the order specified by the tabindex. tab index can be applied to man..

11:52 pm, July 1, 2019
html
Applied Accessibility - Access Keys

Access keys can be applied to link elements and in chrome you can access them by pressing ALT+ SHIFT + [accesskey] for some reason when testing this in chrome the a key was not accessible, but g and ..

11:40 pm, July 1, 2019
html
Dropdown Box with Searchable Text

Here we have a dropdown select box, that you can type into to search the available options. No Javascript Required for this the browser does all the work. Press into the text box, and you will see a..

11:57 pm, June 30, 2019
jquery
Change link target with JQuery

this will change the link href target to # on document load rather than its original link

12:17 am, June 28, 2019
css
Drop Down Menu Swapping Left align to Right

this is useful if you have a nav that hits the right side of the screen and you want it to open on the left rather than the right side. you can see on the very right drop down item opens with its item..

5:36 am, June 26, 2019
php
create a mysql or sqlite current timestamp with php

just in case you need to create a CURRENT_TIMESTAMP using php, this formats the current date into the following.

5:45 am, May 27, 2019
php
Cut a string when it finds a certain character with PHP

ok so lets say we have a string like this: Hi there im a string. I am also part of the same string. And we want to shorten the above string into just:  Hi there im a string. This is what i wo..

5:30 am, April 17, 2019
php
validate a url using php with FILTER_VALIDATE_URL

checks if a url is valid

11:04 pm, March 28, 2019
php
How Many Days Since a Date and other Calculations

Here i calculate the number of days since a certain date in php and use the values for checking how much something costs per day.  Start Date Lets add the date that the item was purchaced. In d..

12:27 am, February 11, 2019
css
Using Flexbox rather than Floats

So i was still using float left for a bunch of elements i was working on the other day, sometimes it's hard to drop old techniques. What are the actual benefits of using flexbox rather than float lef..

4:27 am, January 16, 2019
css
white space pre-wrap formatting

when you want to preserve line breaks in plain text without having to add br tags or p tags.

10:23 pm, January 1, 2019
php
for loop set variables $p1,$p2.. etc as blank - variable variables

this will loop through and assign the variable $p1 = ""; to each in the loop so it appends the loop number to the variable name so you end up with $p1 = "value"; $p2 = "value2"; etc, rather than h..

3:53 am, October 24, 2018
php
get current class name with get_class

This will return the current class name, can be used in side a function of the current class object or give it another object name to return. class myclass {function myfunction() {echo get_class($thi..

3:37 am, October 22, 2018
php
generate a random color rgb code with php

this code will generate a random color every time its loaded using the rand function in php and generate something like this. .random-color { color:rgb(111,222,111); } PHP Code <?php ..

12:07 am, October 17, 2018
css
css :active pseudo-class usage

The :active selector is a CSS pseudo-class. It represents an element that is being activated by the user when they are interacting with a button or link.

1:22 am, October 5, 2018
php
for loop with a 5 increment

$css_out = "";$max_width = "50";for($i=0; $i<=$max_width; $i = $i + 5) {$css_out .= ".m".$i."{margin:".$i."px;}";}return $css_out;

2:45 am, September 17, 2018
php
get text between tags

Using DOMDocument you can get strings between tags Useful if you are processing raw html files with php function getTextBetweenTags($string, $tagname){ $d = new DOMDocument(); $d->load..

6:20 am, August 31, 2018
php
convert all images into base64 encoded

if you have a bunch of html with inline image links this will convert them into base64 images inline. <?php $html = "my html string with multiple image tags..."; $dom = new DOMD..

6:20 am, August 31, 2018
php
using parse_url to extract parts of a url

Category: PHP the parse_url php function will split a url into an array of url fragments $url = "http://kruxor.com/path/?argument=value#anchor"; var_dump(parse_url($url)); parse_url example ..

6:20 am, August 31, 2018
wordpress
wordpress enqueue slicknav and slick slider

add this to your theme scripts functions file here is the full one from HTML5 Blank // Load HTML5 Blank scripts (header.php) function html5blank_header_scripts() { if ($GLOBALS['pagenow'] != ..

6:20 am, August 31, 2018
php
extract meta tags from url and return as json array

this will download the url and extract its meta tags returning a json encoded string, with json headers. If the url is accessable. <?php header('Content-Type: application/json'); if(!isset($..

6:20 am, August 31, 2018
php
csv read example

Not sure if this is the best or correct way of handling CSV file imports, but it worked for me. here is an example of opening a csv and importing the content into a class, you will need to create ..

6:20 am, August 31, 2018
php
php get the file modified time with filemtime

Good for reading the modified time of files with php... echo date("F d Y H:i:s.",filemtime("html/php-get-the-file-modified-time-with-filemtime.html")); will output

6:20 am, August 31, 2018
wordpress
wordpress advanced custom fields replace shortcode for site url with blog url

Using advanced custom fields, if you know what the shortcode is and what you want to replace it with you can do so with the following. $site_url = get_site_url(); $field = get_field('template_ht..

6:20 am, August 31, 2018
php
using custom request headers array with curl

this function passes in an array with custom request headers to curl, good if you need to pass in some headers to request an api url and give it an auth key or something like that. Also added to the a..

6:20 am, August 31, 2018
php
find the 1st occurence of a string in another string

do a case-sensitive search for a string within another string strpos mixed strpos ( string $haystack , mixed $needle [, int $offset = 0 ] ) usage find the 1st location of a string position within a..

6:20 am, August 31, 2018
php
pretty printing json with php

nice if you are working with json string data and just want to be able to read through the structure without copy pasting it somewhere else. $json_string = json_encode($data, JSON_PRETTY_PRINT);

6:20 am, August 31, 2018
wordpress
wordpress show posts loop with feature image thumbnail

this is surprisingly hard to find code that lists all blog posts in a template with the feature image that does not use an additional plugin. you shouldnt need a plugin to do this as its already built..

6:20 am, August 31, 2018
php
search within files in a directory

During my quest to create a semi-static site that is searchable and fast to load. I thought while loading all of this content in with ajax and such that it would be interesting if i could do a text ..

6:20 am, August 31, 2018
php
show errors in php with toggle

Toggle showing errors in php if your server is configured not to show them, good for testing. If you dont have this enabled it will usually just show a 500 error with no details of where the error o..

6:20 am, August 31, 2018
js
google map with overlay data

Ever wanted to add a really slightly complex google map to your site? Working Example /* Always set the map height explicitly to define the size of the div * element that con..

6:20 am, August 31, 2018
js
round number with js

Round a number to two decimal places. code var rounded = Math.round(num * 100) / 100; demo Result... function round_val() { var val = $("#rval").val(); var rounded = Math.r..

6:20 am, August 31, 2018
js
truncate string using jquery

.test { padding:10px;border:1px solid #999;border-radius: 3px; } so lets say we had the following string on the page and we needed to make it a bit shorter for some reason. like if you dont have co..

6:20 am, August 31, 2018
js
detect window scroll position jquery

This one adds or removes a class if the document is scrolled 50 px near the top of the window. $(window).scroll(function() { if ($(document).scrollTop() > 50) { $('nav').addClass('shrink');..

6:20 am, August 31, 2018
js
flems embed in url

Flems.io is a single-file, embeddable Web sandbox. It keeps all its state in the URL, so just make your changes, copy the URL from the address bar, and send it wherever you please. Most popular link s..

6:20 am, August 31, 2018
js
change the window title

 This is a pretty easy one liner But we can make it a bit more complex with jquery and add a counter It is questionable that crawlers and bots will see this so may be bad for SEO. document.t..

6:20 am, August 31, 2018
js
Slick Slider Carousel

Edit: Sorry this page was broken for a bit, its fixed now with working examples! 😛 Nice and simple slider / carousel

6:20 am, August 31, 2018
js
change favicon with jquery

Updated: This seems to not work on this page, as it has multiple link icon elements to deal with different sizes. I just changed it to a function and it runs ok, but the browser seems to choose a diff..

6:20 am, August 31, 2018
js
load google sheet data into json string with jquery

Just discovered this the other day, you can actually export google sheets data into json format and load it directly into your site, how good is that. A free mini basic database! Initially i was lo..

6:20 am, August 31, 2018
js
mithril testing

https://mithril.js.org/simple-application.html example this example is not going to work without npm Adding Elements How to add a link using mithril with target _blank m("a[href=https://mithril..

6:20 am, August 31, 2018
js
validate form data using javascript to check required html elements

for use in a javascript function to submit a form var form = document.getElementById('myForm'); for(var i=0; i < form.elements.length; i++){ if(form.elements[i].value === '' && form.elements[i..

6:20 am, August 31, 2018
js
do something later with settimeout or loop with setinterval

setTimeout This one will run a certain time after the document loads. So if i want to execute something 5 seconds (or so) after the page loads i would do this. You will need to check your console..

6:20 am, August 31, 2018
js
tiny mce editor tinymce

Just loading the editor, as its useful for formatting stuff sometimes 😋. I usually use a function to load it into text areas with the tool bars + styles that i find useful. Example fu..

6:20 am, August 31, 2018
js
clipboard copy js

for copying things to the clipboard, like the click to copy. Basic Usage Include the script <script src="js/clipboard.min.js"></script> add a field to copy to the clipboard..

6:20 am, August 31, 2018
javascript
json loop load elements

Loading json content from a url can be tricky, there are a few different things you need to watch out for. Here is some examples using an example json feed. Load the feed this will load the feed and..

6:20 am, August 31, 2018
jquery
document ready wordpress jquery

Wordpress uses JQuery rather than $ to initialize so here is a workaround that allows you to still use the $ to access JQuery functions. Just incase your normal document ready is not working. tags: ..

6:20 am, August 31, 2018
js
testing chartjs

Update: 30 June 2020 I checked this code, and it was broken all fixed now. The issue with the demo included on the main site is that it was trying to run the chart js before the chart library was load..

6:20 am, August 31, 2018
js
check length of element jquery

this one can be good for checking if an element exists before doing something with it and can stop warning messages if you are running the script on multiple pages. if ($('#mydivid').length) { con..

6:20 am, August 31, 2018
js
set and check a cookie using js cookie

this library makes setting and checking cookies so easy its amazing! include this script <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.1.4/js.cookie.m..

6:20 am, August 31, 2018
js
using regex with replace to replace all instances of something in a string

so you have a string and you want to replace a recurring character, use this to do it: String Example: var string = "a-string-with-dashes.txt"; var string = "a-string-with-dashes.txt"; string..

6:20 am, August 31, 2018
js
digital clock with jquery

Just a simple digital jquery clock that updates every second. Also added the dropshadow animation, not sure why... ;) .digital-clock { font-size:80px; } .transition { transition..

6:20 am, August 31, 2018
js
find all elements add class jquery

this will grab all a elements, and dump them to the console. var allLinkElements = $( "a" ); console.log(allLinkElements); then we need to split into a jquery object, this is a jquery version of an..

6:20 am, August 31, 2018
js
load content with jquery

Load data from the server and place the returned HTML into the matched element. this one seems simple but very useful $( "#result" ).load( "ajax/test.html" ); this one will load the content o..

6:20 am, August 31, 2018
js
stacktable jQuery plugin for stacking tables on small screens

stacktable.js The purpose of stacktable.js is to give you an easy way of converting wide tables to a format that will work better on small screens. It creates a copy of the table that is converted in..

6:20 am, August 31, 2018
js
jquery clone and append elements

This jquery function clones an element and appends it to another one.  Here is the basic code: $( ".clone-me" ).clone().appendTo( ".append-me" );I also updated this to work with just raw js, so..

6:20 am, August 31, 2018
js
show the year with js

just a simple one liner that will show the current year, so no more need for static years in html footers! var d = new Date(); document.getElementById("year").innerHTML = d.getFullYear(); Usage E..

6:20 am, August 31, 2018
js
get select option form value with jquery

Handy if you need to get the value of a selected item in an option list basic code $("#select option").filter(":selected").val(); working demo Value 1 Value 2 Value 3 Value 4 ..

6:20 am, August 31, 2018
js
fancybox youtube showing video links in a lightbox

Updated version with code here do people still use lightboxes, it seems yes in some cases. ;) if you feel the urge to use lightboxes and need to link to some youtube videos this is how you can do it..

6:20 am, August 31, 2018
js
jqueryui date selector with examples and code

This has to be one of the most used date picker items from jquery ui. And its usually the reason i even include jquery ui. Without using a theme this one looks pretty good. This version of it does n..

6:20 am, August 31, 2018
js
using vue and json data

Based on This Demo: https://jsfiddle.net/kkpLnv6k/ so i was looking through the jquery way of loading json data and was wondering what the point of loading it in with a vue.js instance is. I guess ..

6:20 am, August 31, 2018
js
using getElementById and innerHTML to change the html of content no jquery

this is pretty simple, but i always forget it so ill add it here document.getElementById("theid").innerHTML = "the new content"; heres how it works, add a div with an id of theid Example .. <d..

6:20 am, August 31, 2018
js
make clickable element with clickable class

makes an element with a link into a clickable element

6:20 am, August 31, 2018
html
simple dropdown multi level navigation ul li css

updated to work standalone and not effect other list elements on the page

6:20 am, August 31, 2018
html
using foundation 6.4 xy grid basics

Foundation 6.4 introduced a new xy grid which replaces the old row and large-x format here is a basic grid layout (foundation grid) add some style to show the cell border <style> .grid-x .ce..

6:20 am, August 31, 2018
html
youtube extract thumbnail from video link

Good if you need to extract the ^^ for some reason. replace $v with your video id. raw links https://img.youtube.com/vi/$v/default.jpg https://img.youtube.com/vi/$v/hqdefault.jpg max size https:/..

6:20 am, August 31, 2018
html
youtube embed no controls auto play iframe

Sometimes you want the video to loop and play with just no controls on it, this is how you can do it. You can still click to pause it, but the normal controls are gone. Also it seems you have to ..

6:20 am, August 31, 2018
emoji
emoji data - version 1.0

  Emoji Data version 1.0 This is a better emoji list that you can search by title ctrl + f emoji-data.txt # Emoji Data for UTR #51 # # File: emoji-data.txt # Version: 1.0 # Date: 20..

6:20 am, August 31, 2018
html
video embed no controls

embed a video, for use as a background or a slide element, or wherever you need a large video. I found that there was a bug in chrome (which is probably fixed now) that was ignoring the autoplay tag ..

6:20 am, August 31, 2018
css
use an image to replace bullet in ul list

How to replace the default bullet with an image in a ul tag .widget ul, .page-content ul { list-style-image: url('images/favicon.png'); }

6:20 am, August 31, 2018
css
border box reset

with a bonus transition to all * { box-sizing: border-box; transition: all 0.2s; }

6:20 am, August 31, 2018
css
css grid sidebar main content fluid layout with fallback

this is a continuation from the original post with added fallback for older browsers that do no support the grid elements yet. I have tested this fallback in IE11 and it seems to work well, if you wa..

6:20 am, August 31, 2018
css
bootstrap styled buttons

Just in-case you would like the shiny (flat/rounded) blue buttons from bootstrap without all the css. Example Button add the class btn and btn-primary to your link An Example Primary Button (bt..

6:20 am, August 31, 2018
css
color cycle drop shadow - rainbow drop shadow

Just incase you are bored with a static shadow, here you can cycle through a bunch of different shadow colours. .cycle-shadow { -webkit-animation:img-cycle 3s infinite; animation:img-cycle 3s i..

6:20 am, August 31, 2018
css
css grid sidebar main content fluid layout

I was playing around with css grid the other day and i found a nice (and easy) way to do a standard left sidebar and fluid main content area. this is rather than floating the sidebar and then setting ..

6:20 am, August 31, 2018
css
truncate text long titles with text overflow ellipsis

this one can be useful for fitting text into smaller places without it looking broken. text-overflow: ellipsis; this basically adds the 3 dots where the end of the text used to be... Also if you are ..

6:20 am, August 31, 2018
css
css grid for layouts with no rows

I had a look at this recently, but my previous example still used rows for a grid, which apparently is not the correct way of using css grids. I think the issue (I had) with css grid is it seems co..

6:20 am, August 31, 2018
css
css grid for layouts and how to use it

Note: Added version 2 of this with no rows for the grid css grid for layouts with no rows so there is this thing called the CSS Grid Layout, and apparently we dont need a framework for grids anymore...

6:20 am, August 31, 2018
css
click through an overlay element pointer events

This one is usefull if you have an element overlapping another element and you want the one underneath to be clickable, like positioning an image over the top of a slider with controls underneath it. ..

6:20 am, August 31, 2018
css
why are people so amazed that a column layout can have a full width element

Is it because its inside a grid still? i must me missing something anyway i have been noticing that there is this post (and this one) going around showing that you can break out of a css grid and go ..

6:20 am, August 31, 2018
css
margin padding framework

Just a quick margin and padding framework that i came up with, to make margins padding and basic styles a bit quicker.

6:20 am, August 31, 2018
css
target internet explorer with css and html

target all internet explorer versions with this <!--[if IE]> <link rel="stylesheet" type="text/css" href="all-ie-only.css" /> <![endif]--> target ie 10 and 11 p { col..

6:20 am, August 31, 2018
css
darken background image using css

darken a background image using css only useful if you have overlay text or just want to add a nicer effect to an image, i usually find that adding this to an image with the text over the top makes it..

6:20 am, August 31, 2018
css
material design icons google font

you can just link to this like a font in your header how do we use the icons? <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> this one should ..

6:20 am, August 31, 2018
css
flex align center vertical horizontal

lets say you have a box within another box, like so: .box { height:500px; width:500px; background:#CCC; } .another-box { height:50px; width:50px; background:#999; } ..

6:20 am, August 31, 2018
css
targeting the printed version of a page with media print

there are 2 ways to target the printed version of a webpage, you can do it with a @media print query inside your css, or you can link the whole style sheet and target the print media. target print ..

6:20 am, August 31, 2018
css
make your images look non squished when not using image backgrounds

Update: Fixed the code, you can see it here.  i deal with a lot of sites where they have a bunch of images listed and sometimes they can end up looking a bit sqashed unless you add a div and set..

6:20 am, August 31, 2018
css
css accordion basics

can we create an accordion with out using jquery ui? I think yes, it will be basic but also keeping it simple it probably a good idea. tried adding transitions to make the divs showing a bit smooth..

6:20 am, August 31, 2018
css
use font awesome on elements lists ul

good if you need to use font awesome in list items like ul lists, etc. .element { position: relative; } /*replace the content value with the corresponding value from the list below*/ ..

6:20 am, August 31, 2018
css
set transparent menu over background image

this is probably obvious, but i found it useful for those themes that look nice with a semi-transparent header sitting over the top of an image. I think ill do this as an external example, as its eas..

6:20 am, August 31, 2018
css
table border collapse

I see this quite often when dealing with tables the border-collapse: collapse; used on a table as so: table { border-collapse: collapse; } So what is the point of doing this? It seems to help..

6:20 am, August 31, 2018
css
stack a table using css responsive

this can be useful for fitting tables into smaller screens, usually add this to a media query. #tableid td { display: table-row; width:100%; display:block; } and with a screen size added @me..

6:20 am, August 31, 2018
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


Me
Random CSS Property

@page

The @page CSS at-rule is used to modify some CSS properties when printing a document.
@bottom-center css reference