Posts

Better Auth on Cloudflare Workers with Hono and D1

Image
A TypeScript-based lightweight authentication service optimized for Cloudflare Workers Stack Summary 🔥 Hono A fast, lightweight web framework built on web standards. 🔒 Better Auth A comprehensive authentication framework for TypeScript. 🧩 Drizzle ORM A lightweight, high-performance ORM for TypeScript, built with DX in mind. 🐘 Cloudflare D1 A serverless Sqlite optimized for the cloud. Installation Hono Select cloudflare-workers template npm create hono Better Auth npm i better-auth Drizzle ORM npm i drizzle-orm npm i -D drizzle-kit Environment Variables Set the following environment variables to connect your application to Better Auth . echo " BETTER_AUTH_URL = http://localhost:8787" >> .env echo " BETTER_AUTH_SECRET = $(openssl rand -base64 32)" >> .env cp .env .dev.vars npx wrangler d1 create myDb --update-config Required Files:  .dev.vars  Used by Wrangler in local development In production, these should be set as Cloudflare Worker Secrets. .env Us...

To deactivate Intel Turbo Mode on a Linux MacBook

Image
Deactivate Intel Turbo Mode immediately caps CPU frequency to the base speed, reducing heat and increasing battery life. For a permanent change, create a systemd rule.  Temporary Method (Until Reboot) Run this command in your terminal to immediately disable turbo boost:  echo 1 | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo To re-enable it, change the 1 to a 0.  Permanent Method (Across Reboots) Since this setting resets upon rebooting, create a startup rule using systemd-tmpfiles.  Create a new configuration file: echo "w /sys/devices/system/cpu/intel_pstate/no_turbo - - - - 1" | sudo tee /etc/tmpfiles.d/noturbo.conf Alternative: Using TLP  If you have tlp installed for power management, you can configure it to handle this automatically: Edit /etc/tlp.conf or /etc/default/tlp. Set INTEL_CPU_BOOST_ON_AC=0 and INTEL_CPU_BOOST_ON_BAT=0.  Verification You can check if Turbo Mode is active by reading the file: cat /sys/devices/system/cpu/intel_pstate/...

Tutorial VNC Server on Linux Debian Bookworm

Image
To set up an X11 VNC server on Debian, the recommended package is x11vnc , which provides remote access to an existing X session. Alternatively, you can use other VNC servers like TightVNC or TigerVNC to create a new, virtual X desktop session.  Using x11vnc to Access the Current Desktop  x11vnc is ideal for remote assistance or accessing the same desktop visible on the physical monitor.  Installation: sudo apt update && sudo apt install x11vnc Configuration and Usage: Set a VNC password (optional but highly recommended): x11vnc -storepasswd This creates a password file, typically located at ~/.vnc/passwd . Run the server: To run it in your current terminal session, use: x11vnc -display :0 You will likely need to use the -auth option or set the XAUTHORITY environment variable to grant x11vnc permission to connect to the X server.  x11vnc -auth -forever -loop -noxdamage -repeat -rfbauth ~/.vnc/passwd -rfbport 5900 -shared ncache_cr -ncache 10 -forever : k...

Tutorial TanStack Query React Native

Image
TanStack Query (formerly known as React Query) is often described as the missing data-fetching library for web applications, but in more technical terms, it makes **fetching, caching, synchronizing and updating server state** in your web applications a breeze. Installation npm i @tanstack/react-query Compatibility React Query is compatible with React v18+ and works with ReactDOM and React Native. Recommendations It is recommended to also use our ESLint Plugin Query to help you catch bugs and inconsistencies while you code. You can install it via: npm i -D @tanstack/eslint-plugin-query Example // App.tsx import {   QueryClient,   QueryClientProvider,   useQuery, } from '@tanstack/react-query'; import React from 'react'; import { Image, StatusBar, StyleSheet, Text, useColorScheme, View } from 'react-native'; import {   SafeAreaProvider,   useSafeAreaInsets, } from 'react-native-safe-area-context'; function App() {   const isDarkMode = useColorScheme() === ...

Tutorial React Navigation React Native

Image
  Getting started The Fundamentals section covers the most important aspects of React Navigation. It should be enough to build a typical mobile application and give you the background to dive deeper into the more advanced topics. Minimum requirements react-native >= 0.72.0 expo >= 52 (if you use Expo Go) typescript >= 5.0.0 (if you use TypeScript) Installation The @react-navigation/native package contains the core functionality of React Navigation. In your project directory, run: npm install @react-navigation/native Installing dependencies Next, install the dependencies used by most navigators: react-native-screens and react-native-safe-area-context. In your project directory, run: npm install react-native-screens react-native-safe-area-context If you're on a Mac and developing for iOS, install the pods via Cocoapods to complete the linking: npx pod-install ios Configuring react-native-screens on Android react-native-screens requires one additional configuration to properl...

Tutorial Expo React Native Google AdMob

Image
Getting Started The AdMob module allows you to display adverts to your users. All adverts are served over the Google AdMob network, meaning a Google AdMob account is required. First steps Installation # Install the admob module and config plugin npx expo install react-native-google-mobile-ads On Android, before releasing your app, you must select "Yes, my app contains ads" in the Google Play Console under "Policy and programmes" > "App content" > "Manage". Optionally configure iOS static frameworks Follow these steps on iOS if you need to use static frameworks (that is, use_frameworks! :linkage => :static in your Podfile). You may need this if you use this module in combination with react-native-firebase v15 and higher since it requires use_frameworks !. Expo users may enable static frameworks by using the expo-build-properties plugin. To do so follow the official expo-build-properties installation instructions and merge the followin...