Skip to content

Instantly share code, notes, and snippets.

@meglio
meglio / saved.css
Created January 31, 2014 12:14
Creates a nice caption which disappears with animation like on this video: http://www.screenr.com/4xmH - useful for "Saved" notifications over "Save" buttons etc.
.action-success {
position: absolute;
z-index: 1000;
color: green;
border: 1px dashed green;
background-color: rgba(255,255,255,0.5);
font-size: 14px;
padding: 2px 4px;
border-radius: 8px;
text-align: center;
@meglio
meglio / denis-x.js
Last active August 29, 2015 13:56
Denis' generic utils for JS
RegExp.escape = function (text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
}
if (!Math.sqr) {
Math.sqr = function (x) {
return x * x;
}
}
<?php
# Autoload that works only with _ namespace
if (!spl_autoload_register(function ($class) {
if (substr($class, 0, 2) !== '_\\')
return;
$class = (string)str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 2));
$file = ROOT_PATH . '/_core/' . $class . '.php';
if (file_exists($file))
include $file;
<?php
# Router:
R::route('GET|POST', '/ajax', '\_\web\Ajax::processAjaxCall');
# Handler method:
static function processAjaxCall()
<?php
namespace _\lang;
trait Classes
{
static function fullClassName()
{
return __CLASS__;
@meglio
meglio / affx-api-documentation-example
Created August 27, 2014 14:07
API documentation example
# API ACCESS
* Access Point: http://affiliatex.com/api
* All fields must be passed in POST variables; GET variables will be ignored.
* You will have to retrieve a secret key in order to use AffiliateX API.
# API RESPONSE FORMAT
The response will be always JSON-encoded.
@meglio
meglio / Eway.php
Created August 28, 2014 13:49
Integration with eWay payment system
<?php
namespace _\integrations;
use _\Curl;
use _\lang\Arr;
use _\lang\Lazy;
use RuntimeException;
@meglio
meglio / Lazy.php
Created August 28, 2014 13:51
Simple but powerful class that allows for easy static and per-instance parametrized lazy value storage
<?php
namespace _\lang;
use ReflectionFunction;
use RuntimeException;
/**
* Trait Lazy
*
@meglio
meglio / act-type-input.js
Created August 28, 2014 14:00
JS component used in notarzvit.com for fast multi-word binary tree search of notary act type names
function ActiveActsBranch()
{
// { actTypes: ..., searchTree: ... }
var meta = null
this.load = function(callback)
{
if (typeof activeActsBranchTimestamp !== "undefined" && activeActsBranchTimestamp && $.jStorage.storageAvailable())
{
var savedTimestamp = $.jStorage.get('activeActsBranchTimestamp', null)
@meglio
meglio / ajax-items.js
Created August 28, 2014 14:17
JS component to allow for inline edition of CRM items in admin panels through inline dialogs.
function AjaxItems($container, config) {
var defaultOpts = {
textNoItems: "Не знайдено",
removalActionClass: "actionRemove",
removalDialog: function(el) { return confirm('Видалити?') },
showNoItems: function($container, message) {
$container.empty().append( $div().text(message) )
},
// If you want item removal to be handled, add an element with class .actionRemove (or another specified in removalActionClass option)
itemDom: function(el) {