Skip to content

Instantly share code, notes, and snippets.

View rgasch's full-sized avatar

Robert Gasch rgasch

View GitHub Profile
@rgasch
rgasch / UserAgent.php
Created October 21, 2022 22:29
Get a random user agent in PHP
public static function getUserAgent (): string
{
static $agents = null;
if (!$agents) {
$agents = [
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0',
@rgasch
rgasch / replace.php
Last active June 22, 2019 21:13
PHP Recursive CLI Search/Replace Script
<?php
global $count;
global $dirCount;
$searchReplaceData = array (
'searchString1' => 'replaceString1',
'searchString2' => 'replaceString2'
);
@rgasch
rgasch / gist:5c7f76c0e953f6782478420bb4c1da57
Created April 24, 2016 21:45
Adding Twig Extension to Slim Framework V3
<?php
namespace App\TwigExtension;
class IsLoggedIn extends \Slim\Views\TwigExtension
{
public function __construct()
{
}
@rgasch
rgasch / gist:8c8e66e180a3ba0ff594
Created March 28, 2015 16:09
PHP Micro Benchmark for data access times: direct variable access vs. class getters
<?php
/*
* Test how data access times compare: direct variable access vs access through a class method
*/
$GLOBALS['var'] = 'value';
class Test {
public function get () {
.pretty-buttons(@color, @background, @text-shadow: none) {
color: @color;
#gradient > .vertical(lighten(@background, 5%), darken(@background, 5%), 0%, 100%);
border-color: darken(@background, 10%);
border-bottom-color: darken(@background, 20%);
text-shadow: @text-shadow;
.box-shadow(inset 0 1px 0 rgba(255, 255, 255, .1));
&:hover,