Skip to content

Instantly share code, notes, and snippets.

@pirey
pirey / react-convention.md
Created April 22, 2020 09:25
React.js Project Convention

React.js Project Convention

This convention is intended to unify react project to a certain style and structure, thus making it more maintainable.

File Naming

  • Component file are capitalized. E.g. App.js, Button.js
  • Folder are lowercased. E.g. components, checkout, products
  • Files containing hooks, or helper functions, named using dash as separator. E.g. use-list-api.js, use-modal-state.js, date-formatter.js
  • Tests files are suffixed with .test.js, e.g. App.test.js

I know its trivial, but I also know I easily forgot little stuff like this.

To generate helptags, run:

:helptags doc/

@pirey
pirey / yeri_crkbd36_reversed.json
Last active August 14, 2024 08:39
yeri crkbd keyboard mapping
{
"name": "Crkbd",
"vendorProductId": 1179844609,
"macros": [
"{KC_LALT,KC_ESC}",
"{KC_LCTL,KC_Z}",
"{KC_LCTL,KC_X}",
"{KC_LCTL,KC_C}",
"{KC_LCTL,KC_V}",
"",
@pirey
pirey / CapsLockCtrl
Last active May 21, 2024 10:05
autohotkey script to remap capslock as both control and escape key.
; Remap Caps Lock to Ctrl
Capslock::Ctrl
; Remap Ctrl + [ to Escape
^[::
Send, {Escape}
return
; Remap Escape to Caps Lock
Escape::Capslock
@pirey
pirey / profile
Created May 16, 2023 07:33
powershell goodies
# nvim $profile - to edit the file
Import-Module PSFZF # enable fzf keybinding
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete # enable autocomplete
@pirey
pirey / sample.nix
Created June 5, 2023 17:39
create service in nixos configuration
# https://www.reddit.com/r/NixOS/comments/mwbr8t/comment/gvhm2mh/?utm_source=share&utm_medium=web2x&context=3
systemd.services.touchegg = {
enable = true;
description = "Touchégg. The daemon.";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
Group = "input";
Restart = "on-failure";
RestartSec = 5;
set -g default-terminal "screen-256color"
set-option -sa terminal-overrides ",xterm-256color:RGB"
@pirey
pirey / useOutsideAlerter.js
Created October 25, 2023 03:57
event handler outside element
function useOutsideAlerter(ref, eventType, callback, childSelector) {
useEffect(() => {
function handler(event) {
if (!ref.current) return;
const clickedOutside = childSelector
? !Array.from(ref.current.querySelectorAll(childSelector)).some(
(node) => node.contains(event.target),
)
: !ref.current.contains(event.target);
@pirey
pirey / notes.md
Created October 27, 2023 16:56
Personal laravel notes

laravel version: 10

authorization

policy

  • -> authorization logic for model
  • -> auto detected if following naming convention, User -> UserPolicy
  • $request->user()->can('update', $post)
  • $request->user()->cannot('create', Post::class)
  • $this->authorize('update', $post);
@pirey
pirey / multilinecontent.jsx
Last active October 28, 2023 10:58
react display multiline text content
function Comp({ content }) {
return content.split('\r\n').map((line, i) =>
<p key={i}>{line.length ? line : <br />}</p>)
}