Instantly share code, notes, and snippets.

View HTML: List of entities
znak kl.zkratka Alt+# HTML kód název
" ---------- Alt+34 " uvozovka/quote
# Ctrl+Alt+X Alt+35 mřížka/hash/sharp
$ Ctrl+Alt+ů Alt+36 dollar
& Ctrl+Alt+C Alt+38 & ampersand
' ---------- Alt+39 ' apostrof
* Ctrl+Alt+- Alt+42 hvězdička/asterisk
/ ---------- Alt+47 / lomítko/slash
: ---------- Alt+58 dvojtečka/colon
View js-fns-prototypes.js
// stripslashes
String.prototype.stripslashes = function(){
return this.replace(/<.*?>/g, '');
};
String.prototype.htmlspecialchars = function(){
var str = this.replace(/&/g, '&amp;');
str = str.replace(/</g, '&lt;');
str = str.replace(/>/g, '&gt;');
str = str.replace(/"/g, '&quot;');
return str;
View zip-folder.php
<?
class zipuj_helper
{
protected $jmeno_zipu;
protected $root;
protected $zip;
public function __construct($root = ".", $jmeno_zipu = "zip.zip")
{
$this->root = $root;
$this->jmeno_zipu = $jmeno_zipu;
View unzip-folder.php
<?
$extract_dir = "./sprites/";
$extract_file = "sprites.zip";
$zip = new ZipArchive;
$res = $zip->open($extract_file);
if ($res === TRUE) {
$zip->extractTo($extract_dir);
$zip->close();
echo "OK";
} else {
View readable-filesize.php
<?
function HumanReadableFilesize($size) {
// Adapted from: http://www.php.net/manual/en/function.filesize.php
$mod = 1024;
$units = explode(' ','B KB MB GB TB PB');
for ($i = 0; $size > $mod; $i++) {
$size /= $mod;
}
return round($size, 2) . ' ' . $units[$i];
View csv-export.php
<?
$out = '';
$fields = dibi::fetchAll("SHOW COLUMNS FROM web_application");
foreach ($fields as $field)
{
$out .= '"'.$field->Field.'";';
}
$out = rtrim($out, ';');
$out .= PHP_EOL;
foreach ($this->model->csvExport() as $index => $row)
View jquery plugin function expression v2
1/
(function($){
$.extend({
jYoutube: function( url, size ){
if(url === null){ return ""; }
size = (size === null) ? "big" : size;
var vid;
var results;
results = url.match("[\\?&]v=([^&#]*)");
vid = ( results === null ) ? url : results[1];
View gist:6941782
<input onkeypress="return !isNaN(String.fromCharCode(event.charCode || event.keyCode))">
View gist:7008505
(function($) {
$.fn.extend({
check : function() {
return this.filter(":radio, :checkbox").attr("checked", true);
},
uncheck : function() {
return this.filter(":radio, :checkbox").removeAttr("checked");
}
});
}(jQuery));
View array of date range.php
<?php
function dateRange( $first, $last, $step = '+1 day', $format = 'Y/m/d' ) {
$dates = array();
$current = strtotime( $first );
$last = strtotime( $last );
while( $current <= $last ) {