Why to-do apps for JavaScript frameworks

Leave a comment

Somehow whenever I see some new Javascript framework, most of them always have the same To-Do application as their showcase sample. If someone/ some company is going to build a new framework and going to tell me, we built an awesome framework you can do so much with that and then they go ahead and give me a sample of a To-Do application, anyone would be like meh!!

How difficult can a to-do application be that the said framework is going to make your life much easier.

Just wrote a small to-do app myself, it only needs 1 single line of javascript, yup you read that right.

All the things you need are –

  1. Text area for the To-do
  2. Button to add it.
  3. Checkbox to mark the todo complete.

The addtodo() function inside the <script> tag is what does all of this.

I feel designers, developers need to come up with something more innovative than a todo list app. Just saying!

Script Processor in EDQ is cool

Leave a comment

So I started with a bit of work on EDQ and I must say its a pretty neat tool. Basically Oracle EDQ stands for Enterprise Data Quality where you get to fix all the invalid, inconsistent and simply put bad, very bad, very very bad data.

I was just playing with it a bit and found the script processor very handy since I could do anything I want with use of a scripting language like javascript or groovy.

I just wrote a sample script to have convert the currency values of products from one currency to another. Maybe this could help someone writing a script for the first time in EDQ.

Here is what my data looks like –

I created a quick web service on mockable.io. It is a pretty neat tool where you can create a web service to output any data that you want to, here is the sample data I created –

And finally here is the code of the script processor which will convert the values to specific currency, the data used is pretty self explanatory.

There are few things which I am sure, you would know if you have used EDQ before.

  1. All inputs and outputs have to be used in the form of array. input1[0], input1[1], input1[2] and so on will be automatically mapped with your columns which you would have selected.
  2. There can be only one output of the script and you need to store it in output1 variable only.
  3. You can simply ignore the logic of Currency conversion in the code, since this is for a very specific task.

All this was just to show you how you can manipulate data with the use of Web Services in EDQ. Hope this helps πŸ™‚

Fetch Data from Web Services in Excel Macro

Leave a comment

Since the time I have started working in Enterprise Solutions. There is only one universal truth, everything can be done in Microsoft Excel. Murphy Law fits it completely, what can happen will happen in Excel.

Having said that, just wrote a small snippet to call Web Service from Excel Macro. The code is pretty self explanatory.

“strResponse” will store the return data in requested format”. In my case I had data coming in JSON format, there is however no native support to read that, I had to use a 3rd party JSON library

Details on the Library @ https://github.com/VBA-tools/VBA-JSON

SOAP XML – A different way to pass nil

Leave a comment

I have been working on some standard Oracle ERP Cloud SOAP payloads and found something different.

Suppose you want to update the End Date field on the Trading Partner Item, you can simply send the below request to set the date.

However what if you want to make the field update to no value or null value, or simply blank, however you want to put it.

In that scenario, you cannot simply use any of the below forms of the XML Attributes.

The only way in which you can achieve the operation i.e. setting the attribute to no value in the database is, if you pass it in the below format.

A different namespace is also required for setting the xsi:nil=”true”. Make sure you include that in your request.

5000+ lines of SQL Query

Leave a comment

Why you should not use online code formatting tools? Coz most of them suck at their job.

A friend wrote a query for an Oracle Report which had 52 unions and spanned over 5000 lines. Tested and all working fine, before saving the report, she decided to format and indent the code using an online code formatter one of many many available all across the internet.

And it broke it just enough to not run anymore and just not enough to notice the difference immediately.

The error message was pretty clear that one of the unions had less/more number of selected columns but no message on which union, thanks to the bad code analyzer of Oracle BI EE.

As always, ruby magic always comes to rescue when you are in a tight pinch.

The code is pretty straight forward to read. It starts with the line starting with “SELECT” and ends before the line starting with “FROM”. We had a total of 52 unions, so I just needed to store that list of selected columns from all these 52 unions in an Array. We cannot really define a 2-D array in Ruby however we can always define an Array within an Array and that solves our purpose of Multi dimensional Array.

The script provided us a nice sheet with all the column names and helped in figuring out the incorrect SELECTED list of columns from a specific union list.

Phew!!

Light it up!

Leave a comment

So I got myself a 1m strip of WS2812B LEDs or commonly known as individually addressable 5050 LED ICs. I saw a lot of youtube videos on infinity mirror and thought if the same concept can be applied to creating a clock and voila! lots of people have already done that in the past.

To be very honest it doesn’t not look like a very difficult project to accomplish. So I went ahead and got myself an Arduino Mega Rev 3.

Here are the steps I used to make the LEDs glow like a clock hands move.

  • My first step was to find a suitable power supply, I didn’t get one with the strip so I just had to search for my mobile chargers and check which one was suitable. Most of them had a voltage rating of 5V but I needed one with a higher Ampere rating.

Each 5050 LED IC needs around 60mA and I had a total of 60 LED ICs.

So power required is simply = 60 * 60 mA = 3.6 A

Thankfully my One Plus phone charger had a 4A rating. So it fit the budget just fine.

  • I simply cut the USB cable I had with the charger and found the two thicker wires which had to be the ones with +5V and Neutral. I checked it with my newly bought Mastech Multimeter to confirm.

