This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const app = express() | |
const { Client } = require('pg') | |
require('dotenv').config() | |
app.get('/test', async (req, res) => { | |
let connectionString; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import './App.css'; | |
function App() { | |
return ( | |
<div className="App"> | |
<GreetingComponent /> | |
</div> | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]++; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Document</title> | |
</head> | |
<body> | |
<h1>Contacts</h1> | |
<div id="contact-container"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
React Native Cheatsheet | |
+------------------------------+-----------------------------------------+--------------------------------------------------+ | |
| | React | React Native | | |
+------------------------------+-----------------------------------------+--------------------------------------------------+ | |
| CSS | inline + css | just inline | | |
+------------------------------+-----------------------------------------+--------------------------------------------------+ | |
| HTML Containers | <div>,<section>, etc | <View/> | | |
+------------------------------+-----------------------------------------+--------------------------------------------------+ | |
| HTML Text | <p>,<h1>,etc | <Text/> + style |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rm -fr ~/.expo/starter-app-cache |
NewerOlder