Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Tuesday, May 7, 2024

Review: GitHub "squash and merge" versus "merge pull request" for pull requests

I have been using "squash and merge" for a few months and just recently switched to "merge pull request" in GitHub. My opinion is that "merge pull request" is much better option than "squash and merge" for our case.

Brief Background

Here is a brief background to my case. The software development process (10+ developers) for this "project" is extremely chaotic and monolithic so a lot of changes are deployed "chaotically" which basically means they deploy whenever developers and/or testers think it is ready. So I may get changes A, B, C, D, E, F but may be deployed C, A, E, F, possibly never B, and D could be "maybe" on hold for a year or tomorrow.

For some reason, I am responsible for the implementation of git (with no prior experience). I am a deployment manager (technically release coordinator... whatever that means). Please forgive if I butchered the purpose of git. Also our tech team is extremely reluctant to change which means I am not going to change process over a minor issue even if it is the industry norm.

Environment

We have 3 environments: DEV, STG, and PRD. 

Each has only a single instance. Master branch is what is in production. 

Stage branch is what is in stage. Stage branch also almost like a fork of master but still technically a branch. By this I mean it is a branch that I never merge with feature branches or master branch. All changes are cherry-picked from the feature branch. 

The feature branch is a clone of master. All pull requests are for the feature branch onto master branch.

Please accept that this is the scenario. As to why we do it this way will be too long to explain for this post.

Squash and Merge

Pro

This was pretty cool to see on the git history. A nice single line and easy to see issues with merges. As I will learn later, this is a very minor pro.

Con

Although I knew that a squash and merge created a new commit id, I didn't fully realize what implications this meant.

For a long period of time, I have been merging the changes to master so I have been doing all the conflict resolutions in git. While trying to get the developers to get into the practice of merging master into their feature branch (particularly really old changes), I found that there were a lot of differences from my personal expectations.

I had thought that git will compare the differences to the final result, but it actually compares the commit history. Because it is a new commit id, this throws a lot of flags at git.



Merge Pull Request

Pro

Merges are much simpler if developers update their feature branches with changes from master branch.

Con

"Messier" history. It's not pretty looking. But from my experience, there has been no real value to seeing a pretty history because there is nothing to get from it. With a merge history, git will know which commits to merge. Also if there is an issue, there is more information in the history. A clean history won't be very helpful.


Conclusion

"Squash and merge" is positive only cosmetically. When things are good, I don't need to look at the history. When things are not good, there is usually not enough information. "Merge pull request" is helpful in both the merge and in troubleshooting. For those who skipped the above, this is based on our process.

If we following a process that was closer to FIFO, then the Merge Pull Request would be slightly less beneficial which I then can potentially see a case for Squash and Merge. I would still prefer Merge Pull Request.

If there was maybe a case for using Squash and Merge, that scenario would be if pull requests were on the development branch (eg feature branch). I have lots of commits of minor fixes and I want to bundle them all together so there is less commits to review when troubleshooting.

Saturday, August 5, 2023

C# SMO: Unable to get objects by name but able to get by index

Replicating Issue

StoredProcedure sp = db.StoredProcedures["spName"]; // Returns null

Does not return the same as 
StoredProcedure sp = db.StoredProcedures[0]; // Returns object


If I traverse the array (technically a collection), I will find spName. Even if I do:
StoredProcedure sp = db.StoredProcedures[0]; // Returns object
StoredProcedure spByName = db.StoredProcedures[sp.Name]; // returns null


Possible Solution

First I tried. https://www.tek-tips.com/viewthread.cfm?qid=1736324
StoredProcedure storedProcedure =
db.StoredProcedures.Cast<StoredProcedure>().SingleOrDefault(sp => sp.Schema == "YourSchemaName" && sp.Name == "YourSprocName"); 

This worked and this caused me to see that the schema is explicitly entered. After some more research, I could not find how you would provide the schema to the stored procedure name.

Later I tried to look under Database which has a property, DefaultSchema. After setting this, this also returned the correct result.

So the simplest solution:

db.DefaultSchema = "schemaName";
StoredProcedure sp = db.StoredProcedures["spName"]; 

Root Cause Analysis

