Search
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..
add an outline to everything!
very handy for checking elements and other things on your page. this one line will add an outline to every element, so you can see where all the elements are located.
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..
card.html template
a card template with title, content and a mb-3 for bottom margin for usage with the php template system.
making the search page nicer
Sometimes i dont even notice things like this, as i look at them all day and go, ah yeah thats a search box. I forget that all these things can be fixed. Anyway, even just adding this form to a..
function to delete older sqlite records when the limit is reached
I had an issue where a sqlite database was hitting over 100,000 records and this was causing quite a lot of lag and crashing on my server, the number of records was not really meant to be this high, s..
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..
loop to arr.length or array length
showing a simple loop that uses the length of the array to find the end of the loop. This just console logs each item in the array and stops the loop when it gets to the end of the array.
bootstrap form basic
a nice simple bootstrap form layout example template
get directions from google maps form embed
this is a random form that posts back to google maps showing the directions needed to get from one address to another location, im not sure where this would be usefull. Maybe on a site where you neede..
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..
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));
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..
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.
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
add new random image with button
this appends a new random image from picsum.photos to the div with the id app
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
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.
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.
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
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..
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..
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..
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..
simple javascript no library accordion
a simple button and div based accordion with a toggled indicator
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..
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..
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 ..
How to download music to mp3 format from youtube using youtube-dl
How to download ABGT from youtube. youtube-dl sudo apt install python3-pip ffmpeg brew install ffmpeg brew install youtube-dl Getting this error: The operation couldn’t be completed. Un..
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..
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 ..
How to Assign the Value of One Variable to Another in Javascript
Showing a very basic script that assigns the value of the variable a to b and then console log's the object.
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..
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..
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..
Console Tips and Tricks
Here are some quick commands for the console. Getting to the console in your browser Press F12 and Find the console tab. That little blue > there is the console. this is in brave or chrome, bu..
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..
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..
pi400 how to take a screen shot
This is actually built in, well if you have scrot installed anyway. Which it already was for me. Press Print Screen button and it saves it into your home folder.
Add custom symbol to ul li list and align text items
Pick a symbol from here. Then you can copy and paste it into the following css to change the list symbol, for more unique looking list items. If the list items dont align correctly you will nee..
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..
php export csv from string to browser download
exports an array to a csv string and returns the result in the browser
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..
convert json string to a php array
takes a json string in php and converts it into a php array using the json_decode function.
how to decode xml in php
how to decode xml into an array in php Here is a full example taking an xml string and converting it into a php array.
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..
count total results from distinct sqlite
a query to count the total items found on a distinct query
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..
php get file and save it
gets a file from a url and saves it to your local server
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..
list all array json function list_all_array_json
I wrote this a while ago, and i always forget the complex functions i write so ill add it here. This loads all fields and then returns them as json.
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 ..
php function to remove the query string from a url
i was reusing this a few times manually and thought i would save my self a bit of time by just using the following function which returns the same full url, but removes the query string from it. ..
using php parse_url function to remove the query string from a url
I recently had to remove the query string from a url, the bit after the ?key=1 or whatever is after the actual url. I initially thought i could just use a explode function on the ? which would ..
add every value in the load_array array into the out for testing
quick foreach to add every variable and variable name into out and return it. good for testing.
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..
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..
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
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.
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.
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..
php return json header and content
sets the header to json and returns a simple json formatted array.
php get file extension from a file name
this function returns the file extention, however if the file name has multiple . in it this will return a false value.
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..
add a divider to your dropdown nav toggles
good for seperating menu sections in the same dropdown item add this to your toggle <li><hr class="dropdown-divider"></li>
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..
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..
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..
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.
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..
How to Override Default Props in React
The following code explains how you can override the default props in react. In this example the default of quantity is set to 0, so we can pass in quantity in the items to override its default..
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..
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..
add hero title to category listing page [not done]
add the hero title and background to the category listing page as a page title or category header. e.g: https://kruxor.com/category/code/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..
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..
How to Pass an Array as Props in React
If you need to pass larger amounts of information to a component you can pass in an array rather than just a single variable. More information on the join method on the array can be found here. Here..
list_all_array an early stages of list all function that uses an array to pass in main variables
I think this is more neat than passing in individual variables into the list_all function, seems to work ok so far. Still in early stages of this listing function, more needs to be built into i..
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..
using the $_SERVER['HTTP_REFERER'] to check referring pages
shows how you can display the contents of the $_SERVER['HTTP_REFERER'] tag in php to show referring pages i read in an article that this is stripped out of HTTPS requests, but it seems to still be wo..
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..
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.
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..
How to Write a React Component from Scratch
Just testing my react component writing skills...
How to Render a React Class Component to the DOM
This shows how you can get react to render a component into the page or DOM. So actually getting and showing the code that you have been writing in react.
get element by id with javascript
gets an element using its id using javascript
set a cookie on click and then check if the cookie is set and dont show that message again
this script shows a message, and if the message is closed it will set a cookie to not show that message again for 1 day. The cookie in this example is set to expire in a day, so then if you com..
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. ..
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..
Changing the default hero image based on the category name [not yet done]
This is more of a todo item, at the moment the hero image uses the same image for every post unless a hero is specified for each, i would also like to set the default image per category so if the post..
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 ..
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..
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 ..
using the kbd html tag
You can use the tag <kbd> to highlight keyboard shortcuts, i love this tag! Now i just need a reason to use it.
How to Create a React Component using the ES6 class method
One way to add a react component is to use the Stateless Functional Component method, and another way is to use the ES6 extends syntax. This method seems more complex than the 1st for some reason mayb..
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.
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 ..
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..
How to Define a HTML Class in JSX in React
When writing JSX you cant add classes like you would in HTML so this code would not work: JSX <div class="my-class"></div> Instead we have to use className. JSX uses camel case for a l..
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 ..
How to Add Comments in JSX
To put comments inside JSX, you use the syntax {/* */} to wrap around the comment text. You do actually need the curley brackets, and have to add it under the other elements for this to wor..
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..
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.
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..
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..
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 ..
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 ..
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..
react basic hello world
the most basic hello world using react js
console table rather than console log for javascript objects and arrays
so i just saw on a tweet, that you can use console.table and i cant wait to try it out! good thing i already have a test object and array ready to go!
timeline class and function
this is a class extend that generates a timeline based on structured data and order's the items by year decending. this code will not work out of the box as it has other requirements, but it is a goo..
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..
bootstrap list group card with footer
a list group within a card and also a footer on the card for additional links.
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 ..
list group card item template
this is a list group item for usage with the template list group or list group card template.
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.
list group card template
list group card template for usage with the php template class
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 ..
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..
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..
create a 200 character summary from a longer html string
this is a quick function that can create a 200 word plain text summary from a html string. Also added the option to specify the char length of the string. Function function create_summary($htm..
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..
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..
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 ..
open sans @import embed font quick
just a quick and nasty css import for the Open Sans google font.
using strlen to check the length of a string and do something about it
in the following code i use the php function strlen to check the length of a string and then add an if statement to check if the string is longer or shorter than the required length.
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 $..
get and show the featured image on a wordpress page template
this will extract the featured image on wordpress page if you are using custom page templates.
document placeholder for a4 in portrait
a nice document placeholder image with dropshadow and transparency
landscape image document placeholder
A nice landscape image of a blank presentation format, in landscape mode with drop shadow.
easy section wrap in foundation - 3 boxes responsive
this is a 3 box section responsive wrap in foundation, you can change this to large-auto if you want to have multiple boxes
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..
wordpress show page content on template file
shows the page content on a wordpress template file
show post content on template wordpress
show the post content on a wordpress template
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..
hidden scroll anchor for custom scroll position
just incase you need to link to a scroll anchor that is not in the place where you need it.
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
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..
load from fields array php class function
this class function loads from multiple fields from an array, much easier than passing in a bunch of variables into a function nice and clean, the only issue is you need to remember what fields to add..
ken burns slow image zoom
No i had never heard of Ken Burns either, but hey i like the zoom effects. Slow Zooom...
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 ..
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..
easy section wrap in foundation
i am always writing these wrap sections so i thought i would just add a basic one here, easy to copy and paste into a new section
test image url that always changes unsplash placeholder
good if you are doing a test site and need some changing images for test placeholders, and they are nice looking images as well. you can just use this image tag link and specify the size required.&nb..
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 ..
change the box-shadow of an element with javascript boxShadow
changes the box shadow of test_div using the javascript object(?) boxShadow
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
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 ..
javascript update item in object
find something in a javascript array by its array id and then update the value of that item i changed this from an array to an object as i wanted to use something other than numbers for the index Ob..
change padding of element with javascript
change the padding of an element with javascript only
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..
get the current week as a number with php
retrieves the current week as a number from 1 to 52.
animated duck on footer
Thought this was cool. How do i do it? Page Source: https://www.learninpublic.org/ Copy this section Lets see what is attached to it. So i can see from the classes its a tailwind based ..
twitter json feed testing
just testing using the Twitter Post Fetcher script, seems to be working well.
atom on mac and synchronise settings
installing atom and syncronise settings between windows and mac versions. Install the package Syncronize Settings the package is called sync-settings but searching for sync-setting and Syncroniz..
fancybox load iframe inline
All you need to load content in an iframe using fancybox modal javascript plugin. not quite an inline load, but not much script to get this going.
using filter grayscale to make an image dark
lets make this image grayscale using a css filter
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, ..
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..
moving the hits widget into the post header and footer
I wanted to make a smaller deal of the views page widget, i was adding it as a full widget and it does not need to be that huge so moving from widget area to the top of the post. Move it down..
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..
test php bundle write
just testing
check if a file exists with php
checks if a file exists in php returns true of false
check if the file is a directory or check if the directory exists in php
this checks if the file is a directory or if the directory exists
get the current working directory in php
gets the current working directory... in 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..
mouse enter mouse leave jquery hover hoverout
showing how you can do things on mouse over and then something else when the mouse leaves an element using 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 ..
bootstrap dark mode
Bootstrap Darkmode https://github.com/vinorodrigues/bootstrap-dark/blob/master/README.md#method-1 https://github.com/vinorodrigues/bootstrap-dark CSS Dark Mode Preparing for dark mod..
twitter icon font awesome
twitter and linked in icons from font awesome
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..
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..
gallery carousel center mode
i found this one here, looks cool. see if i can get it working like the demo. currently getting this error on running the script i wonder if this is caused by a document ready issue? what is..
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..
load random videos module using template
load 3 random items and extract the video url, and use the youtube function to create a thumbnail and link to that video page
PHP/SQLite - Load Random Item
loads a random item from the current class / db using sqlite.
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..
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 ..
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 ..
extract youtube image from video url
showing how you can get the image wallpaper in different sizes from a youtube video I used to have this tool a while ago, it just passes the video id and extracts the images and also can produce the ..
simple php ip blocker
just to quickly block annoying ip addresses using an array and $_SERVER['REMOTE_ADDR'] so i woke up this morning to find 200 comments from this spam ip, here is a simple script that will block that i..
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 ..
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 ..
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 ..
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...
check browser version and show a message
a button that displays your browser version in a modal Demo (gif)
roboto and poppins fonts include quick code
css import for poppins and roboto google fonts with the common font weights
search bug Above
not sure why this is still happening, need to investigate: 23 Nov 2021 this bug is still happening, i thought i fixed it, but apparently not.
CSS Drawing - Beach Scene
i did this one a while ago, cantr even remember it just appeared when i searched in google. here is an animated version, check the bottom for the css version of this:
404 Error Page Codepen
found this in my links the other day, still looks cool...
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
right align something in its element
easily align a block or inline block item to the right in its outer element
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..
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..
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
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
globe svg testing (broken)
nope seems not to be working, it seems you cant just copy the glyph path into a normal svg and hope for the best, oh well i tried.
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..
fix for wordpress requesting ftp login details installing plugins
add this to wp config define('FS_METHOD', 'direct');
simple backup to google drive fron linux
i added these scripts a while ago to backup mysql databases and web files to google drive a while ago, i just run them on a daily cron to copy the backups every day. the files so the bain backup_a..
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..
scroll down the page using a button click
scrolling down 600px from where you currently are on the screen demo vid
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..
Scroll down indicator css javascript and html
I have seen these a couple of times, indictating to the user that there is further content down the page, and they should scroll to view it. Then as you scroll down the indicator dissapears. So we w..
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..
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
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.
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.
add a gtag.js pdf click event
how to add a pdf click event using the gtag.js analytics
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..
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..
jquery check if a sub element exists
this can be done with .length
jquery toggle menu testing
using jquery toggle to show and hide the sub menu's
responsive menu research full screen multi level
i was just looking into responsive menu's that are easy to impliment and navigate even if they have multiple levels still just in research mode at the moment Menu One Menu Sub One Menu Sub..
Comments Listing should be a custom list rather than using search
For some reason when i listed the comments under posts on this site, i used the search function and then searched for the related uid, which maybe was easier at the time than adding an additional cate..
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..
load the latest single item only
this function loads the lastest item from the selected class
load oldest item based on insdate then update the insdate to now - load_latest_single_update
i keep finding these functions that i wrote ages ago and forgot about so ill list them here so maybe i can remember them. I think this one was to loop through items, so it grabs the oldest item and t..
change this to a list group - other items
Other item format is a bit average, list group should fix this. This uses the template: core-list-item-simple.html So we can change this a bit to the list group format. Which i..
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..
dropdown section
What generates the dropdown widget items? generated by the function generate_section_button() per class template file section-dropdown-bootstrap.html
Latest from Code Widget
What generates the Latest from Code Widget? Code PHP $widget_latest_list = $class->list_all( $start = 0, $max = 10, &n..
rtrim strip white space or strings from the end of a string
good for removing trailing , or any repeating character from the end of a string
prevent default click event on link
This will prevent the default event on a link url, so for example if you have a <a href="">link</a> link this code will prevent it from loading the href link when clicked and you can do so..
make your images look non squished when not using image backgrounds v2
this is a working version of this post, for some reason that image was deleted I think due to a content upgrade. Basically this uses the object-fit: cover; to make images not stretch when they ..
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..
show the difference between two dates in years, months, days, hours and seconds
i modified this code into a function that also detects if there is any values in each item before adding it to the text.
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..
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..
backup script to google drive that can be used for multiple directories
this zips the content of the target directory and then uploads it to a google drive backup location just create a file called ~/_backup_dir.sh and then add the following BASH - _backup_dir.sh ..
backdrop-filter: blur(10px);
just testing this filter
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..
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..
load json with vanilla javascript no jquery
this basically does the same thing that a jquery .getJSON does but without the need for 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..
add chevrons to a ul list
adding a chevron to a list item rather than the default dot and the moving one, here is the demo:
unable to access the $_FILES when submitting a form php
I was getting this weird error when submitting an image for a form upload and i could not see why the $_FILES was not set as this is where the files go from a $_POST back form in php. The error i was..
check column exists in table sqlite
this will return 1 if the column name exists in the table or 0 if it does not
set active class based on url value
this will check the full url and then loop through all the a elements in #test-div when it finds a matching url it will add the class active to that button this is good for persisting active links o..
show all methods or functions in a class (class function version)
add this to your class to show all its methods including this one... sorts the array ascending by values so should be sorted in a-z
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..
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.
check if a variable is undefined or NULL
this will check if the check1 variable is set if it undefined or NULL it will return
foundation accordion for version 6.x
yep the foundation does weird things to this sites css, but the demo still works if you want to use the built in foundation accordions.
foundation responsive tables
in foundation you can make a table scroll when it hits its width limit by adding the class <div class="table-scroll"></div> wrapping the table element
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..
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..
check server https or http value in php using $_SERVER
this will check the server method and if its https assign the value to $server_http_val so this will either be "https://" or "http://" good for generating full url's for your domain.
fancybox image popout easy
just in case you want to easily apply a modal or pop out effect to your images when they cant be displayed full size on the page. related: https://kruxor.com/view/code/3gNUD/inline-fancybox-m..
css responsive max and min targets @media
showing how you can target elements within a max and min screen width demo:
check box highlight text area css
i just wanted to be able to highlight a text field if a certain check box was checked on a form in this demo below, if you click on the check1 checkbox it will give you an alert saying if the box is ..
Remove background image php with image magic
untested research on removing background and making it transparent with php
validate an email address from a form field - version 2
This javascript function will check if the email address in the text box has an @ and a . in it and return a message saying if its valid or not. This is pretty basic as it only includes checkin..
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');
form submit override with javascript
if you need to run some additional checks on a form before submitting it
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
dropdown change input box on select
changes the value of an hidden input depending on the selection of the dropdown
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
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.
pre-line white space settings
this preserves line spacing but also wrapping as well
pre-wrap preserve line spacing but also wrap where needed
a class to pre-wrap your line text this preserves line spacing but also wraps the text if the line goes out of its limit
php list all the functions in a class
this should return in an array the methods or functions for a class
php print an array nicely
this works for variables and arrays
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..
dont use md5 for password hashing using password_hash and password_verify
apparently md5 is not the best method for password hashing, you should use the php functions password_hash(); and then password_verify(); to verify the hash matches PHP password_hash..
change photoshop to show px rather than pt
if your photoshop is showing pt when you select font sizes, you can change this in the settings. in the Edit menu go into Preferences and then Units and Rulers then you can change both uni..
clear a input field when it looses focus using onblur
this will cause the input field to clear when it is not in focus
a page with two images
a page with two images for testing
python extract images into an array from a url
this should extract all images from a url into an array using python python from bs4 import BeautifulSoupfrom urllib.request import urlopenurl = "https://www.kruxor.com/view/code/LOveX/"page = urlop..
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..
python Install Beautiful Soup
this allows you to install the Beautiful Soup library for python which is used for html parsing BASH python3 -m pip install beautifulsoup4 python3 -m pip show beautifulsoup4 if you get an error say..
python extract title tag from url and html using regex
this will extract the title tag as text from the url and the title tag in the following python script Python import refrom urllib.request import urlopenurl = "http://olympus.realpython.org/profiles/..
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..
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..
git pull changes from a repository
use this to pull from an existing git repo into a new directory
commit and push changes to git repo
run this to add all files in current directory to repo and push the changes to git git add * git commit git push
start ssh and add key git
i usually add this to a .sh file and make it +x to run ssh agent and add the github key bash eval "$(ssh-agent -s)"ssh-add ~/.ssh/github
play youtube videos on firefox in ubuntu 18
sudo apt install libavcodec-extra also checked that firefox was able to pla drm video
css double page document preview with shadow
two div elements that look like blank documents with drop shadows
adding a background image to the titles of the dark mode card on this page
Just wanted to see what it would look like if i added some kinda image to the background of the titles. Side Note: i wonder if its a bad idea to add images that are uploaded to imgur rather than to t..
blur the background image while keeping the foreground normal
this one uses the ::before element to add a background and apply the blur filter to it, while allowing the foreground content to still be non blurry
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
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-..
page scroll indicator research
I was wondering the other day how they do those page scroll indicators, i saw one when viewing this site: https://blog.wolfram.com/2021/03/24/the-solution-of-the-zodiac-killers-340-character-cipher..
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..
rounded click me button with icon
just a rounded button with a font awesome icon
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..
replacement slider for ken wheeler's slick carousel tiny slider 2 [testing]
I have been looking for a little while for a replacement for the now classic and a bit depreciated, ken wheeler's slick carousel. After a bit of looking around i think the best replacement, is a non ..
change a select box back to its initial select value
this will reset the select box selected value back to the 1st item in its options list
select onchange
select onchange run a function this will run the check_years function when the select value is changed
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
using moment.js to make your time format nicer
moment.js is a very nice way to handle multiple date strings and output them in a nicer format. grab the latest copy of momen from cdnjs lets say our date is in this format, i think this is un..
loop through object json javascript
this shows how you can loop through a javascript object using for if you check the console you can see the loop results
json jquery ajax request
get json data with jquery using getJSON
logo tickers marquee slow scrolling
logo tickers with a slide animation
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..
add a moving chevron to your href link
this adds a right chevron that moves when the link is active demo: * note: this may not show up in light mode as the chevron is white, so would need to change the color it
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..
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..
set the html of an element javascript
this will set the innerhtml value of an element
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..
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..
minutes to decimal calculator javascript version
trying to do a more simple version of this post. https://kruxor.com/view/code/NIjAQ/quick-tool-to-convert-time-into-decimal/ the php version requires post back to the server, so i think this c..
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..
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..
append a query string to all url's on a page
this should append the query string test=1 to all url's on this page. if it works... make sure its added to document ready.
using text-stroke to add a border to your text
this is quite good for webkit enabled browsers, and most of them are these days. Check what is supported: https://caniuse.com/?search=webkit-text-stroke
installing exfat and ntfs drivers to enable reading of these filesystems
this will install the ntfs package on your linux system, allowing you to read and mount ntfs partitions on drives. NTFS 3G BASH sudo apt updatesudo apt install ntfs-3g This should give you the fol..
linux list all drives and partitions
the following command will list all drives and partitions in your shell BASH sudo lsblk -o UUID,NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,MODEL It should look something like this depending on your drive se..
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..
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
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..
how to check linux kernel version on rasberry pi rasberian
You can check which linux kernel version on rasberry pi a couple of ways, the easiest is using the uname command BASH uname -r which should give you something like this (but probably not exactly th..
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..
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/..
slick carousel jump to a slide on element hover
jumps to a specific slider on hover over on an element this is working now, here is the example, mouse over the buttons to see the slide change. trying to add this: Javascript $( selector ).mous..
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..
github logo background png css
just the github transparent logo as a css class, yes it should probably be a svg, but here it is in all its PNG glory.
animated rings expanding with delay ripple water effects
just testing this one
css slow zoom in animation
give a bit of extra interest to otherwise static images
using the last-of-type css selector to remove a border from the last item in a list
i find using the last-of-type css selector quite useful when there is a list or re-occuring items and the last one has to be slightly different from the other ones. This allows me to target the..
Aligning Images in TinyMCE or Floating them left and right (code)
Here is the code for this page Aligning Images in TinyMCE or Floating them left and right
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..
calculate a percentage (dec) difference based on two numbers
I wrote this function a while ago, but im not actually sure what its suppost to do, so ill test it here and see what it returns. I think after running this function it returns the differents in perce..
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..
jquery page search [testing]
just testing this one at the moment for a in page search. Based on this: https://codepen.io/chriscoyier/pen/ExgqWab I would like to adapt this code to search through page elements and ma..
Testing
test <p>test</p> x .my-selector{ value:1px;} HTML <table></table> CSS .css{} Javascript function test() { console.log('test'); } PHP a = 1; x x
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..
how can i make my code look nice, or highlighted in evernote
* update: this is actually a paid tool, so i will be skipping this, as the code highlighting function is not that important to me. If anyone finds a nice free way to do this let me know. I have only ..
TortoiseSVN for updating wordpress plugins
For updating wordpress plugins, and probably other SVN related stuff, i found that using TortoiseSVN is the easiest. For windows anyway. Just go to the downloads page, and pick the correct flav..
box hover over effects using pulsate animation
Bit of a different box hover over effect. Just using the pulse animation.
install atom editor on ubuntu
You can download atom from https://atom.io/ and run the .deb package or if you want to use apt you will need to add it as a repository. https://flight-manual.atom.io/getting-started/sections/installi..
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..
change images to upload file also to imgur [reported]
may also create a seperate db to store imgur image links? can update the source_link in the current images to link to the imgur version. I remember i did this a while ago but cant remember the code ..
enable dark mode in tinymce
Here we have a darkmode verion of tinymce, ahh my eyes feel much better. The change to version 5 seems quite easy as well, as it uses the same init script as 4 still. You need to also includ..
codemirror htmlmixed textarea
a working (hopefully) version of codemirror using the htmlmixed mode, not sure why its not doing code highlighting.
install codemirror for textareas [added]
i think rather than editing all the code using just a plain textarea element it might be nice to have codemirror format them nicer https://stackoverflow.com/questions/21085170/codemirror-how-to-insta..
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..
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:/..
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..
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..
@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.
my default text shadow css
just a quick copy and paste for easy text shadow that fits in most places
spin rotate an element on mouse over [css]
i thought it might look good to spin this element around when the mouse is over it. Added the following css to second_nav_toggle.
animate and zoom six elements on a timer [addClass, removeClass, setTimeout]
set of six elements that i wanted to highlight using a simple setTimeout and the addClass and removeClass this also involves some css changes to get this working i would also like in the fut..
add a comment recording system for posts [idea]
add a custom comment system for code and posts with google recapcha
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..
style page numbers [fixed]
need to style the page numbers. https://kruxor.com/list-table/search_links/ Before: After: Dark Mode Light Mode
explode a string into an array
This uses the php explode function to split a string into an array based on a delimiter character. I always forget which order this goes in.
checking the current url and then marking a link active based on that url
i want a script that can check the current page uri and then match it to a list of links to be able to add an active class that survives page reloading So here we go... 1. Get the current page url. ..
using gzdeflate on a string php
yes you can actually run compression on a string to save space and then uncompress it at the other end...
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..
change the cursor to a pointer for an element
i find this class quite useful if you are adding a javascript click event to an element, and need the mouse to look like its a click item rather than just a normal item. If you mouse over the test ..
set maxHeight of element by id with javascript
sets the max height value of an element with javascript demo pending
badge border colour is too dark or light on number badges [fixed]
I noticed that the badges here were to light, so i must have missed something when updating the badge css. Demo Linkhttps://www.kruxor.com/search/code/site+bugs/ Bug Status:Fixed Problem: The bo..
badge placement is offset in list pages [fixed]
Another bug caused by the badge changes I think this can be added to a grid as well, and have the category on the left and the date on the right. Then need to align the category badge nicer. ..
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 ..
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..
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..
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.
easy twitter embed code
Just need to switch your twitter user name to show that feed here. Back when i used to use twitter, apparently.
How to add jquery to squarespace site
I dont use square space, but if i did and i wanted to use jquery in it. This is where i would add it... ;) Settings > Code Injection > Header Then add your script, like this one:
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 ..
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..
foundation old grid format
This uses the old foundation grid style, i think it was a float grid, not sure which version it was maybe version 5 foundation. Somewhere around here: https://cdnjs.com/libraries/foundation/5.0.0&nbs..
replicating the bootstrap dropdown toggle in jquery
here is a code that can toggle a sub element using the same format as bootstrap. Update: also added another line that closes all the open menu's when one is clicked, so that you dont have a bunch of ..
use an emoji on your list items ul li
I didnt think this would work but it does somehow, i guess it may differ depending on what emojis are available on your system.
bootstrap basic grid layout
nice and easy copy and paste for a basic grid layout
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..
Windows Emoji Shortcut
I keep forgetting this shortcut so ill add it here. Windows Key + . Windows Key + ; These both pop open the emoji menu in windows. Enjoy Your Emoji's 😘
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..
css prefers-color-scheme example
This uses the @media and prefers-color-scheme to check which one you have as a setting in your browser
play a sound every # of seconds
This plays a beep sound every # of seconds, to stop it just reload the page 4 Minutes is 240 4.5 Minutes is 270 5 Minutes is 300
bootstrap toggle element collapse
the example code for toggling elements, show and hide
adding pagination to custom wp_query
you can add this to your custom wp_query making sure your query also has the paging passed through to it
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..
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.
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..
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..
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
check that a number is in the correct range based on a form selection
This script will check if the number is correct based on a form selection this can be used for checking that a postcode matches a state value or something similar Lets grab the html select form from ..
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..
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 ..
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..
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..
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..
using javascript to open a link in the same window and in a new window or tab (open link)
a nice easy way to target _self or _blank when opening a link using javascript
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..
Leaflet Quick Start Example
just a quick start map embed for leaflet js an alternative to google maps
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.
setting up css variables in your stylesheet
Using css variables at the start of your stylesheet can make things down the road much easier to change. You can also use it for more complex variables like drop shadow settings as shown below. ..
match a category id in wordpress and then add styles just for that id
this is in template-parts/content.php which may be different based on your theme or version of wordpress. you can locate the category id in wordpress by going into categories and then clicking ..
simple table stripe striping
this uses the nth-child(even) element to add color striping to the following table test table x x x &..
bootstrap collapse or toggle a div visibility
if you have bootstrap and want to toggle an element or show and hide a div its already built in, just use the following code to toggle something.
drop shadow text class easy drop shadow
makes it a bit easier to read light text on a dark background or vice versa
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..
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..
country select javascript check which option is selected and show a hidden element
this shows a country dropdown and then if a selected country name is matched it will show the second part of the form for this test australia is the confirmed country
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
php countries array to dropdown form element
here we generate a form dropdown from a php countries array using the country code as the name of the form option
get the current post id from content.php
this should assign the current wordpress post id to $post_id, from template-parts/content.php if you want to show it, just echo the $post_id
wordpress get the current category id name and slug
This gets and displays the current category id in a wordpress blog post if you have the current id, if not you can leave the $post_id blank and it should see if there is a category loaded to the curre..
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 or a <p> tag to the element Removed the space and this f..
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..
css font style italic
i had a request to make some font italic the other day, and for some reason i could not remember the css for it. It's font-style: italic; I should know that! I guess italic fonts annoy me a bi..
create a rainbow background using css linear gradient
just incase one gradient is not enough for you we can also use it to create a rainbow background gradient
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..
Bootstrap 4 Center menu items in a navbar
Here we have an example bootstrap navbar you can find the original navbar here. I just want to center the menu item links so they dont appear over to the left on larger screens. Add the follow..
certbot add a certificate for one domain
this adds a certificate for one domain and modifies the nginx config to use the certificate also giving you the option to redirect all traffic to the secure version
renew all SSL certificates with certbot
just issue the following command in bash
Fix for Fatal error: Uncaught Error: Call to undefined function file_get_dom() simplehtmldom simple_html_dom
This error is caused due to a function name change in the simple_html_dom.php library if you are using an older one and upgrading to the never version, you can see it in the change log here: https://s..
Fixing PHP SQLite database is locked warning - Unable to execute statement: database is locked
Apparently this error is caused by not closing the database after using it. Warning: SQLite3::query(): Unable to execute statement: database is locked. You can close the database using the fol..
simple usage for php password_hash
password_hash is used to generate a hash for a password. using this in its simple form can be good for generating a hash from some text like the following code.
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
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..
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..
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..
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..
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..
stop overscrolling on responsive ios
this stops the site bouncing around all over the place when you try and scroll in ios
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 ..
To make Ubuntu do nothing when laptop lid is closed
sudo nano /etc/systemd/logind.confchange this to ignore: `HandleLidSwitch=ignore`save the filerestart the login daemon sudo service systemd-logind restart
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
change upper case case string to lower case (uppercase, lowercase)
this can change a lower case or any case into upper case using the str to upper php function Example
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..
bold the numbers in a ol li list
sounds like an easy thing to do, but maybe not so simple. you can do this using the counter css element. code below:
convert a string to uppercase with php
use this function to convert a lower case or sentence case string into its uppercase form
php substr return part of a string
good if you want to .. return part of a string
php countries array
country codes to country names array in php
loop through each directory in a target directory and compress them
this one loops through each of the target directory and also compresses each one
loop through each directory in a target directory
i thought this would be useful for backing up all files in the /var/www/html/ directory rather than having to do each seperately, this loops through all of them
add a class or remove it based on window scroll location
if you inspect the header div you will see a class added to it when scrolled down, i have added additional margins to it so you can still see it even when scrolled. then you add a fixed property to m..
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 ..
javascript window.onload
wait for the window to load and then run a function
adding pulsating dots to your css ul li list
get rid of those boring dots in your list and add some pulsation! See the Pen Pulsate your <ul><li> list item dots! by Luke (@kruxor) on CodePen.
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..
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..
hide parts of a form until the 1st item is selected
this code can be used when you just want to show the 1st field on a form then when it is selected it shows the rest of the form elements
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. ..
getting the site title vs the page name
this statement will check if the current page is the home page and show the get_bloginfo('name') if its another page in the site it will get that pages title using wp_title('')
add a tag to wordpress header from a plugin
when i googled this it just showed me plugins to add and remove things from the wordpress header. here is how you actually add your own tags to the wordpress header. This function will add the tag hi..
list items matching a category title
this is just raw at the moment, not tested or working. this is matching a category number at the moment so would need an additional way to link that number to the category name, or know what the categ..
fixing the website footer and making it less ugly
Here i show you in a couple of steps how to make the footer on this site look nicer, while actually doing it. Here is what the footer currently looks like. Yep pretty average looking. Lets add a ..
loading content into fancybox modal using ajax
This loads content into a fancybox modal using an ajax request so you can specify a url to load into the modal when the button is clicked
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..
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.
wp register plugin settings admin
for usage in a wordpress plugin, this will register its settings
fancybox modal popup example
an example showing fancybox text modal window attached to a button to open it
wordpress main nav dropdown fix
this unsets the flex and allows the menu items to stack properly in a dropdown menu, not sure if this is reusable
tar.gz to compress a directory in linux and then decompress it
a pretty common way to zip up contents in a directory into one (or technically two) archive(s). Add to tar.gz This will add the directory and all sub directories into the archive called the-archiv..
javascript isset equivalent
i was just looking for an equivalent to the isset in php for javascript, i was initially using .length but this can still cause errors so i found this solution. if (typeof my_var !== 'undefined') {}
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.
find and replace hrefs in existing page links using jquery
sometimes i have to do these things when you cant change the source files for some reason, usually due to old code. Its kind of a patch, but it works. The reason i had to add a delay in running the fu..
Use Sweet Alert rather than alert!
i love this script, it make the default alert look so much nicer, and its very easy to install. Just add the one script to your site, and then use Swal.fire rather than alert. simple usage Swal.fire..
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..
check if a timestamp is older than one hour
this will check if the timestamp string is less or more than one hour old.
Add a post date to your custom wordpress post listing
this is an example using: get_the_date: this one gets the post date the_excerpt: which gets the .. excerpt or summary text from the post and get_the_post_thumbnail_url which gets the image from th..
making var_dump look nice
i was var_dumping an array the other day, and it comes out like a massive string you cant read. a fast way to make this readable is just to add some pre tags to it.
use javascript to open a link in a new tab or window
im not sure why you would use this rather than using the html target="_blank" but it could be useful if you needed to open a new tab in a javascript function.
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.
Find Disk Space Usage using DU
The easiest way to check the space used in a directory in linux is this command: du -h This will do the current directory and all its sub directories. if you want to see a specific one type this d..
Load and Unload TinyMCE editor from a button
Enable TinyMCE Disable TinyMCE Some Content function load_tinymce(idclass) { tinymce.init({ selector: idclass, plugins: [ "spellchecker code aut..
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..
pulsating dots - glow glowing
a column of pulsing dots using css keyframes animation
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..
using css linear gradient for background overlays
a few examples using css linear gradient for the background
ES6 Nested Object Example
extracting variables from a nested object with new variable names
ES5 vs ES6 Object Example
here you can see the syntax changes between ES5 vs ES6 Object declaration, you can still access the values in the same way.
Use Recursion to Return a Range Array
using recursion to return a range array between the two numbers added
Use Recursion to Count Down
just a slight change to the count up version of this, using unshift rather than push to the array.
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.
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.
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..
how to unzip in linux
How to easily unzip in linux sudo apt install unzip unzip myzip.zip done.
php mysql table exists function
this checks if a mysql table already exists in the selected database and returns true or false
how to display a php file as html with php
you can use the following function to show a php source file as html
jquery add a click function if the window size is greater than target_width
this function will add a click event to the target if the window size is greater than the target_width
js using recursion to create a range of numbers
in this we will create a function that calls its self to add to an array a range of numbers