Skip to content

Instantly share code, notes, and snippets.

View cagataycali's full-sized avatar
🧬

./c² cagataycali

🧬
View GitHub Profile
@cagataycali
cagataycali / README.md
Last active July 31, 2022 16:43
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
@cagataycali
cagataycali / index.html
Last active November 25, 2021 02:36
[HTML + CSS + JS] Simple auto complete
<!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>Auto Complete</title>
<style>
#container {
width: 200px;
@cagataycali
cagataycali / auto-complete.js
Created November 24, 2021 08:28
[Trie] Prefix tree for find auto complete suggestions
class Node {
constructor(char) {
this.char = char;
this.children = new Map(); // It's limited by 26 chars, hashmap.
this.isEndWord = false;
}
}
class Trie {
constructor() {
this.root = new Node("");
@cagataycali
cagataycali / throttle.js
Created November 24, 2021 04:08
[JavaScript] throttle
function throttle (callback, limit) {
var waiting = false; // Initially, we're not waiting
return function () { // We return a throttled function
if (!waiting) { // If we're not waiting
callback.apply(this, arguments); // Execute users function
waiting = true; // Prevent future invocations
setTimeout(function () { // After a period of time
waiting = false; // And allow future invocations
}, limit);
}
@cagataycali
cagataycali / index.html
Created November 24, 2021 04:03
Star component - simple
<html>
<head>
<title>Star component</title>
<style>
.star-wrapper {
display: flex;
flex-direction: row-reverse;
justify-content: flex-end;
}
.star {
@cagataycali
cagataycali / index.html
Last active November 24, 2021 01:05
[HTML] Accordion menu - simple
<html>
<head>
<title>Accordion menu - Simple</title>
<style>
.accordion-wrapper {
display: flex;
align-items: center;
flex-direction: column;
}
.accordion {
@cagataycali
cagataycali / button-generator.html
Last active November 25, 2021 02:48
HTML Button generator
<html>
<head>
<title>Button Generator</title>
<style>
#container button {
padding: 1rem;
margin: 1rem;
border-color: transparent;
border-radius: 5px;
color: white;
@cagataycali
cagataycali / bad-words.js
Last active November 24, 2021 09:57
[JavaScript] Bad word finder
const assert = require("assert");
function generateTrie(array) {
const trie = { "": {} };
for (const word of array) {
let currentNode = trie[""];
Array.from(word).forEach((char) => {
if (!currentNode[char]) {
currentNode[char] = {};
}
@cagataycali
cagataycali / hashmap-of-hashmaps.js
Last active November 22, 2021 15:38
[JavaScript] Hashmap of hashmaps
function generate(...input) {
const tree = {'': {}};
for (const text of input) {
let currentNode = tree[''];
Array.from(text).forEach(char => {
if (!currentNode[char]) {
currentNode[char] = {};
}
currentNode = currentNode[char]
})
@cagataycali
cagataycali / debounce.js
Created November 22, 2021 12:23
[JavaScript] Debounce
function debounce(func, wait, immediate) {
let timeout = null;
return function () {
let context = this;
let args = arguments;
const later = function () {
timeout = null;
if (!immediate) func.apply(context, args);
}
const callNow = immediate && !timeout;