Sunday, January 24, 2016

Cleanup Merged Github Branches

For big projects with multiple contributors where nobody is really cracking the whip on Github maintenance, there is a tendency for the branch count to just keep climbing.  I have seen cases where it tops 100 branches, and it becomes quite painful to clean up.  In cases like that, I have developed the following method for handling it:

First, you need local copies of all the remote branches.  This is not as easy as just doing a fetch origin, as that just pulls over an underlying awareness of the fact that the branches exist.  You do not actually create local copies of all those branches.

So we run the following command:

for remote in `git branch -r`; do git branch --track ${remote#origin/} $remote; done

This creates local copies of all the branches including one called HEAD, which is not a real branch and is dangerous.  So let’s get rid of that by renaming it  to something else and then deleting it.

git branch -m HEAD bogusBranch
git branch –D bogusBranch

We now want to delete all the branches that are already merged.  We can get a list of them by running:

git branch --merged master | grep -v master

If we like the list, we now delete them from the origin:

git branch --merged master | grep -v master |  xargs -n 1 git push --delete origin

And we now delete the same list locally:

git branch --merged master | grep -v master |  xargs -n 1 git branch -D 

And we have now cleaned up our repository by removing everything that has already been merged to master. 

If something is not on the merged list, and we want to know what changes are not merged, we get a list of un-merged commits from that branch:

git cherry -v master <unmergedBranchName>

Now we checkout that local branch:

git checkout unmergedBranchName

And we do a whatchanged to see what the difference is:

git whatchanged -m -n 1 -p <SHA of target commit>


Samsung LNT5271F Horizontal Line Issue

This is a blog about a failed attempt to fix a Samsung LNT5271F 52-inch LCD TV.  It developed problems with horizontal lines on the screen.  If the TV warms up sufficiently (about half an hour), it goes away.  The lines look like this:

I swapped the electrolytic caps on the power board because people in various forums were saying that was a potential solution.  I was not feeling good about that.  It seems tantamount to sacrificing a chicken over it, but it is cheap, so I gave it a shot first.  It did nothing.

I then swapped the T-Con board which set me back about $100.  I ordered it from:

There are many places that have the board cheaper—some of them much cheaper, but they were all out of stock.

I have since heard that horizontal lines are almost never caused by the T-Con board.  But I did not become aware of that until I had already ordered the part.  It is a bit of a delicate operation to swap it because of the LCD panel connectors, and because it is not at all obvious how those connectors work.  But at the end of the day, I was able to do it without issue.  Unfortunately, it had no effect on the problem.  The horizontal lines remain, and they still go away after half an hour.

The TCON board LCD connectors look like:

They open by folding them downwards.  In the picture, the right one is open.  Notice also the black horizontal line on the connector, which just lines up with where the top of that connector is going to be once we close it.  You should not be able to see any of that black line if the connector is securely fastened against a properly positioned wire.

I think the issue is likely the LCD controller, and it’s just come to the point that it is a better bet to just buy a new television.  I’ll suffer with the thirty minutes of horizontal lines for now until OLED come up to the point where the OLED TVs are better priced.  In the meantime, I have another 32” LCD TV next to the bigger one I use for gaming.  I have a dual 4-port HDMI switch attached to both TV’s, so it is a small matter to route the cable box to the smaller TV if it is really critical.

So the point of this blog is if you have a problem similar to what I am showing in the above photo, you are probably better off just giving up on the TV rather than wasting $150 and a good bit of time tearing down and reassembling this TV a couple times over.



Saturday, November 15, 2014

PHP Alphanumeric Encoder/Decoder

The following two functions are an alphanumeric encoder and decoder respectively.  The intent of the first function is to take a base 10 number and encode it using some character set.  It is hardcoded to use a charset of “1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ”.  Because there are 36 characters in this character set, the encoder effectively becomes a base 10 to base 36 encoder by default.  But you can either alter the default encoding string or pass in the alphabet you want to use as a second argument and encode the base 10 number to any base you desire.  The second function reverses the process.

I have tested both functions quite extensively, and they both appear to work flawlessly.

  /**
    * Encode a base 10 number into some alternate base
    *
    * @param int $num
    * @param string $alphabet
    * @return string $alphaNum
    */
   public static function alphaEncode($num, $alphabet=null) {
      $result = '';
      if (!$alphabet) {
         $alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
      }
      $alphabet = str_split($alphabet);
      if ($num == 0) {
         return $alphabet[0];
      }
      $base = count($alphabet);
      while ($num > 0) {
         $remainder = $num % $base;
         $num = floor($num / $base);
         $alphaNum = $alphabet[$remainder] . $alphaNum;
      }
      return $alphaNum;
   }
   
   /**
    * Decode an encoded number back into base 10
    *
    * @param string $alphaNum
    * @param string $alphabet
    * @return int $num
    */
   public static function alphadDecode($alphaNum, $alphabet=null) {
      $result = '';
      if (!$alphabet) {
         $alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
      }
      $alphabet = str_split($alphabet);
      $base = count($alphabet);
      $num = 0;
      $idx = 0;
      $charCount = strlen($alphaNum);
      $charArray = str_split($alphaNum);
      foreach ($charArray as $char) {
         $power = ($charCount - ($idx + 1));
         $charIndex = array_search($char, $alphabet);
         $num += $charIndex * pow($base, $power);
         $idx++;
      }
      return $num;

   }

Wednesday, August 20, 2014

Disable Toyota Prius Backup Alarm Using Techstream

I recently bought my daughter a 2010 Toyota Prius.  I noticed the backup alarm when we were test driving it, and it doesn’t grow on you over time.  So I decided to try and disable it. 

I had a Toyota Techstream compatible module (an overseas knockoff) leftover from a problem with my wife’s Lexus.  The same module works on all Toyotas.  So I was able to use it on the Prius as well. 

You can find one by Googling “toyota mini vci amazon”.  You will get a bunch of hits.  One of them is here: http://www.amazon.com/Newest-V8-00-034-Techstream-Diagnostic-Software/dp/B00C9B32J4.

Make sure it comes with the software, or you can locate a copy somewhere.  I got a copy of the software with mine, and I downloaded a newer one as well.  I assume the “V8.00.034” in the above product refers to the software version as the cable doesn't have versions like that, and so I assume the software is included.

Anyway, assuming you now have a usb driven mini-VCI on hand because you ordered it from somewhere, plug it in to the port under the driver’s side dashboard and fire up the Techstream software on your PC.

If you need help setting up the software and connecting it, there are a lot of other sources such as this one: http://www.obdinnovations.com/mini-vci-for-toyota-software-installation-guide/

There’s some screenshots below, but to make a long story short, the sequence of commands you need to run is:

Combination Meter/Select Utility & then Select Customize/Select Warning/Select Reverse Buzzer/Change it from “Continual” to “Single” and then press the right arrow at the bottom.  Continuous beeping should now be off.

First, go to system select: Combination Meter as shown below.


Click the green arrow at the bottom right.  Now select Utility from the left hand menu of the resulting page and hit the bottom right green arrow again (sorry no screenshot of that).  Now select the Customize option and hit the lower right green arrow again.




Select the backup buzzer option on this page and change it from continual to single.




Now press the Green Arrow bottom right, and you are done.  Test your backup buzzer.  It should now be a single beep.   There are some other settings available on this menu such as the seatbelt buzzers, but I'd prefer my daughter use the seat belts, so I did not mess with them.