Skip to content

Instantly share code, notes, and snippets.

View sbarbat's full-sized avatar
👨‍💻

Santiago Barbat sbarbat

👨‍💻
View GitHub Profile
@sbarbat
sbarbat / Chat.tsx
Created March 13, 2023 13:48
Chat.tsx
"use client";
import { Transition } from "@headlessui/react";
import {
ChatBubbleLeftIcon,
PaperAirplaneIcon,
XMarkIcon,
} from "@heroicons/react/24/outline";
import clsx from "clsx";
import { noop } from "lodash";
@sbarbat
sbarbat / SOQL Queries.sql
Created June 22, 2022 12:32 — forked from sholloway/SOQL Queries.sql
Useful SOQL queries for exploring a Salesforce org.
--------------------------------------------------------------------
-- Queries related to distribution of metadata.
-- Find the number of users per profile.
SELECT count(id), Profile.name
FROM User
WHERE User.IsActive = true
GROUP BY Profile.name
-- Find the distribution of Apex classes per namespace.
select count(id), NameSpacePrefix
import OutsideRoot from './OutsideRoot';
const Modal = () => {
return (
<OutsideRoot>
<MyModalComponent />
</OutsideRoot>
);
};
@sbarbat
sbarbat / OutsideRoot.tsx
Created November 5, 2021 12:18
OutsideRoot Component
import React, { useEffect, useState } from 'react';
import { createPortal } from 'react-dom';
import { randomInt } from '../services/utils';
const outsideRootContainer = document.getElementById('outside-root');
/**
* Used to render React components outside the
* `<div id="root"></div>` element. Handy to show
* alerts, modals, etc.
@sbarbat
sbarbat / deconstruction.tsx
Created October 8, 2021 08:35
Objects & Arrays deconstruction
const x = ['x']
const y = ['y']
const arr1 = [x, y] // [['x'], ['y']]
const arr2 = [...x, ...y] // ['x', 'y']
const a = {a: 'a'}
const b = {b: 'b'}
const obj1 = {x: a, y: b} // { x: {a: 'a'}, y: {b: 'b'}}
const obj2 = {...a, ...b} // {a: 'a', b: 'b'}
@sbarbat
sbarbat / App.tsx
Created August 11, 2021 16:42
App component for Medium article
import { nanoid } from 'nanoid';
const data = [
{
component: 'Test',
},
{
component: 'Test1',
props: {
name: "Santi"
import React, { Suspense } from 'react';
const DynamicComponents = (props: any) => {
return (
<Suspense fallback={<></>}>
{React.createElement(React.lazy(() => import(`./${props.component}`).catch(() => {})), props)}
</Suspense>
);
}
@sbarbat
sbarbat / Test2.tsx
Created August 11, 2021 16:37
Test2 component
const Test2 = (props: any) => (<div>Test2 - {props.name}</div>)
export default Test2;
@sbarbat
sbarbat / Test1.tsx
Created August 11, 2021 16:37
Test1 component
const Test1 = (props: any) => (<div>Test1 - {props.name}</div>)
export default Test1;
@sbarbat
sbarbat / app-error-handler.ts
Created December 29, 2020 13:56
Error handler for medium article
import {ErrorHandler, Inject, Injectable, PLATFORM_ID} from '@angular/core';
import {isPlatformBrowser} from '@angular/common';
@Injectable()
export class MyErrorHandler implements ErrorHandler {
constructor(@Inject(PLATFORM_ID) private platformId: any) {
}
handleError(error: any): void {