REST services – the Node JS simple server

NodeJS has actually encapsulated all of the hard work. A simple server that will wait for HTTP GET statements.

This simple server program has a lot of functionality. It is an example of three different endpoints that can be called. The /hello and /goodbye are pretty obvious and simply return a json message to the caller.

const express = require('express')
let app = express()
app.use(express.json());



app.get('/hello', (request, response) => {
  response.json({ "message": "hello world" });
});

app.get('/goodbye', (request, response) => {
  response.status(200).send("goodbye world");
});

app.get('/x/:id', (request, response) => {
  response.status(200).send(request.params.id );
});

const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`listing on port ${port}` ));

The third endpoint is a bit more interesting as it allows you to pass in a parameter and easily as part of the URL. This particular example might be good for retrieving a value (ie book) by the code that is passed in. Because this is a service and not a web server it is only returning a value and not a webpage. But this is pretty useful as a backend server for your website.

Just as important as the ability to get information it is important to be able to pass in a complex structure.

app.post('/newitem', (request, response) => {

  let body = request.body;
  console.log("body of post")
  console.log(body);


  var keys = Object.keys(body);
  for (i in keys)
    console.log(i,keys[i],body[keys[i]]);

  response.status(200).send(request.params.id );
});

This example post endpoint allows us to pass in any structure and print it out to the console.

In my next post I will expand on this for other features that might be useful.

Posted in programming | Comments Off on REST services – the Node JS simple server

I want to support my local store

Don’t you hate it when you go to your local store to purchase their wares and they tell you nope we don’t want your money.

I might be paraphrasing my recent encounter at Conrad Electronics. I wanted to purchase one of the electronic SMD switches only to be told that that was for businesses only. You cannot become part of their program unless you have a company registered in Germany.

I did manage to find a very similar part on Ebay and there are other companies such as Mouser, Digikey and Reichelt.

I guess capitalism will out.

Posted in Soapbox | Comments Off on I want to support my local store

Consumer DRM – pecked to death by ducks

It is difficult to where exactly we are on the spectrum. A few instances of creative companies using DRM and other protective designs preventing consumers from buying compatible consumables.

Previously, it seemed that companies were using Patent law to prevent their competitors from selling compatible consumable items to their customers. I am certain there are many examples but the one that I think sticks out is the Nespresso coffee machines. They had apparently a unique shaped capsule that was under Patent protection. This did a good job of keeping other companies from selling that profitable coffee to their consumers – alas all good things come to an end. Their original capsule patent expired in 2012 forcing them to compete with others.

I have seen other companies that have other protection mechanisms to prevent you from using compatible soap refills or air fresheners refills. Some of these methods can be easily circumvented with simple items or methods. ( felt tip marker circumvents Sony disc copy prevention )

Some of these companies do try to sell products as a loss leader with the goal of making their profit on the back end. It does seem that the printer industry seems to fall under that heading based on the costs of some of their low end printers. I am not sure I want to pay for overpriced ink or toner but I can understand that model.

I am a bit less understanding of General Electric and how they deal with water filters connected to their refrigerator.

Patents, protective mechanisms, as well as DRM to lock the consumer in are methods that could be used to try and guarantee future profits, but what makes these methods awesome for the company and less so for the consumer is the DRMC passed in the US in 2004.

The DRMC has a provision that prevents makes it illegal to circumvent technical measuresĀ in copyrighted materials. It didn’t take the companies too longer to see this as a cudgel that could be used against competitors as well as people who circumvent this on their own legally purchased devices. What could be better, protection from competition with the power of law.

It is difficult to know at this time if this is the top of the slippery slope or if we are further down. It doesn’t really matter but there is a dystopian future where this type of DRM will prevent virtually all competition.

https://arstechnica.com/gaming/2020/01/unauthorized-bread-a-near-future-tale-of-refugees-and-sinister-iot-appliances/

Posted in Soapbox | Comments Off on Consumer DRM – pecked to death by ducks

Unanticipated consequences from BREXIT to climate change

Who would have thought that BREXIT or perhaps Covid 19 could have such an effect. I try to actually shop in stores to ensure there is competition to Amazon and Alibaba. However, from time to time I will purchase something online or get something from Ebay.

Imagine my surprise the other day when I did purchase something from Ebay to have to pay some customs charges. It did not take long to realize that this is probably to be expected as the UK has left the European Union – no more free ride I guess. The customs fees were actually not so amazing 2.28 EUR for purchasing an item valued at 10 GBP or about 12 Euros.

Rules are rules and I suppose that the the EU is trying to protect itself from people cleaning out their basement and selling it abroad. This cost doesn’t really bother me but what does is was the additional 6 EUR Auslagepauschale (storage fee) I was charged. It does rather change some of the economics of purchasing used things from the basements of UK sellers.

Used brass tag10 GBP
Postage3.05 GBP
Customs tax2.28 EUR
Storage fee6.00 EUR
Total24.05 EUR

