Bookmarks

Bookmarks

49750 bookmarks
Custom sorting
Why Do We Have a Cache-Control Request Header? – CSS Wizardry
Why Do We Have a Cache-Control Request Header? – CSS Wizardry
Learn how the Cache-Control request header works, how browsers handle refresh and hard refresh caching, and when developers should use it for realtime data and offline-first applications.
·csswizardry.com·
Why Do We Have a Cache-Control Request Header? – CSS Wizardry
Using modules in JavaScript
Using modules in JavaScript
Do you want to write cleaner JavaScript? Jump into this article to learn how modules in JavaScript can make your code better.
·honeybadger.io·
Using modules in JavaScript
daltonmenezes/electron-app: 💅 An Electron app boilerplate with React 19, TypeScript 5, Tailwind 4, shadcn/ui, Electron Vite, Biome, GitHub Action releases and more.
daltonmenezes/electron-app: 💅 An Electron app boilerplate with React 19, TypeScript 5, Tailwind 4, shadcn/ui, Electron Vite, Biome, GitHub Action releases and more.
💅 An Electron app boilerplate with React 19, TypeScript 5, Tailwind 4, shadcn/ui, Electron Vite, Biome, GitHub Action releases and more. - daltonmenezes/electron-app
·github.com·
daltonmenezes/electron-app: 💅 An Electron app boilerplate with React 19, TypeScript 5, Tailwind 4, shadcn/ui, Electron Vite, Biome, GitHub Action releases and more.
Representing graphs in PostgreSQL with SQL/PGQ | EDB
Representing graphs in PostgreSQL with SQL/PGQ | EDB
As a huge fan of Tolkien and graph theory, this excellent blog post shared by my colleagues at EDB piqued my interest.The author describes how a graph can be modeled in PostgreSQL and recursive CTEs can be used to execute graph-traversal queries and concludes: This is one way of representing graph-like data in Postgresql, and querying it in a flexible way.I’d be very interested in hearing about other techniques or improvements.And indeed there is a new technique under development for natively working with graphs in Postgres!SQL Property Graph QueriesSQL Property Graph Queries (SQL/PGQ) are now part of the SQL:2023 ISO standard and provide the ability to efficiently represent and query existing relational data as a graph without requiring a separate graph database management system (such as Neo4j).Representing relationships between nodes through connected edges is a very natural and useful ability which is particularly well-suited for representing networks— social networks of friends of friends, transportation networks, computer networks and more.Adding this Power to Postgres!While there are third-party extensions which add graph database functionality to Postgres, such as Apache AGE™, discussion and work to implement SQL/PGQ into Postgres has been ongoing by contributors in the pgsql-hackers mailing list.While still very much a work-in-progress with no release date, it is functional and can be patched into Postgres for you to explore!Patching in three easy stepsApplying these patches requires that Postgres is built and installed from the source code. The Postgres documentation provides a comprehensive overview on the topic.1. Download all .patch files from this psql-hackers thread2. Get the Postgres source code (see https://www.postgresql.org/docs/current/install-getsource.html), then change into the directory that contains the Postgres source code for the rest of the installation procedure3. For each .patch file downloaded (mine downloaded under the Downloads directory on Debian 12), runpatch -p1 < ~/Downloads/v10-00NN-x-y-z.patchReplacing NN-x-y-z with the appropriate patch file name.Once all the patches are applied, we are ready to build and install SQL/PGQ-patched Postgres!Building and InstallingNOTE: Before running ./configure, ensure the required tools are installed (on a Debian 12 OS, I had to install libicu-dev, bison and flex).The short version should suffice for building and installing Postgres, but build it according to your needs../configure make su make install adduser postgres mkdir -p /usr/local/pgsql/data chown postgres /usr/local/pgsql/data su - postgres /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start /usr/local/pgsql/bin/createdb test /usr/local/pgsql/bin/psql testGraphs in Action!The blog post which inspired this post uses Tolkien characters as example data; we will create the same data and demonstrate query parity using SQL/PGQ methods.Creating tablesFirst, fire up psql and generate two tables; one for characters (nodes) and one for relationships (edges):CREATE TABLE nodes ( id SERIAL PRIMARY KEY, name TEXT, details JSONB ); CREATE TABLE edges ( id SERIAL PRIMARY KEY, type TEXT, from_id INTEGER REFERENCES nodes(id), to_id INTEGER REFERENCES nodes(id), details JSONB );Creating dataNext, populate these tables with data:INSERT INTO nodes (name, details) VALUES ('Frodo Baggins', '{"species": "Hobbit"}'), -- 1 ('Bilbo Baggins', '{"species": "Hobbit"}'), -- 2 ('Samwise Gamgee', '{"species": "Hobbit"}'), -- 3 ('Hamfast Gamgee', '{"species": "Hobbit"}'), -- 4 ('Gandalf', '{"species": "Wizard"}'), -- 5 ('Aragorn', '{"species": "Human"}'), -- 6 ('Arathorn', '{"species": "Human"}'), -- 7 ('Legolas', '{"species": "Elf"}'), -- 8 ('Thranduil', '{"species": "Elf"}'), -- 9 ('Gimli', '{"species": "Dwarf"}'), -- 10 ('Gloin', '{"species": "Dwarf"}'); -- 11 -- Parents INSERT INTO edges (type, from_id, to_id, details) VALUES ('parent', 2, 1, '{}'), ('parent', 4, 3, '{}'), ('parent', 7, 6, '{}'), ('parent', 9, 8, '{}'), ('parent', 11, 10, '{}');Creating a Property GraphSQL/PGQ allows the user to create "Property Graphs" on top of one or more existing relational tables, and query these graphs natively using a powerful new operator, called GRAPH_TABLE, which provides a graph pattern matching language fully integrated into SQL.Note: Because SQL/PGQ is still under development in Postgres, there is sparse documentation.Below, we reference the documentation for OracleDB's Property Graph Query Language (PGQL), which has incorporated the SQL:2023 standard and provides an explanation of the features, even though it is for a different database management system.By defining VERTEX TABLES to encapsulate our nodes and EDGE TABLES to encapsulate the relationships between these nodes, a PROPERTY GRAPH represents our data as a graph.We have only one VERTEX TABLE corresponding to our nodes table for characters and a single EDGE TABLE corresponding to our edges table for relationships. We give this edge a LABEL named relationship which has the type property ('parent' or 'friend'). Pay special attention to the keys (SOURCE KEY and DESTINATION KEY) of the edge, as direction matters when traversing a graph (which will be seen querying data).CREATE PROPERTY GRAPH characters VERTEX TABLES ( nodes LABEL node PROPERTIES ( id, name, details ) ) EDGE TABLES ( edges SOURCE KEY ( from_id ) REFERENCES nodes ( id ) DESTINATION KEY ( to_id ) REFERENCES nodes ( id ) LABEL relationship PROPERTIES (type) );Simple queries - finding parents and childrenWe can find someone’s parents by traversing our characters property graph along edges with the relationship label of type parent.Let's find Samwise Gamgee's parent:Recursive CTEWITH child AS (SELECT id FROM nodes WHERE name = 'Samwise Gamgee') SELECT parent.name FROM child JOIN edges ON edges.to_id = child.id JOIN nodes parent ON edges.from_id = parent.id;SQL/PGQSELECT name FROM GRAPH_TABLE (characters MATCH (a IS node WHERE a.name='Samwise Gamgee')
·enterprisedb.com·
Representing graphs in PostgreSQL with SQL/PGQ | EDB
Postgres query plan visualization tools - pgMustard
Postgres query plan visualization tools - pgMustard
When you’ve got a slow Postgres query, EXPLAIN and its parameters are incredibly useful for working out why. However, the information returned can be difficult (and time-consuming) to interpret, especially for more complex queries. Over the years, people have built quite a few tools for visualizing
·pgmustard.com·
Postgres query plan visualization tools - pgMustard
Migrating from Sidekiq to Solid Queue - DONN FELKER
Migrating from Sidekiq to Solid Queue - DONN FELKER
I recently migrated Listomo (my email marketing platform) from Sidekiq to Solid Queue. There are lots of posts out there showcasing how various companies migrated to Solid Queue from Sidekiq but they did not help that much, so hopefully this helps someone else. Migration Steps Install Solid Queue This one is quite self explanatory. The […]
·donnfelker.com·
Migrating from Sidekiq to Solid Queue - DONN FELKER
Rails views, web components, React. Why make a choice?
Rails views, web components, React. Why make a choice?
How many times have you heard or read statements like these in tech discussions? "Everything needs to be a single-page app these days. Server-rendered templates are holding you back." "Web components…
·aha.io·
Rails views, web components, React. Why make a choice?
The Pitchfork Story
The Pitchfork Story
A bit more than two years ago, as part of my work in Shopify’s Ruby and Rails Infrastructure team, I released a new Ruby HTTP server called Pitchfork.
·byroot.github.io·
The Pitchfork Story
The cost of Go's panic and recover
The cost of Go's panic and recover
TL;DR ¶ Some of the wisdom contained in Josh Bloch’s Effective Java book is relevant to Go. panic and recover are best reserved for exceptional circumstances. Reliance on panic and recover can noticeably slow down execution, incurs heap allocations, and precludes inlining. Internal handling of failure cases via panic and recover is tolerable and sometimes beneficial. Abusing Java exceptions for control flow ¶ Even though my Java days are long gone and Go has been my language of predilection for a while, I still occasionally revisit Effective Java, Joshua Bloch’s seminal and award-winning book, and I never fail to rediscover nuggets of wisdom in it.
·jub0bs.com·
The cost of Go's panic and recover
codepo8/trimMiddle
codepo8/trimMiddle
Contribute to codepo8/trimMiddle development by creating an account on GitHub.
·github.com·
codepo8/trimMiddle
Viselect
Viselect
Visual Selection Library
·simonwep.github.io·
Viselect
simonwep/viselect: ✨ Viselect - A high performance and lightweight library to add a visual way of selecting elements, just like on your Desktop. Zero dependencies, super small. Support for major frameworks!
simonwep/viselect: ✨ Viselect - A high performance and lightweight library to add a visual way of selecting elements, just like on your Desktop. Zero dependencies, super small. Support for major frameworks!
✨ Viselect - A high performance and lightweight library to add a visual way of selecting elements, just like on your Desktop. Zero dependencies, super small. Support for major frameworks! - simonwe...
·github.com·
simonwep/viselect: ✨ Viselect - A high performance and lightweight library to add a visual way of selecting elements, just like on your Desktop. Zero dependencies, super small. Support for major frameworks!
Automate the Creation of GitHub Releases
Automate the Creation of GitHub Releases
I maintain many open-source projects and one of the most common tasks for me is to “create a GitHub release”, which is more or less the process of attaching some release notes and build artifacts to a Git tag, so GitHub users would see them on the “Releases” page of a project. Here’s an example, from my RuboCop project.
·batsov.com·
Automate the Creation of GitHub Releases
Use Rails I18n for more than translations
Use Rails I18n for more than translations
Discover how to leverage Rails I18n beyond its traditional translation role. Learn practical examples of using the internationalization framework f...
·dotruby.com·
Use Rails I18n for more than translations