Skip to content

Instantly share code, notes, and snippets.

🌍
xaviesteve.com

Xavi Esteve luckyshot

🌍
xaviesteve.com
Block or report user

Report or block luckyshot

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
@luckyshot
luckyshot / forms.php
Last active Aug 21, 2019
Laravel Speed Coding Notes and Command Reference
View forms.php
<?php
// View form:
<form ...>
{{ csrf_field }}
</form>
// Saving the form
use Illuminate/Http/Request;
@luckyshot
luckyshot / apache-commands.sh
Created Jul 2, 2019
Apache Commands OSX (Local environment)
View apache-commands.sh
sudo apache2ctl -S (tests config)
sudo apachectl -k restart
sudo code /usr/local/etc/httpd/httpd.conf
sudo code /usr/local/etc/httpd/extra/httpd-vhosts.conf
sudo code /etc/hosts
code /usr/local/etc/php/7.2/php.ini
ErrorLog "/usr/local/var/log/httpd/error_log"
ServerRoot "/usr/local/opt/httpd"
@luckyshot
luckyshot / median-average.sql
Last active May 28, 2019
Computing Average/Median value ignoring outliers/extremes (MySQL)
View median-average.sql
-- Exclude outliers while trying to get the average
SELECT AVG(price) FROM transactions WHERE ABS(price - (SELECT AVG(price) FROM transactions) < 3*(SELECT stddev(price) from transactions));
@luckyshot
luckyshot / generate-backups.php
Created Jan 22, 2019
Quick & Simple MySQL database backups using PHP & Gmail
View generate-backups.php
<?php
/* Database Backup to email by Xavi Esteve */
// ======================================
// ======== MODIFY SETTINGS HERE ========
// ======================================
$config = [
// MySQL
'db_host' => 'localhost',
'db_user' => null, // default, used if nothing declared in 'databases'
@luckyshot
luckyshot / paperclips-bot.js
Last active Jan 7, 2019
Universal Paperclips Auto-bot code
View paperclips-bot.js
/**
clearInterval(t);var t = setInterval(function(){run()}, 100);
*/
var run = function(){
// Make paperclip
// Clicks the 'Make paperclip' button, useful at the very beginning of the game
var wire = parseInt(document.querySelector('#wire').innerText);
if (wire > 0){
for (let index = 0; index < 100; index++) {
@luckyshot
luckyshot / readingmode.js
Last active Mar 28, 2019
Bookmarklet: Readability (remove all styling from a website, optimize for reading and scroll to article). Also available as a Chrome Extension: https://chrome.google.com/webstore/detail/readingmode-lightest/peoapnglceoafojobbkpohnojniabmkd
View readingmode.js
javascript:
var el = document.getElementsByTagName("*");
var htmlDiv = document.createElement("div");
var readingModeMenu = document.createElement("div");
var title = document.title;
/* Remove all event listeners */
document.querySelector("body").outerHTML = document.querySelector("body").outerHTML;
/* Remove everything in head */
@luckyshot
luckyshot / queryselector.js
Created Apr 9, 2018
QuerySelector short-hand
View queryselector.js
$ = function(sel, ctx){return (ctx || document).querySelector(sel)}
$$ = function(sel, ctx){return (ctx || document).querySelectorAll(sel)}
@luckyshot
luckyshot / js-notify.js
Created Feb 23, 2018
Tiny jQuery Notify (notification bubble/alert) in <1KB
View js-notify.js
/*! Tiny jQuery Notify by Xavi Esteve © 2018 MIT */
/*
{
text: string
type: success, error, warning, danger... any CSS class you want to add
}
notify({text: 'Hello world!', type: 'success' });
*/
var timers = [];
@luckyshot
luckyshot / check-disk-space.sh
Created Feb 21, 2018
Check Disk Space through SHELL script (cronjob) and send an HTTP request when it reaches the limit
View check-disk-space.sh
#!/bin/bash
# Check Disk Space and send an HTTP request when it reaches the limit
# Once used space is higher than this limit, the webhook will be triggered (in percentage)
LIMIT='80'
# Stores the percentage of used space
USED=`df . | awk '{print $5}' | sed -ne 2p | cut -d"%" -f1`
# Webhook URL
@luckyshot
luckyshot / multi-language.php
Last active Jan 26, 2018
Multi-language system in PHP
View multi-language.php
<?php
// config.php
$config['language'] = [];
$config['language']['default'] = 'en'; // no file for this language exists, will be just echoed as is
$config['language']['list'] = [
'en' => '🇺🇸 English',
'es' => '🇪🇸 Español',
];
You can’t perform that action at this time.