Skip to content

Instantly share code, notes, and snippets.

View win0err's full-sized avatar
⌨️
Sergei is typing...

Sergei Kolesnikov win0err

⌨️
Sergei is typing...
View GitHub Profile
@win0err
win0err / habratest.php
Last active September 3, 2017 11:23
Тест различных циклов в PHP на время выполнения и потребление памяти
<?php
echo 'PHP ' . phpversion() . PHP_EOL . PHP_EOL;
$test = [];
for($i = 0; $i < 100000; $i++)
$test[$i] = $i;
process_test(function() use ($test) {
foreach($test as $t)
#!/usr/bin/env sh
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.tar.xz) tar xvfJ $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
@win0err
win0err / pre-commit
Created September 21, 2017 23:30
A git hook for php-cs-fixer
#!/usr/bin/env php
<?php
exec('git diff --cached --name-only', $stagedFiles);
$fixedFiles = [];
foreach ($stagedFiles as $fileName) {
if (preg_match('/\.php$/', $fileName) && is_file($fileName)) {
exec(sprintf('php-cs-fixer fix %s -q', $fileName), $output, $exitCode);
import java.awt.Color;
import java.awt.Robot;
import java.awt.AWTException;
import java.awt.MouseInfo;
import java.awt.Point;
public class ColorPicker {
public static void main(String[] args) {

Keybase proof

I hereby claim:

  • I am win0err on github.
  • I am win0err (https://keybase.io/win0err) on keybase.
  • I have a public key ASBtc0DCpdjb3oFq3rZMjx2i_75fYLN9p3sLte7Q9pslFwo

To claim this, I am signing this object:

import axios from 'axios';
// parameterize :: replace substring in string by template
// parameterize :: Object -> String -> String
// parameterize :: {userId: '123'} -> '/users/:userId/activate' -> '/users/123/activate'
const parameterize = (url, urlParameters) => Object.entries(urlParameters)
.reduce(
(a, [key, value]) => a.replace(`:${key}`, value),
url,
@win0err
win0err / block_jorgee.sh
Last active February 9, 2021 07:10
Blocks IPs from Jorgee Security Scanner searching for vulnerabilities on a server
#!/usr/bin/env bash
printf "Searching in Apache2 and nginx access logs for Jorgee's scans";
zcat -f /var/log/{apache2,nginx}/access.*\
| grep Jorgee \
| grep -oE '^([0-9]{1,}\.){3}[0-9]{1,}' \
| sort -n \
| uniq \
| awk '{ system("iptables -A INPUT -s " $0 " -j DROP"); printf "."; }'
@win0err
win0err / gamecontrollerdb
Last active April 23, 2022 15:03
PS5 Controller Layout for GNOME Games (~/.var/app/org.gnome.Games/config/libmanette/gamecontrollerdb)
030000004c050000e60c000011810000,Sony Interactive Entertainment Wireless Controller,platform:Linux,b:b1,a:b0,x:b3,y:b2,start:b9,guide:b10,back:b8,leftstick:b11,rightstick:b12,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,
@win0err
win0err / 1.sql
Created February 11, 2018 21:13
Продвинутая работа с JSON в MySQL – https://habrahabr.ru/post/348854/
SELECT * FROM `players`;
+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------+
| id | player_and_games | names_virtual |
+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------+
| 1 | {"id": 1, "name": "Sally", "games_played": {"Puzzler": {"time": 7}, "Battlefield": {"rank": "Sergeant V", "level": 20, "weapon": "sniper rifle"}, "Crazy Tennis": {"won": 4, "lost": 1}}} | Sally |
| 2 | {"id": 2, "name": "Thom", "games_played": {"Puzzler": {"time": 25}, "Battlefiel
@win0err
win0err / fedora-install-raw-thumbnailer.sh
Created February 19, 2023 22:54
Display .NEF (RAW) thumbnails in Gnome's Nautilus — Fedora
sudo dnf install libopenraw-gnome libopenraw libopenraw-pixbuf-loader raw-thumbnailer