Skip to content

Instantly share code, notes, and snippets.

Avatar
🌍
xaviesteve.com

Xavi Esteve luckyshot

🌍
xaviesteve.com
View GitHub Profile
@luckyshot
luckyshot / default.yml
Last active May 31, 2021
Xavi Esteve's Espanso config file (~/Library/Preferences/espanso/default.yml)
View default.yml
# espanso configuration file
# This is the default configuration file, change it as you like it
# You can refer to the official documentation:
# https://espanso.org/docs/
# Matches are the substitution rules, when you type the "trigger" string
# it gets replaced by the "replace" string.
# https://espanso.org/docs/matches/
@luckyshot
luckyshot / colors.scss
Created Mar 2, 2021
Dieter Rams (Braun) - CSS/SCSS Color Palette
View colors.scss
/**
* 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 Feb 26, 2021
Bookmarklets: Useful miscelaneous
View bookmarklets.md

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 Mar 17, 2021
Hacker News Dark Theme Mode CSS code
View hacker-news.css
/**
* HackerNews better readability
* Use any Browser extension that lets you add CSS code.
* © XaviEsteve.com
* https://gist.github.com/luckyshot/af6687f8ac3b0dc458818753dccbd412/
*/
/* Home */
html, body {
background: #1C1917;
@luckyshot
luckyshot / example.css
Last active Jan 15, 2021
TailWindCSS Color Palette as CSS native variables
View example.css
html {
--colorIndigo50: #EEF2FF;
color: var(--colorIndigo50);
}
@luckyshot
luckyshot / download.js
Created Sep 18, 2020
Download all images from website (JS + PHP)
View download.js
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 Sep 14, 2020
Tiny Minimal Flexbox Grid
View flexbox.css
.flex-grid {
display: flex;
}
.col {
flex: 1;
}
/* Break on mobile? */
@media (max-width: 400px) {
.flex-grid {
@luckyshot
luckyshot / distance.php
Created Sep 9, 2020
PHP distance between two points (flat coordinates 2 XY axis)
View distance.php
<?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 Apr 4, 2021
Simple PHP benchmarking script
View php-benchmark.php
<?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 May 22, 2020
JavaScript - Add/Append custom text on copy to clipboard
View magic-copy.js
/**
* 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}`;