List Code

Showing page 3 of 9 in latest. Total Items: 436
A Collection of Code
javascript
Use Recursion to Count Up
...

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

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

10:06 pm, January 28, 2020
wordpress
get the stylesheet directory in wordpress theme
...

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

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

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

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

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

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

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

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

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

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

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

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

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

enable and disable an element

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

5:14 am, October 1, 2019
javascript
Writing Arrow Functions with Parameters
...

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

12:36 am, October 1, 2019
javascript
using arrow functions to convert small functions into one line statement functions
...

in this exercise i will take a function variable and write it in one line using the arrow function

12:09 am, October 1, 2019
javascript
Prevent Object Mutation
...

This shows how you can lock an object so its content cannot be modified. if you comment out the line Object.freeze(my_object); it will allow it to be modified again.

11:16 pm, September 30, 2019
javascript
Changing an array declared with const
...

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

6:17 am, September 30, 2019
php
return a state name from an australian postcode
...

this will return an australian state code based on the postcode, so you can enter a valid postcode and see which state it belongs too. e.g: 2000 should return NSW

11:25 pm, September 29, 2019
javascript
using let and const example
...

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

4:55 am, September 27, 2019
javascript
using let rather than var
...

Using let rather than var and use strict can avoid some overwriting of variables i will write a function here that shows how let throws an error. This function now gives an error in the console. Uncau..

4:18 am, September 27, 2019
javascript
Use Multiple Conditional (Ternary) Operators
...

I actually find if then statements much easier to read than these ones, but these seem more efficient. 

3:18 am, September 27, 2019
javascript
js - Use the Conditional (Ternary) Operator
...

this statement can be used instead of if this else that statements. to me it makes it look a bit more complex when reading it. this is the basic syntax. condition ? statement-if-true : statement-if-fa..

6:23 am, September 24, 2019
javascript
Use the parseInt Function with a Radix
...

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

6:14 am, September 24, 2019
javascript
Using parseInt in a function to return an integer or not
...

this function uses the parseInt function to return a proper integer or an error code if it can't. So this demo should return NaN for the Not an Int (x1235) and The int for the 00001235. I think that N..

5:57 am, September 24, 2019
javascript
Generate Random Whole Numbers within a Range
...

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

5:15 am, September 24, 2019
javascript
split a string into an array using split javascript
...

this will split the string into an array based on the spaces inbetween words. you can split it based on any character, for example if you had words in csv comma format you could use the second example..

4:47 am, September 16, 2019
javascript
get the current url in javascript
...

this will get the current address add it to a variable and show it on the result element

3:47 am, September 13, 2019
css
Custom 12 Grid using CSS Grid
...

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

2:19 am, September 6, 2019
html
template for testing and live reloading html files
...

this is a template that i use while testing flat html files, if you add it to a server it will live reload. this does seem to cause issues depending on the site that is is used on, like reloading all ..

3:27 am, September 4, 2019
css
Radial Click Effect
...

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

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

generate a random whole number function with test buttons

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

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

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

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

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

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

3:27 am, August 26, 2019
javascript
Do While Loop
...

showing how to use a do while loop, i don't use these ones very often usually just a for loop.

11:26 pm, August 25, 2019
javascript
for loop through an array with javascript
...

looping through an array with javascript using a basic for loop

12:18 am, August 23, 2019
php
get the average of a number list using an array in php
...

get the average of a array of numbers

12:48 am, August 21, 2019
sublime
sublime text find and replace style tag
...

good if you have inline styles you want to remove using regex find and replace. in sublime press ctrl + H to do find and replace then paste in the style="([^

12:43 am, August 19, 2019
javascript
tinymce remove auto p tags setting
...

this is the setting to remove the automatic p tag's when pressing enter and forces the use of br tags instead which can also be toggled, if you dont want it to add anything.

6:15 am, August 13, 2019
javascript
get the dimensions of an image with javascript
...

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

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

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

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

showing an example of chevron toggles kinda like a manual accordion

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

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

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

moving a background with css keyframes

12:27 am, August 6, 2019
Welcome

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

âĪðŸ‘Đ‍ðŸ’ŧðŸ•đ

Random Quote
time you enjoyed wasting is not wasted time
Unknown