Skip to content

Instantly share code, notes, and snippets.

View jordiup's full-sized avatar
👀
Looking for my next role!

Jordi Hermoso jordiup

👀
Looking for my next role!
View GitHub Profile
@jordiup
jordiup / zod-postgres-connection.ts
Created August 29, 2024 14:45
Zod Postgres Connection Schema
import { z } from 'zod';
const connectionSchema = z.object({
user: z.string(),
password: z.string(),
host: z.string(),
database: z.string(),
port: z.number().int().positive().default(5432),
ssl: z.boolean().default(true),
pooling: z.boolean().default(true),
@jordiup
jordiup / use-multiple-gh-accounts-in-desktop.md
Last active October 24, 2024 19:56 — forked from TheGardenMan/use-multiple-gh-accounts-in-desktop.md
How to use multiple GitHub accounts in GitHub Desktop

How to use multiple GitHub accounts in GitHub Desktop

Background

Let's say you have two users and repos likejordiup/repo1 and not_jordiup/repo2.

You want to push and pull from them using different accounts.

Solution

@jordiup
jordiup / getLastModifiedGitDate.ts
Last active October 25, 2023 04:53
useful for fetching a last modified value from a blog post
function getLastModifiedGitDate(filePath: string): Date {
filePath = 'README.md';
const query = `
{
repository(owner: "jordiup", name: "sharehouse") {
ref(qualifiedName: "refs/heads/main") {
target {
... on Commit {
history(first: 1, path: "${filePath}") {
edges {
{
"activities": [
{
"actor": {
"email": "[email protected]",
"familyName": "Wilkes",
"givenName": "Josh",
"id": "usr_2SPP3b2dtynEPF9RMJESySftFJu"
},
"allowed": true,
@jordiup
jordiup / CustomAvatar.tsx
Created May 27, 2023 02:49
# Nativebase Avatar with Coloured Text (Chakra UI Equivalent)
import React from 'react';
import ColorHash from 'color-hash';
import { Circle, ICircleProps, Image, Text } from 'native-base';
type Props = {
firstName: string;
lastName?: string;
name?: string;
size?: string;
src?: string;
{
"targets": [
{
"id": "1a3a6e75-fc32-4f36-8d7c-9fe2f7c0a2a1",
"targetGroupId": "group-1",
"targetGroupFrom": {
"publisher": "common-fate",
"name": "aws",
"version": "v1.0.0",
"kind": "string"
@jordiup
jordiup / Tabs.tsx
Created April 2, 2023 05:24
Tabs Component in React Native, complete with Typescript Typings
import React, { ReactNode, useEffect, useState } from 'react';
import { View } from 'react-native';
interface TabsProps {
tabIndex: number;
children: ReactNode[];
}
export const Tabs: React.FC<TabsProps> = ({ tabIndex, children }) => {
const [activeTab, setActiveTab] = useState(0);
import { ChatGPTAPI } from 'chatgpt';
import { NextApiRequest, NextApiResponse } from 'next';
import { notifyAdmin } from '../../../utils/twillio';
export type InputAI = {;
variableA: string;
variableB: string;
variableC: string;
};
@jordiup
jordiup / chat_gpt_export_to_html.js
Created December 5, 2022 13:06
ChatGPT Export To HTML - run this in your browser console :)
javascript:(function() { const a = document.createElement('a'); a.href = URL.createObjectURL(new Blob([document.querySelector('[class^="ThreadLayout__NodeWrapper"]').innerHTML.replace(/<img[^>]*>/g, '').replace(/<button[^>]*>.*?<\/button>/g, '').replace(/<svg[^>]*>.*?<\/svg>/g, '')], {type: 'text/html'})); a.download = 'chatGPT.html'; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(a.href); })()
@jordiup
jordiup / docker-compose.yml
Created September 25, 2022 06:36
postgres/pg-web docker compose file
version: '3'
services:
postgres:
image: postgres:12
ports:
- '5432:5432'
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres