Skip to content

Instantly share code, notes, and snippets.

View madeinfree's full-sized avatar
🐱
Focusing

Whien_Liou madeinfree

🐱
Focusing
View GitHub Profile
@javilobo8
javilobo8 / download-file.js
Last active May 13, 2025 05:55
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@danseethaler
danseethaler / StyledButton.js
Last active July 5, 2017 19:20
A styled css-in-js button
('use strict');
import React from 'react';
import glamorous from 'glamorous';
const colors = {
success: '#29A88E',
danger: '#C65F4A',
primary: '#6DCFD3',
info: '#FFD035',
@acdlite
acdlite / coordinating-async-react.md
Last active June 17, 2024 11:56
Demo: Coordinating async React with non-React views

Demo: Coordinating async React with non-React views

tl;dr I built a demo illustrating what it might look like to add async rendering to Facebook's commenting interface, while ensuring it appears on the screen simultaneous to the server-rendered story.

A key benefit of async rendering is that large updates don't block the main thread; instead, the work is spread out and performed during idle periods using cooperative scheduling.

But once you make something async, you introduce the possibility that things may appear on the screen at separate times. Especially when you're dealing with multiple UI frameworks, as is often the case at Facebook.

How do we solve this with React?

@rauschma
rauschma / reasonml-operators.md
Last active April 10, 2018 21:12
ReasonML operators
Construction or operator Associativity
prefix operator
. .( .[ .{
[ ] (array index)
#···
applications, assert, lazy left
- -. (prefix)
**··· lsl lsr asr right
*··· /··· %··· mod land lor lxor left
/* file: Recompose.re */
/* The very definition of a HOC, it's a function that gets a react component and returns another react component */
type hoc = ReasonReact.reactClass => ReasonReact.reactClass;
module type CreateWithStateParams = {
/* This is the secret sauce ingredient, with it the users can pass whatever state they want */
type state;
let defaultValue: state;
};
@swalkinshaw
swalkinshaw / tutorial.md
Last active June 6, 2025 19:24
Designing a GraphQL API
@bvaughn
bvaughn / index.md
Last active February 25, 2025 15:56
Interaction tracing with React

This API was removed in React 17


Interaction tracing with React

React recently introduced an experimental profiler API. After discussing this API with several teams at Facebook, one common piece of feedback was that the performance information would be more useful if it could be associated with the events that caused the application to render (e.g. button click, XHR response). Tracing these events (or "interactions") would enable more powerful tooling to be built around the timing information, capable of answering questions like "What caused this really slow commit?" or "How long does it typically take for this interaction to update the DOM?".

With version 16.4.3, React added experimental support for this tracing by way of a new NPM package, scheduler. However the public API for this package is not yet finalized and will likely change with upcoming minor releases, so it should be used with caution.

@Tynael
Tynael / README.md
Last active April 11, 2025 07:03
How to use npx to run gist based scripts
@argoc
argoc / helloworld.s
Last active January 26, 2023 03:14
Hello World in RISC-V
.data # declare and initialize variables
hello: .asciz "Hello world!" # string with null terminator
.text # code starts here
main: # label marking the entry point of the program
la a0, hello # load the address of hello into $a0 (1st argument)
addi a7, zero, 4 # code to print the string at the address a0
ecall # make the system call
addi a7, zero, 10 # code to exit
import random
from typing import Tuple
def get_reciprocal(value: int, mod: int) -> int:
for i in range(1, mod):
if (i * value) % mod == 1:
return i
return -1