Skip to content

Instantly share code, notes, and snippets.

View ziadoz's full-sized avatar

Jamie York ziadoz

View GitHub Profile
@ziadoz
ziadoz / include-me-func.php
Last active August 24, 2019 19:48
Prevent Variable Leakage In PHP Includes
<?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 / convert_video.sh
Last active October 10, 2019 03:40
MKV to MP4 (Docker, FFMpeg, AVConv)
#!/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 / install.sh
Last active July 22, 2017 13:35
Install Atom Editor PHP Integrator Core 3.0.0 on macOS Sierra
#!/usr/bin/env bash
brew tap homebrew/homebrew-php
brew install php71
cd ~/.atom/packages/php-integrator-base/core
/usr/local/bin/php ./composer.phar create-project php-integrator/core ./3.0.0 3.0.0 --prefer-dist --no-dev
@ziadoz
ziadoz / setup.md
Created July 22, 2017 13:32
Using XDebug in Atom Editor

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
@ziadoz
ziadoz / fizzbuzz.go
Last active December 24, 2017 22:06
FizzBuzz in Go
package main
import "fmt"
const (
FIZZ = 3
BUZZ = 5
FIZZBUZZ = 15
)
@ziadoz
ziadoz / game-save-clean-up.go
Created May 26, 2019 17:28
Clean Up Game Save Manager Folders
// 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 / gists.go
Created July 26, 2019 13:31
Test Golang API Client Using httptest Package
package gists
import (
"encoding/json"
"fmt"
"net/http"
)
type Api struct {
client *http.Client
@ziadoz
ziadoz / .php_cs.dist
Last active December 15, 2020 21:14
Strictish PHP CS Fixer Configuration
<?php
// https://mlocati.github.io/php-cs-fixer-configurator/
return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'align_multiline_comment' => ['comment_type' => 'all_multiline'],
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'backtick_to_shell_exec' => true,
@ziadoz
ziadoz / readme.md
Created August 30, 2019 22:21
Cloning Github Gists

Cloning Github Gists

To clone a gist:

git clone [email protected]:[GIST ID].git

If you need to add a remote to an existing repository:

git remote add origin [email protected]:[GIST ID].git
@ziadoz
ziadoz / main.go
Last active June 5, 2021 21:11
Download a webpage as HTML with base64 encoded assets using Golang
// Usage: go run main.go https://www.theguardian.com/uk
// Based on Monolith: https://github.com/Y2Z/monolith
package main
import (
"bytes"
"encoding/base64"
"fmt"
"io"
"io/ioutil"