code formating

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.

Wednesday, October 14, 2015

A case against bloom filters in bitcoin

Bitcoin Bloom filters are like mazes with many entries and two ways out, lets call them "no way" and "my way". One decides that a transaction has not to be sent to us the other one to be sent. The maze it's built in a way that all our wanted transactions are going to get out of the "my way" and some unwanted too. For the sake of correctness, note that the maze can not be run backwards and every element will repeat its own way every time its thrown through the "maze"".

The anonymity that this technique claims to achieve it's coming from the "unwanted" elements that come out of "my way". This will supposedly confuse anyone that is trying to follow our wanted elements.

Whether with this technique we really achieve anonymity might be arguable or not but I do not have a problem with that part.

With bloom filters, before anything is sent to us by a node, the node has to "build the maze" run every transaction, outpoint, sig script and pub script (this four have been called elements up to now) through the maze and send us the ones that come out of "my way".

Bitcoin it's an open protocol and accessible to anyone so potentially everyone can ask for their own maze to be build. This means that the node now has to build a maze and run every element through it for every client that asks and yet they get no rewards.

I's clear where I want to get with this. This bloom filer building (maze building) and specially the rehashing (rerunning everything through the maze) its none less than practical. The stress the bitcoin community can put on the full nodes is in my opinion unjustifiable. We can not build anonimous bitcoin wallets at the expense of the full nodes. In my opinion we ought to find a better way.

I started to build bloom filters in nicotib in order to avoid downloading the full blockchain. It felt fresh until I thought of implementing the other side of the equation. At this point I have decided to stop building bloom filter in nicotib and I'll be taking the code out of the project.

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 ...