Skip to content

Instantly share code, notes, and snippets.

View lihourchhin's full-sized avatar
🎯
Focusing

Lihour lihourchhin

🎯
Focusing
View GitHub Profile
@lihourchhin
lihourchhin / FactoryTests.kt
Created October 13, 2020 05:39 — forked from sombochea/FactoryTests.kt
Simple Factory Pattern on Kotlin
package com.cubetiqs.factory
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
class FactoryTests {
@Test
fun factoryTest() {
val carA = CarFactory(CarType.CAR_A).getCar()
@sombochea
sombochea / FactoryTests.kt
Last active October 13, 2020 05:39
Simple Factory Pattern on Kotlin
package com.cubetiqs.factory
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
class FactoryTests {
@Test
fun factoryTest() {
val carA = CarFactory(CarType.CAR_A).getCar()
@slikts
slikts / advanced-memo.md
Last active February 10, 2026 01:17
Advanced memoization and effects in React

nelabs.dev

Advanced memoization and effects in React

Memoization is a somewhat fraught topic in the React world, meaning that it's easy to go wrong with it, for example, by [making memo() do nothing][memo-pitfall] by passing in children to a component. The general advice is to avoid memoization until the profiler tells you to optimize, but not all use cases are general, and even in the general use case you can find tricky nuances.

Discussing this topic requires some groundwork about the technical terms, and I'm placing these in once place so that it's easy to skim and skip over:

  • Memoization means caching the output based on the input; in the case of functions, it means caching the return value based on the arguments.
  • Values and references are unfortunately overloaded terms that can refer to the low-level implementation details of assignments in a language like C++, for example, or to memory
@slykar
slykar / docker-compose-hackintosh.md
Last active December 4, 2025 14:50
Docker and Docker Compose on AMD OSX Hackintosh via Docker Machine

Introduction

Docker.app will complain about incompatible processor, so we will use Docker Machine.

Instalation

Download Docker for Mac (Docker.app). It contains some binaries that are necessary.

brew install virtualbox docker-machine
@mittalyashu
mittalyashu / fetch_data_in_react.js
Created April 8, 2018 06:54
Fetch Data From RSS Feed In React
class FetchDataFromRSSFeed extends Component {
constructor() {
super();
this.state = {
recentBlogPost: {
name: '',
url: ''
}
}
}
@ibraheem4
ibraheem4 / postgres-brew.md
Last active September 27, 2025 02:49
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@fgilio
fgilio / axios-catch-error.js
Last active February 11, 2026 16:18
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@mihow
mihow / load_dotenv.sh
Last active March 6, 2026 10:58
Load environment variables from dotenv / .env file in Bash
# The initial version
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
# My favorite from the comments. Thanks @richarddewit & others!
set -a && source .env && set +a
@umayr
umayr / recover-deleted-branch.sh
Created April 1, 2016 11:41
How to recover a deleted branch
## Pre-requisite: You have to know your last commit message from your deleted branch.
git reflog
# Search for message in the list
# a901eda HEAD@{18}: commit: <last commit message>
# Now you have two options, either checkout revision or HEAD
git checkout a901eda
# Or
git checkout HEAD@{18}
@paulirish
paulirish / what-forces-layout.md
Last active March 15, 2026 16:37
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent