C++ Compiler Targets The Web

It is a common problem these days. You have a piece of code in C or C++. Maybe it is older code. Or maybe you prefer prototyping your ideas using C. But, inevitably, someone now wants your code to run in a Web browser. The options for making this happen have expanded quite a bit lately and one possibility is Cheerp, an open-source compiler that handles up to C++ 17 and can output to WebAssembly, JavaScript, or asm.js.

The compiler is free to use for GPLv2 projects. If you aren’t open yourself, it looks like you have to cut a deal to use Cheerp with its maker, Learning Technologies.

Continue reading “C++ Compiler Targets The Web”

Roll Your Own Photo Sharing, Minus The Social Networking Baggage

[Niklas Roy] rolled his own photo diary, because he found the core functionality of something like instagram attractive, but didn’t want the social network baggage that it came with. His simple system is called my own insta ;) and it consists of some javascript and PHP to create a nice progressive web app photo diary and backend that can be accessed just fine from a mobile device. It is available on GitHub for anyone interested in having their own.

This project came up because [Niklas] sometimes found himself working on small projects or experiments that aren’t destined for proper documentation, but nevertheless could benefit from being shared as a photo with a short description. This dovetails with what many social networks offer, except that those platforms also come with other aspects [Niklas] doesn’t particularly want. His online photo diary solves this by having a simple back end with which he can upload, sort, and caption photos in an easy way even from a mobile device.

Rolling one’s own solution to some small core functionality offered by a social network is one way to avoid all the extra baggage, but another method is to simply automate away all the pesky social bits with a robot.

Turning GitHub Into A URL Shortening Service

URL shortening services like TinyURL or Bitly have long become an essential part of the modern web, and are popular enough that even Google killed off their own already. Creating your own shortener is also a fun exercise, and in its core doesn’t require much more than a nifty domain name, some form of database to map the URLs, and a bit of web technology to glue it all together. [Nelsontky] figured you don’t even have to build most of it yourself, but you could just (ab)use GitHub for it.

Using GitHub Pages to host the URL shortening website itself, [nelsontky] actually repurposes GitHub’s issue tracking system to map the shortened identifier to the original URL. Each redirection is simply a new issue, with the issue number serving as the shortening identifier, and the issue’s title text storing the original URL. To map the request, a bit of JavaScript extracts the issue number from the request, looks it up via GitHub API, and if a valid one was found (and API rate limits weren’t exceeded), redirects the caller accordingly. What’s especially clever about this is that GitHub Pages usually just serves static files stored in a repository, so the entire redirection logic is actually placed in the 404 error handling page, allowing requests to any arbitrary paths.

While this may not be as neat as placing your entire website content straight into the URL itself, it could be nicely combined with this rotary phone to simply dial the issue number and access your bookmarks — perfect in case you always wanted your own website phone book. And if you don’t like the thought of interacting with the GitHub UI every time you want to add a new URL, give the command line tools a try.

A Different Kind Of IKEA Hack: Javascript Price Comparison By Location

When looking for the best deal, it pays to shop around. When it comes to chain stores, of course, one expects the price to be the same across their retail network. However, where international companies are concerned, occasionally a better deal is just a border crossing away. To investigate the best possible price on IKEA’s flatpacked goods, [Sn0w5t0rm] whipped up a scirpt to make comparisons easy.

The hack consists of a small piece of Javascript that runs in a browser extension like Greasemonkey (Firefox) or Tampermonkey (Chrome). When visiting an IKEA product page, it shows the price of the same item in the alternative country of your choice. Often, significant savings can be had – the SKOGSTA table is €176 cheaper in the Netherlands compared to Belgium.

While the script does require some customization to suit your location, it could nonetheless save you a bundle on some home furnishings if your live near enough to a border. We’d love to see the concept taken further to tease out best prices in a given region for goods from all stores. Similar techniques can net you cheap airfares, too!

DIY Regular Expressions

In the Star Wars universe, not everyone uses a lightsaber, and those who do wield them had to build them themselves. There’s something to be said about that strategy. Building a car or a radio is a great way to learn how those things work. That’s what [Low Level JavaScript] points out about regular expressions. Sure, a lot of people think they are scary. So why not write your own regular expression parser and engine? Get that under your belt and you’ll probably never fear another regular expression.

Of course, most of us probably won’t do it ourselves, but you can still watch the process in the video below. The code is surprisingly short, but don’t expect all the bells and whistles you might find in Python or even Perl.

Continue reading “DIY Regular Expressions”

The Game Boy Camera, Or: How I Learned To Stop Worrying And Love The Pixels

Never underestimate the power of nostalgia. In an age when there are more megapixels stuffed in the sensor of a smartphone camera than the average computer display can even represent, why would jagged images from a 20-year-old grayscale camera with pixels numbering in the thousands still grab attention? Maybe what’s old is new again, and the coolness factor of novelty is something that can’t be quantified.

The surprise I had last Monday when I saw my Twitter notifications is maybe only second to the feeling I had when I was invited to become a Hackaday contributor. I’d made a very simple web app which mimics a Game Boy Camera using the camera from your phone or desktop, and it got picked up by people so much that I’m amazed my web host is still holding. Let’s look at why something seemingly so simple gained so much traction.

Continue reading “The Game Boy Camera, Or: How I Learned To Stop Worrying And Love The Pixels”

Browser Makes Tiny Office Suite

There’s a recent craze of people living in tiny houses of 400 square feet down to as little as 80 square feet. Maybe [zserge] was thinking about that and created a very tiny office suite in which each tool weighs in at less than 1K. If you are guessing you couldn’t squeeze much functionality in C or C++ code or even assembly, you’d be right. The language of choice? HTML and JavaScript. So while the code is small, it relies on a pretty big piece of software. On the other hand, you have a browser open right now, so the incremental cost of using these tools is very small.

We get the idea that there’s not much chance this is going to sweep the shelves of Microsoft Office, Libre Office, and all the many competitors. However, it is a pretty stunning example of what you can do with modern HTML. There’s even a GitHub repo and a subreddit.

Continue reading “Browser Makes Tiny Office Suite”