Skip to content

Instantly share code, notes, and snippets.

View artidataio's full-sized avatar
👨‍🔬
Trial and Error

Imaduddin Haetami artidataio

👨‍🔬
Trial and Error
View GitHub Profile
@artidataio
artidataio / compile-to-js.md
Last active May 15, 2022 05:56
Things that compile to JavaScript
@artidataio
artidataio / favorite-realtime-dashboard.md
Created April 27, 2022 11:22
A list of my favorite realtime dashboards.
@artidataio
artidataio / react-sandboxes.md
Last active May 20, 2022 12:21
A list of my ReactJS sandboxes.
@artidataio
artidataio / fb-debug.pas
Last active July 6, 2022 13:32
Fb group pascal debugging
{https://web.facebook.com/photo/?fbid=1106883760205734&set=gm.5560213294029429}
program program_segitiga;
uses crt;
type
segitiga = Record
alas : Integer;
tinggi : Integer;
end;
@artidataio
artidataio / pengertian-cors-proxy.md
Last active August 9, 2022 15:40
Pengertian CORS Proxy

Mungkin saya luruskan dulu pengertian CORS nya. Sebenernya "CORS error" di browser terjadi karena browser Fetch API tunduk sama same-origin policy. Jadi defaultnya, JavaScript yang di serve di situs https://domain-a.com tidak dibolehkan browser melakukan http request ke https://domain-b.com/data.json.

Justru CORS (Cross-Origin-Resource-Sharing) itu mekanisme yang membolehkan kode JavaScript yang di browser yang di serve di https://domain-a.com untuk melakukan http request ke domain lain contohnya https://domain-b.com/data.json.

Implementasinya seperti apa?

Melalui http header Access-Control-Allow-Origin dari server. Kalau misalnya http header itu valuenya *, berarti CORS enabled, jadi javascript dari website apapun dibolehkan browser mengakses resources dari server tersebut.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
function computeClosestToZero(arr: number[]) {
return arr.length > 0
? arr.sort((a, b) => {
let absDiff = Math.abs(a) - Math.abs(b);
return absDiff === 0 ? b - a : absDiff;
})[0]
: 0;
}