Skip to content

Instantly share code, notes, and snippets.

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

Hasan Biyik hahuaz

🏠
Working from home
View GitHub Profile
@hahuaz
hahuaz / index.vue
Created September 26, 2021 08:23
edit typo in vue
<template>
<div class="text__container">
<label for="text">put text:</label>
<textarea
id=""
v-model="text"
name="texts"
cols="30"
rows="10"
style="border: 1px solid black"
@hahuaz
hahuaz / useEffect-with-setTimeout.jsx
Last active November 14, 2021 04:14
useEffect-with-setTimeout
import React, { useEffect } from 'react';
import { useImmer } from 'use-immer';
export default function Input() {
const [state, setState] = useImmer({
name: '',
});
const handleNameChange = (e) => {
setState((draft) => {
@hahuaz
hahuaz / background-image-opacity.html
Created February 20, 2022 05:04
makes text more readable over the image
<!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>
.block {
position: relative;
@hahuaz
hahuaz / debounce.js
Created February 20, 2022 20:58
Debounce input event with vanilla js
// Debounce input event on vanilla js
// let debounceTimer;
// function handleInput(e) {
// window.clearTimeout(debounceTimer);
// debounceTimer = window.setTimeout(() => console.log(e.target.value), 1000);
// }
// document.querySelector('#input').addEventListener('input', handleInput);
// Use higher-order debounce function to debounce an event listener
/**
*
* @param {} obj object to filter
* @param {...any} allowedKeys proporties to keep
* @returns object with only allowed keys
*/
const filterObj = (obj, ...allowedKeys) => {
const newObj = {};
Object.keys(obj).forEach((key) => {
if (allowedKeys.includes(key)) {
{
"name": "myproject",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"switch": "shopify switch --store <storeUrl>",
"dev": "npm-run-all --parallel serve convert-sass",
"serve": "shopify theme dev <storeUrl> --live-reload hot-reload --theme-editor-sync",
"convert-sass": "sass --watch --no-source-map sass/:assets/"
@hahuaz
hahuaz / encryption.js
Created October 16, 2022 13:19 — forked from vlucas/encryption.js
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
<body>
<div class="ui-settings">
<div>
<label for="dark">Enable dark mode:</label>
<input type="checkbox" name="dark" id="dark-mode-checkbox" />
</div>
</div>
<div class="ui-elements">
<div class="w-20 h-20 bg-green-500 dark:bg-gray-500"></div>