For my specific case, our DBA changed the default schema of the user. 

Wednesday, June 28, 2023

DEV: Finding Google Client Id and Secret

  1. console.cloud.google.com
  2. APIs & Services
  3. Credentials
  4. Under OAuth 2.0 Client IDs
  5. Click client
  6. Find Client ID and Client secret

 

To add Google authentication for Microsoft Blazor Server: https://learn.microsoft.com/en-us/answers/questions/830958/how-to-implement-google-authetication-in-blazor-se


Install nuget: Microsoft.AspNetCore.Authentication.Google

Friday, April 14, 2023

Buggish: MS VS does not display git branch names with slash properly (I was wrong-ish)

EDITED (2023-04-24): As I watched demos for other features, I noticed that people used the slash to organize their branches. So, it seems this was intentional. Below is the original post.

Original Post

Microsoft Visual Studio 2022 does not display git branch names with forward slash properly although it is allowed in git and GitHub. Does it do the same with backslash? I do not know and do not wish to test this.

Basically VS will display it with a folder name then a branch in the folder with a name with the rest of the branch name text. For example if the branch name is abc/def, then there will be a folder called abc and a branch in their named def. In GitHub, you will see branch abc/def. Thus this is a bug in Visual Studio.

You cannot delete the folder, but if you delete the branch ('def' from the example above), this will delete both the folder and the branch. Which makes this a visual bug only. Functionally, looks like everything else will work properly.

OR... maybe this is a feature where you can group branches but only in Visual Studio?

Monday, August 8, 2022

Life: Encouraging People to Learn to Code/Program/Develop

There is a lot of context to baseline here. By people, I mean the general population. By coding, I mean software programming like assembly, C#, or C++ on a very basic level. And the issue I am try to address is why many people find programming too difficult to want to learn.

Although easy and hard are relative, I am going to generalize that when most people say that it is hard, they mean that they do not want to bother learning or even understand it. Yet, they can follow the most complex story lines, office politics, and so many non-standard social norms on a regular basis.

We are in an era where technology is being embedded everywhere. Knowing how to code will likely be needed everywhere whether you are a waiter, box mover, design, doctor, lawyer, president, etc.

To me, the odd part is that coding uses a very tiny subset of our language yet executes the result nearly 100% of the time. So it should not be difficult to at least understand. In some ways, it basically is a simulation of logic.

The troubling part when I hear people not wanting to understand coding is that I "hear" them say that they don't want to understand logic and leaving that for someone else to fix.

Wednesday, July 13, 2022

Buggish: In Jira cloud, unable to create sub-stories

This may be more of a problem with our team inability to break problems down into smaller parts but that is out of my control and little that I can do about it. Because the story spans more than one sprint, the group has divided the story not into smaller stories but into roles. So one sprint will have the Refinement part of the story. Another sprint with Development part. Another sprint for the Test part.

This makes it troublesome in tracking what the Jira ID is for the story. Is it the refinement story, or the dev story, or is it test? Preferably, I want to use the Dev story because it contains the code that is referenced everywhere else. But it is neither the beginning nor the end.

Can I use the epic? Not really, because the epic contains other stories.

Can I use tasks? Possibly but it is not the same as a sub-task. Task is not considered a child of the story. It can be associated with a story but it can also be associated with other stories.

Can I use sub-tasks? Possibly, but we already use sub-tasks to break down the tasks for dev, testing, deployment, etc. And in Jira none of these can have additional sub-types. Also sub-tasks cannot be assigned a sprint. Because of this case, a task would make more sense.

More complications come up due to the integration with GitHub. Because the integration is dependent on the Jira ID used in the branch name, commit comments, and pull request, consistent use of the Jira ID is important. 

The more I think on it, the more I think the issue is more on the broken SDLC process.

Sunday, April 3, 2022

Navbar not working with Bootstrap 5.1.3 and Jquery 3.6.1

Resolution

If using newer version of 5.1.3 from older Bootstrap, make sure the parameters are correct. There is a change from data-toggle to data-bs-toggle and data-target to data-bs-target. Jquery version should not matter. It does make a difference in the older version.

Root Cause Analysis (RCA)