This might really be a chart that suggests I visit flea markets close to where I live. I wish my car was brand new but as an older car it probably does contribute to greenhouse gases (or pollution if you prefer).

However, apparently the playing field is not quite level. Either Germany or the EU is concerned about commerce and gifts flowing in. This seems to be true for gifts/packages from the United States and from the UK. If other sources are to be believed this is true for quite a number of non-EU countries.

What does not seem to be the case is receiving new items from China. I did actually order a few printed circuit boards from China and if you are in no hurry it is a cost effect way to import project boards.

circuit boards2.00 USD
postage3.90 USD
Customs0.00
Storage fee0.00
Total5.39 EUR

It is not clear what the cost to the environment is to ship items from the other side of the world but intuitively it should be greater than something shipped from an EU adjoining country.

It is not often that I do this, but this does pretty much offer an interesting precedent. If you need some thing reasonably small or affordable why reuse / recycle an existing item when you can get a brand new one shipped from China for cheaper.

These two examples are not actually completely comparable but especially now during (essentially) pandemic conditions getting electronics is difficult. I have been forced to purchase items from the US in the past which really didn’t make all that much sense because of the shipping costs, but now with these extra little taxes* and fees it makes more financial sense to take the anti-climate choice.

I guess that either BREXIT, the fear of BREXIT competition or attempts to squeeze extra fees from the postal consumers is creating a situation of unexpected consequences** that seems anti-climate to me.

* Customs tax is not new but recent changes for items starting at 0 EUR instead of 22 EUR along with the stories that gift package (45 EUR or less) also seems to be no longer be exempt. It is possible that this 45 EUR level is being applied inconsistently.

** Who would have thought that Economics class would still be in my head after all these years.

Posted in Germany, Soapbox | Comments Off on Unanticipated consequences from BREXIT to climate change

Making a fortune in 2022

The amount of IT that is at your finger tips in the year 2022 (or really since 2015) is amazing. It is possible to research how to make vegetarian chili or get help in selling your old computer monitor.

From the comfort of your own home you can sell new or old items on ebay, ebay kleinanzeigen (Germany), Amazon, ETSY, Facebook marketplace just to name a few. This makes it easy to sell your old playstation or perhaps an old laptop.

You would think selling that item should be easy, just take a few pictures, and create an auction or a sale. Bingo you are rich.

Well, it turns out that the world is a large place and a lot of people have old or broken laptops in their basement. Just try and sell one to discover how many items are for offer. I thought I could sell an old slimline dvd drive only to discover what appears to be dozens of similar items that can be had for not much more then the cost of shipping.

This is great if you are looking to build some Frankenstein computer with 10 slimdrive dvd’s but less interesting if you are trying to sell your old 512 mb laptop ram module or old laptop keyboard.

As always, your mileage may vary.

Posted in Soapbox | Comments Off on Making a fortune in 2022

A bit of (excessive) advertising

I am actually glad that I do not see how many minutes per week I spend at YouTube. It is a convenient place to get some news, see some how to video and if you need to relax there are a lot of funny animal or children videos.

It has been long known that the internet is actually watching us and selling us to their advertisers. What the heck, why not watch a few of the commercials or use that as an opportunity to get a sandwich from the fridge.

What I don’t understand is what advertiser thinks I would like to stop watching cat videos to see their 6 – 52 minute long infomercial. Not only that, the infomercials don’t seem to even remotely match up with my video history.

Perhaps Google believes that everyone wants to purchase mystery supplements or the belief we can become some sort of work from home and earn 250 dollars by tomorrow morning and perhaps 150k by the end of the year.

It is difficult to know who is getting the better deal, some company whose video is streamed for the first minute or two or Google who gets them to pay for this. I guess there is one born every minute …

Oh, what is the record for an add? Just under 3 1/2 hours.

Posted in Soapbox | Comments Off on A bit of (excessive) advertising

Raspberry Pi – fun with electronics

Internet of things devices are amazing. They are just really smart really tiny computers used in innovative ways.

  • smart electric socket
  • smart light bulbs
  • doorbell camera
  • video picture frames
  • autonomous vacuum cleaner
  • Amazon echo
  • Sonos speakers
  • Internet radios

It is really not that difficult to create your own IOT device but it is possible to get a head start by using either the Arduino or Raspberry Pi as a starting point. Both of these platforms bring a lot to the table but in different ways.

It might seem intimidating to create your own but this book can help clarify everything you need to know.

Topics
Theory and components
Tools
Simple circuits
Integrated circuits
Software tools
Arduino
Raspberry Pi
C programming
Makefiles
Kicad design software
Linux commands

Projects
Streaming audio
Network storage
Arduino LED cube
LED cube with custom PCB

This book describes everything you need to create your own custom device. This could be built on top of a pre-existing platform or even by designing your own custom circuit. This makes it fun to create your very own device from scratch. Most importantly everything is described with the assumption you are a beginner.

Getting started with Arduino and Raspberry pi

Posted in programming | Comments Off on Raspberry Pi – fun with electronics

