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 / 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 / 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}`;
@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 / tvshows.js
Created September 3, 2015 13:51
TV Shows - Full list (JSON)
var shows = {"shows":["12 Monkeys","19-2 (2014)","2 Broke Girls","24","60 Minutes Australia","60 Minutes US","8 Out of 10 Cats","A D The Bible Continues","A to Z","A Young Doctor's Notebook","About a Boy","Adventure Time","Air Crash Investigation - Mayday","Alaska: The Last Frontier","Alaskan Bush People","Ali G: Rezurection","Allegiance","Almost Human","Almost Royal","Alpha House","Ambassadors","America Declassified","America Unearthed","America's Got Talent","America's Next Top Model","American Crime","American Dad!","American Horror Story","American Idol","American Ninja Warrior","American Odyssey","American Pickers","American Restoration","Ancient Aliens","Anger Management","Another Period","Anthony Bourdain: Parts Unknown","Antiques Roadshow UK","Aqua TV Show Show","Aquarius (US)","Archer (2009)","Arctic Air","Arrow","At Midnight","Atlantis","Attack on Titan","Avengers Assemble (2013)","Awkward.","Axe Cop","Baby Daddy","Babylon","Bachelor in Paradise","Back in the Game","Backstrom","Bad Education","Bad I
@luckyshot
luckyshot / abusecheck.php
Last active April 28, 2023 07:46
Throttle client requests to avoid DoS attack (scroll down for IP-based)
<?php
/**
ABUSE CHECK
Throttle client requests to avoid DoS attack
*/
session_start();
$usage = array(5,5,5,5,10,20,30,40,50,60,120,180,240); // seconds to wait after each request
if (isset($_SESSION['use_last'])) {
$nextin = $_SESSION['use_last']+$usage[$_SESSION['use_count']];
@luckyshot
luckyshot / readingmode.js
Last active April 4, 2023 05:35
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
javascript:
/*! ReadingMode © Xavi Esteve */
(function (d) {
var el = d.getElementsByTagName("*");
var htmlDiv = d.createElement("div");
var readingModeMenu = d.createElement("div");
var readingModeAlert = d.createElement("div");
var title = d.title;
var rmSettings = {};
@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 / 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 / paperclips-bot.js
Last active November 4, 2022 18:03
Universal Paperclips Auto-bot code
/**
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 / autofilter-vanilla.html
Last active September 15, 2022 01:37
Filter a list of items by typing in a textbox
<html>
<body>
<input type="text" id="projects-search" placeholder="Search projects&hellip;">
<script>
var filterProjects = function( query ){
var list = document.querySelectorAll('#projects-table tbody tr'),
query = query.toLowerCase();
for (let i = 0; i < list.length; i++) {
if ( query.length > 0 && list[i].innerText.toLowerCase().indexOf( query ) === -1 ){