Skip to content

Instantly share code, notes, and snippets.

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

Mikdat DOĞRU mikdatdogru

🏠
Working from home
  • Istanbul, Turkey
View GitHub Profile
import { useState, useLayoutEffect } from 'react'
const useLocalStorage = (key, defaultValue = null, prefix = 'store') => {
const storeKey = `${prefix}-${key}`
const [value, setValue] = useState(() => {
const data = localStorage.getItem(storeKey)
return data === null ? defaultValue : JSON.parse(data)
})
@HJianBo
HJianBo / LC_CTYPE.txt
Created November 7, 2017 02:02 — forked from jampajeen/LC_CTYPE.txt
Centos warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
vi /etc/environment
add these lines...
LANG=en_US.utf-8
LC_ALL=en_US.utf-8
@paulhayes
paulhayes / ColorExt.cs
Last active July 20, 2022 11:37
Extension to Unity3d Color and Color32. Allows easy converting of Color to hex string.
using UnityEngine;
using System.Collections;
public static class ColorExt {
public static string ToHexString(this Color32 c){
return string.Format ("{0:X2}{1:X2}{2:X2}", c.r, c.g, c.b);
}
public static string ToHexString(this Color color){
// This will open up a prompt for text to send to a console session on digital ocean
// Useful for long passwords
(function () {
var t = prompt("Enter text to be sent to console, (This wont send the enter keystroke)").split("");
function f() {
var character = t.shift();
var i=[];
var code = character.charCodeAt();
var needs_shift = "!@#$%^&*()_+{}:\"<>?~|".indexOf(character) !== -1