Restart Mac From Command Line / / No Comments Restarting and shutting down a computer remotely is a frequent task for remote system administrators. As someone that writes many shell scripts, I also find myself automating system restarts. Let’s look at a few ways to restart Mac systems from command line! Restart a Local Mac To restart a local Mac system from command line, you can execute: sudo shutdown -r now Restart a Remote Mac To restart a remote Mac system, you can execute: ssh -l {AdminSystemAddress} sudo shutdown -r now Restart at a Specific Time You can specify a restart at a specific time: # Format: sudo shutdown -r hhmm # Restart at 11:30pm local time sudo shutdown -r 2330 System restarts are good after massive updates... more → Posted in: JavaScript Tagged with: Command, from, line, Restart
How to Use Your Domain on Bluesky / / No Comments Bluesky is a hot new social networking platform that functions like Twitter from Twitter’s original founder. New users are flooding into the platform as a respite from Elon Musk’s vision of Twitter and the fumbles that have happened since his takeover. Upon signing up for Bluesky, your username defaults to {yourdesiredhandle}.bsky.social, but there’s a better and more secure option. One of Bluesky’s awesome features is the ability to base your username on a hostname’s DNS record. In short, if you control a hostname’s DNS, you can essentially verify yourself. For example, my Bluesky username is davidwalsh.name. Let’s look at how you can base your username... more → Posted in: JavaScript Tagged with: Bluesky, domain
Updating and Supporting URL Parameters in JavaScript / / No Comments Not quite a long time ago, but roughly two years ago I wrote a blog post on updating and supporting, URL parameters with Vue.js. The idea was this: Given an application that lets you perform various tweaks, it would be nice if the URL was updated to reflect the current state of the application. This would let you bookmark, or share, the URL with others and they would get the same view as you. In that post, I built a very basic "data filtering" application and then updated it to support updates to the URL. I thought I’d revisit that post and demonstrate building it in vanilla JavaScript. As always, I’d love to hear your thoughts on this, especially if you’ve done something... more → Posted in: JavaScript Tagged with: JavaScript, Parameters, Supporting, Updating
CSS content-visibility / / No Comments The CSS language is full of small gaps which are frustrating to navigate. Between CSS properties to hide a container and its contents, there is still room for improvement. visibility: hidden keeps height and width integrity while display: none on a container hides everything. You can use .container > * to hide all contents of a container, but what if there was a better way? There is a better way to hide the contents of an element while respecting the container’s border and dimensions. That better way is using the content-visibility property: .my-container.contents-loading { content-visibility: hidden; } A demo of such functionality: See the Pen Untitled by David Walsh... more → Posted in: JavaScript Tagged with: contentvisibility
How to Get a Base64 Version of a File From Command Line / / No Comments A while back I wrote an article on how to Convert Image to Data URI with JavaScript. It’s a neat trick developers can use for any number of reasons. Instead of abusing canvas, however, why not simply get the base64 data from command line? You can use base64 and pbcopy to convert a file to base64 and copy it to the clipboard: # base64 gets data, pbcopy copies to clipboard base64 -i logo.jpeg | pbcopy Once you have the file data copied in base64 format, the URL format to use the data is: # data:{mime-type};base64,{data} data:image/jpeg;base64,/9j/4AAQSkZJRgAB...... While base64 data and data URIs do look cryptic, they’re useful to avoid making requests to other files. I use them... more → Posted in: JavaScript Tagged with: Base64, Command, file, from, line, version
How to Get a Computer’s Hardware ID / / No Comments Cheating in online games is a huge issue these days — just ask anyone playing PUBG. Cheaters aren’t difficult for players to spot but vendors oftentimes don’t do enough to punish these villains. Krafton recently announced they would start banning cheaters by hardware ID, which got me thinking about how you can get a user’s hardware ID. There’s no definitive “hardware ID” provided by a machine, but you can create your own based on how specific you want to get. The hardware ID you create can be created from multiple pieces of hardware. Let’s discover how to get important IDs of different hardware components: # Get information about the motherboard... more → Posted in: JavaScript Tagged with: Computer’s, Hardware
JavaScript Array Group / / No Comments Managing, sorting, and manipulating data with JavaScript is a skill we’ve often delegated to third party libraries like lodash. As the JavaScript language progresses, however, these features eventually get. added to the JavaScript specification. Two such APIs for grouping of Array data are `Array.prototype.group and Array.prototype.groupToMap. Array.prototype.group To group an array of objects by a given property, call the group method with function that returns the grouping string: const teams = [ { name: "Arsenal", origin: "London", tier: "legendary" }, { name: "Manchester United", origin: "Manchester", tier: "legendary" }, { name: "Liverpool", origin: "Liverpool", tier: "legendary"... more → Posted in: JavaScript Tagged with: Array, Group, JavaScript
Using the Cookie Store API / / No Comments Today while browsing a list of web APIs over at MDN, I ran across one that surprised me – the Cookie Store API. This is clearly marked as experimental (currently only supported in Chrome/Edge) but looks to be fascinating. Cookies are the oldest (as far as I know) way for web applications to store data on the client. They’re also typically the least recommended way of doing so, for many, many reasons. However, sometimes you need to work with cookies, and this looks like a really nice new way of dealing with them. Here’s a quick look. The Old Way # For the past few hundred years or so, working with cookies in the browser involved string parsing. There really wasn’t even... more → Posted in: JavaScript Tagged with: Cookie, Store, using