Skip to content

Instantly share code, notes, and snippets.

@libesto
libesto / Custom_HTML_Signature_in_Apple_Mail_app.md
Created October 11, 2024 00:15 — forked from icetee/Custom_HTML_Signature_in_Apple_Mail_app.md
Custom Apple Mail HTML signature creation guide
@libesto
libesto / README.md
Created November 10, 2023 14:02 — forked from qdm12/README.md
Wireguard and iptables restrictions for multiple users

Wireguard and iptables restrictions for multiple users

If you don't know what Wireguard is, well, you should. It's fast, easy to setup and highly configurable. We will configure Wireguard for multiple users with various restrictions using iptables.

Assumptions

This should fit most setups (not mine though 😉)

@libesto
libesto / GoogleDriveServiceProvider.php
Created March 28, 2023 07:57 — forked from sergomet/GoogleDriveServiceProvider.php
Setup a Laravel Storage driver with Google Drive API
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class GoogleDriveServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
@libesto
libesto / multiple-ssh-keys-git.adoc
Created December 9, 2022 12:18 — forked from alejandro-martin/multiple-ssh-keys-git.adoc
Configure multiple SSH Keys for Git

Use Multiple SSH Keys for Git host websites (Github, Gitlab)

This is guide about how to configure multiple SSH keys for some Git host websites such as Github, Gitlab, among others.

Creating SSH keys

  1. Create SSH directory:

@libesto
libesto / console.save.js
Created January 27, 2022 17:04 — forked from raecoo/console.save.js
Save JSON object to file in Chrome Devtool
// e.g. console.save({hello: 'world'})
(function(console){
console.save = function(data, filename){
if(!data) {
console.error('Console.save: No data')
return;
}
if(!filename) filename = 'console.json'
if(typeof data === "object"){
data = JSON.stringify(data, undefined, 4)
@libesto
libesto / ID.js
Created March 2, 2021 18:19
ID - a unique ID/name generator for JavaScript
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`

PHP API to return table names from a given SQL statement with multiple tables

Input

 $query = "SELECT `main_categories`.*, `categories_views`.`view` AS view_ctg, (SELECT COUNT(id_geo) FROM main_geo WHERE id_geo=geo_filter_ctg AND FIND_IN_SET('PK', `countries_geo` )) as countryCount
 FROM (`main_categories`)
 JOIN `categories_parents` ON `main_categories`.`id_ctg` = `categories_parents`.`id_ctg`
 JOIN `categories_views` ON `main_categories`.`id_ctg` = `categories_views`.`id_ctg`

WHERE categories_parents.parent_ctg = '8701'

@libesto
libesto / isElementInViewport.js
Created January 26, 2021 15:07 — forked from davidtheclark/isElementInViewport.js
JavaScript: Is element in viewport?
/*
No jQuery necessary.
Thanks to Dan's StackOverflow answer for this:
http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport
*/
function isElementInViewport(el) {
var rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
@libesto
libesto / laravel-sortby-closure.md
Created December 3, 2020 14:20 — forked from remoblaser/laravel-sortby-closure.md
Laravel Collection: Sort a String Datefield with a closure
$sorted = $collection->sortBy(function ($element, $key) {
      $timestamp = strtotime($element->date_field);   
      return $timestamp;
});
@libesto
libesto / randomcolors.js
Created July 30, 2020 01:19 — forked from kettuniko/randomcolors.js
Random RGBA colors with javascript
const randomNumber = (min, max) => Math.floor(Math.random() * (max - min + 1) + min);
const randomByte = () => randomNumber(0, 255)
const randomPercent = () => (randomNumber(50, 100) * 0.01).toFixed(2)
const randomCssRgba = () => `rgba(${[randomByte(), randomByte(), randomByte(), randomPercent()].join(',')})`