I do not use javascript much so I jumped from page to page. It is quite frustrating troubleshooting javascript with VS Community 2022 in a Blazor Project. Each item was somewhat new so it was difficult to figure which one was causing the issue.

The source of my problem was that the first navbar used an older version of bootstrap. After finding the new code sample, I did not copy directly and attempted to modify the missing parts. This did not work, then I had to look up what version of bootstrap came with VS 2022. Eventually, my problem was picked from each step.

Reference

https://getbootstrap.com/docs/5.1/components/navbar/

Tuesday, August 10, 2021

Buggish: The full path must be less than 260 characters long; other restrictions apply. If the report server is in native mode, the path must start with slash.

One of those moments where I just want to pull my hair out. I had this working last night, and suddenly stopped working. I just spent the last several hours troubleshooting the error: tried different configurations, parameters, figure out how to use Fiddler, several google searches, etc.

The problem/answer was basically that I was using the wrong slashes. The path should be using forward slashes '/' not back slashes '\' and without rdl.

\Folder1\ReportName

Psychology

To give myself the tiniest of credit, I initially solved this while rushing to pick up my daughter. It's a lame excuse but I think it important to why I didn't remember what I did. It worked and I left figuring I could return to see my work.

I think I left my project running and stopped the debugging, so I didn't see what values I ended putting in. This probably wouldn't have helped because I probably wouldn't have looked at the direction of the slash. I figured I had it in the code because I got tired of entering the data so I hard-coded the initial value.

I assumed that was correct and maybe I just put in the wrong path. I tried several paths like http://SsrsServer/ReportServer, http://SsrsServer/Reports/, http://Ssrs/Reports/browse, /folder1/reportName, /folder1/reportName.rdl, and also sorts of permutations of paths and file names.

I do not know why I didn't even check the slashes as that should have been one of the first things to check. To make it worse, I do not know why I even thought of it so suddenly. After this entire ordeal, I recall how I figured it out in the first place was because I used the http path then removed the beginning part. Because it used forward slashes, this fixed my problem.

Sometimes I really find how amazing my brain is at forgetting things.

Sunday, June 6, 2021

Info: Command to get OS version from remote server

WMIC /user:domain\userId /password:userPassword /node:remoteServerName os get buildnumber,caption,CSDVersion /format:csv

Thursday, May 20, 2021

Buggish: C# Replacing \n with
versus \r\n versus \n\n

Problem to be solved

I need to replace MS SQL break lines with HTML break lines so that it can be displayed on a web page.

Background

Our network group decided to make routers reject posts that are too big. I have a tool to compare database objects across multiple environments to validate and to promote. I used a text box to display the sql queries. If there were five environments, then there would be five textboxes. If the stored procedure was really large, then I would have it five times. So when I post back to the server, I could potentially return a lot of data.

I don't want to truncate because most new changes are at the bottom. I don't want to skim because are at the top. And fixes are typically in the middle.

So decided to use html <pre> tag. This requires me to convert new lines to html new lines. I'm usually lazy and just convert \n to <br/> but then I realized that this returned two break lines which caused a blank line in between every line. This was a pain because that means it took me twice as long to skim through the code.

For some odd reason, I felt like doing both a \n\n and \r\n replace and found this did the same... even though the string value was just \r\n. This is really odd. Although works for me, this is not what I expected.


Final decision

string.Replace("\r\n", "<br/>");

Tuesday, August 25, 2020

Code: Display Net Use default results with C#

 Win32_NetworkConnection


Summary

This was the WMI OS CIM class needed to get the results from a simple Windows command prompt "net use" command. 



Thoughts

This was somehow amazingly hard to find on google. For whatever reason, the only command I can find were for Win32_OperatingSystem or Win32_Share.

There is plenty of information on all the elements but just could not find a connection between net use and Win32_NetworkConnection. 


My Sample Code

                string serverName = @"\\serverName";
                string WMIClassName = "Win32_NetworkConnection";

                List<string> shares = new List<string>();

                ConnectionOptions connectionOptions = new ConnectionOptions();

                ManagementScope scope = new ManagementScope(serverName,
                                                            connectionOptions);
                scope.Connect();

                ManagementObjectSearcher worker = new ManagementObjectSearcher(scope,
                                   new ObjectQuery($"select Name from {WMIClassName}"));

                foreach (ManagementObject share in worker.Get())
                {
                    shares.Add(share["Name"].ToString());
                }


