Skip to content

Instantly share code, notes, and snippets.

View mathieutu's full-sized avatar
🚴

Mathieu TUDISCO mathieutu

🚴
View GitHub Profile
@mathieutu
mathieutu / gitForcePull
Last active November 21, 2017 15:08 — forked from vladimirtsyupko/gist:10964772
Git force pull to overwrite local files
git fetch --all
git reset --hard origin/master
git pull origin master
@mathieutu
mathieutu / checkbox.css
Created September 6, 2017 16:38
How to personalize html checkbox
.label-highlighted:before {
font-family: FontAwesome;
content: "\f006";
}
.checkbox-highlighted:checked + .label-highlighted:before {
content: "\f005";
}
.checkbox-highlighted {
display: none;
}
@mathieutu
mathieutu / checkboxes.js
Created September 6, 2017 16:48
How to make parent/child checkboxes.
document.querySelector('form').addEventListener('input', (event) => {
let match;
if (match = /child-(\d+)/.exec(event.target.id) && event.target.checked) {
document.querySelector(`#parent-${match[1]}`).checked = true;
}
if (match = /parent-(\d+)/.exec(event.target.id) && !event.target.checked) {
document.querySelector(`#child-${match[1]}`).checked = false;
}
});
@mathieutu
mathieutu / HighOrderProxy.php
Last active October 17, 2017 12:58
Stripe Wrapper
<?php
namespace App\Services\Stripe;
class HighOrderProxy
{
private $class;
public function __construct($stripeObject)
{
@mathieutu
mathieutu / DumpAllSqlQueries.php
Created November 21, 2017 15:07
Dump all sql queries in Laravel
<?php
// \App\Providers\AppServiceProvider::boot
if ($this->app->runningInConsole() && !$this->app->runningUnitTests()) {
$this->dumpAllSqlQueries();
}
private function dumpAllSqlQueries()
{
DB::listen(function ($query) {
@mathieutu
mathieutu / Model.php
Created November 21, 2017 15:19
Some functions to add to all Laravel models.
<?php
namespace App\Models;
abtract class Model extends \Illuminate\Database\Eloquent\Model
{
public function getLinkAttribute(): string
{
return route($this->getRouteName() . '.show', $this, false);
}
@mathieutu
mathieutu / iterm workflow.py
Created February 6, 2018 09:12
Iterm workflow form phpstorm one.
import sys
import glob
import json
from workflow import Workflow, ICON_WEB, web
def getProjectDirectories():
with open('config.json') as data_file:
data = json.load(data_file)
projects = {}
@mathieutu
mathieutu / ExceptionHandler.php
Created April 6, 2018 14:12
Exception Handler Symfony with GuzzleHttp Handling.
<?php
namespace App\Infrastructure\Http;
use Exception;
use GuzzleHttp\Exception\RequestException;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@mathieutu
mathieutu / uri.js
Created April 19, 2018 06:37 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@mathieutu
mathieutu / Link.vue
Last active April 19, 2018 12:20
Component which selects <nuxt/vue-router> or <a href>, depending of the url you're passing to it, and projects dependencies.