Skip to content

Instantly share code, notes, and snippets.

View tarsusi's full-sized avatar
🏠
Working from home

Ömer Burak KARATAŞ tarsusi

🏠
Working from home
View GitHub Profile
@tarsusi
tarsusi / CountDown.jsx
Created May 13, 2024 08:22
CountDown React Component
import { useState, useEffect } from 'react';
const CountDown = ({ hours = 0, minutes = 0, seconds = 0 }) => {
const [paused, setPaused] = useState(false);
const [over, setOver] = useState(false);
const [[h, m, s], setTime] = useState([hours, minutes, seconds]);
const tick = () => {
if (paused || over) return;
if (h === 0 && m === 0 && s === 0) setOver(true);
@tarsusi
tarsusi / gist:dae9fe640d9397ce8e94520f02d699c0
Created October 6, 2023 07:26
Difference between slice, substr and substring
TL;DR:
If you know the index (the position) on which you'll stop (but NOT include), use slice().
If you know the length of characters to be extracted, you could use substr(), but that is discouraged as it is deprecated.
Otherwise, read on for a full comparison
Syntax
string.slice(start,end)
string.substr(start,length)
string.substring(start,end)
Note #1: slice()==substring()
@tarsusi
tarsusi / useOnlineStatus.jsx
Last active September 23, 2023 04:33
useOnlineStatus
import { useState } from "react"
import useEventListener from "../useEventListener/useEventListener"
export default function useOnlineStatus() {
const [online, setOnline] = useState(navigator.onLine)
useEventListener("online", () => setOnline(navigator.onLine))
useEventListener("offline", () => setOnline(navigator.onLine))
return online
}
@tarsusi
tarsusi / Create and Host a Wordpress Website on AWS EC2.md
Last active September 23, 2023 04:33 — forked from teja156/gist:8c35a05f43635da4cbd06b47c0d91e93
Commands for deploying wordpress website on AWS EC2 shown in my YouTube video

YouTube video link: https://youtu.be/8Uofkq718n8 All the commands that are executed in the above youtube video are mentioned in this gist.

  1. Install Apache server on Ubuntu sudo apt install apache2

  2. Install php runtime and php mysql connector sudo apt install php libapache2-mod-php php-mysql

  3. Install MySQL server

import * as d3 from "d3";
export function BarChartRace(chartId, extendedSettings) {
const chartSettings = {
width: 500,
height: 400,
padding: 40,
titlePadding: 5,
columnPadding: 0.4,
ticksInXAxis: 5,
@tarsusi
tarsusi / dataGenerator.js
Last active March 5, 2020 18:30
Data Generator for Bar Chart Race
import { timeFormat } from "d3";
const brands = [
"Alcatel",
"Apple",
"Google",
"Huawei",
"LG",
"Motorola",
"Nokia",