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 / artisan_db_open.php
Created Feb 4, 2020 — forked from calebporzio/artisan_db_open.php
An artisan command for opening the project's database in TablePlus
View artisan_db_open.php
<?php
Artisan::command('db:open {connection?}', function ($connection = null) {
if (! file_exists('/Applications/TablePlus.app')) {
$this->warn('This command uses TablePlus, are you sure it\'s installed?');
$this->line("Install here: https://tableplus.com/\n");
}
$driver = $connection ?: config('database.default');
$host = config("database.connections.{$driver}.host");
@ziadoz
ziadoz / composer-install.sh
Created Feb 4, 2020
Install Composer Locally Using Bash
View composer-install.sh
#!/bin/bash
mkdir -p ~/.bin
curl -sS https://getcomposer.org/installer | php -- --install-dir=~/.bin --filename=composer
@ziadoz
ziadoz / composer-latest.sh
Last active Feb 4, 2020
Check running Composer version is latest using Bash
View composer-latest.sh
#!/bin/bash
# Sometimes it's useful to know if Composer actually needs updating or if it was updated, for example for CI builds.
# 1) Check if you're running the latest version of Composer.
# - https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c
# - https://superuser.com/questions/363865/how-to-extract-a-version-number-using-sed
LATEST_COMPOSER_VERSION="$(curl --silent "https://api.github.com/repos/composer/composer/tags" | jq -r '.[0].name')"
CURRENT_COMPOSER_VERSION="$(composer --version | sed -ne 's/[^0-9]*\(\([0-9]\.\)\{0,4\}[0-9][^.]\).*/\1/p')"
if [ $LATEST_COMPOSER_VERSION != $CURRENT_COMPOSER_VERSION ]; then
@ziadoz
ziadoz / main.go
Created Jan 20, 2020
Go Video Web NAS
View main.go
// Create a video with the path: ./media/test.mkv
package main
import (
"log"
"net/http"
"text/template"
)
func main() {
@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 / 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 / main.go
Last active Sep 1, 2019
Download a webpage as HTML with base64 encoded assets using Golang
View main.go
// 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"
@ziadoz
ziadoz / readme.md
Created Aug 30, 2019
Cloning Github Gists
View readme.md

Cloning Github Gists

To clone a gist:

git clone git@gist.github.com:[GIST ID].git

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

git remote add origin git@gist.github.com:[GIST ID].git
@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 / 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
You can’t perform that action at this time.