Excited that the power supply of my mobile charger met my LED requirements so amazingly I connected both and turned on the power.

Aaanddd!! it did not light up 😦 I thought maybe my connections are weak, so I redid them again and again and again and it never worked. The LEDs just wouldn’t light up.

I tried to measure the current flowing through the LED strip and there was definitely current flowing through so the circuit was continuous. So even if some of the LEDs were not working, some of them should have lit up. I spend the next few hours trying to test if power is flowing through LEDs randomly and it was.

But still no glow.

Google didn’t help all that much since I never thought that the strip didn’t light up coz I was not sending any control/data signals to it.

Finally I figured it out the next day, I connected it to my arduino and imported the FASTLED library. The code sample was easy enough to test and I modified it as per my LED Strip and here is the code to run a simple clock on a LED Strip with 60 LEDs.

Hope this helps anyone who is just starting up. I will post the code for lighting up the LEDs like a clock in the next blog post.

Oracle why you bug!!

2 Comments

So I have been using OBIEE for some time now for reporting purpose in my organization. Although its an easy to use tool there are good amount of bugs in it and for such a widely used tool some of the bugs outright seems stupid.

For instance you cannot delete records properly from a Fixed Value List if it has more than 10 records.

Here is a sample of that, I created a Fixed list with 10 + records. See how it asks for deletion of the element correctly but deletes an element different altogether. It should have deleted “Record 12” but deleted “Record 2”

The reason is simply bad coding. So there is a javascript function “LovPanel.NVEntry.remove” which does the removal of record from the list. But it does not work!!

Oracle if you are listening fix this.

How to send Notification in Android App

Leave a comment

We are going to do a quick tutorial today on how we can generate notifications in Android. Although the standard Android Guide does explain it, but I dont think its a very quick way to understand stuff.

So here we go.

Here are the basic steps –

  1. Create a notification channel
  2. Build a notification
  3. Send a notitification.

How do we create a notitification channel, we do it simply by keeping in mind that we need a unique channel id(“1000111”) and channel name(“cld_notif_channel”). The values do not matter, however they need to be unique.

The notitification channel can be invoked as many number times as required, although once invoked and available it will just not create another if its already present. I would suggest to create your notitification channels as soon as your application opens.

The way you do it is simply by calling the createNotificationChannel() function in your Main Activity.

Step 2 involves creating the notification itself. There are few basic things we need to take care of, it must have a Small Icon available, this one is mandatory along with the Channel Id, which we created above.

Step 2.5 involves creating a notification manager which is actually going to be responsible for sending out notifications.

Step 3 involves obviously firing the notification and sadly this again requires a unique id(“1001”) to uniquely identify the notification and send it.

And there you go, its so simple it hardly would take 10 minutes of your time to learn how to send notifications in your Android application.

*Note – where you see *this* that is android.content.Context so this goes inside your class for the activity.

A blog a day challenge

Leave a comment

I am going to start with the blog a day challenge. Simply put for the next 100 days I am going to write a blog every single day without fail on any topic.

I need to invest a considerable amount of time in learning new things for career growth and my own as well. Having a regular blog should help in prioritising the activities in that direction.

How do we start?

Leave a comment

Hi Guys

Long time no see πŸ™‚ sometimes I feel like I should tell that to myself as well.

So how do we start, we start by noting down what we need to do, and while we are at it, we note down what we didn’t write in the first place and also few more things which you should have thought of before. To do things is to improvise, learn and also to keep on adding more things to do, obviously a to-do list never ends, because to do something or to learn something, you need to do a lot of things πŸ™‚

To understand that lets write a blog post πŸ™‚ This is going to be quick. All you need is rails setup in your system.

Lets start with creating a blank app

rails new todoapp # this will create a blank slate for you to work on

rails g scaffold todo task:string complete:boolean parent_task_id:integer # this will create your model/views/controller/migration etc etc files which you will do the work for you

rake db:migrate # if this throws an error, you gotta do “rake db:setup first” this will create your database migration and the schema for todo tasks.

Now we need to build something like the below to sorta have a parent child relationship between the tasks. Why ? just read the 2nd para again from top.

Parent Task 1
—- Child Task 1
—- Child Task 2
Parent Task 2
Parent Task 3
—- Child Task 1
——– Child Task 2

In your new and shiny app/models/todo.rb add these two lines to create the parent child hierarchy.

has_many :child_tasks, :class_name => 'Todo', :foreign_key => "parent_task_id"
belongs_to :parent_task, :class_name => 'Todo', :foreign_key => "parent_task_id"

Now a bit of magic is needed to the views to allow us to easily select the Parent tasks for any child task.

Head over to your app/views/todos/_form.html.haml or *.erb file depending on the templating engine and change the f.parent_task_id to a collection_select

.field
= f.label :parent_task_id
= collection_select :todo, :parent_task_id, Todo.all + [Todo.new], :id, :task

This will allow us to choose a parent task, whenever we are creating a new task with – not a very bad hack? πŸ˜›

Finally in the show and index page, we need to display the parent task.

replace your todo.parent_task_id with
Todo.find_by_id(@todo.parent_task_id).task rescue "No Parent Task"

And the end result is tada!!!

Todoapp

Older Entries