Skip to content

Instantly share code, notes, and snippets.

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

Renan Coelho sayhicoelho

🏠
Working from home
View GitHub Profile
<!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 / 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)
<?php
namespace App\Http\Controllers;
use PagSeguro;
use Carbon\Carbon;
use App\Transaction;
use Artistas\PagSeguro\PagSeguroException;
use Illuminate\Http\Request;
@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==
@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 / 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 / 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 / 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-sendMessage.js
Last active October 8, 2023 06:58
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 / README.md
Last active September 19, 2018 15:36
A simple flash function for Express applications using Node.

Node & Express flash messages

Using this bit of code you will able to pass flash messages between requests, i.e you can pass old inputs passed by the last request, errors and custom strings, objects and arrays.

Usage

app.post('/login', (req, res) => {
  if (false) {
    req.flash('input', {
      username: req.body.email
 })