References

Sunday, July 26, 2020

Buggish: Amazon WorkSpaces Locked Shift Key (Unresolved / workaround) Update: Resolved? [2020-07]

Replicate: Unknown
Frequency: Multiple times a day, but can get half a day without it occurring
Environments: Two different machines running different versions of AWS Client. Issue seems to be similar even though different OS and different clients.

Workaround: Turn on caps lock, then turn off caps lock. Repeat if necessary. Toggling may not work if toggle too quickly. At most 3 times, but works every time.

Behavior: Basically, the shift key locks on AWS because all actions appear to be as if the shift key is down. Like highlight text between two different mouse-clicks in a text box, select multiple rows in spreadsheet, etc.

Shift is not locked on my machine. This only occurs in AWS. Pressing the shift key does not appear to do anything which kind of makes sense because it should act as if shift key is down. But release shift key does not return the state back. I found toggling caps lock will return the shift key state.

I do not use caps lock at all, so this is not caused by using caps lock. I figured this out randomly.

I cannot guarantee that this does not happen when not using the shift key as I use the shift key very often. I do also use both shift keys (not at the same time). It does seem to occur more often when I am coding C# which uses a lot of shift keys for curly braces and for sql because I cap the keywords. I want to say that it seemed like this issue still occurred once or twice when there was no shift key used, but this seems to be a very rare occurrence.

It may be possible that there is a delayed or lag response to a shift key press which would explain why it occurs more often when I am coding. Oddly, I can also go a few hours without this occurring. This could just be my mind playing tricks, but also seem to occur less often when I work off peak-hours.

There also seems to be quite a few posts dating back to 2016 with no solution so I am not expecting this to be ever resolved, so beware if you decide to use AWS.

Update 2020-09-03

Interesting, not long after this post... this problem has gone away. I cannot recall when this stopped but feels like at least a couple weeks. Has this problem been resolved? Seems like it.

Update 2022

As of 2021, we have moved from AWS to Azure so there will be no more updates on AWS.

Thursday, March 5, 2020

Coding: Difficulties of Learning New Programming Languages (Python/Django for example)

I always assumed that it would always be easy for me to pick up a new language since I have already had experience with Java, VB, C#, and several scripting languages. This was kind of the case in the past, but not so much in the modern era.

Knowing a programming language definitely helped me learn Python. What makes learning today is not the language itself anymore but all the frameworks, configurations, all the options, and all the new standards.

At first I spend so much time in just figuring out all the environments that Python can be used in. Maybe this step could be skipped if you already stuck on a certain platform like Windows, Linux, or MacOS.

Then I spend a lot of time just how to build out the infrastructure, like Apache, Django, PostGRESql, MariaDb, etc. Yet, I still kind of regret not going simply with mySQL. I imagine this would be longer for first time programmers as I already had some experience with IIS and MS SQL.

Finally the most time-consuming part of a new language is learning its new framework, process flow, terminology, plug-ins, and standards. For example in Django, I spent the last few days figuring how the engine picks the templates that you designate in the views.py after I built a second application. By default, Django looks through each templates folder start with the order the apps were listed in the settings.py.

At this point, I started to understand the importance of community support. I just could not find the proper wording to find the solution to my problem. My problem was that I attempted to make my template folders have the same structure. Because I did not learn the folder standards yet, I had some files in the template root folder like the index.html. So when I try to access my app2/template/index.html, my page showed my home page (app0/template/index.html). This did not make sense to me because I assumed that the views.py in app2 will use the index.html in app2. I kind of guessed this was the case so I tried to find a way to force the rendering to pick app2's index.html which led me down a lot of rabbit holes.

Each time I meet a new challenge, I find not only do I spend time to research the problem but in some cases, I have to also redesign my application to fit the community's standards. One example is learning about PyLint in its standard on documentation. I had to go through each file to provide documentation which is a triple quote description after the component declaration. I have been using the same method as MS Visual Studio which uses comments prior to the component declaration. It also checks naming schemes, tab spaces, proper empty lines, lines with spaces, etc. Although great for consistency, this took up a lot of time to learn and implement. I do not feel any of my past experience made this process any simpler or faster to learn.

