Skip to content

Instantly share code, notes, and snippets.

View Amunak's full-sized avatar
🐺
🐺

Jiří Barouš Amunak

🐺
🐺
View GitHub Profile
301 moved permanently (redirect):
<?php
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.example.com');
die();
?>
302 moved temporarily(redirect):
<?php
header('Location: http://www.example.com');
@mindplay-dk
mindplay-dk / session-life-cycle.md
Last active March 28, 2024 19:52
Complete overview of the PHP SessionHandler life-cycle

This page provides a full overview of PHP's SessionHandler life-cycle - this was generated by a set of test-scripts, in order to provide an exact overview of when and what you can expect will be called in your custom SessionHandler implementation.

Each example is a separate script being run by a client with cookies enabled.

To the left, you can see the function being called in your script, and to the right, you can see the resulting calls being made to a custom session-handler registed using session_set_save_handler().

@Antnee
Antnee / password_hash_cost_calculator.php
Created February 29, 2016 13:48
PHP password_hash() cost calculator
<?php
/**
* Password Hash Cost Calculator
*
* Set the ideal time that you want a password_hash() call to take and this
* script will keep testing until it finds the ideal cost value and let you
* know what to set it to when it has finished
*/
// Milliseconds that a hash should take (ideally)
@AlexEmashev
AlexEmashev / swipe-detect.js
Last active August 17, 2023 09:54
Simple snippet to detect swipe in jQuery without jQuery mobile. Works for touch as well as mouse input.
// Demo http://codepen.io/AlexEmashev/pen/BKgQdx
(function ($) {
$.fn.swipeDetector = function (options) {
// States: 0 - no swipe, 1 - swipe started, 2 - swipe released
var swipeState = 0;
// Coordinates when swipe started
var startX = 0;
var startY = 0;
// Distance of swipe
var pixelOffsetX = 0;