Skip to content

Instantly share code, notes, and snippets.

View muthu32's full-sized avatar

Muthu Kumar muthu32

  • Selvam Softech
  • TamilNadu
View GitHub Profile
@muthu32
muthu32 / Defer_loading_js_css.php
Last active December 13, 2016 09:51
Defer Loading Javascript & Css in pure javascript & PHP
<?php
/*
*This library will be used for speeding up website using defer loading of javascript & Css
*Made in pure javascript
async - javascript will be executed while loading the page.
defer - javascript will be executed after loading the page.
*/
//To include in Header files
$deferJs = "h1:{src:'/javascript/shop_general.js',async:1},h2:{src:'http://www.google-analytics.com/ga.js',async:1}";
//following script ussed to get data from td of Jquery Datatable.
$('#table tbody').on( 'click', 'td', function () {
var data = table.cell(this).data(); //td element data
var column = table.cell( this ).index().column; //column index
var row = table.row( this ).index(); // Row index
var rowid = $(this).closest('tr').attr('id'); //Get Row Id
var columnvisible = table.cell( this ).index().columnVisible //visble column index
} );
<a href="#0" class="cd-nav-trigger"><span></span></a>
<style>
.cd-nav-trigger span, .cd-nav-trigger span::before, .cd-nav-trigger span::after {
/* hamburger icon in CSS */
position: absolute;
height: 3px;
width: 24px;
background: #ffffff;
}
.cd-nav-trigger span::before {
<div class=" icon icon-like-off" style="width:50px;height:50px;">
</div>
<div class=" icon icon-like-on" style="width:50px;height:50px;">
</div>
<div class=" icon icon-friend-off" style="width:50px;height:50px;">
</div>
<div class=" icon icon-friend-on" style="width:50px;height:50px;">
function isValidDate(date)
{
var matches = /^(\d{1,2})[-\/](\d{1,2})[-\/](\d{4})$/.exec(date);
if (matches == null) return false;
var d = matches[1];
var m = matches[2] - 1;
var y = matches[3];
var composedDate = new Date(y, m, d);
return composedDate.getDate() == d &&
composedDate.getMonth() == m &&
<?php
class storage
{
protected $data;
public function __construct($data)
{
$this->data = $data;
}
@muthu32
muthu32 / Singleton design pattern
Last active January 13, 2018 06:03
Singleton design pattern and pool design pattern to increase efficiency of code
<?php
class produkt_pool
{
protected static $instance = array();
public static function get_instance($pid)
{
if(!isset(self::$instance[$pid]))
{
<html>
<head>
<title>Side by Side Element</title>
<style>
/*---------White space: no wrap Method---------*/
.parent {
white-space: nowrap;
width: 400px;
}
@muthu32
muthu32 / README.md
Created December 22, 2017 08:22 — forked from tmilos/README.md
Modified Preorder Tree Traversal

Modified Preorder Tree Traversal

Hierarchical data metrics that allows fast read operations on tree like structures.

Based on Left and Right fields that are set during tree traversal. When entered into node value is set to it's Left, when exiting node value is set to it's Right.

Sample implementation

@muthu32
muthu32 / PHP_week_functions.php
Last active January 2, 2018 13:25
php get week range
<?php
function weekrange($year, $i = 0)
{
$week = sprintf("%02d", $i);
$dto = new DateTime();
$dto->setISODate($year, $week);
$year2 = $dto->format('Y');
if ($year2 < $year) $st = '01-';
else $st = $dto->format('d') . "-";
$dto->modify('+6 days');