Skip to content

Instantly share code, notes, and snippets.

@farhd
farhd / Defer.jsx
Created October 30, 2024 10:52 — forked from 3nvi/Defer.jsx
A way to defer rendering of a big list
const Defer = ({ chunkSize, children }) => {
const [renderedItemsCount, setRenderedItemsCount] = React.useState(chunkSize);
const childrenArray = React.useMemo(() => React.Children.toArray(children), [
children
]);
React.useEffect(() => {
if (renderedItemsCount < childrenArray.length) {
window.requestIdleCallback(
@farhd
farhd / .tmux.conf
Last active June 17, 2024 01:05
zsh setup
unbind r
bind r source-file ~/.tmux.conf
bind P source-file ~/.tmux_profile
unbind C-b
set -g prefix C-s
bind-key * set-window-option synchronize-pane
bind -n M-Left select-pane -L
@farhd
farhd / app-builder.Dockerfile
Created February 23, 2024 11:23 — forked from alexbaumgertner/app-builder.Dockerfile
Docker and private github packages
ARG DEPS_IMAGE=deps-installer:latest
FROM $DEPS_IMAGE as deps-installer
FROM node:8.15.0-alpine
WORKDIR /app
COPY ./ ./
COPY --from=deps-installer /deps/node_modules ./node_modules
@farhd
farhd / Dockerfile
Created February 23, 2024 11:23 — forked from noelbundick/Dockerfile
How to use Docker build secrets
# syntax = docker/dockerfile:1.0-experimental
FROM python:3.7-alpine AS builder
WORKDIR /app
COPY . .
# mount the secret in the correct location, then run pip install
RUN --mount=type=secret,id=pipconfig,dst=/etc/pip.conf \
pip install -r requirements.txt
@farhd
farhd / one-liners.sh
Created March 18, 2019 10:12
[bash tricks] utility one-liners
# show folders sizes
du -chd 1 | sort -h
# show installed DDR memory info
lshw -short -C memory
@farhd
farhd / parallel-vanilla-limited.js
Last active October 25, 2018 10:58
[async iteration] #async #patterns
const tasks = ...
let concurrency = 2, running = 0, completed = 0, index = 0;
function next() { //[1]
while(running < concurrency && index < tasks.length) {
task = tasks[index++];
task(() => { //[2]
if(completed === tasks.length) {
return finish();
}
completed++, running--;
@farhd
farhd / style.css
Last active October 25, 2018 10:31
[tilda custom GTK style] including a fix for the scrollbar: do a backup of the old file, and copy this one to ~/.config/tilda/style.css #tilda #fix #linux
/*
The .8 transparency value can be calculated using the transparency config value (V)
with the formula: (100-V)/100. I have the transparency set to 20, so when I apply the
formula, I get: (100-20)/100 = 80/100 = 0.8 = .8
For no transparency (V = 0), set the value to 1.
*/
notebook > header {
background-color: rgba(0,0,0,.8);
border: none;
@farhd
farhd / Fresh-Install.md
Last active February 18, 2025 02:33
[mac fresh install config] #mac #config

Mac OS X

Homebrew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor
brew install git wget curl node