Skip to content

Instantly share code, notes, and snippets.

View yakubenko's full-sized avatar
👽
Eat. Sleep. Code.

Stanislav Yakubenko yakubenko

👽
Eat. Sleep. Code.
View GitHub Profile
@yakubenko
yakubenko / locations.php
Created August 23, 2016 05:44
Bitrix get locations group
<?php
function getLocationGroup() {
// из конфига config.php
global $defaultLocationsGroup;
$obCache = new CPHPCache;
if($obCache->InitCache(7200, "cities", "/klamas/all")) {
$locationsCache = $obCache->getVars();
$locations = $locationsCache['cities'];
@yakubenko
yakubenko / JTokensComponent.php
Last active April 2, 2018 06:49
Simple JWT component for CakePHP 3
<?php
namespace App\Controller\Component;
use Cake\Controller\Component;
use Cake\Utility\Security;
class JTokensComponent extends Component {
public $secretKey;
public $algorythm = "HS256";
public $type = "JWT";
public $payload = [];
@yakubenko
yakubenko / PasswordComponent.php
Created April 2, 2018 06:48
A password component for CakePHP 3. Allows generating a password which matches a given pattern.
<?php
namespace App\Controller\Component;
use Cake\Controller\Component;
use Cake\Auth\DefaultPasswordHasher;
class PasswordComponent extends Component {
public function generate() {
return $this->create_password('##CcC#C');
}
version: '3'
services:
apache:
build: ./apache/
ports:
- "8080:8080"
volumes:
- /your/path:/var/www/app/
nginx:
FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y apache2
RUN apt-get install -y php php-common php-cli php-mysql php-curl \
FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y nginx
RUN mkdir /var/www/app/
@yakubenko
yakubenko / geonames_postgres.rb
Created June 9, 2018 17:25 — forked from kaspergrubbe/geonames_postgres.rb
Import files from Geonames.com into a PostgreSQL database that runs Postgis
#!/usr/bin/env ruby
require 'open3'
require 'fileutils'
def run_command(command)
puts("+: " + command)
Open3.popen2e(command) do |stdin, stdout_stderr, wait_thread|
Thread.new do
stdout_stderr.each {|l| puts l }
<?php
namespace App\Database\Type;
use Cake\Database\Driver;
use Cake\Database\Type;
class FileType extends Type
{
/**
* Marshalls flat data into PHP objects.
@yakubenko
yakubenko / myjs.js
Created June 27, 2018 07:01
JS gems
// get a string representation of the client's timezone
console.log(Intl.DateTimeFormat().resolvedOptions().timeZone);
<?php
return [
'inputContainer' => '<div class="form-group {{required}}">{{content}}<small class="form-text text-muted">{{help}}</small></div>',
'inputContainerError' => '<div class="form-group {{required}} error">{{content}}<small class="form-text text-muted">{{help}}</small>{{error}}</div>',
'error' => '<div class="invalid-field">{{content}}</div>',
'input' => '<input type="{{type}}" class="form-control" name="{{name}}"{{attrs}} />',
// 'checkbox' => '<input type="checkbox" class="form-check-input" name="{{name}}" value="{{value}}"{{attrs}}>',
'checkboxFormGroup' => '<div class="form-check">{{label}}</div>',
'checkboxWrapper' => '<div class="form-check">{{label}}</div>',
'nestingLabel' => '{{hidden}}{{input}}<label {{attrs}}>{{text}}</label>',