Skip to content

Instantly share code, notes, and snippets.

@Akifcan
Akifcan / elasticdemo.js
Created October 20, 2022 19:44
Elastic Search Demo
const data = [
'the bright blue butterfly hangs on the breeze',
'its best to forget the great sky and to retire from every wind',
'under blue sky in bright sunlight, one not need search around',
'Love is blind. ',
`I don't want to go to school.`,
`Let's get it over with.`,
`The red one. `,
`I have a big dog. `,
`Where's the nearest bus stop? `,
@Akifcan
Akifcan / useScript.js
Created September 15, 2022 09:18
Next.js useScript hook. Rerender script when route changed
import React, { ReactNode, useState, useEffect } from "react"
import { useRouter } from "next/router"
import Script from "next/script"
const useScript = (paths: string[]) => {
const [scriptTag, setScriptTag] = useState<ReactNode>(<></>)
const router = useRouter()
useEffect(() => {
@Akifcan
Akifcan / slider.js
Created September 11, 2022 16:12
slider
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
@Akifcan
Akifcan / stacked-cards.js
Created August 16, 2022 19:45
Stacked Cards
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
@Akifcan
Akifcan / calendar.js
Created August 11, 2022 07:11
Calendar
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
@Akifcan
Akifcan / schedule.js
Created July 23, 2022 23:50
My task scheduling implementation
const schedules = [{
id: 'a',
fun() {
console.log('a dependency run!')
},
depends_on: ['b', 'c']
},
{
id: 'b',
fun() {
@Akifcan
Akifcan / flat.js
Created July 10, 2022 11:40
Flatten
const x = [[5, 3, 2], 5, 1, 99, [3, [4, 5]]]
const flatten = []
function myFlat(arr){
arr.forEach(i => {
if(Array.isArray(i)){
myFlat(i)
@Akifcan
Akifcan / map.js
Created July 10, 2022 09:08
My own map implementation in javascript
const people = [
{
name: 'akif',
status: 'full stack developer'
},
{
name: 'sebnem ferah ❤❤',
status: 'artist'
},
]
@Akifcan
Akifcan / split.js
Created July 10, 2022 08:26
My own split implementation in javascript
const mySplit = (str, part) => {
const arr = []
let currentWorld = ''
for(let i = 0; i<str.length; i++){
const current = str[i]
if(current !== part){
currentWorld+=current
}
if(current === part || str.length - 1 === i){
arr.push(currentWorld)
@Akifcan
Akifcan / missing-number.js
Created May 4, 2022 10:20
Missing Number
const profile = {
name: 'peter',
age: 55,
kids: [{
name: 'jil',
age: 23
},
{
name: 'peter',
age: 1