Skip to content

Instantly share code, notes, and snippets.

View pedroborges's full-sized avatar
🏠
Working from home

Pedro Borges pedroborges

🏠
Working from home
  • Brazil
View GitHub Profile
@EllyLoel
EllyLoel / reset.css
Last active April 13, 2024 18:14
CSS Reset
/*
Made by Elly Loel - https://ellyloel.com/
With inspiration from:
- Josh W Comeau - https://courses.joshwcomeau.com/css-for-js/treasure-trove/010-global-styles/
- Andy Bell - https://piccalil.li/blog/a-modern-css-reset/
- Adam Argyle - https://unpkg.com/open-props@1.3.16/normalize.min.css / https://codepen.io/argyleink/pen/KKvRORE
Notes:
- `:where()` is used to lower specificity for easy overriding.
*/
@rikschennink
rikschennink / nudgeable.ts
Last active October 22, 2023 05:53
⌨️ A Svelte action to add arrow key interaction to an element
export default (element: HTMLElement, options: any = {}) => {
// if added as action on non focusable element you should add tabindex=0 attribute
const {
direction = undefined,
shiftMultiplier = 10,
bubbles = false,
stopKeydownPropagation = true,
} = options;
function flattenFolderTree(folders) {
return folders.reduce((acc, folder) => {
const {children, ...rest} = folder;
if (!children || !children.length) {
return [...acc, rest];
}
return [...acc, rest, ...flattenFolderTree(children)];
}, []);
<x-layout>
<x-section>
<x-tabs active="First">
<x-tab name="First">
First content goes here.
</x-tab>
<x-tab name="Second">
Second content goes here.
</x-tab>
<?php
$spaces = [
'driver' => 's3',
'key' => env('DO_SPACES_KEY'),
'secret' => env('DO_SPACES_SECRET'),
'endpoint' => env('DO_SPACES_ENDPOINT'),
'region' => env('DO_SPACES_REGION'),
'bucket' => env('DO_SPACES_BUCKET')
];
@lukaskleinschmidt
lukaskleinschmidt / bootstrap.php
Created March 2, 2020 09:17
Kirby Thumbnails
<?php
// bootstrap/kirby.php
include dirname(__DIR__) . '/vendor/autoload.php';
$kirby = new Kirby([
'roots' => [
'base' => $base = dirname(__DIR__),
'index' => $base . '/public',
'content' => $base . '/content',
@lukaskleinschmidt
lukaskleinschmidt / index.js
Last active October 2, 2020 14:06
Kirby Structure Field Preview
panel.plugin('lukaskleinschmidt/site', {
components: {
'k-structure-field-preview': {
props: {
value: String,
column: Object,
field: Object
},
computed: {
text: function() {
@nkeena
nkeena / HasFilters.php
Created February 5, 2020 04:52
A simple trait that provides robust filtering by a model's attributes
<?php
namespace App\Traits;
use Illuminate\Support\Str;
trait HasFilters
{
public function scopeFilter($query, $filters = [])
{

How to setup a practically free CDN using Backblaze B2 and Cloudflare

⚠️ Note 2023-01-21
Some things have changed since I originally wrote this in 2016. I have updated a few minor details, and the advice is still broadly the same, but there are some new Cloudflare features you can (and should) take advantage of. In particular, pay attention to Trevor Stevens' comment here from 22 January 2022, and Matt Stenson's useful caching advice. In addition, Backblaze, with whom Cloudflare are a Bandwidth Alliance partner, have published their own guide detailing how to use Cloudflare's Web Workers to cache content from B2 private buckets. That is worth reading,

@lucaspar
lucaspar / IRRF-imposto.js
Last active January 22, 2024 16:04
Cálculo de IR em JavaScript com teste unitário.
/* Fonte: https://gist.github.com/lucaspar/2c20754b37920217678cebb64170cb7a */
/**
* Calcula o imposto de renda sobre o valor de rendimentos tributáveis,
* conforme tabela progressiva do ano tributário de 2023, seguindo a
* incidência mensal do imposto sobre a renda de pessoas físicas (IRPF).
*
* @params {Number} rendimentos Renda a ser tributada, em R$.
* @returns {Number} imposto a pagar sobre `rendimentos`, em R$.
**/