Skip to content

Instantly share code, notes, and snippets.

View luckyshot's full-sized avatar
🌍
xaviesteve.com

Xavi Esteve luckyshot

🌍
xaviesteve.com
View GitHub Profile
@luckyshot
luckyshot / default.yml
Last active October 31, 2023 16:51
Xavi Esteve's Espanso config file (Linux: ~/.config/espanso/match/base.yml // Mac: ~/Library/Preferences/espanso/default.yml)
# espanso match file
# For a complete introduction, visit the official docs at: https://espanso.org/docs/
# You can use this file to define the base matches (aka snippets)
# that will be available in every application when using espanso.
# Matches are substitution rules: when you type the "trigger" string
# it gets replaced by the "replace" string.
matches:
@luckyshot
luckyshot / colors.scss
Created March 2, 2021 23:50
Dieter Rams (Braun) - CSS/SCSS Color Palette
/**
* Colours taken from Dieter Rams legendary production collection for Braun. Made by Chad Ashley.
* Source: http://blog.presentandcorrect.com/rams-palettes
* Demo: https://xaviesteve.com/pro/colorpalettes/
* Try it: https://xaviesteve.com/pro/sass-palette/
* Compiled by Xavi Esteve
*/
// DR06
@luckyshot
luckyshot / bookmarklets.md
Created February 26, 2021 19:03
Bookmarklets: Useful miscelaneous

CaixaBank

Get total fluctuation to paste in Excel:

let total = '';
document.querySelectorAll('.color--gray500.font--size-90.white_space--nowrap').forEach(function(item){total += "\n" + item.innerHTML.replace('+ ', '').replace('.','').replace(',','.');});
console.log(total)
@luckyshot
luckyshot / hacker-news.css
Last active December 18, 2022 18:10
Hacker News Dark Theme Mode CSS code
/**
* HackerNews better readability
* Use any Browser extension that lets you add CSS code.
* © XaviEsteve.com
* https://gist.github.com/luckyshot/af6687f8ac3b0dc458818753dccbd412/
* Last updated: 18 Dec 22
*/
/* Home */
html, body {
@luckyshot
luckyshot / example.css
Last active January 15, 2021 09:43
TailWindCSS Color Palette as CSS native variables
html {
--colorIndigo50: #EEF2FF;
color: var(--colorIndigo50);
}
@luckyshot
luckyshot / download.js
Created September 18, 2020 13:28
Download all images from website (JS + PHP)
var buffer = [];
document.querySelectorAll('img').forEach(function(item) {
if (item.src){
buffer.push( item.src );
}
});
console.log('Total items:', buffer.length );
localStorage.buffer = JSON.stringify(buffer);
// Now grab localStorage.buffer and paste it in PHP
@luckyshot
luckyshot / flexbox.css
Created September 14, 2020 08:34
Tiny Minimal Flexbox Grid
.flex-grid {
display: flex;
}
.col {
flex: 1;
}
/* Break on mobile? */
@media (max-width: 400px) {
.flex-grid {
@luckyshot
luckyshot / distance.php
Created September 9, 2020 09:56
PHP distance between two points (flat coordinates 2 XY axis)
<?php
function distance($x1, $y1, $x2, $y2){
return sqrt(
pow(abs($x1 - $x2), 2)
+
pow(abs($y1 - $y2), 2)
);
}
@luckyshot
luckyshot / php-benchmark.php
Last active April 4, 2021 14:04
Simple PHP benchmarking script
<?php
$benchmark_time = microtime(1);
$benchmark_string = '';
function benchmark( $string = ''){
global $benchmark_time, $benchmark_string;
$return = sprintf('%f', microtime(1) - $benchmark_time) . 's ' . $benchmark_string;
$benchmark_time = microtime(1);
$benchmark_string = $string;
return $return;
@luckyshot
luckyshot / magic-copy.js
Last active December 11, 2023 21:00
JavaScript - Add/Append custom text on copy to clipboard
/**
* Magic Copy
* This little script will append some text to the clipboard when a user copies text from the website
*
* WARNING: This feature is an anti-pattern and a bad usability practice in 99% of cases, use only in
* those situations where it can really benefit the user to have a link to the full resource
*/
document.addEventListener('copy', (event) => {
if (document.getSelection().toString().length < 10){ return; }
const pagelink = `\n${document.location.href}`;