Skip to content

Instantly share code, notes, and snippets.

View berkslv's full-sized avatar

Berk Selvi berkslv

View GitHub Profile
@berkslv
berkslv / docker-compose.yml
Created March 26, 2023 02:25
React deployment
version: '3'
services:
my-react-app:
build:
context: .
dockerfile: Dockerfile
ports:
- "80:80"
volumes:
@berkslv
berkslv / nginx.conf
Created March 26, 2023 02:23
React deploymeny
server {
listen 80;
server_name example.com;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}
@berkslv
berkslv / Dockerfile
Created March 26, 2023 02:20
Dockerfile for react deployment
# Use an official Node runtime as a parent image
FROM node:19-alpine as build
# Set the working directory to /app
WORKDIR /app
# Copy the package.json and package-lock.json to the container
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code to the container
COPY . .
@berkslv
berkslv / newtonRoot.js
Created January 22, 2021 20:38
Newton method for square root calculation in JavaScript. This code can be improved.
const newtonSquareRoot = (num) => {
let x = 1;
let result;
for (let i = 0; i < 20; i++)
{
result = x - ( x*x - num )/( 2*x );
x = result;
}
@berkslv
berkslv / app.js
Last active November 8, 2020 10:57
complete app.js
let puppeteer = require('puppeteer');
var nodemailer = require('nodemailer');
scrapePrice('https://www.google.com/search?client=opera&hs=Wzk&sxsrf=ALeKk00I7IW96h0D13mdL99WUos0Xhz5MA%3A1604829566135&ei=fsGnX_DmB4XosAeQpInwAQ&q=türk+hava+yolları+hisse&oq=türk+hava+yolları+hisse&gs_lcp=CgZwc3ktYWIQAzIICAAQyQMQywEyBQgAEMsBMgUIABDLATIFCAAQywEyBQgAEMsBMgUIABDLATIFCAAQywEyBQgAEMsBMgUIABDLATIFCAAQywE6BAgAEEc6CwguEMcBEK8BEMsBUMULWKYSYNcSaABwAngAgAGpAogBwAeSAQUwLjQuMZgBAKABAaoBB2d3cy13aXrIAQjAAQE&sclient=psy-ab&ved=0ahUKEwjwnduB2PLsAhUFNOwKHRBSAh4Q4dUDCAw&uact=5');
function main(srcTxt)
{
let currentPrice = srcTxt;
let myPrice = 9.62;
@berkslv
berkslv / app.js
Last active November 8, 2020 10:46
puppeter using
async function scrapePrice(url){
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(url);
const [el] = await page.$x('<XPath>');
const txt = await (await el.getProperty('textContent')).jsonValue(); // return 9,71 but parseFloat need to period not comma
browser.close();
let stringTxt = JSON.stringify(txt).replace('"',"").replace('"',"").replace(",","."); // first change json to string type, this return "number.decimal" and some string methods
}
@berkslv
berkslv / Chat.js
Created October 20, 2020 13:44
Chat.js for SignlaR
import React, { useState, useEffect, useRef } from "react";
import { HubConnectionBuilder } from "@microsoft/signalr";
import ChatWindow from "./ChatWindow";
import ChatInput from "./ChatInput";
import { Container } from "reactstrap";
const Chat = () => {
const [connection, setConnection] = useState(null);
const [chat, setChat] = useState([]);
const latestChat = useRef(null);
@berkslv
berkslv / index.js
Created October 20, 2020 13:41
index.js for reactstrap & bootstrap
import "bootstrap/dist/css/bootstrap.min.css";
@berkslv
berkslv / Startup.cs
Created October 20, 2020 13:25
Startup.cs ConfigureServices for SignalR
services.AddSignalR();
@berkslv
berkslv / Startup.cs
Created October 20, 2020 13:20
Startup.cs Configure for CORS
app.UseCors("ClientPermission");