Skip to content

Instantly share code, notes, and snippets.

View fadonascimento's full-sized avatar

Fabricio Henrique fadonascimento

View GitHub Profile
Backup specifc database
docker exec -i database pg_dump --u postgres DATABASE_NAME_HERE > DUMP_`date +%d-%m-%Y"_"%H_%M_%S`.sql
Backup all databases
docker exec -t -u postgres CONTAINER_NAME_HERE pg_dumpall -c > DUMP_`date +%d-%m-%Y"_"%H_%M_%S`.sql
to restore:
cat YOUR_FILE.sql | docker exec -i CONTAINER_NAME_HERE psql -U USER_NAME_HERE -d DATABASE_NAME_HERE
@mglaman
mglaman / drush-loop.php
Created July 7, 2019 02:28
ReactPHP Drupal Tasks
<?php declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
function run_command(string $command): void {
$loop = React\EventLoop\Factory::create();
$process = new React\ChildProcess\Process($command);
$process->start($loop);
$process->on('exit', function ($exitCode) use ($command) {
// Trigger alerts that the command finished.
@VitorLuizC
VitorLuizC / Home.vue
Last active November 14, 2022 20:05
Exemplo de Autenticação com JWT em Vue.js
<template>
<h1>Página secreta!</h1>
</template>
@thedaviddias
thedaviddias / Preload CSS - Not blocking CSS.html
Last active February 1, 2024 08:24
Preload CSS and don't block the DOM with your CSS file request.
<link rel="preload" href="css/global.min.css" as="style" onload="this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="css/global.min.css"></noscript>
<script>
/*! loadCSS. [c]2017 Filament Group, Inc. MIT License */
!function(a){"use strict";var b=function(b,c,d){function j(a){if(e.body)return a();setTimeout(function(){j(a)})}function l(){f.addEventListener&&f.removeEventListener("load",l),f.media=d||"all"}var g,e=a.document,f=e.createElement("link");if(c)g=c;else{var h=(e.body||e.getElementsByTagName("head")[0]).childNodes;g=h[h.length-1]}var i=e.styleSheets;f.rel="stylesheet",f.href=b,f.media="only x",j(function(){g.parentNode.insertBefore(f,c?g:g.nextSibling)});var k=function(a){for(var b=f.href,c=i.length;c--;)if(i[c].href===b)return a();setTimeout(function(){k(a)})};return f.addEventListener&&f.addEventListener("load",l),f.onloadcssdefined=k,k(l),f};"undefined"!=typeof exports?exports.loadCSS=b:a.loadCSS=b}("undefined"!=typeof global?global:this);
/*! loadCSS rel=preload po
@romanych
romanych / fif.js
Created April 29, 2016 13:23 — forked from jasdeepkhalsa/fif.js
Friendly iFrames (FIF) - Loading JavaScript Asynchronously Without Blocking window.onload by Stoyan Stefanov. Designed for loading third party scripts only (for first party scripts this script may have a negative performance impact, as tested by Yahoo)
// Documented by Stoyan Stefanov: https://www.facebook.com/note.php?note_id=10151176218703920
(function() {
var url = 'http://example.org/js.js';
var iframe = document.createElement('iframe');
(iframe.frameElement || iframe).style.cssText =
"width: 0; height: 0; border: 0";
iframe.src = "javascript:false";
var where = document.getElementsByTagName('script')[0];
where.parentNode.insertBefore(iframe, where);
var doc = iframe.contentWindow.document;
@jonhattan
jonhattan / example_ajax.php
Last active November 17, 2023 15:28
Drupal 8 - detect if we're in an ajax request, and if building the form for the first time, or re-building within the input processing.
<?php
use Drupal\Core\Form\FormStateInterface;
function example_ajax_form_alter() {
$ajax_form_request = \Drupal::request()->query->has(FormBuilderInterface::AJAX_FORM_REQUEST);
if ($ajax_form_request) {
if (!$form_state->isProcessingInput()) {
\Drupal::logger('example')->notice('first pass');
}
@jmauerhan
jmauerhan / wait.php
Last active August 5, 2017 21:34
Behat: Wait For AJAX Angular & jQuery
public function waitForAjax()
{
$waitTime = 10000;
try {
//Wait for Angular
$angularIsNotUndefined = $this->getSession()->evaluateScript("return (typeof angular != 'undefined')");
if ($angularIsNotUndefined) {
//If you run the below code on a page ending in #, the page reloads.
if (substr($this->getSession()->getCurrentUrl(), -1) !== '#') {
$angular = 'angular.getTestability(document.body).whenStable(function() {
@keopx
keopx / import_gzip_drush.sh
Created July 16, 2015 18:36
Import gzipped sql using Drush
gunzip -c database.sql.gz | drush sqlc
@jbouzekri
jbouzekri / FeatureContext.php
Created February 27, 2015 18:48
A nice wait for js calls ending function in behat
<?php
/**
* @author Gildas Quéméner <gildas@akeneo.com>
* @copyright 2013 Akeneo SAS (http://www.akeneo.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
use Behat\Behat\Exception\BehaviorException;
use Behat\Mink\Driver\Selenium2Driver;
@jirutka
jirutka / sample.png
Last active April 26, 2023 14:03
Nested numbered list with correct indentation in CSS. Live example at http://jsfiddle.net/a84enL8k/.
sample.png