Skip to content

Instantly share code, notes, and snippets.

@hertz1
hertz1 / gist:2d80efc9ec578c9d2dbfb323466c222d
Created November 11, 2024 19:29
Slack Web Auto Dark Mode
// ==UserScript==
// @name Slack Web Auto Dark Mode
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Automatically toggle dark mode on web version of slack.com
// @author Danilo Azevedo
// @match https://app.slack.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=slack.com
// @grant none
// @license Apache-2.0
@hertz1
hertz1 / UserRepository.php
Last active March 13, 2020 20:26
Laravel Lazy-Collections With Doctrine
<?php
namespace App\Repositories;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Internal\Hydration\IterableResult;
class UserRepository extends EntityRepository
{
public function getUsersIterable(): IterableResult
@hertz1
hertz1 / range.js
Last active September 22, 2015 14:45
Implementation of python's range() function in javascript.
/**
* Range function, similar to python's one.
* If you want to use it in for...in loops, all 4 arguments must be passed.
* @param {Number} Start - If omited, it defaults to 0.
* @param {Number} Stop
* @param {Number} Step - If omited, it defaults to 1.
* @param {Boolean} Object - If returns an object or not. Mostly used in for...in loops.
* @return {Mixed} If Object is true, returns an object, otherwise, returns an array.
*
* Examples:
@hertz1
hertz1 / removerAcentos.js
Last active August 20, 2024 12:44
Função simples e eficiente para remover todos os tipos de acentos da língua portuguesa.
/**
* Remove acentos de strings
* @param {String} string acentuada
* @return {String} string sem acento
*/
var map={"â":"a","Â":"A","à":"a","À":"A","á":"a","Á":"A","ã":"a","Ã":"A","ê":"e","Ê":"E","è":"e","È":"E","é":"e","É":"E","î":"i","Î":"I","ì":"i","Ì":"I","í":"i","Í":"I","õ":"o","Õ":"O","ô":"o","Ô":"O","ò":"o","Ò":"O","ó":"o","Ó":"O","ü":"u","Ü":"U","û":"u","Û":"U","ú":"u","Ú":"U","ù":"u","Ù":"U","ç":"c","Ç":"C"};
function removerAcentos(s){ return s.replace(/[\W\[\] ]/g,function(a){return map[a]||a}) };