Skip to content

Instantly share code, notes, and snippets.

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

Renan Coelho sayhicoelho

🏠
Working from home
  • Hotcafe.io
  • Rio de Janeiro, Brazil
View GitHub Profile
@sayhicoelho
sayhicoelho / whatsapp-sendMessage.js
Last active January 5, 2025 10:31
Send messages to WhatsApp (web version only) programmatically.
function sendMessage(message){
const mainEl = document.querySelector('#main')
const textareaEl = mainEl.querySelector('div[contenteditable="true"]')
if(!textareaEl) {
throw new Error('There is no opened conversation')
}
textareaEl.focus()
document.execCommand('insertText', false, message)
@sayhicoelho
sayhicoelho / slugify.js
Created November 25, 2018 04:35
Javascript slugify.
function slugify (str) {
str = str || ''
const a = 'àáäãâèéëêìíïîòóöõôùúüûñçßÿœæŕśńṕẃǵǹḿǘẍźḧ·/_,:;άαβγδεέζήηθιίϊΐκλμνξοόπρσςτυϋύΰφχψωώ'
const b = 'aaaaaeeeeiiiiooooouuuuncsyoarsnpwgnmuxzh------aavgdeeziitiiiiklmnxooprsstyyyyfhpoo'
const p = new RegExp(a.split('').join('|'), 'g')
return str.toString().trim().toLowerCase()
.replace(/ου/g, 'ou')
.replace(/ευ/g, 'eu')
.replace(/θ/g, 'th')
@sayhicoelho
sayhicoelho / whatsapp-emoji-reply.js
Created November 25, 2018 05:21
WhatsApp auto reply based on emoji.
let interval, emojis
emojis = {
cachorro: '🐶',
gato: '🐱',
rato: '🐭',
rato: '🐹',
coelho: '🐰',
raposa: '🦊',
urso: '🐻',
@sayhicoelho
sayhicoelho / index.html
Created January 12, 2019 03:38
Noscript for HTML.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<noscript>
<meta http-equiv="refresh" content="0; URL=/noscript.html" />
</noscript>
<title>Loading...</title>
@sayhicoelho
sayhicoelho / select_estados.html
Last active May 23, 2019 22:39 — forked from quagliato/select_estados.html
<select> com todos os estados brasileiros
<select id="estado" name="estado">
<option value="AC">Acre</option>
<option value="AL">Alagoas</option>
<option value="AP">Amapá</option>
<option value="AM">Amazonas</option>
<option value="BA">Bahia</option>
<option value="CE">Ceará</option>
<option value="DF">Distrito Federal</option>
<option value="ES">Espírito Santo</option>
<option value="GO">Goiás</option>
@sayhicoelho
sayhicoelho / facebook-instant-block-user.js
Last active March 13, 2020 17:47
Block users in their comments by pressing right mouse button.
// ==UserScript==
// @name Facebook Instant Block User
// @namespace http://tampermonkey.net/
// @version 1.0.0
// @description try to take over the world!
// @author You
// @match https://www.facebook.com*
// @grant none
// ==/UserScript==
<?php
namespace App\Http\Controllers;
use PagSeguro;
use Carbon\Carbon;
use App\Transaction;
use Artistas\PagSeguro\PagSeguroException;
use Illuminate\Http\Request;
@sayhicoelho
sayhicoelho / encodable.dart
Created July 27, 2019 00:47
Generate JSON from object instance in Dart lang.
import 'dart:mirrors';
import 'dart:convert';
class Encodable {
String toJson({List<String> only, List<String> except}) {
InstanceMirror myClassInstanceMirror = reflect(this);
ClassMirror myClassMirror = myClassInstanceMirror.type;
List<DeclarationMirror> dms = myClassMirror.declarations.values
.where((dm) => dm is VariableMirror && !dm.isStatic)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>example-app</title>
<style>
html,
body {
@sayhicoelho
sayhicoelho / CustomValidator.php
Last active December 12, 2019 13:51
Translate 'yesterday', 'now', 'today' and 'tomorrow' words with Laravel
<?php
namespace App\Validator;
use Carbon\Carbon;
class CustomValidator extends \Illuminate\Validation\Validator {
protected function getTimePeriods($parameter) {
$keys = array_keys(trans('validation.time_periods'));
$values = array_values(trans('validation.time_periods'));