Skip to content

Instantly share code, notes, and snippets.

View weilueluo's full-sized avatar
code ^ sleep

Weilue Luo weilueluo

code ^ sleep
View GitHub Profile
@weilueluo
weilueluo / simple-react-themes.md
Last active April 12, 2023 00:45
Simple Theme Management for React

Simple React Theme Management

  • Single themes.tsx file, ~200 lines.
  • Flashless (with ssr).
  • Typescript.

themes.tsx

import React, { useContext, useState } from "react";

// utils

Fonts

  • Alaska
  • Baloo 2
{
"compilerOptions": {
// type checking
"strict": true,
// modules
"module": "esnext",
"moduleResolution": "nodenext",
"paths": {
"@/*": ["./src/*"]
@weilueluo
weilueluo / git-reset-pull-master-all.sh
Created November 22, 2022 13:50
for every repo in the current directory, checkout master, reset --hard and pull
find . -mindepth 1 -maxdepth 1 -type d -print | xargs -I {} bash -c 'git -C {} rev-parse --is-inside-work-tree &> /dev/null && echo {} && git -C {} checkout master && git -C {} reset --hard && git -C {} pull'
@weilueluo
weilueluo / z component of the cross product.txt
Created November 12, 2021 10:51
z component of the cross product
cross(a, b)'s z component:
z = a.x * b.y - a.y * b.x
@weilueluo
weilueluo / content.txt
Created November 8, 2021 15:02
slow stroke-dashoffset animation/transition in chrome
https://bugs.chromium.org/p/chromium/issues/detail?id=167569
@weilueluo
weilueluo / conda_create_http_error.md
Last active October 8, 2021 15:53
[CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/main/win-64/current_repodata.json>] #conda

Just copy these:-

1)libcrypto-1_1-x64.dll

2)libssl-1_1-x64.dll

from D:\Anaconda3\Library\bin to D:\Anaconda3\DLLs.

@weilueluo
weilueluo / UOM CGVI Links.md
Created October 3, 2021 09:25
[UOM CGVI Links] #links
@weilueluo
weilueluo / multihead_attention.py
Created April 10, 2021 22:22
minimum multi-head attention implementation
import torch
from torch import nn
class MultiHeadAttention(nn.Module):
def __init__(self, in_size, n_heads=1, scaled=True):
super().__init__()
# in_size = d_k in the paper
self.scale = in_size ** 0.5 if scaled else 1