Web Tools #517 - Cookies, CSS Tools, Git/CLI, JS Utils

Web Tools Weekly
WEB VERSION
Tools for Web Developers

Issue #517 • June 15, 2023

Advertisement

The Terminal of Choice for AI-generated Commands ⚡
Built with Rust and integrated AI, Warp is a modern terminal that will make you faster on the command line. Type ‘#’ to open AI Command Search. Then, use natural language to look up commands without leaving your terminal.

Warp

Ask Warp AI about how to troubleshoot a React state management problem or handle a specific npm package. It can even guide you step-by-step through setting up a Node.js server. With Warp, executing suggested commands is as easy as a single click – no copy-pasting necessary.

Try Warp AI today

The one thing I've never covered in this intro is one of the oldest and controversial web APIs: cookies! As we all know, modern web APIs like IndexDB and Web Storage (using localStorage and sessionStorage) have come into general use in recent years.

Though those newer technologies are recommended for larger amounts of data, it's still good to be familiar with how cookies can be accessed and created via JavaScript. So let's dig into the four basic things you can do with cookies.

Setting a Cookie
To set a cookie, you can use the document.cookie property, which allows you to read and write cookies. To set a cookie, you assign a string value to document.cookie, following the format name=value. Here's an example:

document.cookie = "username=John Doe";

Once that cookie is created, you can access it via the same property.

Reading a Cookie
To read a cookie, you can access the same document.cookie property. It returns a string containing all the cookies associated with the current document, with the cookies separated by semi-colons. To extract a specific cookie value, you'll need to parse the string, as shown below:

let cookies = document.cookie.split(";");

for (let cookie of cookies) {
  let trimmedCookie = cookie.trim();
  if (trimmedCookie.startsWith("username=")) {
    let username = trimmedCookie.substring(
      "username=".length
    );

    console.log("Username: " + username);
  }
}

As you can see, cookies aren't very intuitive to work with, which is another reason why other data storage formats have become more popular.

Accessing a Cookie
To access a cookie value directly, you can use a helper function to retrieve the value based on the cookie name. Here's some code to demonstrate:

function getCookieValue(cookieName) {
  let cookies = document.cookie.split(";");

  for (let cookie of cookies) {
    let trimmedCookie = cookie.trim();
    if (trimmedCookie.startsWith(cookieName + "=")) {
      return trimmedCookie.substring(
        cookieName.length + 1
      );
    }
  }

  return null; // Cookie not found
}

let username = getCookieValue("username");
console.log("Username: " + username);

I've formatted the above code for readability but you should be able to get the gist of it. Again, you can see how convoluted it can be to access cookies, and why it would be much better to use a small library to do this sort of thing!

Expiring a Cookie
Finally, to expire a cookie, you can set its expiration date to a past date. This will cause the browser to remove the cookie, as in the following code:

function deleteCookie(cookieName) {
  document.cookie = cookieName + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
}

deleteCookie("username");

Once again, it would be much easier to have a small library to do all this work behind the scenes so you can just work with a simple API. But if you've never actually worked directly with cookies before using JavaScript, the above code examples should give you a decent overview of how they're created and accessed.

And if you want to demo any of the above code, you can go to any web page and just enter those snippets in the browser console, and you should more or less get the expected results (though the output may differ if the page has cookies set already).

Now on to this week's tools!

 

CSS and HTML Tools

Realtime Colors
An interactive website where you can test color palettes on real live UI elements in real time, with the ability to generate palettes and deep link to a specific palette demo.

CSS Gradient Generator
A gallery of CSS gradients with a tool to generate random gradients and adjust the angle of the gradient and you can also generate based on preferred colors.

Swap.js
A JavaScript micro-library that uses HTML attributes to facilitate Ajax-style navigation in web pages in less than 100 lines of code.

Branition
Browse over 300 hand-curated color palettes with advanced filter options best fitted for logos & branding.

The Terminal of Choice for AI-generated Commands ⚡
Built with Rust and integrated AI, Warp is a modern terminal that will make you faster on the command line. Troubleshoot a React state management problem, handle a specific npm package, or get help on setting up a Node.js server. As easy as a single click, no copy-pasting necessary.   SPONSORED 

SupportsCSS
Live, in-browser detection of modern CSS support for selectors, features, and at-rules, as an extension of the @supports feature. Applies support-based classes, exposes a results object, and allows custom tests.

SupportsCSS

Toaster
An impressive pure CSS 3D editor that looks like Canvas or WebGL where the elements are built with nothing but HTML and 3D transforms.

CSS Patterns
A gallery of background patterns that resemble SVG-based patterns but are built using pure CSS gradients (linear, radial, and conic).