In summary, I am starting to understand the demand for specific language requirements in current job descriptions. I think I would definitely learn much faster with an experienced language programmer to guide me through the differences. I feel that I will still learning faster than a new programmer but will still take time to learn the framework and learn how to troubleshoot compared to an experienced programmer of that language. I feel that it would take me about a month to be somewhat familiar with the new language, tools, and standards; probably a couple weeks if I had a resource dedicated to point me in the right directions. I probably spend 80% reading solutions to different problems similar but not exactly.

Saturday, October 12, 2019

Expanding to Linux, Apache, Postgres, Python, and Django in Google Cloud

I finally got around to learning Linux and Python for the second time. I tried many years ago at a friend's place but never went back after I messed up a build. This time it was way faster with Google Cloud.

I spent about half a day figuring out the free trial versus always free. In reality, I was trying to figure out and extrapolate the always free part. Because as a hobbyist, this was very intriguing part. So basically, I can spin up a small VM and Cloud Sql for free, of course up to a certain limit which I think is well below the traffic and usage that I will be working in.

I think this is great because I am mostly on to practice and learn. If I were to expand my projects, scaling up my projects looks to be kind of simple for both infrastructure and cost. Although I did not delve deep into how to do that exactly. But the costs seem rather reasonable on a personal level.

I spent the rest of the day learning the different parts of google cloud. I quickly went through some of the options then saw all the different types of OS and DB google cloud has to offer. Of course, I spent most of the time figuring out which Linux distro to choose (Debian) and database (Postgre).

I chose Debian because it was free and seemed to have good amount of documentation online. I chose Postgre because it is new to me (I have worked with Oracle, MySql, and MS Sql in the past) and appears to be gaining some popularity (and also been seeing quite a few on job posts).

The next day, I spent all day trying to install Python, Apache, and Django. I spent part of the day looking into which web server to use which I almost scrapped because Python had its own server. I could not get the Python web server to work properly because I did not know how to open a web browser to be local within my google cloud "space" (I am still unsure if that is even possible). I was not able to open the ports to access it from an external source.

I also spent a lot of time trying to learn all the Linux commands to install. I spent a good amount of time trying to find what I can do without super user (sudo) which I found to be almost nothing. I was eventually able to install Apache with Python by following directions and open it from my system's browser (outside of google cloud).

I then looked into Python IDE which then I stumbled across Django which I later learn is a framework for python web development. So then I attempted to install Django, but ran into a lot of issues. Because I already had Python and Apache installed, I was trying not to repeat certain steps or skip certain steps. Because I was not exactly clear on what needed to be done and things were not working, I deleted my Django project and tried to start over.

I had to start over a few times until I found a different site (https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-debian-8) that eventually got me up and running. On the bright side, I am now a bit more familiar with a few basic Linux commands: sudo, nano, mkdir, rm, mv, cp, service, etc. At least I think they are Linux commands as opposed to Python or Apache commands.

I have not started any programming yet, but excited to eventually get to that point. I still need to learn a bit about the Django framework before I can really start. So hopefully, I will get some time to work on that soon. Also, I still need to find an IDE or text editor.


Reference

https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-debian-8

Wednesday, October 9, 2019

I stopped using Microsoft Visual Studio and Azure (2019)

I am mostly a hobbyist developer. I had moved to more process management in software engineering. So the cost of paying for the professional version ($1200 / $800) of Visual Studio is quite steep even though I still paid for several years. I am aware there is an Express version which I had used initially but the professional provided a lot of neat features also provided Azure credit so I figured it compensated some of the cost.

I was content with paying but then my real work got busy for several months, also many things came up in my personal life, so I had neglected programming for a bit. When I returned, I realized Visual Studio no longer let me log in. I eventually found that my subscription had expired. I then noticed that I had received a bunch of emails that said I was overdue. This was due to a fraudulent charge on my credit card which was canceled, and that card was the one on record to renew.

