Skip to content

Instantly share code, notes, and snippets.

View Ulv's full-sized avatar
🤔
Working

Ulv Ulv

🤔
Working
View GitHub Profile
@Ulv
Ulv / mime-types.php
Created October 24, 2012 16:42
mime types
// Atom
header('Content-type: application/atom+xml');
// CSS
header('Content-type: text/css');
// Javascript
header('Content-type: text/javascript');
//JPEG Image
header('Content-type: image/jpeg');
//JSON
header('Content-type: application/json');
# all php files :: disallow direct access of file
# between <?php and ?>
defined('_JEXEC') or die;
# index.php :: define variable with application
# between <?php and ?>
$app = JFactory::getApplication();
# index.php :: define variable with document
# between <?php and ?>
@Ulv
Ulv / htmlform.php
Created June 27, 2013 16:58
парсит формы html, вынимает input text. input hidden и textarea. Возвращает массив объектов form
/**
* парсит формы в html. Выбирает input[type=text], input[type=hidden] и textarea
*
* @return массив объектов form()
*/
public function extract()
{
$dom = new DOMDocument();
$dom->loadXML(self::$saw->get('form')->toXml());
$xpath = new DOMXPath($dom);
@Ulv
Ulv / htmlform.php
Created June 27, 2013 16:59
объект form. Содержит спарсенные данные html формы
/**
* Class form
* just a container
*/
class form implements IteratorAggregate
{
private $_formAction;
private $_formMethod;
private $_inputs;
@Ulv
Ulv / joomla add trailing slashes to urls
Created August 16, 2013 08:08
Joomla router patch for adding trailing slashes to generated urls
*** 397,403 ****
//Set query again in the URI
$uri->setQuery($query);
! $uri->setPath($route);
}
protected function _processParseRules(&$uri)
--- 397,403 ----
@Ulv
Ulv / script.js
Created November 1, 2013 10:53
disable selection in html page
document.body.onselectstart = function () {
return false;
}
@Ulv
Ulv / script.js
Created November 1, 2013 10:53
disable mouse right click
document.onmousedown = function(event) {
if (event.button == 2) {
return false;
}
}
@Ulv
Ulv / script.js
Created November 1, 2013 10:54
async load css files. Usage: require('style.css');
function asyncInject(array, fn, delay) {
var i = 0;
window.setTimeout(function iter() {
if (i === array.length) {
return;
}
fn.call(array, array[i], i++);
window.setTimeout(iter, delay);
}, 0);
}
@Ulv
Ulv / script.js
Created November 1, 2013 10:55
lazy load images. No jQuery or such req.
window.echo = (function (window, document) {
'use strict';
var Echo = function (elem) {
this.elem = elem;
this.render();
this.listen();
};
var echoStore = [];
@Ulv
Ulv / _a_clear_log.php
Created November 13, 2013 10:51
masterovoy clear db queries & recalculate stats
$queries = array(
'delete from `s_robots_log` where YEAR(dtlabel) <> YEAR(CURDATE())',
'delete from `s_visits_log` where YEAR(dtlabel) <> YEAR(CURDATE())',
'truncate table `s_robots_stat`',
// 'truncate table `s_visits_stat`',
'truncate table a_ua_ranges',
'truncate table a_log',
'truncate table a_http_error',
// restore stats