ColorSlurp
A native color picker tool for macOS or iOS that lets you pick any color on your screen using a high-precision magnifier, create and organize palettes, and check color contrast for accessibility.

Type Scale
A visual, interactive type scale generator that's integrated with Google Fonts and lets you choose either a predefined scale or enter a custom one.

table-magic
An online tool to convert between CSV, TSV, HTML, SQL, and Markdown and has a form editor and preview.
 

Git, GitHub, and CLI Tools

Framed
A Go-based CLI tool that simplifies the organization and management of files and directories in a reusable and architectural manner.

Map of GitHub
A searchable, visual representation of 400,000+ GitHub projects. Search for a project by name to drill down and show related projects based on GitHub stars (i.e. multiple people starred the same projects so they appear close together).

Mods
A simple Go-based tool that makes it easy to use AI on the command line and in your pipelines, and works with OpenAI and LocalAI.

Turn Leads Into Customers
Created specifically for sales and marketing professionals, Invido can give you a much-needed boost in video prospecting, follow up rates, and ultimately help close more deals.    SPONSORED 

snips.sh
An SSH-powered pastebin with a human-friendly TUI and web UI, usable from any machine with an SSH client installed and it's self-hostable.

snips.sh

Monolith
A Rust-based CLI tool for saving complete web pages as a single HTML file, with features that improve the "Save page as..." method used in browsers.

logss
A simple Rust-based command line tool that helps you visualize an input stream of text.

PR Explainer Bot
A GPT-powered, AI-based GitHub app that analyses your pull requests and offers explanations, suggestions, spots bugs, and more.

citty
An elegant CLI builder that has a fast and lightweight argument parser, nested sub-commands, lazy and async commands, and more.

Zero
Unique, powerful, and secure secrets management software for developers. Includes a free plan for solo developers with unlimited secrets and projects.

Envio
A Rust-based command-line tool that simplifies the management of environment variables across multiple profiles.
 

JavaScript Utilities

jiti
Runtime Typescript and ESM support for Node.js with seamless interoperability between ESM and CommonJS.

@webreflection/promise
A JavaScript module that exposes a drop-in replacement for both Promise and AbortController with extra features.

supercluster
A fast JavaScript library for geospatial point clustering for browsers and Node.js.

Turn Leads Into Customers
Created specifically for sales and marketing professionals, Invido can give you a much-needed boost in video prospecting, follow up rates, and ultimately help close more deals.    SPONSORED 

jscanify
An open-source pure JavaScript mobile document scanner designed to run in any JavaScript environment.

jscanify

Memize
A barebones memoization library with a focus on speed with support for multiple arguments, including non-primitive arguments (by reference).

ohash
A super-fast hashing library written in vanilla JavaScript and based on murmurhash3.

TS Writer
A just-in-time template string template engine designed to generate TypeScript code at runtime. Simple to use and has a small footprint, useful for CLIs and code generation tools.

queue
An asynchronous function queue with adjustable concurrency that implements most of the Array API.

Croner
Trigger functions or evaluate cron expressions in JavaScript or TypeScript, no dependencies and works with Node, Deno, Bun, and the browser.

TypeScript API Utils
Utility functions for working with TypeScript's API, a successor to an older project called tsutils.

jsdoc-to-markdown
Generates markdown API documentation from jsdoc annotated source code, useful for injecting API docs into project README files.
 

Commercial Apps and Classifieds

These are commercial apps, affiliate links, PPC ads, and paid classifieds. Buy a Classified here.
CSS Pro – A DevTools enhancement to easily live-edit CSS on a web page.
Meco – Enjoy newsletters in a space built for mindful reading and give your inbox space to breathe.    AD
Microlink – A fast, scalable, and reliable high-level API to control a headless browser.
Chatspell – A live chat service for your website, powered by ChatGPT.
VSCode.Email – The latest news, articles, and tools for the world's most popular text editor.  AD
OpenWidget – Service to add interactive widgets to your website (contact us, FAQ, etc.)
Wrap – Design and edit images for social media, product development, presentations, and more.

A Tweet for Thought

This is one of the more impressive robot demos I've seen, showing how far this kind of technology has come.
 
A Tweet for Thought
 

Send Me Your Tools!

Made something? Reply to this email or send links via Direct Message on Twitter @WebToolsWeekly (details here). No tutorials or articles, please. If you have any suggestions for improvement or corrections, feel free to reply to this email.
 

Before I Go...

If you're trying to glue two things together and don't know what kind of glue to use, check out This to That. Select the two materials you want to glue and this tool will tell you the best possible adhesive to use.

Thanks to everyone for subscribing and reading!

