Skip to content

Instantly share code, notes, and snippets.

@lorisleiva
lorisleiva / AppWithLocalStorage.vue
Last active May 19, 2024 12:05
Abstraction of the local storage using Vue3's composition API
<script setup>
import useLocalStorage from './useLocalStorage'
const publicKey = useLocalStorage('solana-wallet-public-key')
</script>
<template>
<div>
<input type="text" v-model="publicKey">
<div v-text="publicKey"></div>
</div>
@butageek
butageek / windows_activation.md
Last active May 19, 2024 12:05
Activate Windows for free

For Windows 10

Step 1 - Open PowerShell or Command Prompt as administrator

Step 2 - Install KMS client key

slmgr /ipk your_license_key

Replace your_license_key with following volumn license keys according to Windows Edition:

@cloudwithax
cloudwithax / server.py
Created October 3, 2023 02:02
openai api to ollama api translator
import httpx
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
app = FastAPI()
# Define a Pydantic model for request input
class GenerateRequest(BaseModel):
model: str
prompt: str
@basham
basham / css-units-best-practices.md
Last active May 19, 2024 11:58
CSS Units Best Practices

CSS units

Recommendations of unit types per media type:

Media Recommended Occasional use Infrequent use Not recommended
Screen em, rem, % px ch, ex, vw, vh, vmin, vmax cm, mm, in, pt, pc
Print em, rem, % cm, mm, in, pt, pc ch, ex px, vw, vh, vmin, vmax

Relative units

Relative units

@NjohPrince
NjohPrince / update-about-info.validations.ts
Last active May 19, 2024 11:58
This snippet defines custom validation rules for updating user profile information, ensuring that inputs meet specific criteria before form submission. The updateAboutInfoValidations object is designed to validate fields such as about, companyLocation, jobTitle, and company.
import { UpdateAboutInfoType } from '../../../../services/api/profile.service'
import { Place } from '../../../../types'
import { Validations } from '../../../hooks/use-form'
export const updateAboutInfoValidations: Validations<UpdateAboutInfoType> = {
about: {
custom: {
isValid: (value: string) => value?.length >= 128 && value?.length <= 256,
message: 'Your bio should be atleast 128 characters and atmost 256 characters.',
},
@cecilemuller
cecilemuller / 2019-https-localhost.md
Last active May 19, 2024 11:58
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@NjohPrince
NjohPrince / use-form.ts
Last active May 19, 2024 11:58
The UseForm hook is a versatile solution for managing form state, validation, and submission in React applications. It simplifies handling forms by providing a clean and efficient way to manage input data, validate fields, and handle form submissions.
import _ from 'lodash'
import { FormEvent, useEffect, useState } from 'react'
import { useAppDispatch } from '.'
import {
NotificationTitleType,
showNotification,
} from '../../app/features/notification/notification.slice'
import { Place } from '../../types'
@kilian-gebhardt
kilian-gebhardt / MinMaxHeap.py
Last active May 19, 2024 11:55
Min-max heap in Python
class MinMaxHeap(object):
"""
Implementation of a Min-max heap following Atkinson, Sack, Santoro, and
Strothotte (1986): https://doi.org/10.1145/6617.6621
"""
def __init__(self, reserve=0):
self.a = [None] * reserve
self.size = 0
def __len__(self):
@astamicu
astamicu / Remove videos from Youtube Watch Later playlist.md
Last active May 19, 2024 11:51
Script to remove all videos from Youtube Watch Later playlist

UPDATED 22.11.2022

It's been two years since the last update, so here's the updated working script as per the comments below.

Thanks to BryanHaley for this.

setInterval(function () {
    video = document.getElementsByTagName('ytd-playlist-video-renderer')[0];

 video.querySelector('#primary button[aria-label="Action menu"]').click();
@pylover
pylover / a2dp.py
Last active May 19, 2024 11:50
Fixing bluetooth stereo headphone/headset problem in ubuntu 16.04, 16.10 and also debian jessie, with bluez5.
#! /usr/bin/env python3
"""Fixing bluetooth stereo headphone/headset problem in debian distros.
Workaround for bug: https://bugs.launchpad.net/ubuntu/+source/indicator-sound/+bug/1577197
Run it with python3.5 or higher after pairing/connecting the bluetooth stereo headphone.
This will be only fixes the bluez5 problem mentioned above .
Licence: Freeware