Skip to content

Instantly share code, notes, and snippets.

Jamie York ziadoz

Block or report user

Report or block ziadoz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ziadoz
ziadoz / include-me-func.php
Last active Aug 24, 2019
Prevent Variable Leakage In PHP Includes
View include-me-func.php
<?php
// Use a closure so nothing leaks out when included.
return (function () {
$array = ['foo', 'bar'];
foreach ($array as $string) {
// Some exciting logic.
}
return 'FOOBAR';
@ziadoz
ziadoz / .php_cs.dist
Last active Aug 8, 2019
PHP CS Fixer Configuration
View .php_cs.dist
<?php declare(strict_types=1);
$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->path('.php_cs.dist')
->in(__DIR__);
return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
@ziadoz
ziadoz / OpenStruct.php
Last active Aug 2, 2019
OpenStruct and Struct in PHP
View OpenStruct.php
<?php
class OpenStruct extends ArrayObject
{
public function __construct($input = array())
{
parent::__construct($input, static::ARRAY_AS_PROPS);
}
public function offsetSet($key, $value)
{
@ziadoz
ziadoz / gists.go
Created Jul 26, 2019
Test Golang API Client Using httptest Package
View gists.go
package gists
import (
"encoding/json"
"fmt"
"net/http"
)
type Api struct {
client *http.Client
@ziadoz
ziadoz / .bash_profile
Last active Jul 14, 2019
Simple Bash Colours With TPut
View .bash_profile
# See: http://en.wikipedia.org/wiki/Tput
BOLD="$(tput bold)"
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
BLUE="$(tput setaf 4)"
MAGENTA="$(tput setaf 5)"
CYAN="$(tput setaf 6)"
WHITE="$(tput setaf 7)"
@ziadoz
ziadoz / stripe-checkout.html
Last active Jun 24, 2019
Custom Stripe Checkout Button
View stripe-checkout.html
<form action="." method="post">
<noscript>You must <a href="http://www.enable-javascript.com" target="_blank">enable JavaScript</a> in your web browser in order to pay via Stripe.</noscript>
<input
type="submit"
value="Pay with Card"
data-key="PUBLISHABLE STRIPE KEY"
data-amount="500"
data-currency="cad"
data-name="Example Company Inc"
@ziadoz
ziadoz / game-save-clean-up.go
Created May 26, 2019
Clean Up Game Save Manager Folders
View game-save-clean-up.go
// Usage: game-save-clean-up --src="/Files/Game Saves" [--limit=2] [--dryrun]
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
@ziadoz
ziadoz / jquery-capture-css3-transition-end-event.js
Created Jul 9, 2012
jQuery Capture CSS3 Transition End Event
View jquery-capture-css3-transition-end-event.js
$(document).ready(function() {
$('div').on('transitionend MSTransitionEnd webkitTransitionEnd oTransitionEnd', function(event) {
// Do stuff after transition
});
});
@ziadoz
ziadoz / fix-osx-wifi-battery-drain.md
Last active May 3, 2019
Fix OSX battery draining on sleep due to wifi activity
View fix-osx-wifi-battery-drain.md

Fix OSX battery draining on sleep due to wifi activity

Install SleepWatcher using Homebrew:

sudo chown -R $(whoami) /usr/local
brew update
brew install sleepwatcher

Start the SleepWatcher service:

@ziadoz
ziadoz / setup.md
Created Jul 22, 2017
Using XDebug in Atom Editor
View setup.md

Using XDebug in Atom Editor

Install the XDebug plugin for Atom and then add the following to the config.cson file (Atom > Config…):

"php-debug":
  PathMaps: [
    "remotepath;localpath"
    "/server/path/to/project/;/local/path/to/project/"
  ]
  ServerPort: 9001
You can’t perform that action at this time.