Keep tooling,
Louis
@WebToolsWeekly
PayPal.me/WebToolsWeekly

Key phrases

Older messages

Web Tools #516 - Frameworks, SVG Tools, Svelte

Monday, June 12, 2023

Web Tools Weekly WEB VERSION Issue #516 • June 8, 2023 Advertisement Powerful Git Client for Mac and Windows Boost your team's productivity with Tower – a beautiful, native Git client designed to

Web Tools #515 - JS Libraries, Database Tools, Uncats

Thursday, June 1, 2023

Web Tools Weekly WEB VERSION Issue #515 • June 1, 2023 Advertisement Warp: The AI-Powered Terminal for Mac 🤖 Warp is a Rust-based terminal with AI fully integrated so you always know which command to

Web Tools #514 - Jamstack, ChatGPT Tools, React

Thursday, May 25, 2023

Web Tools Weekly WEB VERSION Issue #514 • May 25, 2023 Advertisement The Terminal for the 21st Century ⚡ Warp is a Rust-based terminal with IDE-style input that lets you point, click, and select – like

Web Tools #513 - SVG, JS Utilities, Uncats

Thursday, May 18, 2023

Web Tools Weekly WEB VERSION Issue #513 • May 18, 2023 Advertisement Meet Your New Favorite Terminal ⚡ Warp is a Rust-based terminal that works like a modern app. Edit your commands like in an IDE,

Web Tools #512 - CSS/HTML, Build Tools, React

Friday, May 12, 2023

Web Tools Weekly WEB VERSION Issue #512 • May 11, 2023 Advertisement Effortlessly Manage Your Web3 Community Lithium is a community engagement platform designed for projects seeking to build, nurture,

You Might Also Like

Microsoft Outlook Flaw Exploited by Russia's APT28 to Hack Czech, German Entities

Saturday, May 4, 2024

THN Daily Updates Newsletter cover Webinar -- Data Security is Different at the Petabyte Scale Discover the secrets to securing fast-moving, massive data sets with insights from industry titans

Stop spam texts today!

Saturday, May 4, 2024

Have you been receiving a ton of spam texts lately? In April alone, spammers sent out over 19.2 billion texts. Ever wonder where they get your info to begin with? Data brokers. They sell your address,

DeveloPassion's Newsletter #165 - She Said Yes ❤️

Saturday, May 4, 2024

Edition 165 of my newsletter, discussing Knowledge Management, Knowledge Work, Zen Productivity, Personal Organization, and more! Sébastien Dubois DeveloPassion's Newsletter DeveloPassion's

📧 Implementing API Gateway Authentication With YARP

Saturday, May 4, 2024

​ Implementing API Gateway Authentication With YARP Read on: m​y website / Read time: 5 minutes BROUGHT TO YOU BY ​ Supercharging Development With AI and APIs ​ ​Announcing Postman v11: Streamline API

Software Testing Weekly - Issue 218

Friday, May 3, 2024

Unit, Integration and End-to-End Tests 🔧 View on the Web Archives ISSUE 218 May 4th 2024 COMMENT Welcome to the 218th issue! I loved going through this discussion among software engineers: What is your

gpt2-chatbot and OpenAI search engine - Weekly News Roundup - Issue #465

Friday, May 3, 2024

Plus: Med-Gemini; Vidu - Chinese answer to OpenAI's Sora; the first race of Abu Dhabi Autonomous Racing League; deepfaking celebrities to teach math and physics; and more! ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏

NASA comes to the rescue of crowded rocket launch sites

Friday, May 3, 2024

Plus: Fisker's legal woes and Sprinklr lays off 100 View this email online in your browser By Christine Hall Friday, May 3, 2024 Good afternoon, and welcome to TechCrunch PM. We made it to Friday,

🎮 Forget the PS5 Pro, I Still Love My PS4 — The Best Lock Screen Widgets for iPhone

Friday, May 3, 2024

Also: Smart Home Mistakes to Avoid, and More! How-To Geek Logo May 3, 2024 Did You Know Half of the world's geysers are located in Yellowstone National Park. 🔑 More Passkeys Happy Friday! You can

JSK Daily for May 3, 2024

Friday, May 3, 2024

JSK Daily for May 3, 2024 View this email in your browser A community curated daily e-mail of JavaScript news The Power of React's Virtual DOM: A Comprehensive Explanation Modern JavaScript

Musk raises $6B for AI startup

Friday, May 3, 2024

Also, is TikTok dodging Apple's commissions? View this email online in your browser By Haje Jan Kamps Friday, May 3, 2024 Welcome to Startups Weekly — Haje's weekly recap of everything you can