Skip to content

Instantly share code, notes, and snippets.

View wvovaw's full-sized avatar
👀
I don't blink anymore...

Vladimir Ivakhno wvovaw

👀
I don't blink anymore...
View GitHub Profile
@wvovaw
wvovaw / README.md
Last active February 7, 2024 13:47
Nuxt SSR friendly color theme switcher

Nuxt 3 + vueuse + Pinia SSR friendly color theme switcher

  1. Declare theme cookie in the app.vue.
  2. Use HTML nuxt builtin to bind data-theme attribute (your may differ) to the cookie.theme.
  3. Create theme.store.ts Pinia store. cycle function cycles through the list of modes and sets current state in the theme cookie
  4. Create ThemeSwitcher.vue component.

This approach is universal, SSR friendly and easy adoptable.

Read more about useColorMode

@wvovaw
wvovaw / Modal.vue
Created April 22, 2023 08:25
Nice responsive mobile-friendly modal window implementation with TailwindCSS and HeadlessUI (and some DaisyUI styles)
<script lang="ts" setup>
import {
Dialog as HDialog,
DialogPanel as HDialogPanel,
TransitionRoot as HTransitionRoot,
TransitionChild as HTransitionChild,
} from "@headlessui/vue";
const props = defineProps({
show: {
@wvovaw
wvovaw / nuxt_strapi.conf
Last active December 24, 2022 18:06
nuxt + strapi nginx proxy config
upstream strapi {
server 127.0.0.1:1337;
}
upstream nuxt {
server 127.0.0.1:3000;
}
server {
server_name www.domainname.com domainname.com;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
@wvovaw
wvovaw / utils.ts
Last active July 21, 2024 15:00
Some JS and TS code snippets that I need to use sometimes
// Generate random string
export const generateUID = (length: number) =>
Array(length)
.fill("")
.map((v) => Math.random().toString(36).charAt(2))
.join("");
// Convert ArrayBuffer to HEX string
export const bytesToHEX = (bytes: ArrayBuffer) =>
Array.from(new Uint8Array(bytes)).map(b => b.toString(16).padStart(2, '0')).join('');
@wvovaw
wvovaw / NASA original Mars rovers API.postman_collection.json
Created November 6, 2022 18:58
Original NASA Mars photos API schema for Perseverance and Curiosity rovers
{
"info": {
"_postman_id": "5be5d43b-8bce-418d-a8f8-9eb7a42c2911",
"name": "NASA original API",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "14509461"
},
"item": [
{
"name": "Mars2020,ingenuity",
@wvovaw
wvovaw / discord_install.sh
Last active June 25, 2024 17:18
Discord instalation script
#!/bin/env bash
# Ask a pass if not enough privileges
if (($EUID != 0)); then
if hash pkexec 2>/dev/null; then
pkexec "$0" "$@"
elif hash gksu 2>/dev/null; then
if [[ -t 1 ]]; then
sudo "$0" "$@"
else
@wvovaw
wvovaw / solarized-colors.css
Created June 7, 2021 18:38
Solarized colorscheme as css variables
:root {
--solarized_base03: #002b36;
--solarized_base02: #073642;
--solarized_base01: #586e75;
--solarized_base00: #657b83;
--solarized_base0: #839496;
--solarized_base1: #93a1a1;
--solarized_base2: #eee8d5;
--solarized_base3: #fdf6e3;
--solarized_yellow: #b58900;
@wvovaw
wvovaw / gruvbox-colors.css
Created June 7, 2021 18:37
Gruvbox colorscheme as css variables
:root {
/* dark */
--gboxd_bg: #282828;
--gboxd_bg0: #282828;
--gboxd_bg0_h: #1d2021;
--gboxd_bg0_s: #32302f;
--gboxd_bg1: #3c3836;
--gboxd_bg2: #504945;
--gboxd_bg3: #665c54;
--gboxd_bg4: #7c6f64;
@wvovaw
wvovaw / vimium-options.json
Last active May 24, 2021 14:47
Vimium config. It has several search engines and Groovebox Dark theme
{
"settingsVersion": "1.66",
"exclusionRules": [
{
"pattern": "https?://mail.google.com/*",
"passKeys": ""
},
{
"pattern": "https://godbolt.org/",
"passKeys": ""
@wvovaw
wvovaw / CMakeLists.txt
Created May 7, 2021 16:01
CMakeLists.txt for C/C++ projects
cmake_minimum_required(VERSION 3.10)
set(PROJECT_NAME myProject)
project(${PROJECT_NAME} VERSION 1.0 LANGUAGES CXX) # OR C
set(EXECUTABLE_OUTPUT_PATH bin/${CMAKE_BUILD_TYPE})
file(GLOB_RECURSE SOURCE_FILES src/*)
file(GLOB_RECURSE SOURCE_HEADERS include/*)
set(SOURCES ${SOURCE_FILES} ${SOURCE_HEADERS})