26 March 2014

Freaky Amazing Details

I picked up this Photoshop sharpening technique from these sources:

https://www.youtube.com/watch?v=ZV9u0Wu8L0M
http://fstoppers.com/sharpening-with-blur-bring-back-insane-detail-with-this-quick-technique

And because no one on the web seems capable of putting together a simple step-by-step tutorial:

  1. Make 2 copies of the original image (3 layers total)
  2. Group the top two layers
  3. Change the group's blending mode to Overlay
  4. With regards to the group's top layer:
    1. Blending mode to Vivid Light
    2. Invert the layer
    3. Apply a Surface Blur filter (better yet, change it to a smart object with the filter)
Seems like a radius=8 and threshold=10 is a good place to start for the layer.

24 March 2014

Capturing mouse coordinates on touchmove events

I'm testing a relatively recent version of Android, iOS, and Chrome to capture mouse coordinates during a move event. I was having trouble with Android, surprisingly, and found this to solve it:

on Chrome and iOS off the jquery event object passed to the touchmove event listener, simply event.pageX and event.pageY returned coordinates as expected. However, Android always returned zero.

You can find a bunch of posts about needing to preventDefault to get the touchmove event to trigger in the first place....

But to get the coordinates, this object seems to work:

window.event.touches[0]

 So I'm using something along these lines ...

if (window.event.touches) event = window.event.touches[0];

Then I use event.pageX and event.pageY as expected...

20 March 2014

Data Cache on Excel Pivot Tables

I'm just starting to get more familiar with Excel's pivot tables and their functions. I've noticed that changing the grouping on one table affects the grouping on another table, even though they are completely separate pivot tables.

Turns out this is Excel's "data caching" in order to save memory and disk space. Great, I'm very happy Excel's saving disk space on my whopping 300 records of data, but this reminds me of Office's warnings of having a "large amount" of data left on the clipboard.

Um, hello, Office dev team, it's 2014. Let's raise that bar of what a "large amount" of data really is.

Tangent. Back to pivot table grouping.

See here: http://office.microsoft.com/en-us/excel-help/unshare-a-data-cache-between-pivottable-reports-HA010226675.aspx

20 February 2014

Slow LAN speeds between Windows 7 machine and Server 2003

I upgraded a few machines from Windows XP to Windows 7 recently, and all has been well for several weeks. Yesterday, two machines (relatively old Dell desktops) started exhibiting extremely slow connections to our Windows 2003 server. However, connections to other Windows 7 machines were a-okay. All machines are gigabit cabled.

Luckily, a coworker had found a solution to this months ago, so I wanted to make note of it here:

From the command line with admin privileges:

netsh int tcp set heauristics disabled
netsh int tcp set global autotuninglevel=disabled

... then reset the network adapter.

09 January 2014

VBA Name Parser

