Skip to content

Instantly share code, notes, and snippets.

View lucaslgr's full-sized avatar
🎯
Focusing

Lucas Guimarães lucaslgr

🎯
Focusing
View GitHub Profile
@lucaslgr
lucaslgr / request_ajax.js
Created June 8, 2020 12:34
Getting the response of ajax request but the flow doesn't enter in ".then"
document.addEventListener('DOMContentLoaded', () => {
document.getElementById('form-edit input[type=submit]').addEventListener('click', (event) => {
event.preventDefault();
let formData = new FormData(event.target.closest('form'));
const url = '<?php echo BASE_URL ?>home/edit/<?= $_SESSION[md5(BASE_URL) . '_' . 'cLogin'] ?>';
const params = {
method: 'POST',
body: formData,
//Encapulando o document.querySelector e o document.querySelectorAll para reutilizar código
const $ = document.querySelector.bind(document);
const $$ = document.querySelectorAll.bind(document);
document.addEventListener('DOMContentLoaded', () => {
$('#btn-play').addEventListener('click', () => {
$('span').innerText = "Aguarde...";
const urlBling = "https://www.bling.com.br/vendas.lojas.virtuais.php";
@lucaslgr
lucaslgr / gist:583e91eadcfe9664c9915c63cc8ad75a
Created September 14, 2020 12:48
Settings do VsCode para JS e ES6
{
//!Settings of Oh My Zsh
"terminal.integrated.shell.linux": "/bin/zsh",
"terminal.integrated.shell.osx": "/bin/zsh",
"terminal.integrated.fontFamily": "'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback', 'PowerlineSymbols'",
// "workbench.colorTheme": "Monokai",
"editor.fontSize": 15,
"editor.lineHeight": 26,
"editor.tabSize": 2,
@lucaslgr
lucaslgr / delete-all-tables.sql
Created December 17, 2020 12:15
SQL script to delete all tables in a Database dynamically
SET FOREIGN_KEY_CHECKS = 0;
SET @tables = NULL;
SELECT GROUP_CONCAT('`', table_schema, '`.`', table_name, '`') INTO @tables
FROM information_schema.tables
WHERE table_schema = 'database_name'; -- specify DB name here.
SET @tables = CONCAT('DROP TABLE ', @tables);
PREPARE stmt FROM @tables;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
@lucaslgr
lucaslgr / acelerador de video
Last active June 16, 2021 19:08
Acelerador de video para tag <video>e <iframe>
//<IFRAME>
var playbackRate = 3;
var data = {event: 'command', func: 'setPlaybackRate', args: [playbackRate, true]};
var message = JSON.stringify(data);
$('iframe')[0].contentWindow.postMessage(message, '*');
//<ALL IFRAMES WITHOUT JQUERY>
var playbackRate = 3;
var data = {event: 'command', func: 'setPlaybackRate', args: [playbackRate, true]};
var message = JSON.stringify(data);
@lucaslgr
lucaslgr / linkedin.js
Created December 21, 2020 20:47
Only a linkedin simple script to expand your network
function conectOneMore() {
var nToConnect = document.querySelectorAll('button[aria-label^="Conecte-se"]').length;
console.log('Número para se conectar: ' + nToConnect);
var nToFollow = document.querySelectorAll('button[aria-label^="Seguir"]').length;
console.log('Número para seguir: ' + nToFollow);
if (nToConnect > 0) {
setTimeout(() => {
if (document.querySelector('button[aria-label^="Conecte-se"]'))
@lucaslgr
lucaslgr / .zshrc
Created January 6, 2021 20:07
Configuration file of setings ZSH terminal for backup
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/home/lgrwolf/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
@lucaslgr
lucaslgr / Linux programs backup
Created January 6, 2021 20:31
An attempt for backup a list of easy way to recover my programs after a linux reinstall
#!bin/bash
# ----------------------------- VARIÁVEIS ----------------------------- #
#PPA
#[NENHUMA AINDA]
#URL
URL_GOOGLE_CHROME="https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"
#DIRETORIO
DIRETORIO_DOWNLOADS="$HOME/Downloads/programas"
@lucaslgr
lucaslgr / Script SQL to return FK from database
Created January 14, 2021 13:55
Script SQL para retornar todas foreign keys da respectiva database em uso
SELECT
`TABLE_SCHEMA`, -- Foreign key schema
`TABLE_NAME`, -- Foreign key table
`COLUMN_NAME`, -- Foreign key column
`REFERENCED_TABLE_SCHEMA`, -- Origin key schema
`REFERENCED_TABLE_NAME`, -- Origin key table
`REFERENCED_COLUMN_NAME` -- Origin key column
FROM
`INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` -- Will fail if user don't have privilege
WHERE
@lucaslgr
lucaslgr / script.js
Created July 18, 2021 18:33
Pega elemento na tela async
//Funcao que pega um elemento na tela de forma assincrona
function getElementAsync(selector) {
return new Promise((resolve, reject) => {
const element = null;
const idInterval = setInterval(() => {
try {
const element = document.querySelector(selector);
if (element) {
clearInterval(idInterval);