Skip to content

Instantly share code, notes, and snippets.

@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 / Router.php
Created August 28, 2014 13:52
Simple router class for small and medium projects
<?php
/**
* Class Router is static class which serves for routing purposes and can be used in 2 modes: full-map and on-the-go.
*
* Reads request uri path from $_GET['_REQUEST_URI']
*/
namespace _\web;
@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) {
@meglio
meglio / wp-restrictions
Created February 14, 2015 03:23
wp-restrictions
# Global restrictions configuration file.
# Designed to be included in any server {} block.
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
@meglio
meglio / wp-single
Created February 14, 2015 03:24
wp-single
# WordPress single blog rules.
# Designed to be included in any server {} block.
index index.php;
# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
@meglio
meglio / wp-nginx
Created February 14, 2015 03:25
wp-nginx
# WWW HTTP -> non-WWW
server {
listen 80;
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
server {
listen 80;
@meglio
meglio / blank_server.sh
Last active August 29, 2015 14:15
Blank Server
# Add locale to the list of generated locales
echo ru_RU.UTF-8 UTF-8 >> /var/lib/locales/supported.d/local
# Regenerate list (it will invoke locale-gen...)
dpkg-reconfigure locales
# Set default passwords for mysql
# TODO: Setting blank password does not work (?)
debconf-set-selections <<< 'mysql-server mysql-server/root_password password'
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password'