Skip to content

Instantly share code, notes, and snippets.

View beyondkmp's full-sized avatar
🎯
Focusing

beyondkmp beyondkmp

🎯
Focusing
View GitHub Profile
@icpz
icpz / darwin-route.c
Last active November 28, 2019 06:16
manipulate routing table via route socket on darwin
#include <sys/socket.h>
#include <sys/types.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <netinet/in.h>
#include <net/route.h>
#include <arpa/inet.h>
#include <ifaddrs.h>
#include <unistd.h>
@viphat
viphat / the-art-of-readable-code.md
Last active September 7, 2022 05:03
The Art of Readable Code

The goal of this book is help you make your code better. And when we say "code", we literally mean the lines of code you are staring at in your editor. We’re not talking about the overall architecture of your project, or your choice of design patterns. Those are certainly important, but in our experience most of our day-to-day lives as programmers are spent on the “basic” stuff, like naming variables, writing loops, and attacking problems down at the function level. And a big part of this is reading and editing the code that’s already there.

KEY IDEA 1 - Code should be easy to understand.

KEY IDEA 2 - Code should be written to minimize the time it would take for someone else (may be you sixth months later) to understand it.

Is smaller always better?

The less code you write to solve a problem, the better. It probably takes less time to understand a 2000 line class than a 5000 line class

@inexorabletash
inexorabletash / @ IndexedDB Full Text Search (Proof of Concept).md
Last active November 8, 2025 05:43
IndexedDB Full Text Search (Proof of Concept)

This demonstrates the implementation of full text search for documents in Indexed DB.

  • Word-breaking and stemming is used to create a list of terms for each document.
  • Document records are annotated with the list of terms when added to the database.
  • A multi-entry index on the list of terms is populated.
  • A query is similarly processed into a list of terms.
  • A join over the terms is implemented using multiple cursors on the index.

The necessity of annotating records with the word list to populate the index is a limitation of the current Indexed DB API. A feature request to support custom