Skip to content

Instantly share code, notes, and snippets.

View Uvacoder's full-sized avatar

uvacoder Uvacoder

View GitHub Profile
@Uvacoder
Uvacoder / simple-form-useref.jsx
Created June 16, 2024 21:58 — forked from jmoggridge/simple-form-useref.jsx
Simplest react form: useRef
// using a useRef hook to manage form state with uncontrolled text area component
import { useRef } from 'react';
export default function TextInputForm() {
const ref = useRef();
const text = 'input';
function submitForm() {
console.log(ref.current);
}
@Uvacoder
Uvacoder / eager-prefetching-async-data-example.js
Created June 16, 2024 21:56 — forked from bvaughn/eager-prefetching-async-data-example.js
Advanced example for eagerly prefetching async data in a React component.
// This is an advanced example! It is not intended for use in application code.
// Libraries like Relay may make use of this technique to save some time on low-end mobile devices.
// Most components should just initiate async requests in componentDidMount.
class ExampleComponent extends React.Component {
_hasUnmounted = false;
state = {
externalData: null,
};
// This is an example of how to fetch external data in response to updated props,
// If you are using an async mechanism that does not support cancellation (e.g. a Promise).
class ExampleComponent extends React.Component {
_currentId = null;
state = {
externalData: null
};
@Uvacoder
Uvacoder / record-with-chromium
Created June 16, 2024 21:51 — forked from bvaughn/record-with-chromium
record-with-chromium
#!/usr/bin/env node
const { spawn } = require("child_process");
const util = require("node:util");
const exec = util.promisify(require("node:child_process").exec);
async function main() {
let { REPLAY_CHROME, RECORD_REPLAY_API_KEY } = process.env;
if (!REPLAY_CHROME || !RECORD_REPLAY_API_KEY) {
@Uvacoder
Uvacoder / index.md
Created June 16, 2024 21:50 — forked from bvaughn/index.md
How to use profiling in production mode for react-dom

React recently introduced an experimental profiler API. This page gives instructions on how to use this API in a production release of your app.

Table of Contents

Profiling in production

React DOM automatically supports profiling in development mode for v16.5+, but since profiling adds some small additional overhead it is opt-in for production mode. This gist explains how to opt-in.

@Uvacoder
Uvacoder / opml.py
Created March 16, 2024 01:17 — forked from capjamesg/opml.py
Process OPML files from Feedly OPML export.
# Written by capjamesg
# Required dependencies: requests, beautifulsoup4
from bs4 import BeautifulSoup
import requests
# Please save your opml file as feed.opml before running this program, otherwise you'll encounter an error
with open("feed.opml", "r") as file:
contents = file.read()
@Uvacoder
Uvacoder / loops.bench.js
Created January 16, 2023 03:09 — forked from caderek/loops.bench.js
JS loops benchmark.
import benny from "benny";
const data = Array.from({ length: 100_000 }, (_, i) => i);
let r1 = 0;
let r2 = 0;
let r3 = 0;
let r4 = 0;
let r5 = 0;
@Uvacoder
Uvacoder / setup-python3-virtual-env.md
Created December 24, 2022 23:58 — forked from MichaelCurrin/setup-python3-virtual-env.md
Set up Python 3 and new virtual environment

Set up Python 3 and new virtual environment

A beginner's guide to installing Python 3 and setting up a virtual environment

This guide covers how to install and upgrade Python 3 and how to create and an install into a Python virtual environment.

This is best practice in Python for both local and production code, as it isolates the scope where your python commands and pip commands run, protecting your global environment and allowing your to manage multiple virtual environments each with their own set of unique Python packages.

@Uvacoder
Uvacoder / README.md
Created December 24, 2022 23:58 — forked from MichaelCurrin/README.md
GitHub GraphQL - Get files in a repository

Get GitHub Files

Get the metadata and content of all files in a given GitHub repo using the GraphQL API

You might want to get a tree summary of files in a repo without downloading the repo, or maybe you want to lookup the contents of a file again without download the whole repo.

The approach here is to query data from GitHub using the Github V4 GraphQL API.

About the query

@Uvacoder
Uvacoder / README.md
Created December 24, 2022 23:57 — forked from MichaelCurrin/README.md
Twitter GraphQL sample

Twitter GraphQL sample

Example of using a GraphQL service to explore the Twitter API

A great way to explore the Twitter API and returned data, without worrying about authorization or local setup. Just add a query in the explorer and hit run.

About

The GraphQL Hub website has an interactive GraphiQL service which allows access to Gitub, Twitter, Giphy and other APIs in the browser without authorization.