Skip to content

Instantly share code, notes, and snippets.

View indie-rok's full-sized avatar
🏠
Working from home

Emmanuel Orozco indie-rok

🏠
Working from home
View GitHub Profile
@indie-rok
indie-rok / backend.js
Created February 3, 2022 14:46
CRUD_react_query
const express = require('express')
const app = express()
const cors = require('cors')
app.use(express.json())
app.use(cors())
let items = [{ id: 1, title: 'Hello' }]
app.get('/items', (req, res) => {
const express = require('express')
const app = express()
const { Client } = require('pg')
require('dotenv').config()
app.get('/test', async (req, res) => {
let connectionString;
import React from 'react';
import './App.css';
function App() {
return (
<div className="App">
<GreetingComponent />
</div>
);
import json from "./data.json";
import { useState } from "react";
function App() {
const [data, setData] = useState(json);
const upvotePost = (postId) => {
const indexToModify = data.post.findIndex((post) => {
return post.id === postId;
});
const n = 6;
const votes = ["red", "yellow", "blue", "red", "yellow", "red"];
function counter(n, votes) {
let histogram = {}; //https://en.wikipedia.org/wiki/Histogram
votes.forEach((vote) => {
if (!histogram[vote]) histogram[vote] = 0;
histogram[vote]++;
});
@indie-rok
indie-rok / client.js
Created January 11, 2022 08:06
websockets
import React, { useState, useEffect } from "react";
import { io } from "socket.io-client";
const socket = io("http://localhost:5000/");
function App() {
const [messageList, setMessageList] = useState([]);
const [nickName, setNickName] = useState("");
const [newMessageText, setNewMessageText] = useState("");
const [number, setNumber] = useState();
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body>
<h1>Contacts</h1>
<div id="contact-container"></div>
React Native Cheatsheet
+------------------------------+-----------------------------------------+--------------------------------------------------+
| | React | React Native |
+------------------------------+-----------------------------------------+--------------------------------------------------+
| CSS | inline + css | just inline |
+------------------------------+-----------------------------------------+--------------------------------------------------+
| HTML Containers | <div>,<section>, etc | <View/> |
+------------------------------+-----------------------------------------+--------------------------------------------------+
| HTML Text | <p>,<h1>,etc | <Text/> + style
module.exports = function solve(maze, miner, exit) {
let directionsArray = ["up", "right", "down", "left"];
const movements = {
left: { x: -1, y: 0 },
right: { x: 1, y: 0 },
up: { x: 0, y: -1 },
down: { x: 0, y: 1 }
};
const xNum = maze.length;
@indie-rok
indie-rok / index.txt
Created January 8, 2019 23:31 — forked from EQuimper/index.txt
clear expo cache
rm -fr ~/.expo/starter-app-cache