This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$path = '/home/someuser/products/data.tar.gz'; // the file made available for download via this PHP file | |
$mm_type="application/octet-stream"; // modify accordingly to the file type of $path, but in most cases no need to do so | |
header("Pragma: public"); | |
header("Expires: 0"); | |
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); | |
header("Cache-Control: public"); | |
header("Content-Description: File Transfer"); | |
header("Content-Type: " . $mm_type); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_day_name($timestamp) { | |
$date = date('d/m/Y', $timestamp); | |
if($date == date('d/m/Y')) { | |
$day_name = 'Today'; | |
} else if($date == date('d/m/Y',now() - (24 * 60 * 60))) { | |
$day_name = 'Yesterday'; | |
} | |
return $date; | |
} | |
print date('G:i:s', $last_access).' '.get_day_name($last_access); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Basic True / False Declaration | |
$is_admin = ($user['permissions'] == 'admin' ? true : false); | |
//Conditional Welcome Message | |
echo 'Welcome '.($user['is_logged_in'] ? $user['first_name'] : 'Guest').'!'; | |
//Conditional Items Message | |
echo 'Your cart contains '.$num_items.' item'.($num_items != 1 ? 's' : '').'.'; | |
//Conditional Error Reporting Level | |
error_reporting($WEBSITE_IS_LIVE ? 0 : E_STRICT); | |
//Conditional Basepath |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remove duplicates from DOM (not done yet) | |
function remDuplicates() { | |
var seen = {}; | |
$('td.group').each(function() { | |
var txt = $(this).text(); | |
if (seen[txt]) | |
$(this).empty(); | |
else | |
seen[txt] = true; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
/** | |
* @constructor | |
*/ | |
Commands = function() { | |
this.undoStack = []; | |
this.redoStack = []; | |
}; | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function load(_this, init){ | |
var name = generateName(_this); | |
var type = _this.attr('type'); | |
if(!type) | |
type = _this.prop("tagName"); | |
if(!init && type != 'radio' && type != 'checkbox') | |
localStorage.setItem(name, _this.val()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (jQuery) | |
(function(jQuery){ | |
jQuery.extend(jQuery.fn, { | |
record: function(options){ | |
jQuery(this).each(function(){ | |
var settings = jQuery.extend({ | |
}, options); | |
var _this = $(this); | |
load(_this, true); | |
_this.on('blur change', function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
'use strict'; | |
$.fn.math = function (operation, a, b) { | |
return this.each(function () { | |
var result = 0; | |
switch(operation){ | |
case '+': | |
result = a + b; | |
break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//You're trying to match a text attribute that does not exist. You cannot write: | |
$("#Select0 option[text='" + myText + "']").get(0).selected = true; | |
You can use filter() instead: | |
$("#Select0 option").filter(function() { | |
return $(this).text() == myText; | |
}).get(0).selected = true; | |
//Or, taking more advantage of the library: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-----BEGIN PGP SIGNED MESSAGE----- | |
Hash: SHA1 | |
// Generated on: 2012-04-13 23:44:46 GMT+00:00 | |
// ************** Tweet 1 of 47455 ************** | |
{ | |
"in_reply_to_screen_name": null, |