This was extremely confusing, because I thought they had moved to subscription basis which I had been paying. When I paid all the overdue costs, I was still unable to use VS 2019. But somehow VS was separate and that had expired several months past, so it will cost me another $1200 to repurchase to use. I am still a bit confused exactly what is what, like what was Visual Studio and what was monthly subscription.

My current understanding is that I was paying monthly for Azure which does not include VS. I had paid for VS the prior year. Sadly, I didn't notice that I had been paying some much to MS for so long. So I still have Azure to host my site temporarily, but absolutely no access to VS. But if I paid for VS, then I should basically own my copy of VS. After talking to support, this was confirmed to be the case. I was unable to find a key in my MSDN subscription. I just grew tired and frustrated, then just refused to use VS again... not even the Express version.

On top of that, since I had purchased VS 2019, I should have had $50 monthly credit to Azure so why was I paying the Azure monthly costs (which was under $50 / month)?! Ugh.... this is so painful.

In Summary

I had once forgot to renew in the past and paid the full cost, so this is the second time. I was barely ok with the cost. Then they moved me to subscription basis which I had complained about because I just wanted to pay a flat amount. Then I found out that I still had to pay the VS subscription and I guess I was paying the Azure subscription. I had been using VS for over 10 years, maybe around 15 years.... and absolutely no sympathy for my situation. I have been a promoter of MS VS, .NET, and MS SQL, but no longer. I don't hate them, but definitely no love anymore. 

And so, I have moved to Google Cloud, Linux, Python, Apache, Django, and Postgres. After one week, the pricing scheme is very reasonable for hobbyists and people who wants to experiment before going full production. First impressions for this new tech stack will come in the future.

Will I go back? Maybe if there were some changes, but unlikely. I'll continue to use MS Windows, although a good chance I may move

Saturday, June 10, 2017

Javascript: Useful script to enable scrollbars

document.documentElement.style.overflow = "auto";


Edit:
Sorry, I posted this primarily for myself. Because for the life of me, I cannot remember this command line.

Tuesday, May 16, 2017

GridView with multiple columns with the same name

Microsoft ASP.NET 4.5
Visual Studio 2013

Scenario: Joining to tables that have the same column names but different uses without using alias (because sometimes you don't have access to the data or query).

Solution: The first column will be the original column name. Each additional column will have an integer counter starting at 1 appended to the end of the column name.

Exampe: If the column name is XXXXXX, then the first column will be XXXXXX, the second column will be XXXXXX1, then XXXXXX2, etc, etc.

Monday, March 27, 2017

SharePoint 2013 DateTime and DateTime format sample

SharePoint 2013 DateTime and DateTime format sample:

2017-03-23


This was surprisingly hard to find for me.

Saturday, March 4, 2017

Javascript - Find elements by the "for" attribute

            function findLableForControl(el) {
                var idVal = el;
                labels = document.getElementsByTagName('label');
                for( var i = 0; i < labels.length; i++ ) {
                    if (labels[i].htmlFor == idVal)
                        return labels[i];
                }
            }

This function is handy when working with C# CheckBoxList (or really any of the C# lists). When creating javascript to manipulate the list, C# does not provide ID to the label, rows, nor columns. Thus to find the label, only the "for" attribute can be used to search.

Reference

http://stackoverflow.com/questions/285522/find-html-label-associated-with-a-given-input/285575

C# DataBinding does not contain a property with the name with custom class object and CheckBoxList

I get the error "DataBinding: class1 does not contain a property with the name prop1"

public class1 {
  public string prop1;
  public string prop2;
}


My setup was an object array of class1 which has a property prop1 and prop2:

class1[] arrClass = new class1[arraySize];

Then I set the DataTextField and DataValue:
checkboxlist1.DataSource = arrClass;
checkboxlist1.DataTextField = "prop1";
checkboxlist1.DataValueField = "prop2";
checkboxlist1.DataBind();

This throws the error above. The fix is the lack of accessors in the class, class1. The class should be corrected to the following:
public class1 {
  public string prop1 { get; set; }
  public string prop2 { get; set; }
}
 Technically, set is not needed.


Reference

https://msdn.microsoft.com/en-us/library/aa287786%28v=vs.71%29.aspx