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 / awesome-php.md
Last active Jan 21, 2020
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
View awesome-php.md
@ziadoz
ziadoz / install.sh
Last active Jan 15, 2020
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 / fix-xbox-one-controller-windows-10.md
Last active Jan 10, 2020
Fix Xbox One Controller issues after Windows 10 Anniversary update
View fix-xbox-one-controller-windows-10.md

Fix Xbox One Controller on Windows 10 Anniversary

After the Windows 10 Anniversary update Xbox One Controllers may start showing up as two XInput devices in Steam, and button presses occur twice.

To fix this you need to patch in the xinputhid.sys file from an earlier Windows 7 driver.

Note: This fix only works for connecting the controller via USB cable or USB wireless adapter, the new Bluetooth controller when paired still doesn't work.

Download the Windows 7 Driver

@ziadoz
ziadoz / scrape.php
Created Aug 13, 2012
Scraping Google using PHP and Goutte:
View scrape.php
<?php
/**
* Todo: Send a random user agent string and sleep a random amount between requests.
*/
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Extract and sanatize input:
$domain = filter_input(INPUT_POST, 'domain', FILTER_SANITIZE_URL);
$terms = filter_input(INPUT_POST, 'terms', FILTER_SANITIZE_STRING);
// Setup Goutte (which also includes Guzzle):
@ziadoz
ziadoz / stripe-checkout.html
Last active Dec 20, 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 / log-errors.js
Created Dec 11, 2019
Log JS Errors via AJAX
View log-errors.js
// On error send to backend route which will log error into central logging service.
window.onerror = function(message, file, line) {
fetch(
'/log/js-error',
{
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
@ziadoz
ziadoz / halt_compiler.php
Last active Dec 4, 2019
Using PHP Halt Compiler
View halt_compiler.php
<?php
/**
* The __halt_compiler() function will stop the PHP compiler when called.
* You can then use the __COMPILER_HALT_OFFSET__ constant to grab the contents of the PHP file after the halt.
* In this example a PHP template is stored after the halt, to allow simple separation of logic from templating.
* The template is stored in a temporary file so it can be included and parsed.
*
* See: https://github.com/bobthecow/mustache.php/blob/dev/src/Mustache/Loader/InlineLoader.php
* http://php.net/manual/en/function.halt-compiler.php
*/
@ziadoz
ziadoz / run-ansible.sh
Created Dec 4, 2019
Run Ansible Playbook Against Host
View run-ansible.sh
# Replace [IP], [USER], [KEY] and [PLAYBOOK]
# Comma after IP address is required, otherwise the command won't work.
ansible-playbook -i [IP], --user=[USER] --private-key=[KEY] [PLAYBOOK]
@ziadoz
ziadoz / index.php
Last active Nov 24, 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 / composer_path.json
Last active Nov 18, 2019
Composer Using Local Repositories and Branches
View composer_path.json
{
"repositories": [
{
"type": "path",
"url": "../relative/project/path"
}
],
"require": {
"${project}": "dev-${branch}"
}
You can’t perform that action at this time.