Skip to content

Instantly share code, notes, and snippets.

View maman's full-sized avatar
🔥

Achmad Mahardi maman

🔥
View GitHub Profile
import * as React from 'react';
const useIsFirstRender = (): boolean => {
const isFirst = React.useRef(true);
if (isFirst.current) {
isFirst.current = false;
return true;
} else {
484e4f4a403f52430039200c50affaac00000137738aea3e0000017f0700001400023e000a140003070001140002413d000d0211020811000143011400024111000242021102000700024301340009110201070003133232421102023a07000426423e0004140001413d004111021007000507000644024a12000711020312000843013400250205000000933b0111020312000b323400111102043a0700042633000611020412000c4301424108421100014a120009430007000a254211020544004a12000d4300421100013a070004253400051100010225470004070000421100013a07000e2547001011000147000607000f45000307001042110001421100023247000607001114000207000014000311000114000411000403002947002e1100031100021102064a1200121102064a12001343001100021200141a430113181700033549170004204945ffc91100034205000000003b0114010f05000000273b00140109050000003d3b0014010b05000000463b0014010a05000000a13b0014010c05000000ad3b0114010d05000000e33b0214010e0842001500204a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a1103066c4f4f7343420d6c06034a4d405f490c48434f59414942586143484909594248494a454249480b4f43425f585e594f58435e01450458495f580b64786160
@naqvitalha
naqvitalha / RecyclableImage.tsx
Last active March 16, 2023 05:16
iOS images inside FlashList
const RecyclableImage = (props) => {
const imageUri = useRef(props.source.uri);
const imageRef = useRef(null);
if (props.source.uri && props.source.uri !== imageUri.current) {
imageUri.current = props.source.uri;
imageRef.current?.setNativeProps({ opacity: 0 });
}
return <Image {...props} ref={imageRef} onLoad={()=> { imageRef.current?.setNativeProps({ opacity: 1 }) }} />
}
@monokee
monokee / define-component.js
Last active May 28, 2024 13:03
Tiny customElement wrapper that enables scalable web component architecture. Define custom elements with a configuration object that separates markup from css and javascript. Uses a slotted light DOM (no shadow DOM) to allow for powerful component extension, composition and easier styling with external stylesheets and global css variables. Expor…
/**
* Tiny customElement wrapper that enables scalable web component architecture.
* Define custom elements with a configuration object that separates markup from css and javascript.
* Uses a slotted light DOM (no shadow DOM) to allow for powerful component extension,
* composition and easier styling with external stylesheets and global css variables.
* Exports a component class that can be imported and explicitly used to be picked up by module bundlers.
* See comments for examples and GNU license below.
*/
export function defineComponent(name, config) {
@nymous
nymous / README.md
Last active July 4, 2024 07:33
Logging setup for FastAPI, Uvicorn and Structlog (with Datadog integration)

Logging setup for FastAPI

This logging setup configures Structlog to output pretty logs in development, and JSON log lines in production.

Then, you can use Structlog loggers or standard logging loggers, and they both will be processed by the Structlog pipeline (see the hello() endpoint for reference). That way any log generated by your dependencies will also be processed and enriched, even if they know nothing about Structlog!

Requests are assigned a correlation ID with the asgi-correlation-id middleware (either captured from incoming request or generated on the fly). All logs are linked to the correlation ID, and to the Datadog trace/span if instrumented. This data "global to the request" is stored in context vars, and automatically added to all logs produced during the request thanks to Structlog. You can add to these "global local variables" at any point in an endpoint with `structlog.contextvars.bind_contextvars(custom

@davidfowl
davidfowl / MinimalAPIs.md
Last active June 28, 2024 17:42
Minimal APIs at a glance
@andreialecu
andreialecu / dtf-perf.diff
Last active June 26, 2021 01:08
performance patch for @formatjs/intl-datetimeformat@4.1.5
diff --git a/src/abstract/FormatDateTimePattern.js b/src/abstract/FormatDateTimePattern.js
index 47fd27397f6fff014af1c4b8862e26fea11e7aab..8d0d1234d9a5dcbd6131bbe206d4655a6c153726 100755
--- a/src/abstract/FormatDateTimePattern.js
+++ b/src/abstract/FormatDateTimePattern.js
@@ -32,6 +32,28 @@ function offsetToGmtString(gmtFormat, hourFormat, offsetInMs, style) {
}
return gmtFormat.replace('{0}', offsetStr);
}
+var numberFormatsCache = new Map();
+function getNumberFormatsForLocale(locale, fractionalSecondDigits) {
@akihikodaki
akihikodaki / README.en.md
Last active July 7, 2024 14:25
Linux Desktop on Apple Silicon in Practice

Linux Desktop on Apple Silicon in Practice

I bought M1 MacBook Air. It is the fastest computer I have, and I have been a GNOME/GNU/Linux user for long time. It is obvious conclusion that I need practical Linux desktop environment on Apple Silicon.

Fortunately, Linux already works on Apple Silicon/M1. But how practical is it?

  • Two native ports exist.

Batching makes it difficult to perform imperative actions like focus

Solution to the problem discussed with Dan Abramov here.

implementation:

export default function useQueueFocus(): (elementRef: React.MutableRefObject<HTMLElement | null>) => void {
  const isUnmountedRef = useRef(false)
  const forceUpdate = useForceUpdate()
  const ref = useRef<MutableRefObject<HTMLElement | null> | undefined>(undefined)
@niw
niw / README.en.md
Last active July 5, 2024 14:28
How to run Windows 10 on ARM or Ubuntu for ARM64 in QEMU on Apple Silicon Mac

How to run Windows 10 on ARM or Ubuntu for ARM64 in QEMU on Apple Silicon Mac

Here is easy steps to try Windows 10 on ARM or Ubuntu for ARM64 on your Apple Silicon Mac. Enjoy!

NOTE: that this is current, 10/1/2021 state.

Running Windows 10 on ARM

  1. Install Xcode from App Store or install Command Line Tools on your Mac