Skip to content

Instantly share code, notes, and snippets.

View lovemycodesnippets's full-sized avatar

The New Stack lovemycodesnippets

View GitHub Profile
@lovemycodesnippets
lovemycodesnippets / Trapc.c
Created March 11, 2025 14:32
From the TNS post on Trapc
int main()
{   
gets_input();
trap { puts("ERROR: invalid input");
return 1;
} return 0;
}
@lovemycodesnippets
lovemycodesnippets / TrapC-Termination.c
Created March 11, 2025 14:25
From the TNS post on TrapC
inline
void gets_input()
{ char buffer[24];
printf("Please enter your name and press <ENTER>\n");
gets(buffer):// TrapC will terminate on overrun!
printf("%s", buffer);
}
@lovemycodesnippets
lovemycodesnippets / postgres.yaml
Created March 4, 2025 19:48
From the article "Kubernetes End-to-End Testing Using Testcontainers and Python"
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
spec:
replicas: 1
selector:
matchLabels:
app: postgres
template:
@lovemycodesnippets
lovemycodesnippets / app.yaml
Last active March 4, 2025 19:49
From the article "Kubernetes End-to-End Testing Using Testcontainers and Python"
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 1
selector:
matchLabels:
app: my-app
template:
@lovemycodesnippets
lovemycodesnippets / import-k3scontainer.py
Created March 4, 2025 19:45
From the article "Kubernetes End-to-End Testing Using Testcontainers and Python"
from testcontainers.k3s import K3sContainer
from testcontainers.postgres import PostgresContainer
import requests
import time
import os
def wait_for_pod_ready(kubeconfig_path, namespace="default", timeout=120):
"""
Wait for all pods in the namespace to be ready.
@lovemycodesnippets
lovemycodesnippets / install.sh
Created March 4, 2025 19:43
From the article "Kubernetes End-to-End Testing Using Testcontainers and Python"
pip install testcontainers
pip install kubernetes
@lovemycodesnippets
lovemycodesnippets / import_navigation-container.tsx
Created February 27, 2025 20:05
From the article "How To Instrument a React Native App To Send OTel Signals"
import {
NavigationContainer,
useNavigationContainerRef,
} from "@react-navigation/native";
import {createBottomTabNavigator} from "@react-navigation/bottom-tabs";
import {EmbraceNavigationTracker} from "@embrace-io/react-native-navigation";
// ...
const Tab = createBottomTabNavigator();
@lovemycodesnippets
lovemycodesnippets / button.tsx
Created February 27, 2025 20:00
From the article "How To Instrument a React Native App To Send OTel Signals"
<Button onPress={createSpan} title="Test Span" />
@lovemycodesnippets
lovemycodesnippets / import_useEmbraceNativeTracerProvider.tsx
Last active February 27, 2025 20:18
From the article "How To Instrument a React Native App To Send OTel Signals"
import {useEmbraceNativeTracerProvider} from "@embrace-io/react-native-tracer-provider";
// ...
function App(): React.JSX.Element {
const {isPending, isStarted} = useEmbrace({
// ... Embrace config
});
const {tracerProvider: embraceTracerProvider} = useEmbraceNativeTracerProvider({}, isStarted);
@lovemycodesnippets
lovemycodesnippets / app.tsx
Last active February 27, 2025 20:23
From the article "How To Instrument a React Native App To Send OTel Signals"
import {useEmbrace} from '@embrace-io/react-native';
// ...
function App(): React.JSX.Element {
const {isPending, isStarted} = useEmbrace({
ios: {
disabledUrlPatterns: ['grafana.net'],
},
exporters: {