Art imitating life

I just saw the movie “Don’t look up”

Synopsis – spoiler alert

Two scientists discover a planet killing asteroid that is headed directly towards earth. The story details their difficulties bringing this fact to the government. Once this issue is brought to light there is a lot of realistic twists and turns from denial that this is a realistic threat to other political denials that turn into a yet another conspiracy theory that the asteroid is to control people. The president has a case of the nepotism’s when staffing up her office. Things really get wild when an ultra rich businessman talks the government out of trying to divert the asteroid.

It is difficult to say if this movie was in any way inspired by the United States previous president Trump but unfortunately he did bring along the nepotism by bringing his daughter and son-in-law into the office of the president.

The first 150 or so years seemed to have politicians that were civic minded while in the last decade or so the American politicians seem to be purely partisan. It is telling that in the last 12 years three billionaires have run for president and one has one the position. In the movie the president seemed to be motivated only by winning and money. This in itself does not seem different from the modus operendi of the Trump adminitration.

https://www.nytimes.com/2019/09/09/us/politics/trump-hotel-turnberry.html

https://www.washingtonpost.com/politics/secret-service-has-paid-rates-as-high-as-650-a-night-for-rooms-at-trumps-properties/2020/02/06/7f27a7c6-3ec5-11ea-8872-5df698785a4e_story.html

Even if this parallel does not seem accurate, another true to life parallel was the different deniers of scientific fact and how it was assumed to be a big conspiracy theory. It does not take too much imagination to see this as our current Covid 19 situation with the various vaccine deniers and conspiracy theorists.

https://www.cnbc.com/2021/10/01/why-the-covid-vaccines-dont-contain-a-magnetic-5g-tracking-chip.html

https://theconversation.com/its-almost-like-grooming-how-anti-vaxxers-conspiracy-theorists-and-the-far-right-came-together-over-covid-168383

The conclusion of the movie was not the typical Hollywood ending but the more likely outcome when reality is ignored and public policy is twisted by economic self interest. With any hope America will go back to electing non-partisan politicians whose goal is the betterment of their citizens both those to voted for them as well as those who didn’t.

Posted in Soapbox | Comments Off on Art imitating life

Trust us, the cartridge is genuine

Allegedly, The chip shortage seems to be affecting the ability of some companies from supporting their own DRM. DRM is one way for content creators to control their content to ensure that others cannot access that content. This type of technology can also be used by hardware manufacturers to control what types of reusable materials the users actually use in this hardware (ie ink or toner in printers).

I remember first thinking this is getting out of control when I read that the popular coffee machine Keurig had implemented DRM preventing any other coffee modules other than theirs from being used. I can understand why companies want to sell the device at a loss or at cost with the expectation of making their money on the backend of the transaction through the sales of consumables.

However, this should not lock out competitors from attempting to fill the need. My last two printers each have a small PCB on the toner cartridge that proves it is a “genuine” toner cartridge from that manufacturer.

I was surprise to see that these small PCB’s are starting to be a victim of the global chip shortage. Specifically, the camera / printer manufacturer Canon that is having problems because it cannot seem to source these custom PCB’s. I first learned of this issue from a Youtube video by Louis Rossmann, but after some investigation it seems that there is a lot of this type of DRM

From the video, it seems that this message can be cleared and you can use non-genuine cartridges. I have heard similar stories of multi-function printers that completely stop working if the ink overflow tray gets full or if the cartridges are completely removed.

https://arstechnica.com/tech-policy/2022/01/chip-shortage-has-canon-telling-customers-how-to-skirt-its-printer-toner-drm/

How to disable Canon message

… as well as a few other general “smart chip” solutions.

https://www.tonergiant.co.uk/blog/2014/07/printer-not-recognising-compatible-cartridges/

https://tonerconnect.net/blog/disable-electronic-chips-inkjet-toner-cartridges/

Posted in Soapbox | Comments Off on Trust us, the cartridge is genuine

Cloud technology – the dark side

There are a lot of good things about using cloud technology. If the cloud is powering your company you might be using the advantage of scaling the resources only when you need them. Nothing could be better than starting up 20 or 30 servers for two days every quarter for your reporting and only paying for the tie you need. Maybe a big Christmas or Super bowl deal supported by 100 times your normal server capacity for the weekend without being forced to buy computers that will be idle most of the year.

All of this is great when you are reaping these benefits but there is a problem with not owning your own infrastructure. It is quite possible that in the near future users of Google drive will no longer be able to share their files.

https://www.techradar.com/news/google-drive-could-soon-start-locking-your-personal-files

Terms of service are there for a reason and you cannot hardly fault the service provider from enforcing them – you really need to follow the rules.

Yet what can be worse than having your IT pulled out from under you? It doesn’t matter if you if renting space on a cloud drive or paying a monthly subscription for using Photoshop. If you don’t actually own your own hardware or software you may be in for rude awakening should your budget not cover these variable expenses.

Posted in security | Comments Off on Cloud technology – the dark side