Skip to content

Instantly share code, notes, and snippets.

View simonespa's full-sized avatar

Simone Spaccarotella simonespa

View GitHub Profile

Get the name of the branch containing this commit

git branch -a --contains 9f12d89998fbd38a3fd3a1d21e7b028b9659c107

Search this commit in the PR

gh pr list --search "${SHA}" --state merged gh pr list --search 9f12d89998fbd38a3fd3a1d21e7b028b9659c107

@simonespa
simonespa / distributed_performance_testing.txt
Created April 21, 2025 18:25
Distributed Performance Testing
- https://www.youtube.com/watch?v=Uv7I75pLmb4
- https://aws.amazon.com/solutions/implementations/distributed-load-testing-on-aws/
@simonespa
simonespa / index.tsx
Created March 31, 2025 18:39
Dash.js player with react
import {
SyntheticEvent,
useCallback,
useEffect,
useRef,
useState,
} from "react";
import RadioList from "@/ui/radio-list";
@simonespa
simonespa / bbc-ai.md
Created March 12, 2025 11:16
BBC AI principles

BBC Mission

Set out in our Royal Charter, the BBC’s Mission is:

To act in the public interest, serving all audiences through the provision of impartial, high-quality and distinctive output and services which inform, educate and entertain.

The BBC's Public Purposes, which describe what the BBC must do for its audiences, are also laid out in the BBC's Royal Charter. Our use of AI must be consistent with them.

  • To provide impartial news and information
  • To support learning for people of all ages
@simonespa
simonespa / data-fetching-with-react-server-components.md
Created December 11, 2024 12:16
Data Fetching with React Server Components
@simonespa
simonespa / nextjs-questions-and-features-requests.md
Created December 11, 2024 12:08
Next.js Questions & Features Requests

Next JS questions and features requests

Environment Variables that are "environment aware" on server and client

  • The default behaviour is as it works right now, with no environments
  • The number and names of environments are flexible and defined by the user. They can be configured in the nextjs.conf file
  • If defined, the client bundle(s)/asset(s) can refer to the environment name/label to lookup the appropriate config value. The bundle doesn't contain the environment value hardcoded but a reference to an external asset that is prefixed with the environment.
  • All of this is transparent to the user

A mechanism to read values globally and share them across multiple requests on the server-only

@simonespa
simonespa / loadtest.js
Created December 11, 2024 11:53
K6 Load Testing
import http from "k6/http";
import { check } from "k6";
const URL = "https://example.com"; // Target URL
export let options = {
// If a cert is required to access the endpoint
//
// tlsAuth:
// [
@simonespa
simonespa / recoil.md
Created December 11, 2024 11:40
Recoil

Recoil

https://recoiljs.org/

Flexible shared state

Useful when two components are not under the same line of inheritance (from two separate branch) and use the same shared state and need to keep the state in synch.

Atom

@simonespa
simonespa / confusion_matrix.py
Created June 14, 2024 14:57
Confusion Matrix with Seaborn
from sklearn.metrics import confusion_matrix
import seaborn as sns
import matplotlib.pyplot as plt
cm = confusion_matrix(y_test, y_pred)
plt.figure(figsize=(12,12))
sns.heatmap(data=cm, # Data to plot
square=True, # Make the cells square, looks nicer.
@simonespa
simonespa / distribute.py
Created June 11, 2024 08:14
TensorfFlow Distribute Strategy
# https://www.tensorflow.org/tutorials/distribute/keras
logical_device_names = [logical_device.name for logical_device in tf.config.list_logical_devices()]
if 'GPU' in ''.join(logical_device_names):
distribution_strategy = tf.distribute.MirroredStrategy()
elif 'TPU' in ''.join(logical_device_names):
tf.tpu.experimental.initialize_tpu_system()
tpu = tf.distribute.cluster_resolver.TPUClusterResolver(tpu='/device:TPU_SYSTEM:0')
distribution_strategy = tf.distribute.experimental.TPUStrategy(tpu)