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
@sayhicoelho
sayhicoelho / bankRoutes.js
Created July 2, 2020 23:34
ACL with Nodejs and MongoDB.
const { Router } = require('express')
const ensureAuth = require('../middleware/ensureAuth')
const ensureHasPermissions = require('../middleware/ensureHasPermissions')
const bankController = require('../controllers/bankController')
const router = Router()
router.use('/', ensureAuth)
router.get('/', ensureHasPermissions('banks.read'), bankController.getAll)
router.get('/:id', ensureHasPermissions('banks.read'), bankController.getOne)
@sayhicoelho
sayhicoelho / getCssSelector.js
Created May 20, 2020 18:24
Get element CSS selector using JS
// ref: https://stackoverflow.com/a/57503796/4158755
// Thanks to Yassine!
function getCssSelector(el) {
const names = []
do {
let index = 0
let cursorElement = el
@sayhicoelho
sayhicoelho / event_emitter.dart
Last active May 9, 2020 19:13
Custom EventEmitter for Dart
class Listener {
final String eventName;
final void Function([Object]) callback;
Listener(this.eventName, this.callback);
}
class EventEmitter {
final _listeners = <Listener>[];
@sayhicoelho
sayhicoelho / EventEmitter.js
Last active May 9, 2020 19:06
Custom EventEmitter for Javascript
class EventEmitter {
constructor() {
this.listeners = []
}
addListener(event, listener) {
this.listeners.push({ event, listener })
}
removeListener(event, listener) {
@sayhicoelho
sayhicoelho / ensureFileIsPresent.js
Created May 6, 2020 21:43
Node.js & Multer check if file is present in the request.
module.exports = (req, res, next) => {
if (!req.file) {
res.status(422).json({ message: 'The file is required.' });
} else {
next();
}
}
@sayhicoelho
sayhicoelho / CustomSearchable.dart
Last active May 2, 2020 22:35
Flutter Searchable Input
import 'package:flutter/material.dart';
import './custom_searchable_dialog.dart';
import './custom_text_field.dart';
class CustomSearchableItem<T> {
final String label;
final T value;
CustomSearchableItem({
@required this.label,
@sayhicoelho
sayhicoelho / config.ini
Last active January 7, 2022 08:26 — forked from FlokiTV/config.ini
Cyber Hunter config.ini
[account]
first_login_game = 0
[settings]
open_music = 1
voice_language = english
graphic_lvl_reported = 1
match_type = 100004
[basic_setting]
<!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" />
<title>Buzzr: Fale com desconhecidos</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
@sayhicoelho
sayhicoelho / fuckyouuselesscomments.js
Created January 5, 2020 20:05
Remove useless comments from Facebook automatically using Tampermonkey.
// ==UserScript==
// @name Fuck you useless comments!
// @namespace http://tampermonkey.net/
// @version 0.0.1
// @description Remove useless comments from Facebook.
// @author Renan Coelho <sayhicoelho@gmail.com>
// @match https://www.facebook.com/*
// @grant none
// ==/UserScript==
@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'));