Skip to content

Instantly share code, notes, and snippets.

View valterbarros's full-sized avatar
👊
Code makes me happy

Valter Barros valterbarros

👊
Code makes me happy
View GitHub Profile
const sheet = new CSSStyleSheet();
// border border-[#B0B0B0] mt-1 rounded outline-none py-1 px-3 h-8
sheet.replace(`
*, ::after, ::before {
box-sizing: border-box;
}
:host {
max-width: 100%;
width: auto;
class PromiseResolver {
constructor() {
this.promise_ = new Promise((resolve, reject) => {
this.resolve_ = resolve;
this.reject_ = reject;
})
}
get promise() { return this.promise_ }
get resolve() { return this.resolve_ }
get reject() { return this.reject_ }
@valterbarros
valterbarros / active_admin.js
Created April 25, 2023 19:53
handle toggle enablement reactivity
// vendor/assets/javascripts/active_admin.js
//= require active_admin/toggles_change_handling
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DocumentDetector</title>
<script src="https://repo.combateafraude.com/javascript/release/document-detector/5.4.0.umd.js"></script>
<script>
const getCafToken = async () => {
import { useEventListener } from '@vueuse/core';
import { computed, ref, watch } from 'vue';
import { useI18n } from '@/locales';
/** twilio message limit */
export const MAX_LENGTH = 200;
export const testingWatch = (maxLengthGeneral, form) => {
watch(form, (val1) => {
const gt = val1.name.length + val1.content.length >= MAX_LENGTH;
@valterbarros
valterbarros / testing-mutation-observer-2.test.js
Created January 27, 2023 16:34
mock mutation observer and use on jest test
const mockMutationObserver = function() {
observerDomChangesCaf.mockImplementation((_, errorCallback) => {
console.log('observerDomChangesCaf');
errorCallback();
});
const el = document.createElement('div');
useMutationObserver.mockImplementation((_, callback) => {
const mut = new MutationObserver(callback);
const orig = EventTarget.prototype.dispatchEvent;
EventTarget.prototype.dispatchEvent = function(...args) {
console.log('dispatch event', args)
return orig.apply(this, args);
}
var signalingChannel = new SignalingChannel();
var pc = new RTCPeerConnection({});
navigator.getUserMedia({ "audio": true }, gotStream, logError);
function gotStream(stream) {
pc.addStream(stream);
pc.createOffer(function(offer) {
pc.setLocalDescription(offer);
class OldCaf {
constructor(param) {
const SdkImport = window.PassiveFaceLivenessSdk;
this._sdk = new SdkImport(param);
}
open() {
}
@valterbarros
valterbarros / robbyrussell-custom.zsh-theme
Last active March 11, 2022 14:02
A oh my zsh theme that resume path string
# As that shows in the terminal: ~/../js/BR-OUROV-ITB-VERDE-SFCC <develop-ativos>
# installing
# on linux
# curl https://gist.githubusercontent.com/valterbarros/55df836e6ea5989bc15052a253c874e4/raw/9c9a73560244f3a520d6f85ad0e15c7f73cfa319/robbyrussell-custom.zsh-theme > $ZSH/themes/robbyrussell-custom.zsh-theme
# see instructions to set the theme https://github.com/ohmyzsh/ohmyzsh#selecting-a-theme
# set theme just for the current terminal instance: ZSH_THEME="robbyrussell-custom"
function return_status() {
echo "%(?..👾)"