PHP Array Sum

July 10, 2008

I was needing to sum all the values in an array today. I was about to make my own function to do this when I found out that PHP has a built in function called array_sum that does that for you.

Read more

PHP Date Function and Formatting a Date

March 27, 2008

The other day someone asked me how to format a date pulled from a MySQL dbase. I do this all the time however a friend was asking the question so I decided to blog about it as well. It comes up alot in programming so I figured it might be of use to someone else. Read on.

Read more

Stripping text from the alt tag of a webpage with regex

March 13, 2008

The other day my fiance needed to get some info from a webpage that was in the alt tags. I decided to write up a script that would do it in php.

I’m not the best at regular expressions so I had to look up on the web on how to do it. Regex is a pain to understand. But if you work at it you start to realize how much power it has.

So without much further ado here is the regex, that suited me for this situation, to find out the text that’s in the alt tags of a webpage.

Read more

Pwning lame ass dupes in excel

February 12, 2008

Well a friend wrote some bitching code. So we thought we should share.

Sub Remove_Dups()
‘much faster dup remover but has dependencies and preparations:
‘1. there must not be over 500 dups of a certain thing, this will only
‘   remove up to 500 dups of each item, must run again if more
‘2. you are required to order the table based on column 1
‘3. column 1 is the only field checked
‘4. only deletes the cell instead of row to keep in order.
‘5. re-sort table based on column 1 and remove all rows with empty first cell
‘6. add THEEND to first cell of a row at the bottom so dup checker
‘   will stop once it gets there
Application.ScreenUpdating = True

Dim x As Long
Dim y As Long

For x = 1 To 59999
    Sheets("Sheet1").Cells(x, 1).Select
    If Sheets("Sheet1").Cells(x, 1).Value = "THEEND" Then
        MsgBox "Done!"
        Exit Sub
    End If
    If Not x = 59999 Then
        For y = (x + 1) To (x + 500)
            If Not Sheets("Sheet1").Cells(y, 1).Value = "" Then
                If Sheets("Sheet1").Cells(y, 1).Value = Sheets("Sheet1").Cells(x, 1).Value Then
                    Sheets("Sheet1").Cells(y, 1).Value = ""
                    DoEvents
                    Sheets("Sheet1").Cells(x, 1).Select
                End If
            End If
        Next y
    End If
Next x

MsgBox "Done!"

End Sub