Skip to content

Instantly share code, notes, and snippets.

View kdallas's full-sized avatar

Larry Browning kdallas

View GitHub Profile
@kdallas
kdallas / php-git-bash-win.sh
Last active March 3, 2023 02:00 — forked from andkirby/php-git-bash-win.sh
Download PHP binaries archive on Windows from GitBash console or similar
#!/usr/bin/env bash
################################################################################
# This script can install PHP binaries on Windows in Bash.
# -- quick hacked together update for downloading PHP v5.6.40
#
# Link to this file:
# https://gist.github.com/kdallas/3726bcc7b86a1a270f6b955696e55c2b/raw/php-git-bash-win.sh
#
# Download latest version by command in GitBash Windows console:
# $ curl -Ls bit.ly/php-bash-win | bash
@kdallas
kdallas / mt_shuffle.php
Created November 4, 2016 09:17
A substitute for the php shuffle() function using mt_rand(), i.e. the Mersenne Twister algorithm - for improved randomness
<?php
function mt_shuffle(&$array) {
$randArr = [];
$arrLength = count($array);
// while my array is not empty I select a random position
while (count($array)) {
//mt_rand returns a random number between two values
$randPos = mt_rand(0, --$arrLength);
@kdallas
kdallas / Account.php
Created October 29, 2015 04:12
Instant response for October CMS Flash messages combined with Romanov.Flashmessage plugin (no page reload)
<?php namespace RainLab\User\Components;
use Lang;
use Auth;
use Mail;
use Flash;
use Input;
use Request;
use Redirect;
use Validator;
@kdallas
kdallas / index.php
Last active February 26, 2017 03:56
CloudFlare DDNS updater, inspired by: http://bit.ly/2mqyiwI -- I put this on a server that I know is going to be up 24/7, and pointed my DD-WRT router to it for Dynamic DNS updates.
<?php
/*
http://SOME_RELIABLE_SERVER/update_cloudflare/CLOUDFLARE_EMAIL/CLOUDFLARE_API-KEY/HOST
...where "update_cloudflare" is a directory containing this file (index.php)
...and the URL slug/segments are parsed with the following regex:
RewriteRule ^/update_cloudflare/([^/]+)?/?([^/]+)?/?(.*) /update_cloudflare/index.php?e=$1&k=$2&h=$3 [L,QSA]
which sends the following GET params: