Skip to content

Instantly share code, notes, and snippets.

View mfaridzia's full-sized avatar
📒
storyteller

Muhammad Farid Zia mfaridzia

📒
storyteller
View GitHub Profile
@bagder
bagder / curl-in-two-hours-agenda.md
Last active February 17, 2024 12:08
Master curl in two hours. A video course by Daniel

The idea is to make a two and a half hour (give or take) video course explaining and detailing curl, the command line tool. How it works, how to use it, from the basics to some more advanced uses. This will be done by Daniel Stenberg, founder and lead developer of the curl project.

The recording and live-stream is scheduled for August 31, 2023. In the US morning and Euro evening.

See blog post for details.

The project (10 min)

@gaearon
gaearon / 00-README-NEXT-SPA.md
Last active March 28, 2024 09:26
Next.js SPA example with dynamic client-only routing and static hosting

Next.js client-only SPA example

Made this example to show how to use Next.js router for a 100% SPA (no JS server) app.

You use Next.js router like normally, but don't define getStaticProps and such. Instead you do client-only fetching with swr, react-query, or similar methods.

You can generate HTML fallback for the page if there's something meaningful to show before you "know" the params. (Remember, HTML is static, so it can't respond to dynamic query. But it can be different per route.)

Don't like Next? Here's how to do the same in Gatsby.

@veekaybee
veekaybee / chatgpt.md
Last active April 12, 2024 20:16
Everything I understand about chatgpt

ChatGPT Resources

Context

ChatGPT appeared like an explosion on all my social media timelines in early December 2022. While I keep up with machine learning as an industry, I wasn't focused so much on this particular corner, and all the screenshots seemed like they came out of nowhere. What was this model? How did the chat prompting work? What was the context of OpenAI doing this work and collecting my prompts for training data?

I decided to do a quick investigation. Here's all the information I've found so far. I'm aggregating and synthesizing it as I go, so it's currently changing pretty frequently.

Model Architecture

@subfuzion
subfuzion / README.md
Last active August 29, 2023 01:41
Node.js 18 Test Runner

Node.js 18 Test Runner

Node.js v18 introduces test runner support. This currently experimental feature gives developers the benefits of a structured test harness for their code without having to install a third party test framework, like Mocha or Jest, as a dependency. Using the test runner produces [TAP] output.

The [online reference] provides the most up-to-date, authoritative reference and have plenty of good testing examples. However, there are a few points that might not be immediately obvious from the reference, so those are highlighted here.

declare function searchForMovies(query?: string): Promise<Movie[]>
declare function MovieList(props: { movies: Movie[] }): JSX.Element
declare function LoadingIndicator(props: { loadingSince: Date }): JSX.Element
declare function ErrorMessageUI(props: { error: Error }): JSX.Element
type Movie = { title: string, id: string }
type ViewState = (
{ status: 'loading', loadingSince: Date } |
{ status: 'done', searchResults: Movie[] } |
@Widdershin
Widdershin / ssr.md
Last active March 8, 2024 11:21
The absurd complexity of server-side rendering

In the olden days, HTML was prepared by the server, and JavaScript was little more than a garnish, considered by some to have a soapy taste.

After a fashion, it was decided that sometimes our HTML is best rendered by JavaScript, running in a user's browser. While some would decry this new-found intimacy, the age of interactivity had begun.

But all was not right in the world. Somewhere along the way, we had slipped. Our pages went uncrawled by Bing, time to first meaningful paint grew faster than npm, and it became clear: something must be done.

And so it was decided that the applications first forged for the browser would also run on the server. We would render our HTML using the same logic on the server and the browser, and reap the advantages of both worlds. In a confusing series of events a name for this approach was agreed upon: Server-side rendering. What could go wrong?

In dark rooms, in hushed tones, we speak of colours.

@sibelius
sibelius / reportJsonExcel.ts
Created September 15, 2021 21:05
Automate your reports using JavaScript
import path from 'path';
import util from 'util';
import fs from 'fs';
import * as XLSX from 'xlsx';
const writeFile = util.promisify(fs.writeFile);
const cwd = process.cwd();
@swyxio
swyxio / useLocalStorage.js
Last active March 14, 2023 18:27
SSR friendly version of useLocalStorage hook. you can also use this in a library https://github.com/astoilkov/use-local-storage-state
// usage
function Comp() {
const [language, setLanguage] = useLocalStorage('mykey', 'typescript')
}
// definition
function useLocalStorage(key, initialValue) {
const [storedValue, setStoredValue] = React.useState(initialValue);
React.useEffect(() => {
// Get from local storage by key
@xdesro
xdesro / index.js
Created June 1, 2021 18:24
Check if the current device is using a mouse with both CSS and JavaScript.
if (matchMedia('(pointer:fine)').matches) {
// This browser has a mouse or other fine-control device as its primary input.
}
// Candidates
const reduceSpread = (users) => {
return users.reduce((acc, user) => {
if (!user.active) {
return { ...acc, [user.id]: user.name }
}
return acc
}, {})
}