Skip to content

Instantly share code, notes, and snippets.

View gentoid's full-sized avatar
😃

Viktor Lazarev gentoid

😃
View GitHub Profile
@gentoid
gentoid / highlight
Created February 10, 2013 19:41
Highlight text
function highlight(text, words, tag) {
// Default tag if no tag is provided
tag = tag || 'span';
var i, len = words.length, re;
for (i = 0; i < len; i++) {
// Global regex to highlight all matches
re = new RegExp(words[i], 'g');
if (re.test(text)) {
@gentoid
gentoid / breakPoint
Created February 10, 2013 19:38
Breakpoints for adaptive design
function isBreakPoint(bp) {
// The breakpoints that you set in your css
var bps = [320, 480, 768, 1024];
var w = $(window).width();
var min, max;
for (var i = 0, l = bps.length; i < l; i++) {
if (bps[i] === bp) {
min = bps[i-1] || 0;
max = bps[i];
break;
@gentoid
gentoid / callback.php
Created January 22, 2013 11:56
Is it HTTP_X_REQUESTED_WITH?
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') {
return;
}
@gentoid
gentoid / callback.php
Created January 22, 2013 11:56
json_encode. Workaround for PHP < 5.1.6
/**
* Workaround for PHP < 5.1.6
*/
if (!function_exists('json_encode')) {
function json_encode($data) {
switch ($type = gettype($data)) {
case 'NULL':
return 'null';
case 'boolean':
return ($data ? 'true' : 'false');
<?php
$modx = new modX();
$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
$modx->initialize('mgr');
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->exec("UPDATE {$modx->getTableName('modResource')} SET uri = '' WHERE uri_override = 0");
//$modx->call('modResource', 'refreshURIs', array(&$modx));
foreach ($modx->getIterator('modResource', $criteria) as $resource) {
@gentoid
gentoid / style.css
Created January 3, 2013 11:39
CSS3 Circle load rotator
/*** Loader ***/
.loader-ball1 {
background-color: rgba(0,0,0,0);
border:5px solid rgba(0,183,29,.9);
opacity:.5;
border-top:5px solid rgba(0,0,0,0);
border-left:5px solid rgba(0,0,0,0);
border-radius:50px;
box-shadow: 0 0 35px #009720;
width:50px;
<?php die('This file is not really here!');
/**
* ------------- DO NOT UPLOAD THIS FILE TO LIVE SERVER ---------------------
*
* Implements code completion for CodeIgniter in phpStorm
* phpStorm indexes all class constructs, so if this file is in the project it will be loaded.
* -------------------------------------------------------------------
* Drop the following file into a CI project in phpStorm
* You can put it in the project root and phpStorm will load it.