test if javascript is enabled or disabled

<script>document.write('Code here for JavaScript enabled')</script>

<noscript>Code here for JavaScript disabled</noscript>

change checkbox style with css

<link rel="stylesheet" type="text/css" href="style.css">

  <h3>Checkbox Blue</h3>
    <div class="checkboxBlue">
      <input type="checkbox" value="1" id="checkboxBlueInput" name=""/>
      <label for="checkboxBlueInput"></label>

/* Start by hiding the checkboxes */
input[type=checkbox] {
    visibility: hidden;

/* Checkbox Blue */
.checkboxBlue {
    width: 40px;
    height: 40px;
    background: #ddd;
    margin: 20px 90px;

    border-radius: 100%;
    position: relative;
    box-shadow: 0px 1px 3px rgba(0,0,0,0.5);

/* Create the checkbox button */
.checkboxBlue label {
    display: block;
    width: 30px;
    height: 30px;
    border-radius: 100px;

    transition: all .5s ease;
    cursor: pointer;
    position: absolute;
    top: 5px;
    left: 5px;
    z-index: 1;

    background: white;
    box-shadow:inset 0px 1px 3px rgba(0,0,0,0.5);

/* Create the checked state */
.checkboxBlue input[type=checkbox]:checked + label {
    background: #80e5ff;

Source: https://paulund.co.uk/style-checkboxes-with-css

create delay for a event in jquery

<script src="jquery-3.3.1.min.js"></script>

<input id=name placeholder="name" type="text">
<input id=age placeholder="age" type="text">
<input type="submit">
<script type="text/javascript">
var delay = (function(){
  var timer = 0;
  return function(callback, ms){
    clearTimeout (timer);
    timer = setTimeout(callback, ms);

$("#name, #age").on('keyup', function() { 
  console.log('without delay');
    console.log('with delay');
  }, 3000 );

get page load time in php

//put this on begin of file 
$load_time_page_start = microtime( true );

//put this on end of file 
echo 'Total execution time in seconds: ', ( microtime( true ) - $load_time_page_start );

save and restore array in file with php

$arr = ['a', 'b', 'c' => 'd'];

// save array in json file 
file_put_contents( '/tmp/json.array', json_encode( $arr ) );

// restore array in json file
$restore = json_decode( file_get_contents( '/tmp/json.array' ), true );

encode and decode array to json php

// raw array
echo "\t", 'raw array', "\n\n";
$arr = ['a', 'b', 'c' => 'd'];
echo '$arr output: '; print_r( $arr );

// encode array
echo "\t", 'encode array', "\n";
$arr_enc = json_encode( $arr );
echo "\n", 'encode array output: '; print_r( $arr_enc ); echo "\n\n";

// decode array
echo "\t", 'decode array', "\n\n";
echo 'array decode output: '; print_r( json_decode( $arr_enc ) ); echo "\n";
echo 'get some values: ', json_decode( $arr_enc )->{0}, ' ', json_decode( $arr_enc )->{'c'}, "\n\n";
echo 'get all values: ';
foreach( json_decode( $arr_enc ) as $value ) echo $value, ' ';

for every x lines insert new line with sed

for every 7 lines insert a blank line

sed '0~7G' file

for every 7 lines insert a new line with string

sed '0~7G; s/\n/\n\tstringHere/' file