Skip to content

Instantly share code, notes, and snippets.

@lrusev
lrusev / swagger-yaml-to-html.py
Last active January 2, 2019 12:02 — forked from oseiskar/swagger-yaml-to-html.py
Converts Swagger YAML to a static HTML document (needs: pip install PyYAML)
#!/usr/bin/python
"""
Usage:
python swagger-yaml-to-html.py < /path/to/api.yaml > doc.html
"""
import yaml, json, sys
TEMPLATE = """
@lrusev
lrusev / array-validation-error-mapping.php
Created June 27, 2018 07:30 — forked from webmozart/array-validation-error-mapping.php
A little experiment: Validating (potentially multi-leveled) arrays with the Symfony2 Validator component and returning the errors in the same data structure as the validated array by using the Symfony2 PropertyAccess component.
<?php
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\Validator\Constraints\All;
use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\Collection;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Optional;
use Symfony\Component\Validator\Constraints\Required;
@lrusev
lrusev / example.puml
Created July 20, 2017 11:43 — forked from QuantumGhost/example.puml
A simple template for PlantUML to draw ER diagram. The basic idea comes from http://plantuml.sourceforge.net/qa/?qa=331/database-modeling
@startuml
' uncomment the line below if you're using computer with a retina display
' skinparam dpi 300
!define Table(name,desc) class name as "desc" << (T,#FFAAAA) >>
' we use bold for primary key
' green color for unique
' and underscore for not_null
!define primary_key(x) <b>x</b>
!define unique(x) <color:green>x</color>
!define not_null(x) <u>x</u>
@lrusev
lrusev / phpcs.xml
Last active December 13, 2016 11:00
PHP coding styles rules
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Custom">
<description>Project Coding Standard</description>
<rule ref="PSR2" />
<rule ref="~/.composer/vendor/object-calisthenics/phpcs-calisthenics-rules/ObjectCalisthenics/ruleset.xml"/>
</ruleset>
{
"require": {
"laravel/lumen-installer": "~1.0",
"phpunit/phpunit": "^4.6",
"phpmetrics/phpmetrics": "*",
"hirak/prestissimo": "*",
"sebastian/phpcpd": "*",
"sebastian/phpdcd": "*",
"phpmd/phpmd": "*",
"squizlabs/php_codesniffer": "*",
{
"bitwise" : true,
"camelcase" : true,
"curly" : true,
"eqeqeq" : true,
"forin" : true,
"immed" : true,
"indent" : 4,
"latedef" : true,
"newcap" : true,
@lrusev
lrusev / vimrc
Last active December 28, 2016 00:17
set rtp+=~/.vim/bundle/vundle/
call vundle#begin()
" let vundle manage vundle
Plugin 'gmarik/vundle'
" Bundle 'Shougo/vimproc'
" Bundle 'Shougo/unite.vim'
" Bundle 'm2mdas/phpcomplete-extended'
" list all plugins that you'd like to install here
Plugin 'kien/ctrlp.vim' " fuzzy find files
@lrusev
lrusev / zshrc
Last active October 27, 2016 19:00
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/home/lgrusev/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="robbyrussell"
@lrusev
lrusev / tmux.conf
Last active December 11, 2016 00:52
# use UTF8
set -g utf8
set-window-option -g utf8 on
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# 0 is too far from ` ;)
set -g base-index 1
@lrusev
lrusev / latency.txt
Created October 17, 2016 11:53 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD