Skip to content

Instantly share code, notes, and snippets.

View pcastelan's full-sized avatar

Paula Castelan pcastelan

View GitHub Profile
@pcastelan
pcastelan / index-laragon.php
Last active November 28, 2024 15:25
Simple Home page for Laragon server root
<?php
date_default_timezone_set('America/Sao_Paulo'); // CHANGE: timezone
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_connect($sock, "8.8.8.8", 53);
socket_getsockname($sock, $localAddr); // now the $localAddr will have the machine ip
$dirs = array_filter(glob('*'), 'is_dir');
?>

Improved .sr-only

Theorically bulletproof CSS class for visually hide anything and keep it accessible to ATs.

A Pen by ffoodd on CodePen.

License.

@pcastelan
pcastelan / localStorage.js
Last active July 21, 2022 15:51
localStorage with fallback in memory
// Local Storage with fallback in memory
class CustomStorage
{
fallbackStorage = {};
isLocalAvailable = false;
prefix = '';
constructor(prefix) {
this.isLocalAvailable = this.isStorageAvailable();
@pcastelan
pcastelan / recursive_list.twig
Created May 3, 2020 22:13 — forked from isthatcentered/recursive_list.twig
Recursive list template for Twig using recursive macros. Compatible Twig 2.x // for grandpas or hipsters using twig in js (hello friends :D )
{% macro list(items, class) %}
<ul class="{{class}}">
{# Iterating over each direct items #}
{% for item in items %}
<li>
<a href="">{{item.name}}</a>
{# If an item has children #}
{% if item.children %}
@pcastelan
pcastelan / README.md
Created March 23, 2019 23:48 — forked from joyrexus/README.md
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@pcastelan
pcastelan / halt-promise.js
Created February 15, 2019 16:37
promise with a "timeout".
public function promiseWithTimeout(something, maxTime) {
let timeout = new Promise ((resolve, reject) => {
let counter = setTimeout(() => {
clearTimeout(counter);
reject('TIMEOUT');
}, maxTime)
});
return Promise.race([
something,
@pcastelan
pcastelan / numberToReal.js
Created February 14, 2019 12:33
turn number into a string in R$ format
numberToReal(numero) {
if (isNaN(numero)) {
return '';
}
numero = Number(numero).toFixed(2).split('.');
numero[0] = numero[0].split(/(?=(?:...)*$)/).join('.');
return numero.join(',');
}
@pcastelan
pcastelan / dateBRtoISO.js
Created February 14, 2019 12:31
format date string from pt-BR to ISO
formatDateString(string) {
let fullDate = string.split(" ");
let day = fullDate[0];
let time = fullDate[1];
day = day.split("/");
return (day[2] + "-" + day[1] + "-" + day[0] + "T" + time);
}