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 / Cache.php
Created February 23, 2018 05:55
Cache headers for images
header('Content-Type: image/png');
$modified = $ch->lastmodified();
if($modified)
{
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $modified)
{
header('HTTP/1.0 304 Not Modified'); exit();
}
//echo $modified;
header('Last-Modified: ' .gmdate('D, d M Y H:i:s T', $modified).' GMT');
#
# Apache/PHP/Drupal settings:
#
# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig\.save)$">
Order allow,deny
</FilesMatch>
# Don't show directory listings for URLs which map to a directory.
Google Suggestion
//Old format
http://suggestqueries.google.com/complete/search?hl=sv&output=toolbar&q=vxthus
//new format
http://clients1.google.com/complete/search?hl=sv&output=toolbar&q=vxthus
//Suspicious
https://www.google.se/complete/search?client=psy-ab&hl=en-IN&tok=0&q=droppslanga
//Select class selector
//select option by index
$('#frakt_type option:eq(0)').prop("selected",true);
//select option by value
$('#frakt_type option[value="'+4+'"]').prop("selected",true);
//Select option by contains
$('#frakt_type option:contains("find_text")').prop("selected",true);
<?php
* This demo is partly based on a post by Anthony Sterling on the sitepoint forum.
* It is partly based on a video by John Lebensold of killerphp.com
*
* http://www.sitepoint.com/forums/showthread.php?t=636303
*
* AnthonySterling
* Twitter: @AnthonySterling
*
* Here's a rather ridiculous, yet interesting way to use __call.
@muthu32
muthu32 / jqm-indexedDB-example.html
Created January 3, 2018 09:23 — forked from greenido/jqm-indexedDB-example.html
indexedDB with jquerymobile - example 1
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Short example on using indexedDB with jquery mobile - last updated: May 2012">
<meta name="author" content="Ido Green">
<title>IndexedDB with JQM</title>
@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');
@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

<html>
<head>
<title>Side by Side Element</title>
<style>
/*---------White space: no wrap Method---------*/
.parent {
white-space: nowrap;
width: 400px;
}
@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]))
{