Give Android a speed boost

Every time I installed Windows XP (which I must have done a thousand times, literally) one of the first things I’d do is to install Tweak UI and adjust the mouse hover speed to 0 and turn off menu animations.  If the computer was particularly slow I’d turn off cursor shadows and menu fading and combo box animations as well.

tweak-UI

Android has a similar setting for changing the window and transition animation scale and the animator scale.  By default these are set to 1x.  I turn them to off but some people like to set them at .5x which speeds them up without loosing the fancy animation.

By default these settings are hidden in a developer options section.  To get access to this area you go to the about device section in the settings and tap on the build number area 7 times.  Sounds a little goofy but kinda fun at the same time.  Once you do that you’ll have a new settings area called developer options.  I haven’t messed with anything else in this area apart from the window and transition animation scale and the animator scale.

Screenshot_2015-04-17-10-44-37

I have only tested this on the Samsung Galaxy S6 and can definitely tell a difference in moving around the system.  Not that the Galaxy S6 is a slow phone by any means but I’d rather have the menus and windows just pop instead of looking pretty.

Original article is from Boy Genius Report

VB.net If then Else with a list of strings

Jpeg

In SQL server you can do an easy exclude or include list by using an in statement.
So you can do:

Select * from someTable where somecolumn in (‘somestring1’, ‘somestring2’, ‘somestring3’, ‘somestring4’)

So you only get records where the contents of somecolumn are in the specified list of strings.
I wanted to do something similiar in VB.net.
You can use an if then or statement but it can get messy.

If someStringToCheck = “somestring1” or someStringToCheck = “somestring2” or someStringToCheck = “somestring3” or someStringToCheck = “somestring4” then
…Do something blah blah…
end if

This works but what if you have a list of 20 strings you want to check for?
Through some internet searching I found this post on stackoverflow.com and came up with the following:

Dim someList = New List(Of String) From {“somestring1”, “somestring2”, “somestring3”, “somestring4”}
If someList.Contains(someStringToCheck) Then
…Do something blah blah…
else
…Do something else blah blah…
end if

It seems kind of backwards but it takes your list of strings and determines if the string you fed it is in that list.  If so do something or if not then do something else.

  • Camera: Venue 8 7840
  • Taken: 7 April, 2015
  • Aperture: ƒ/2.4
  • Focal length: 2.94mm
  • ISO: 37
  • Shutter speed: 1/85s
  • Title: Jpeg

Spring

  • Camera: XT1095
  • Taken: 8 December, 2002
  • Aperture: ƒ/2.25
  • Focal length: 4.235mm
  • ISO: 50
  • Shutter speed: 1/1010s

How to sort DirectoryInfo.Getfiles array

I have an Intranet page that looks at a folder of files and lists them out.  It uses io.directoryinfo.getfiles to get the list of files but there wasn’t anyway to control the sorting.  By default it was sorting ascending but i wanted it reversed.  Here’s what I had at first:

Dim di As New IO.DirectoryInfo(Server.MapPath(“FolderofFiles”))
Dim aryFi As IO.FileInfo() = di.GetFiles(“*.pdf”)
Dim fi As IO.FileInfo
For Each fi In aryFi
..blah blah loop
Next

I tried to add Array.Sort(aryFi) but that resulted in an error:
“At least one object must implement IComparable.”

So after some internet searching I came up with the following based on a post on stackoverflow.com

First you have to create an IComparer class:

Private Class FileNameComparer
Implements System.Collections.IComparer
Public Function Compare(ByVal info1 As Object, ByVal info2 As Object) As Integer Implements System.Collections.IComparer.Compare
Dim FileInfo1 As System.IO.FileInfo = DirectCast(info1, System.IO.FileInfo)
Dim FileInfo2 As System.IO.FileInfo = DirectCast(info2, System.IO.FileInfo)
Dim Filename1 As String = FileInfo1.FullName
Dim Filename2 As String = FileInfo2.FullName
If Filename1 > Filename2 Then Return -1
If Filename1 < Filename2 Then Return 1
Return 0
End Function
End Class

Then use the comparer to sort:

Dim di As New IO.DirectoryInfo(Server.MapPath(“Folderoffiles”))
Dim aryFi As IO.FileInfo() = di.GetFiles(“*.pdf”)
Dim comparer As IComparer = New FileNameComparer()
Array.Sort(aryFi, comparer)
Dim fi As IO.FileInfo
For Each fi In aryFi
..blah blah loop
Next

The comparer I tweaked sorts the files by their filename in a descending order.  You can reverse the Return -1 and Return 1 to get them into ascending order.
Also, if you would like to sort the files by creation date you could use this comparer:

Private Class DateComparer
Implements System.Collections.IComparer
Public Function Compare(ByVal info1 As Object, ByVal info2 As Object) As Integer Implements System.Collections.IComparer.Compare
Dim FileInfo1 As System.IO.FileInfo = DirectCast(info1, System.IO.FileInfo)
Dim FileInfo2 As System.IO.FileInfo = DirectCast(info2, System.IO.FileInfo)
Dim Date1 As DateTime = FileInfo1.CreationTime
Dim Date2 As DateTime = FileInfo2.CreationTime
If Date1 > Date2 Then Return 1
If Date1 < Date2 Then Return -1
Return 0
End Function
End Class

Then you’d change:

Dim comparer As IComparer = New FileNameComparer()
to
Dim comparer As IComparer = New DateComparer()

Categories

Archives