There are plenty of simple name parsers out there, but I needed one that would handle titles, suffixes, prepositions / particles (I'm no grammar expert), etc. This is what I hacked together for a VBA function in Excel:

(Things could be cleaned up more if VBA had better array functions built in, specifically pop and shift...)

Pass in "n" the name to be parsed and "piece," which is an integer 1 thru 5 for:
1: title
2: first name
3: middle name(s)
4: last name
5: suffix


Function Namify(n, piece) as String
    Dim Pieces() As String
    Pieces = Split(n)
    
    Dim Letters() As String
    
    Dim Length As Integer
    Length = UBound(Pieces) + 1
    
    Namify = ""
    If Length < 1 Then Exit Function
    
    If piece = 1 And IsTitle(Pieces(0)) Then
        Namify = Pieces(0)
    ElseIf piece = 5 And IsSuffix(Pieces(Length - 1)) Then
        Namify = Pieces(Length - 1)
    ElseIf Length = 1 Then
        If piece = 2 Then Namify = Pieces(0)
    ElseIf Length = 2 Then
    
        If IsTitle(Pieces(0)) Then
            If piece = 4 Then Namify = Pieces(1)
            Exit Function
        ElseIf IsParticle(Pieces(0)) Then
            If piece = 4 Then Namify = Pieces(0) & " " & Pieces(1)
            Exit Function
        End If
        
        'look for joined abbreviations
        Letters = Split(Pieces(0), ".")
        If UBound(Letters) > 1 Then
        
            If piece = 2 Or piece = 3 Then
                Namify = Letters(piece - 2) & "."
            ElseIf piece = 4 Then
                Namify = Pieces(1)
            End If
            
        'first name
        ElseIf piece = 2 Then
            Namify = Pieces(0)
        ElseIf piece = 4 And Not IsSuffix(Pieces(1)) Then
            Namify = Pieces(1)
        ElseIf piece = 5 And IsSuffix(Pieces(1)) Then
            Namify = Pieces(1)
        End If
        
    ElseIf Length = 3 Then
    
        If IsTitle(Pieces(0)) Then
            
            Namify = Namify(Pieces(1) & " " & Pieces(2), piece)
            
        ElseIf IsSuffix(Pieces(2)) Then
        
            If piece = 5 Then
                Namify = Pieces(2)
            Else
                Namify = Namify(Pieces(0) & " " & Pieces(1), piece)
            End If
            
        ElseIf IsParticle(Pieces(1)) Then
            
            If piece = 2 Then
                Namify = Pieces(0)
            ElseIf piece = 4 Then
                Namify = Pieces(1) & " " & Pieces(2)
            End If
            
        ElseIf piece < 5 And piece > 1 Then
        
            Namify = Pieces(piece - 2)
        
        End If
        
    ElseIf Length = 4 Then
    
        If IsTitle(Pieces(0)) Then
        
            Namify = Namify(Pieces(1) & " " & Pieces(2) & " " & Pieces(3), piece)
        
        ElseIf IsSuffix(Pieces(3)) Then
            
            If piece = 5 Then
                Namify = Pieces(3)
            Else
                Namify = Namify(Pieces(0) & " " & Pieces(1) & " " & Pieces(2), piece)
            End If
            
        Else
        
            If piece = 2 Then
                Namify = Pieces(0)
            ElseIf piece = 3 Then
                If IsParticle(Pieces(2)) Then
                    If Not IsParticle(Pieces(1)) Then
                        Namify = Pieces(1)
                    End If
                ElseIf Not IsParticle(Pieces(1)) Then
                    Namify = Pieces(1) & " " & Pieces(2)
                End If
            ElseIf piece = 4 Then
                If IsParticle(Pieces(1)) Then
                    Namify = Pieces(1) & " " & Pieces(2) & " " & Pieces(3)
                ElseIf IsParticle(Pieces(2)) Then
                    Namify = Pieces(2) & " " & Pieces(3)
                Else
                    Namify = Pieces(3)
                End If
            End If
        
        End If
        
    ElseIf Length = 5 Then
        
        If IsTitle(Pieces(0)) Then
            Namify = Namify(Pieces(1) & " " & Pieces(2) & " " & Pieces(3) & " " & Pieces(4), piece)
        ElseIf IsSuffix(Pieces(4)) Then
            Namify = Namify(Pieces(0) & " " & Pieces(1) & " " & Pieces(2) & " " & Pieces(3), piece)
        Else
            If piece = 2 Then
                Namify = Pieces(0)
            ElseIf piece = 3 Then
                Namify = Pieces(1) & " " & Pieces(2)
                If Not IsParticle(Pieces(3)) Then
                    Namify = Namify & " " & Pieces(3)
                End If
            ElseIf piece = 4 Then
                If IsParticle(Pieces(3)) Then
                    Namify = Pieces(3) & " " & Pieces(4)
                Else
                    Namify = Pieces(4)
                End If
            End If
        End If
    
    ElseIf Length = 6 Then
        
        If IsTitle(Pieces(0)) Then
            Namify = Namify(Pieces(1) & " " & Pieces(2) & " " & Pieces(3) & " " & Pieces(4) & " " & Pieces(5), piece)
        ElseIf IsSuffix(Pieces(5)) Then
            Namify = Namify(Pieces(0) & " " & Pieces(1) & " " & Pieces(2) & " " & Pieces(3) & " " & Pieces(4), piece)
        End If
    End If
    
    ' clean up hanging commas
    If Right(Namify, 1) = "," Then
        Namify = Mid(Namify, 1, Len(Namify) - 1)
    End If
    
End Function

Function IsTitle(t As String) As Boolean
    Dim Titles As Variant
    Titles = Array("Mr", "Mr.", "Ms", "Ms.", "Mrs", "Mrs.", "Dr", "Dr.", "Sir", "Miss")
    IsTitle = (UBound(Filter(Titles, t)) > -1)
End Function

Function IsSuffix(s As String) As Boolean
    Dim Suffixes As Variant
    Suffixes = Array("II", "III", "IV", "V", "Jr", "Jr.", "Sr", "Sr.", "PhD", "Ph.D", "MD", "M.D.", "PE", "P.E.", "Ctech", "P.Eng.")
    IsSuffix = (UBound(Filter(Suffixes, s)) > -1)
End Function

Function IsParticle(p As String) As Boolean
    Dim Particles As Variant
    Particles = Array("de", "De", "le", "Le", "la", "La", "du", "Du", "von", "Von", "van", "Van", "O")
    IsParticle = (UBound(Filter(Particles, p)) > -1)
End Function