Skip to content

Instantly share code, notes, and snippets.

View stmn's full-sized avatar

stmn

  • Self-employed
  • 02:28 (UTC +02:00)
View GitHub Profile
@stmn
stmn / layer7protection.php
Last active August 29, 2015 14:06
Layer 7 Protection / Simple DDoS Protection
<?php
$key = "La1az>T.}+w:uMoZ"; // CHANGE THIS STRING
$code = md5($_SERVER['REMOTE_ADDR'].$_SERVER['HTTP_HOST'].$key);
$cookie = isset($_COOKIE['l7code']) ? $_COOKIE['l7code'] : FALSE ;
$ignored_uri = array();
$ignore = false;
foreach($ignored_uri as $u){
@stmn
stmn / gist:97cd53f1518b4a66ece8
Created March 6, 2015 13:46
My function to handle animate.css
function animate(selector, animation, after, reset){
var $selector = $(selector);
setTimeout(function(){
if(typeof reset == 'undefined'){
reset = true;
}
$selector.addClass('animated '+animation).show();
if(typeof after != 'undefined'){
@stmn
stmn / gist:5009c759444b915bce9e
Created April 20, 2015 00:13
Page / tab visibility
(function() {
var hidden = "hidden";
// Standards:
if (hidden in document)
document.addEventListener("visibilitychange", onchange);
else if ((hidden = "mozHidden") in document)
document.addEventListener("mozvisibilitychange", onchange);
else if ((hidden = "webkitHidden") in document)
document.addEventListener("webkitvisibilitychange", onchange);
@stmn
stmn / gist:b9ce60d4e4ebcbd33ff4
Last active August 29, 2015 14:20
How to run vagrant by executable *.bat file / autorun / windows
if not "%minimized%"=="" goto :minimized
set minimized=true
start /min cmd /C "%~dpnx0"
goto :EOF
:minimized
F:
cd F:\my_directory\my_vagrant
vagrant up
@stmn
stmn / phpstorm.bat
Created November 29, 2015 15:30
How to run PhpStorm project through batch file
FOR /F "skip=2 tokens=2,*" %%A IN ('reg.exe query "HKEY_CLASSES_ROOT\Applications\PhpStorm.exe\shell\open\command" /ve') DO ( SET PHPSTORM_PATH=%%B )
SET PHPSTORM_PATH=%PHPSTORM_PATH:"%1"=%
START "" "%PHPSTORM_PATH%" %~dp0
@stmn
stmn / slug.function.php
Last active May 23, 2017 14:08
Functions to generate slug text pulled from Kohana Framework [*]. Many other solutions in whole web sucks for me but this always worked.
function slug($title, $separator = '-', $ascii_only = FALSE)
{
if ($ascii_only === TRUE)
{
// Transliterate non-ASCII characters
$title = _transliterate_to_ascii($title);
// Remove all characters that are not the separator, a-z, 0-9, or whitespace
$title = preg_replace('![^'.preg_quote($separator).'a-z0-9\s]+!', '', strtolower($title));
}
@stmn
stmn / bitbucket-pipelines.yml
Created February 14, 2021 22:33
Bitbucket pipelines with deployer
image: php:7.3-fpm
pipelines:
default:
- step:
name: Node Build
image: node:14.15
caches:
- node
script:
@stmn
stmn / game.js
Last active February 12, 2022 19:27
k.z() problem
import kaboom from "kaboom";
const k = kaboom({
canvas: document.getElementById('canvas'),
})
k.loadSpriteAtlas("./assets/sprites/Tileset.png", {
'traps': {
x: 0,
y: 0,
@stmn
stmn / kody-pocztowe.sql
Last active April 12, 2022 00:32
Stara lista kodów pocztowych w formie zapytania SQL. Jeśli chcesz mieć aktualną to sparsuj ten plik: https://www.poczta-polska.pl/hermes/uploads/2013/11/spispna.pdf
This file has been truncated, but you can view the full file.
INSERT INTO cities_details(post_code, val, voivodeship, county, community) VALUES ('00-002', 'Warszawa', ' mazowieckie', ' Warszawa', ' Warszawa');
INSERT INTO cities_details(post_code, val, voivodeship, county, community) VALUES ('00-003', 'Warszawa', ' mazowieckie', ' Warszawa', ' Warszawa');
INSERT INTO cities_details(post_code, val, voivodeship, county, community) VALUES ('00-004', 'Warszawa', ' mazowieckie', ' Warszawa', ' Warszawa');
INSERT INTO cities_details(post_code, val, voivodeship, county, community) VALUES ('00-005', 'Warszawa', ' mazowieckie', ' Warszawa', ' Warszawa');
INSERT INTO cities_details(post_code, val, voivodeship, county, community) VALUES ('00-006', 'Warszawa', ' mazowieckie', ' Warszawa', ' Warszawa');
INSERT INTO cities_details(post_code, val, voivodeship, county, community) VALUES ('00-007', 'Warszawa', ' mazowieckie', ' Warszawa', ' Warszawa');
INSERT INTO cities_details(post_code, val, voivodeship, county, community) VALUES ('00-008', 'Warszawa', ' mazowieckie', ' Warszawa', '