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 / index.php
Last active Aug 25, 2019
Simple PHP / jQuery CSRF Protection
View index.php
<?php
// See: http://blog.ircmaxell.com/2013/02/preventing-csrf-attacks.html
// Start a session (which should use cookies over HTTP only).
session_start();
// Create a new CSRF token.
if (! isset($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = base64_encode(openssl_random_pseudo_bytes(32));
}
@ziadoz
ziadoz / photos.sh
Last active Aug 24, 2019
OS X Photos - View Raw Photos in Finder
View photos.sh
#!/usr/bin/env bash
# Make the OS X Photos Library viewable as a folder called Raw in ~/Pictures
cd ~/Pictures
mkdir Raw
ln -s ~/Pictures/Photos\ Library.photoslibrary/Masters/ Raw
@ziadoz
ziadoz / convert_video.sh
Last active Aug 24, 2019
MKV to MP4 (Docker, FFMpeg, AVConv)
View convert_video.sh
#!/usr/bin/env bash
# Convert MKV to MP4
# Uses Docker FFMpeg, FFMpeg or AVConv.
#
# Usage:
# ./convert_video.sh
# ./convert_video.sh /path/to/videos
#
# Notes:
@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 / install.sh
Last active Aug 22, 2019
Install Chrome, ChromeDriver and Selenium on Ubuntu 16.04
View install.sh
#!/usr/bin/env bash
# https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/
# https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c
# http://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver
# http://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception
# http://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal
# http://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04
# Versions
CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`
@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 / composer_path.json
Last active Jul 18, 2019
Composer Using Local Repositories and Branches
View composer_path.json
{
"repositories": [
{
"type": "path",
"url": "../relative/project/path"
}
],
"require": {
"${project}": "dev-${branch}"
}
@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)"
You can’t perform that action at this time.