As a new years resolution… Well I’m happy with my 3440×1440 pixel screen resolution, haha! No but seriously: this is an attempt to really sharpen my programming and computer *stuff* skills. I attempt to write a short article every week or so on something cool I’ve learnt, been working on, am stuck/raging on or that I found genuinely amazing. So, without any further ado, let me get back to work 😛
PS: If you fancy a look to my main blog where I post stuff (very infrequently but fun nonetheless) check it out here.
It has been way too long that I made a quick code post. Now since my friends and I have successfully passed our certification exam to become official MATLAB® professionals, I wanted to share some nifty tricks to deal with optional, missing or false arguments in MATLAB®.
When writing an application, one may want to make it interface with some web based backend. More specifically, I’ll show how simple it is to send HTTP requests using Swift to a PHP based website and obtain a reply.
The process is actually really simple:
- Generate a NSMutableURLRequest; mutable since you’ll have to set its properties later
- Set the request’s HTTPMethod; that will be POST or GET depending on how you interface with the backend
- Set the request’s HTTPBody; by creating a data String and converting it into an NSData object
- Pass the request to a NSURLSession; using the dataTaskWithRequest() function as it will call its completion handler when finished
- Define the content of the completion handler (if needed); to obtain the reply and check for errors
I’ve been coding on a Swift project recently where I develop a small app that has a preferences window. This preferences windows is supposed to be very small and not take up much screen space, so I decided to drop the title bar. But how do you hide and move it now? That’s what I’ll show here…
NumPy is a package that provides cool and simple functionality for n-dimensional array manipulation. I come from a MATLAB® background, so I wanted to try something easy, yet the results were not as I expected. It’s concerning simple vector multiplication, i.e. using the dot-product. Whereas in MATLAB® the that the two operands are used matters in what the result will be, NumPy seemed to be a bit picky when it came to it. Thanks to stackoverflow I finally understood my confusion and this short post may help someone equally stuck.
For our research on electricity networks work we utilise a BDS licensed power system simulator, a.k.a. OpenDSS (link). This simulation platform receives sequential instructions that first define the equipment properties (i.e. define line, load and transformer specifications), then assign the asset placement (i.e. define the netlist) and then simulates the whole thing. Up until now we only implemented two means of interacting with OpenDSS. One is to generate a big bunch of files that are collated in a common master.dss file. Doing this limits the spectrum of our research to OpenDSS’s inherent capabilities and would not be sufficient for dynamic time series analysis. The more flexible approach was to use MATLAB® which can interact with OpenDSS through a registered Component Object Model (COM) server. With all the functionality that MATLAB brings as well as the capabilities of OpenDSS this seemed like a perfect combination. But now we want to take it even further and implement computer science (CS) based solving mechanisms on real communications protocols, yet these may only be simulated in MATLAB®. So I decided to give Python a try as it seems to be able to interact with OpenDSS in a similar fashion, yet with all its packages makes CS life a hell of a lot easier. So let’s see how I got started with that.
Working with objects once a project becomes sufficiently complex makes it much easier to keep track of things. MATLAB® (a.k.a. MATrix LABoratory) is a nice product by a company called MathWorks that makes matrix manipulation incredibly easy. For us engineers and academics it is the standard goto, regardless if we need to rapid prototype some functionality or develop a complex and convoluted system. Only recently did I discover a whole hidden side of MATLAB®: classes! And because I am an incredibly big fan of those beasts I decided to write a quick summary of how to use them.