Skip to content

Instantly share code, notes, and snippets.

View vlastv's full-sized avatar

Vladislav Vlastovskiy vlastv

View GitHub Profile
@vlastv
vlastv / function.inc.php
Last active December 17, 2015 08:49
NetCat CMS extendsRequirments: PHP >= 5.3
<?php
function jm_cc_link($cc, $action = 'index', $absolute = false)
{
static $storage;
global $db;
$storageKey = serialize(func_get_args());
@vlastv
vlastv / app.php
Last active December 20, 2015 12:19
<?php
use Symfony\Component\HttpFoundation\Request;
$loader = require_once __DIR__.'/../app/autoload.php';
require_once __DIR__.'/../app/AppKernel.php';
//require_once __DIR__.'/../app/AppCache.php';
$kernel = new AppKernel('prod', false);
334NH-RXG76-64THK-C7CKG-D3VPT
XHQ8N-C3MCJ-RQXB6-WCHYG-C9WKB
M9Q9P-WNJJT-6PXPY-DWX8H-6XWKK
GCRJD-8NW9H-F2CDX-CCM8D-9D6T9
Y9NXP-XT8MV-PT9TG-97CT3-9D6TC
BB6NG-PQ82V-VRDPW-8XVD2-V8P66
PPBKC-NQYJM-JJ8X6-26W42-VFQ4R
@vlastv
vlastv / pn.js
Created March 23, 2015 09:29
Phone Number
/* <meta content="telephone=no" name="format-detection"> */
(function(a){window.isMobile = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|i
@vlastv
vlastv / node.docker
Last active November 1, 2016 19:22
Docker for npm on Mac OS X
#!/bin/sh
set -e
set -- npm "$@"
docker run -it --rm \
-v cache:/root/.npm \
-v $(pwd):/usr/src/app \
-v $HOME/.ssh:/root/.ssh \
-w /usr/src/app \
@vlastv
vlastv / mysqlfkc.php
Last active November 24, 2015 13:45
Simple script for checking foreign keys consistent
<?php
/**
* usage:
* php mysqlfkc.php mysql://user:pass@host/database
*/
require_once 'vendor/autoload.php';
$conn = \Doctrine\DBAL\DriverManager::getConnection([
@vlastv
vlastv / hook.html
Created March 15, 2017 14:07
Duplicate all Google Analytics hits
<script>
(function (window, variable, task) {
window['GoogleAnalyticsObject'] = variable;
window[variable] = window[variable] || function () {
(window[variable].q = window[variable].q || []).push(arguments);
if (arguments[0] === "create") {
window[variable]((arguments[2] && arguments[2].name || "t0") + ".require", "duplicator");
}
};
@vlastv
vlastv / stats.php
Created June 23, 2017 08:25
PHP Stats
<?php
function median(array $elements, $offset = 0, $length = null)
{
if ($length === null) {
$length = count($elements)-$offset;
}
sort($elements);
$half = $offset + ((int)floor(($length - 1) / 2));
@vlastv
vlastv / Dockerfile
Created November 28, 2017 11:06
docker manticoresoftware/manticore:alpine
FROM alpine
RUN set -ex; \
\
apk add --no-cache --virtual .build-deps \
coreutils \
git \
cmake \
make \
g++ \
@vlastv
vlastv / test.php
Last active December 21, 2017 12:43
<?php
class BalanceTransaction
{
public function __construct(User $user, $amount, $reason)
{
$this->updateReason($reason);
}
protected function updateReason($reason)