Skip to content

Instantly share code, notes, and snippets.

# turn off built-in mouse-acceleration in macOS
defaults write .GlobalPreferences com.apple.mouse.scaling -1
@pr0da
pr0da / git.sh
Last active September 14, 2021 07:35
# Save working space by git stash then make patch file for apply later.
# Credit: https://stackoverflow.com/questions/3973034/export-a-stash-to-another-computer
# First just stash your working space
git stash
# Maybe you need check your stash which file that have right now.
git stash show
git stash show -p
@pr0da
pr0da / README.md
Last active May 30, 2021 09:11
WSL2 + react-native (expo)

source

I needed the same and ran into same issues.

Here's the full of what I found worked for LAN development between my mobile and expo running in WSL2:

1. One time at the start: open Expo ports inbound in Windows Firewall

Windows firewall should be on, and it should block inbound attempts by default. The following will open the Expo ports 19000–19006, inbound, but only on a network that you have configured as "private" (that's the -Profile Private part):

@pr0da
pr0da / constrained-identity-function.tsx
Last active September 4, 2021 19:01
Typescript Tips & Tricks
type OperationFn = (left: number, right: number) => number
const createOperations = <OperationsType extends Record<string, OperationFn>>(
opts: OperationsType,
) => opts
const operations = createOperations({
'+': (left, right) => left + right,
'-': (left, right) => left - right,
'*': (left, right) => left * right,
'/': (left, right) => left / right,
})
@pr0da
pr0da / patterns.css
Created February 17, 2021 17:18
css patterns
.squishy-text {
word-break: break-word; /* Samsung browser */
word-wrap: break-word; /* IE 11 */
overflow-wrap: anywhere;
-webkit-hyphens: auto;
-ms-hyphens: auto;
hyphens: auto;
}
.visually-hidden {
@pr0da
pr0da / breakpoints.less
Last active February 17, 2021 17:12
media breakpoints
@mixin for-phone-only {
@media (max-width: 599px) { @content; }
}
@mixin for-tablet-portrait-up {
@media (min-width: 600px) { @content; }
}
@mixin for-tablet-landscape-up {
@media (min-width: 900px) { @content; }
}
@mixin for-desktop-up {
@pr0da
pr0da / conventional-commits.md
Created October 25, 2020 12:14
Conventional Commits

Commit Message Format

This specification is inspired and supersedes the [AngularJS commit message format][commit-message-format].

We have very precise rules over how our Git commit messages must be formatted. This format leads to easier to read commit history.

Each commit message consists of a header, a body, and a footer.

@pr0da
pr0da / mergeRefs.ts
Last active April 30, 2021 13:23
React Reusable Stuffs
import * as React from "react";
export default function mergeRefs<T = any>(
refs: Array<React.MutableRefObject<T> | React.LegacyRef<T>>
): React.RefCallback<T> {
return (value) => {
refs.forEach((ref) => {
if (typeof ref === "function") {
ref(value);
} else if (ref != null) {
@pr0da
pr0da / interpolate.ts
Created June 3, 2020 13:54
Linear Interpolation
// Linear interpolation
const lerp = (x: number, y: number, a: number) => x * (1 - a) + y * a;
// Inverse Linear Interpolation
const invlerp = (x: number, y: number, a: number) => clamp((a - x) / (y - x));
const clamp = (a: number, min = 0, max = 1) => Math.min(max, Math.max(min, a));
// Range interpolation
const range = (
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi