command line fun – arrays

Work with new people and learn new things. I used to work with someone who was unfamiliar with the Unix world, did not know how to program in Java and couldn’t write shell scripts either.

Victoria was actually a very clever lady and she did manage to conquer these shortcomings to be the best person in our team.  She simply rolled up her sleeves (well put on some reading glasses) and got all of the knowledge that she needed to achieve her goals.

I was actually quite surprised when I was looking through one of her scripts when I saw that she was using array’s in her shell script.  I had always gathered up my files to process into a variable and then continued from there.

My file names actually had no spaces and there would only be a handful each time so my solution was just fine, but it never hurts to put another arrow into your developmental quiver.

The syntax is slightly different to other languages but the syntax is rather straightforward.

VARIABLENAME[indexhere]=somevaluegoeshere

The only thing that is different than some of the more classical languages is how to determine the length of an array.

${VARIABLENAME[@]}

I am not sure that how Victoria actually used arrays was really necessary but it did point out an interesting way we can process data in the future.

#!/bin/bash

FILELIST[0]=dailyclosing.txt
FILELIST[1]=weeklyclosing.txt
FILELIST[2]=monthlyclosing.txt

idx=0
for single in `ls -1 *`
do

  idx=$((idx + 1))

  LEN=${#FILELIST[@]}

  ndx=0
  found=0
  while [ $ndx -le $LEN ]
  do
    arrayitem=${FILELIST[$ndx]}

    #echo $single $arrayitem
    if [ "$single" == "$arrayitem" ]
    then
      found=1
    fi

    ndx=`expr $ndx + 1`
  done

  if [ $found -eq 1 ]
  then
    echo $single true
  fi

done

This solution was altered from something else that was not quite appropriate. The actual solution could have been much much simpler.

1
#!/bin/bash

if [ -f dailyclosing.txt ]
then
  echo do daily stuff
fi

if [ -f weeklyclosing.txt ]
then
  echo do weekly stuff
fi

if [ -f yearlyclosing.txt ]
then
  echo do yearly stuff
fi
Posted in programming | Leave a comment

dipping your toes into the ocean with Mermaid

It began with a great idea.

“lets do our systems graphs in such a way we can version them in GIT”

Anyway, I believe that is how it started.  I was then told that perhaps the open source tool Mermaid would be the solution to that grand idea.

It did look pretty good.  I tried using this for some trivial graphs and I was amazed at how well it worked.  You could create a small flow chart within a few minutes.  Not only that but the graphs that where created were SVG, that wasn’t really on my radar but it would have been useful a few projects back.

 

Version 1
graph TB
AuthServer(“Oath v2.0)”)
UserDB AuthServer–>UserDB
UserDB –>AuthServer
client(user/browser)–https –>AuthServer
extpgm(ext system) — https –>AuthServer

 

I did like this but to be honest it didn’t really keep the systems properly grouped together.  That was also quickly correct by grouping the systems as a sub graph.

Version 2
graph LR
subgraph Internal Systems
AuthServer(“Oath v2.0)”)
UserDB AuthServer–>UserDBUserDB –>AuthServer
endsubgraph Client Services
Login        client(user/browser)–https –>AuthServer
extpgm(ext system) — https –>AuthServer
end

Mermaid seemed to handle these flows just fine.  Not being content with this I tested the sequence diagrams.  They actually seemed to work even easier.

 

Sequence Diagram
sequenceDiagram
user->>+AuthServer: User credentials
AuthServer ->>+ user: token
Note right of AuthServer: Token valid 6 hours
user->>+MediaServer: requests movie + token
alt token valid
MediaServer ->>+ user: streams content
else token valid
MediaServer –>>- user: request refused
end

I was about to bring all of this to my team leaders attention when I received some feedback from one my teammates. He was correct, color makes things not only less boring but can also visually help with grouping like items together.

Version 3
graph LR
classDef cyan fill:cyan
classDef yellow fill:yellowsubgraph Internal Systems
AuthServer[“Oath v2.0)”]
UserDB(Login data)
DetailsDB(Customer Details)
AuthServer–>|JDBC|UserDB
UserDB –>|WebSphere|AuthServerclass AuthServer yellow
class UserDB cyan
class DetailsDB cyan
end
subgraph Client Services
Login        client(user/browser)–https –>AuthServer
extpgm(ext system) — https –>AuthServerend
linkStyle 2 stroke-width:2px,fill:none,stroke:green;
linkStyle 3 stroke-width:2px,fill:none,stroke:green;

 

It was at this point that I realized that these connections between elements was only one way.  Unfortunately you cannot simply have a line with arrows at each end. I didn’t think that adding a few back arrows would make that big of a change to the diagrams but unfortunately they did.  Not only that as you start to add a lot of different elements, each with bi-directional communication, the nicely ordered elements start to change places.

 

Version 4
graph LR
classDef cyan fill:cyanclassDef yellow fill:yellow
subgraph Internal Systems
AuthServer[“Oath v2.0)”]
UserDB(Login data)
DetailsDB(Customer Details)
Presenter[catalog system]
AuthServer–>|JDBC|UserDB
UserDB –>|WebSphere|AuthServer
class AuthServer yellow
class UserDB cyan
class DetailsDB cyan
end
subgraph Client Services Login
client(user/browser)–https –>AuthServer
AuthServer –>clientAuthServer –>extpgm
extpgm(ext system) — https –>AuthServerend
version 5
graph LR
classDef cyan fill:cyan
classDef yellow fill:yellow
subgraph Internal Systems
AuthServer[“Oath v2.0)”]
UserDB(Login data)
DetailsDB(Customer Details)
Presenter[catalog system]
AuthServer–>|JDBC|UserDB
UserDB –>|WebSphere|AuthServer
class AuthServer yellow
class UserDB cyan
class DetailsDB cyan
end
subgraph Client Services Login
client(user/browser)–https –>AuthServer
AuthServer –>client
AuthServer –>extpgm
extpgm(ext system) — https –>AuthServer
end
client –>Details
DBclient –>Presenter
linkStyle 2 stroke-width:2px,fill:none,stroke:green;
linkStyle 3 stroke-width:2px,fill:none,stroke:green;

The colors of the elements remains easy enough, but as the number of elements increases finding and changing the colors of the lines becomes more and more like software development.  The hacking kind, not the software engineering kind.

The task that I was given had enough elements on it to take up half of a keyboard but this type of graph doesn’t automatically look very good.  It is simply too much.

I did like the few hours that I spent fooling around with Mermaid.  I can see how this might be nice if you have some simple elements that should be graphed.

This example exist on Mermaid page

Perhaps Mermaid is an exceptional tool for either sequence diagrams or gantt charts but I don’t really need that at the moment.

If you really want, you can even add Mermaid to your web pages.  As for me, I am not certain that I would want the diagrams to be outside of my direct control and at the moment human beings are able to make more of the simplifying decisions for item placement.

 

I really with I could give this project two thumbs up but I did encounter a few things that would prevent me, certainly in larger sittings, from using this.

  1. It is not possible to have lines with arrows on each side
  2. It is not possible to simply add notes or legends to flow charts
  3. It is snot possible to have a line from one entire subgraph to another item or subgraph
  4. No influence on the element placement
  5. SVG output from the tool isn’t well supported by Microsoft products, or else there is a problem with the SVG image.
Posted in programming | Leave a comment

Stupid postman tricks

First the technology. RESTful calls are actually pretty cool. It is neat to simply send off a GET or POST message and extract or update the server with vital information. I am not going to write up a long article, well at this point anyway, describing RESTful calls.

Due to the flexibility and function of these calls there are a lot of tools and systems that make use of them. One such tool is Postman. This is a perfect tool for testing your RESTful calls on your servers. This might be during testing or it could be during development.

Performance

I was tasked with setting up some performance tests in another tool and my specification was a Postman script. You cannot really ask for a better specification than something that almost works like a finished program.

The only problem was that I had to run a few different steps and one of the steps required value from the previous step. This is actually almost trivial in Postman but the problem was I needed both the name and the value.  The source code that I had needed parse looked like this.

<input type="hidden" name="xsrf_CppTDEqKjryFYA9agpaloQ" value="LugLnMWKGWyiZD64jwys4g">

I need to pass back a variable called xsrf_CppTDEqKjryFYA9agpaloQ with the value LugLnMWKGWyiZD64jwys4g in the next postman step.

The good news is that postman uses java script as its scripting language.  This allows you to do plenty of interesting things when testing response values.  In my case I decided to use java script to parse the login page that is retrieved and then essentially an inelegant  search through the text for these values.


mysplits=data.split(” “);

searchname=’name=”xsrf’;
var idx;
var valueidx=-1;
var cnt=mysplits.length;

for (idx=0; idx < cnt; idx++)
{
//console.log(mysplits[idx]);
var search = mysplits[idx].substr(0,10);
if (search == searchname)
{
var pieces=mysplits[idx].split(“\””);
console.log(“found”);
console.log(search);
console.log(pieces[1]);
valueidx=idx+1;
}

if (valueidx == idx)
{
var pieces=mysplits[idx].split(“\””);
console.log(pieces[1]);
}
}

This isn’t the type of code you would want to use for any production solutions but it is a fun little hack to assist during development.

Posted in programming | Comments Off on Stupid postman tricks

Better late than never – LED cube

A few weeks back I did my blog “Just making it – a new cube” which was my experiences doing my next led cube.  This cube was an 8x8x8 cube.  The only thing that I didn’t do was to put out a video of the patterns.

This cube actually was really well programmed.  You can find a link to the video below.

 

Posted in programming | Comments Off on Better late than never – LED cube

Clone drone in the danger zone

Clone drone In the danger zone is a game made by Doborog games. You are a human mind implanted in a robot form. You can either battle royal, campaign or costum levels. You either have a sword or a hammer.

Here is a video of a challenge from clone drone in the danger zone.

 

 

 

https://www.google.com/search?q=upgrades+clone+drone+in+the+danger+zone&safe=active&client=ms-android-samsung-ss&hl=de&prmd=vin&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjM0tHGvKbgAhVJI1AKHfCtD7sQ_AUoAnoECAsQAg&biw=360&bih=660&dpr=2#imgrc=CgRK9V6E2NPHpM

clone drone in the danger Zone costs 15$ on steam.

 

Posted in Gaming | Comments Off on Clone drone in the danger zone

A thought experiment

There are a lot of words and concepts in the world that are bad.  just one example of this is the suffix “ist”.

  • sexist
  • racist
  • white nationalist
  • ageist
  • exhibitionist
  • bigamist
  • chauvinist

Depending on your own personal circumstances it is easy to pick a side of an argument and feel strongly about it.  Sometimes over the years opinions may change (or may not) but anything that is written down will haunt you forever.  All of this came to mind when I was recently reading that former judge kavinaugh’s spot on the federal court will need to be filled and that his possible successor had indeed written down a few things back in the day.  It appears that successor,  judge Neomi Rao, had apparently written in the 1990s that victims of date rape were partly responsible if they’d been drinking.

It is bad is to blame the victim for the behavior of others.  This particular argument of blaming the victim may sound to be reasonable until you really considered analogous situations to see just how a specious argument this is.

Perhaps the way to try and disprove that this position would be to “accept it” as case law and then see how this precedent would affect different cases.

Not so smart “smartphone”

A person is walking across the street at the crosswalk like some sort of zombie staring at his smartphone.  The driver is driving at a constant rate and the pedestrian gets hit by a car.

Result
The driver argues that the pedestrian was not paying enough attention and is responsible for being hit by the car.

Assault

While discussing politics it becomes apparent that the two people do not agree.  One of them instead of taking the time to make a strong argument uses this as an opportunity to make statements about the other person(person is stupid, looks ugly, isn’t intelligent, …) Nobody likes hearing these types of things and so he hits the other guy.  Can you imagine how this would play out in court?

Result
If he hadn’t been such of a jerk I wouldn’t have had to hit him.

I would imagine that it is possible to create other situations and “blame” the victim to a certain degree as well.

It is important that we don’t lose focus.

It is important that everyone tries to be responsible for his or her actions.  It would be frustrating to watch someone taking an excessive amount of time crossing the road, especially if you are in a hurry or have an appointment, but this is not illegal behavior.  In my opinion is you are being very short-sighted if you are not paying attention to the world around you.

The same is true for having a discussion or argument and hitting the other person.  It is sad that people get so emotional that they lose control but it still isn’t illegal to be a jerk.  It is also legal to be an incredibly arrogant asshat although who wants that as a reputation.

Getting back to the main premise of “is the victim at fault” when he or she has been drinking.  It is bad style for anyone male or female to get drunk to the point that you lose control but you shouldn’t be penalized for that legal behavior – especially when the other party is doing illegal behavior.  In general no matter what situation is taking place you might want to keep the following in mind.

Discretion is the better part of valor.

It is pretty much a truism that nobody loves yourself as much as you do.  As pessimistic as it may sound it is best if to a certain degree you have a small bit of skepticism in mind in all situations.

On a lighter note

Not all words ending with “ist” has to be a bad word.

  • technologist
  • nutritionist
  • agriculturalist

Depending on the situation, perhaps living next door to an exhibitionist might be a silver lining.

Posted in programming | Comments Off on A thought experiment

Tips for Overwatch 2

 

Name Tip
Genji  Use his deflect to deflect Zaryas Ultimate.
 Zarya  Use her shields wenn D.Va uses her ultimate because the damage that her shields absorb makes her
 Junkrat  His Ultimate can climb up walls. You just have to hold space.
 Lucio Use  sound barrier when trying to get the checkpoint.
 Sombra  use emp when you are in a big crowd
 Wrecking ball  Use mine field when you have to protect the checkpoint.
 Reaper  Use shadow walk when you see Junkrats Ultimate.

 

Posted in Gaming | Comments Off on Tips for Overwatch 2

The Expert, helpful neighbor and friend

The problem was a project I built for my boys was no longer working.  I put everything together just a few months back and one of the relays was now failing me.  The actual problem was the switch no longer was catching but instead it was simply switching on and off constantly.

I purchased a package of five small relay boards for Arduino projects as I needed two and might use the others on something else.  Replacing the old relays with new relays should have been a task of 30 minutes at most, but I spent a lot longer working my project than I expected.

The problem was that one of the relay boards that I was using in my led project was not responding to my signals.  Eventually I swapped it out with a different relay board and all of a sudden everything worked perfectly (should have done that sooner).

My real question is why did the first relay’s fail?  Did I buy poor quality? Was it because they were mounted on their side?  Had they been used more than would normally be expected?  Was the power I was using too much for the switch and that caused the short life?

In the past when these types of questions came up I would have asked Mikhail.  He was both a sympathetic ear for your problems but was also an interesting sparing partner for verbal debates (I still think that Linux was a good decision for Munich and could have made them vendor independent and saved money in the long run, but they did at least gain the German Microsoft headquarters in Munich. )

I think we all have a “Mikhail” in our neighbor who helps answer our questions about computers, helps us move apartment, helps with minor plumbing, pick up the mail when we are out of town, cheers us up when we are down and also helps us buy our electronics.

We should all remember thank our own Mikhail for their assistance.

 

 

 

 

Posted in Soapbox | Tagged | Comments Off on The Expert, helpful neighbor and friend

Whose fault is it anyway

I guess I never really believed that a lot of the news organizations were being overtly “liberal” with an agenda.  It seemed to me that any individual writer(s) may have a personal opinion and that is perhaps why he wrote the article

i.e.

“Clubbing baby seals now seen as cruel”

I have had about 24 or so days to listen to or hear about how the US government shutdown is the fault of the president from one group of the media while hearing that it is not from another group.  I actually think there may be enough blame to go around so here is my chance to offer my impartial view.

President Trump

Could the shutdown be the president’s fault? The easiest person to blame about this is the president.  He doesn’t make it easy to give him any benefit of the doubt when he says things like.

Dec 21, 2018

I am proud to shut down the government for border security

I will take the mantle of shutting down. And I’m going to shut it down for border security.

In one sense you could say that it is refreshing that he is willing to stand up for what he believes.  You could also imagine that this is a pretty unrealistic desire. President Trump was unable to get wall funding approved when he had a majority in both the house and the Senate.  How did he imagine it would work with the house of representatives expected to be counter to a lot of his ideas.

Republicans

Could the shutdown be the Republicans fault?  The Republicans in both the house and the Senate did agree in Dec 2018 on a stop gap bill to keep the government open. This was not approved by the president which was the start of this shutdown.  However, a very similar bill has been approved in 2019 by the house of representatives but it has not even been brought to the Senate floor for a vote.  (naughty naughty Senate Majority Leader Mitch McConnell)

Democrats

Could the shutdown be the Democrat’s fault? It is possible to suggest that the Democrats are at fault over this budget impasse. They just got into power and perhaps are kicking up their heels to prevent the “good works” of the president. After all the difference between that money that President Trump wants (5.7Billion) and the total budget of the US government (3.422 Trillion in 2018) is, in essence, a rounding error of 0.16%. They did try and submit the same stop gap bill as in Dec 2018 to the Senate where it didn’t really go anywhere.

How did this start exactly?

The Congress did not actually manage to create a budget for the government by the Oct, which is the beginning of the fiscal year.  In order to keep the government running, they did manage to pass a continuing resolution to fund the US government, but this temporary resolution was not passed by “The Donald”.

Congress

Is it the fault of the congressional branch of the US government?  This is also a very strong possibility.  The taking the busiest of congressional years, 2007, the number of days spent working was 190 which does compare pretty favorably to the number of working days for the average US worker (260).

Don’t misunderstand it is not that I am jealous (I am) as they work less[1] and earn more money than most people.  The reason why this might be a congressional problem is that the budget is late but more importantly it isn’t a proper budget.  Not only that but in the last 48 years which covers a lot of republican and democratic majorities there have only been four budgets that have been in surplus (1998-2001)[4]. A budget deficit in a family budget can occur but usually only for a short time and never for an entire year.  This means that most members of Congress have not really done their job for decades.

Well, I imagine that these men and women of Congress, nay public servants, are actually barely able to make ends meet.  Perhaps they are all overworked with second and third jobs just to pay their bills[2]?  This also does not seem to be the case.  These public servants not only can pay the bills but they are accumulating enough wealth that they may actually disprove the classless society in the united states.

No, those tireless public servants have not been spending their free time thinking of how to balance the budget but have instead spent their time funding raising[3].  The amount of time spent fundraising is mind-blowing.  It seems to me that whether or not Congress is to blame for the current US government shutdown is a bit of a moot point as they have been complicit for nearly 5 decades of poor fiscal management.

You and I the voter

Is it possible that the reason the US government is shut down is the fault of you or me?  I would say that unfortunately the American voters have also been complicit in these problems.  This is not immediately connectable with shutdown but in the permissive attitude that they have supported, nay, encouraged in their representatives.

All of these are important

Strong defense
Protect the weak
Clean water
Safe food
Clean air
Global warming
Anti-discrimination
Strong borders
Nation of laws
Equal protection under the law
1st amendment rights
Right to bear arms

You may not agree with all of these but if we the voter do not look at the bigger picture when we elect a congressman then we are with 100% certainty responsible for this shutdown and the next.

A workaround

It is still possible for both houses of Congress to pass a common bill with 2/3 vote of both houses.  This would override any possible presidential veto and would get the government running again.  Once that is done then having real fact-based discussions on the wall or other ideas for a better and stronger America would be good.

There is enough fault to pass around.  Rather than trying to assign blame lets work in a non-partisan fashion and get things done.

 

[1] https://www.thoughtco.com/average-number-of-legislative-days-3368250
[2] https://bigthink.com/news/heres-how-much-senators-and-congress-members-are-worth-compared-with-us-common-people-surprised
[3] https://www.termlimits.com/congress-fundraising-priority/
[4] https://www.thoughtco.com/history-of-us-federal-budget-deficit-3321439

Posted in Soapbox | Comments Off on Whose fault is it anyway

Tips for Overwatch

Overwatch is a first person shooter made by Blizzerd Entertainment. you have 29 charecters that you can play as.

 

Name Tip
McCree Use his Flashbang if somebody else wants to use their Ultimate.
Tracer Only use her Ultimate if it can stick to somebody. Otherwise it will kill you.
Bastion Best playd when you have to escort a payload.
Ashe Use BOB when the other Team wants to take the Point.
Reinhard Make sure that no shield of either the enemies Reinhard , Zarya or Orisa
Ana Use if somebody wants to do their Ultimate use her sleep dart and wait 30 seconds. Then their Ultimate will be done.
Orisa If Roadhog tries to hook you use your invincibility.
 Mercy If you want to revive somebody always wait until your Orisa places a berrier infront of you.
Torbjörn You can shoot your Ultimate very far.
Hanzo  Shoot your Ultimates into large crowds.

 

Posted in Gaming | 4 Comments