code formating

Friday, June 29, 2018

Expose text from Emacs to another device via QR

Expose text from Emacs to another device via QR I am one of those who uses Emacs extensively. Particularly when it comes to keeping myself organised or simply for annotating and  storing, I use org-mode.

This is not a post about telling how awesome org-mode and Emacs are, for that there are many posts, but for exposing a flaw I had with my setup and explaining a workaround.

I have a couple of desktops in different locations and connected to the internet. In order to keep my agenda and note files synchronised  I keep them encrypted with GNUPG and then post them to a public Git repository. This solves the problem of sharing the data between  different locations as long as I am on those computers.

The problem is that when I am not, I loose track of the things on my calendar. Despite not being at the desktop, I do still have  my phone on and I would like to somehow have the data accesible. Connecting a phone to the PC via USB and start copying file s it's too much hasle.

So I thought: "Wouldn't it be great if I could create a QR code out of the org-agenda view and quickly read it with the phone?".

I did a quick search on the Web and found that there already are some Emacs packages that do that but none (as far as I am aware) are  in Melpa.

Determined to have a solution without much tweaking of my system and having qrencode and feh Linux programs already installed on it, I set to search how to launch them from Emacs. It turns out it's pretty easy and here is the code:

I have found the tecnique it's usefull for a miriad of things.

Thursday, December 7, 2017

Programatically walk a CATIA tree in .NET

One of the most basic tasks when automating anything in CATIA, it's usually to walk the whole tree and apply some changes to objects in the way.

There are many examples written with CATIA macros or VB scripts on the Web but I would like to contribute my VB.NET bit showcasing a practical use of higher order functions.

Here is the code:

The way to call the modifyTree it's as follows:
My hope is for this to be the first CAD-CAE automation post on many to come. Lets see how it goes.

Thursday, July 6, 2017

Conventional bike - ebike convertion for commuting and for fun!

Among the myriad of personal projects laying around, one kept coming up every time
spring showed its head. With good weather conditions and long periods of sunlight
I wanted to commute to work by bike.

This year I had set myself up to the task and tried it a couple of times. The trip it's
about 4.7 Km and mostly on secondary roads and some tracks. I soon realised, that
the short but step climbs I had to overtake, where to much for daily commuting.

After some research on converting a bike to ebike, I found that the Mid Drives
developed by the Chinese company Suzhou Bafang Diandonchi Gongsi, better known in the west as Bafang or 8Fun,
 appear to be the "standard" on the Mid drive ebike conversion arena.

Note that Mid Drives are not the only option in town. There are wheel motors of a variety
of brands and models. However, the balance of the bike and the efficiency of the motor
looks like it's better with the Mid drives. They are also more expensive on average.

Now the Bafang 8Fun 500W Mid Drive, it's a piece of joy. It has an accelerator as well as pedal assist.
While you are on pedal assist if you want a little burst (or just want to avoid pedaling), pres the acceletator and of you go.

There are 3 assistance levels by default but can be easily tweaked (following the manual) to up to 9.
There is also the possibility to hack the controller but that's another topic.

Note that the way the assistance works in this machine, it's by cadence. So it takes you to a speed limit
that's set per assistance mode, while it detects you are pedalling. Every-time it feels the speed has come down it pushes back up.
It feels like a sudden push but you get adapted easily. There are other mid drivers that also play with the actual force you are applying to the pedal
but I didn't want or need to go that far.

I live in a pretty hilly area and it is to note that the default chain ring I received was 46T. I find this one
to be a little to much for hilly areas. I am on the process of thinking how many teeth to reduce and how to do it.

Over all, this thing it's wonderful. I find myself willing to go to places by bike now. The hills that brought laziness
before look like candies waiting for a bite now. With about 10 AH battery I can easily do over 40Km on a charge.

Some considerations:

The whole set up it's heavy. The bike will easily increase 6 Kg. Added to the fact that you now have a motor
below you, caution need to be taken when braking and turning. Specially so on wet weather.

I am in Europe and if you want to follow the law and your converted ebike still to be
considered a bike, take in to account:

