Skip to content

Instantly share code, notes, and snippets.

View roni5's full-sized avatar
πŸ’­
Typescript, Flutter , Python

Roni roni5

πŸ’­
Typescript, Flutter , Python
View GitHub Profile
@roni5
roni5 / !RemixVercelGitHubAction.markdown
Created February 27, 2024 14:34 β€” forked from mcansh/!RemixVercelGitHubAction.markdown
GitHub Action for automatically deploying a Remix app to Vercel

Things to note to make this work:

  1. you'll need to have your remix registry token available in your shell under REMIX_TOKEN
  2. you'll need to add secrets to your GitHub repo for the following items:
  3. you'll need to have your REMIX_TOKEN available in your vercel repo as an environment variable
The below are all the commands you need to run -- make sure to replace the IP with your own.
before deploying:
make sure environment variables are correct (.env vs .env.local)
npm build script (if you use prisma)
"build": "prisma db push && next build"
ssh root@62.72.26.118
apt install npm
npm install -g n
n latest
@roni5
roni5 / chaggpt.tsx
Last active February 21, 2024 18:37 β€” forked from MarkGeeRomano/useAutoScroll.js
useAutoScroll custom hook
import React, { useEffect, useRef } from 'react';
export function useAutoScroll(length) {
const elementRef = useRef(null);
const prevLengthRef = useRef(length);
useEffect(() => {
const prevLength = prevLengthRef.current;
prevLengthRef.current = length;
if (prevLength < length) {
@roni5
roni5 / View2.jsx
Created February 21, 2024 18:31 β€” forked from MarkGeeRomano/View2.jsx
View2 with custom hook
function View2() {
const [dropdowns, setDropdowns] = useState([])
const containerRef = useAutoScroll(dropdowns.length)
const addDropdown = () => {
setDropdowns(dropdowns => [
...dropdowns,
{ label: `Dropdown number ${dropdowns.length}` }
])
}
@roni5
roni5 / View.jsx
Created February 21, 2024 18:30 β€” forked from MarkGeeRomano/View.jsx
Initial View
import React, { useState } from 'react';
import Tile from './Tile';
import pokeUrls from './pokeImgUrls';
import './App.css';
function App() {
const [pokemon, setPokemon] = useState(pokeUrls.map(url => ({ url, isFavorite: false })))
@roni5
roni5 / Tile.jsx
Created February 21, 2024 18:29 β€” forked from MarkGeeRomano/Tile.jsx
Tile memoized
import React, { memo } from 'react';
const Tile = memo(({
toggleFavorite,
pokemon: { url, isFavorite },
}) => {
return (
<div className="tile-container" onClick={toggleFavorite}>
<img src={url} />
<div className="text-container">
@roni5
roni5 / App.jsx
Created February 21, 2024 18:28 β€” forked from MarkGeeRomano/App.jsx
App with callback as arg to setter
import React, { useState } from 'react';
import Tile from './Tile';
import pokeUrls from './pokeImgUrls';
import './App.css';
function App() {
const [pokemon, setPokemon] = useState(pokeUrls.map(url => ({ url, isFavorite: false })))
@roni5
roni5 / function.sh
Created February 21, 2024 18:26 β€” forked from MarkGeeRomano/function.sh
Docker refresh bash function
docker-refresh () {
IMAGE="${1}"
SUBSTRINGED_IMAGE=$(echo "$IMAGE" | cut -c8-)
if [[ "$PORTAL_DOCKER_PATH" != "" ]]
then
source ${PORTAL_DOCKER_PATH}/init.sh
else
source init.sh
fi
@roni5
roni5 / App.jsx
Created February 21, 2024 13:56 β€” forked from MarkGeeRomano/App.jsx
reducer starter
import React, { useState, useEffect, useReducer } from 'react'
//...
function App() {
const [direction, setDirection] = useState('right')
const [position, dispatch] = useReducer(reducer, [0, 0])
function reducer([x, y]) {
const defaultState = [0, 0]
switch (direction) {
@roni5
roni5 / App.jsx
Created February 21, 2024 13:55 β€” forked from MarkGeeRomano/App.jsx
snek -2
import React, { useState, useEffect } from 'react'
const rowsLength = 10
const grid = [];
[...Array(rowsLength).keys()].forEach(i => [...Array(rowsLength).keys()].forEach((_, j) => grid.push([i, j])))
function App() {
const [position, setposition] = useState([0, 0])
return (
<div style={makeOuterStyles()}>