- speed limit of 25 KM/h. After that the motor has to switch off and you are on your own
  until you get below the threshold again.
- Motor Power limit of 250W
- It has to ran on assisted mode, which means that the motor only helps if you pedal.

All in all, it's awesome!

Thursday, April 6, 2017

HIoH (HIoH IoT Hub)

The internet of things it's a trendy topic lately. Armed with a myriad different little devices from temperature sensors to door bells, from elaborate sleep monitoring sensor, to cameras, weather stations, TV boxes or credit card sized computers, there is a ample world to explore.

How to bring together all this information that's been generated? meet HIoH IoT Hub. HIoH makes one assumption: Communication is going to be using MQTT protocol. This protocol is been battle tested and thought for machine to machine communication.

The project focuses on connecting to a MQTT broker and singing up to some configurable topics. Each topic is supposed to be a device. Every device will send data to the broker, and ones configured, HIoT will bring it all together. There is also the possibility for the communication to be from HIoT to device, openning a way to send commands.
Other than HIoH, what else do I need to have it all play as one?
  • An MQTT broker. It can be any broker that implements MQTT. If asked for suggestions, in the land on Erlang, there is Rabbitmq where MQTT can be installed as a module.
  • Each device has to be able to send or receive (or both) MQTT messages to the or from the broker. Many programming languages have libraries to connect to MQTT brokers so I believe having this protocol it's actually a feature in this regard.
Where does it all merge?
HIoH is accessible via browser and it's programmed to work on mobile phones. It makes a heavy usage of web sockets in order to maintain updated data.
HIoH uses d3 for real-time graphics. What the graph update as data arrives.
HIoH can receive and display images.
How is it programmed?
HIoH it's programmed on Erlang. In case you were wondering how could a system connect to multiple topics, get all the data, rely it to the web clients (and possibly back) on real time and not fall to pieces.
Is there anything hidden?
MQTT protocol it's designed for speed not for security. IoT has an incredible potential but this goes in par with the security risks it brings. This should not be a problem but it definitely has to be taken into account. HIoH does not build any security layer as I believe it is not its job. It simple offers a hub that it works
Want to know more?
HIoH is built under the MIT license and can be found here.

Tuesday, February 14, 2017

.NET get anonimous return expando with added fields

If you happened to be programming in VB.NET and happened to receive an IEnumerable of anonymous objects and if you then need to return the IEnumerable with every element slightly modified, it's a pain.

You have to create a new anonymous object and manually type every property of the old object in every step of the loop. In order to automatise this process, this function comes very handy:

Pass it the anonymous object and a list of key value pairs (these would be the properties to be added) and it returns another object retaining all the old properties and adding the new ones.
Note that the implementation uses the Expando object.

Tuesday, May 10, 2016

To pray or not to pray

Here is a discussion:

There is this little private one day party/festival in a little district in a little town. About 60 people gather for lunch, some dancing and few games.
Before lunch there also is a catholic religious service.

Arguing with religious freedoms it is lately become something difficult. Many people does not care and do not want to be involved in the argument. However, I believe that everything has to be questionable because passivity is also an action.

Is it justifiable to vote the continuity of the religious service if the organizers want? Or just plain take it off the calendar? Or it shouldn't be touched?

The service proponents claim that elders attend the service and they really want to have it. They are elders so are we going to take that off from them?

On the other hand, what does a religious service contribute to the festival? We can argue that the lunch, the  music, dancing and games,
contribute directly to the means of the party/festival which is to enjoy and eat. But does the service add up to this?

"Passivity may be the easy course, but it is hardly the honorable one.”― Noam Chomsky

Thursday, February 11, 2016

Should a pharmacy shell homeopathic products?

Not without clearly displaying its inability to cure or at least following the same steps that any other pharmaceutical has to follow.

Stop this nonsense!

 If anyone wants to buy this stuff, that's OK with me But please "Mr. government", stop looking in another direction when facing this stuff.

Expose text from Emacs to another device via QR

Expose text from Emacs to another device via QR I am one of those who uses Emacs extensively. Particularly when it comes to keeping myself o...