Posted by: pueblonative | March 23, 2010

TwitterVB and me

I’ve been associated with TwtiterVB for some time now as a contributing developer. Well, that will change here; I have accepted the job of project coordinator on the TwitterVB project. Duane has found that more and more his interests lie elsewhere which I completely understand. He will still be on the list answering questions (probably better than will), but for now I’m going to be the one to take control.

So, now what do we do with TwitterVB? There are several different paths we can go through, but there are some areas that need to be focused on. First and foremost is xAuth. For those of you who don’t know, xAuth is a form of oAuth that makes concessions to those who aren’t too fond of a browser-based environment. It’s a great alternative to those who weren’t so fond of having to open up a browser in the middle of a desktop program.

Twitter has stated their goal to turn off basic authentication by June of this year. Now maybe they will and maybe they won’t. But I intend to be ready for Twitter to turn it off. If they don’t, then we’ll still have basic authentication for a little while. But we’ll have a way to make Twitter communications that are even more secure.

There are a few caveats, though: first off, in order to use this we will have to add SSL support. SSL is not something that I know that well so I’ll be doing a lot of trial and error. If somebody is reading this and wants to help I would be more than appreciative.

Another area that I think we need to look at is mobile development. Duane put it very succinctly in his e-mail; his main platform for accessing the Net is a mobile device. We’ll probably find more and more people wanting to use twitter in a mobile environment. So we should be looking to make sure that Mobile developers are involved with the effort.

Beyond those two areas I can’t see much. I’d like to get TwitVid support, but given the fact that we have Twic.li support for videos it isn’t a pressing issue. If you have some suggestions for features e-mail the group by signing up at TwitterVB.codeplex.com.

Posted by: pueblonative | March 8, 2010

Thanks Gov.

Amazon Fires Its Colorado Associates – O’Reilly Radar

Interesting! So let me get this straight: I’ve done nothing, and Amazon just fired me? Now, I haven’t used referrals a whole lot so it doesn’t hit me in the pocketbook but this should send chills down the spine of anyone who thought they were building a business, or at least an income, around Amazon services. It’s one thing to be fired for something you did (hey doofus, don’t cause a heap of MPAA infringement notices to land on Amazon’s desk because you were running the new Pirate Bay on EC2) but it’s entirely another to be fired for something outside your control.

No, it was not our fault, but if our government didn’t see this one coming a country mile away then they need to check their prescription. Well, don’t expect to see me promoting Amazon on this or the other sites that I run, at least until the current band of buffoons is out of the Assembly.

Posted by: pueblonative | January 21, 2010

Updates on TwitterVB

  • For now, I have put my TwitVid work on hold. Quite frankly, I have not been able to get much information or support from TwitVid and since their API has changed from the documentation, I need more input. So I have put the TwitVid object on hold. If I get more information later on, I will be more than happy to thaw the object. For now, though, it’s been on ice.
  • Twic.li, on the other hand, has been more than helpful on their objects and more than responsive with the e-amils. I already have the ATwiCliConnection object mapped out and am now mapping out objects and methods to encapsulate the different types of files available. I hope to have a proof of concept app here soon, with the final objects merged in with the library this weekend.
Posted by: pueblonative | January 11, 2010

Tech notes

  • The latest version of the TwitterVB library has been released.Of note, my FileSocialUpload() function has been approved and is part of this library. If you are a .NET developer looking for a good library to access Twitter through this is the library for you. You don’t even necessarily have to use VB (Any language that interacts with the .NET framework can utilize this library). I will be posting up examples in the upcoming weeks. My future work will involve functions for accessing TwitVid() and providing more documentation and tutorials.
  • I am still looking for either an IT job or a freelance writing job.  If you would like to hire me for a project (or view my profile) check out pueblonative at odesk.com
Posted by: pueblonative | January 9, 2010

Extracting the numeric part of the string

Got another question on an excel list regarding splitting off the number of a mixed entry. The person had the following data:

PF309
P1009
P0009

And he wants to extract the numeric part of the string and display it as a number, sans leading zeros:

309
1009
9

There are several ways to do this and an excel guru might have gone to a formula for it, but being an old VB programmer I took the macro route and came up with the following (which is somewhat similar to the code that I used in a prior blog).

Public Sub ExtractNumeric()
Dim strText As String
strText = LCase(ActiveCell.Text)

Dim strNumericString As String

Dim i_inx As Integer

For i_inx = 1 To Len(strText)
Dim strCh As String
strCh = Mid(strText, i_inx, 1)
If IsNumeric(strCh) Then
strNumericString = strNumericString & strCh
End If
Next i_inx

Dim iNumber As Long
iNumber = CLng(strNumericString)

Dim i_row As Integer
Dim i_cell As Integer
i_row = ActiveCell.Row
i_cell = ActiveCell.Column

ActiveSheet.Cells(i_row, i_cell + 1).Formula = iNumber

End Sub

Run that as a macro on the cell you want to extract and you have your answer. You will find that a lot of problems in programming language can be boiled down to a for loop in one way or another (or it’s variant a do until/while. . .loop).

Posted by: pueblonative | December 2, 2009

Thunderbird 3 RC 2: I like what I see

thunderbird1

I have to admit, I was a fan of Thunderbird far far before this latest Release Candidate Release. I use Microsoft Outlook, but only for development purposes. With this release, however, I pretty much think Mozilla put the nail in the coffin in terms of the e-mail wars, provided that it continues with the Thunderbird program.

With this release, Thunderbird moves closer and closer to the tabbed interface we’ve all come to know and love in Firefox. Gone are the floating windows that we’ve come to know and love by default (individual messages can still be pared off as separate windows by right-clicking them).   While old-schoolers may not like the push, it’s inevitable that eventually we’re going to all have the same, web 2.5 design on our sites.

But perhaps the best improvements have to do under the hood.  Thunderbird 3 now autodetects e-mail servers.  It took a step there when it automatically detected gmail accounts.  Now, however, it can autodetect a wide variety of web accounts, such as Hotmail and AIM.  YahooMail seems to still be spotty but I’m sure that will come on line later on.  Setting up these, or any other accounts, seems to be no harder than filling out the e-mail and entering your password.

Another way Thunderbird has implemented the easy button is in saving contacts.  It used to involve right-clicking on the name, filling out a bunch of details, and saving it.  Now, you just click on the star next to the name or e-mail, and the contact is added (you can add additional information later on).

But perhaps the biggest (in my mind) feature is the Archive function ala Gmail.  Now you have an option to remove older e-mails from your view without having to trash them.  At the click of the Archive button the e-mail is moved off into the archive fields but is still there if you have to search for a particular e-mail later on.  While you could replicate this in earlier versions of Thunderbird, Archive makes it much easier as a one-click function.

Speaking of the searches, this is another area where TB has taken a nod from Google.  Search is now laid out in a fashion eerily similar to Google’s search results, with the ability to sub-filter the search based on sender, recipient, and even date.  As of RC 1, the ability to save the search as a filter was not implemented, but when it does go live you will probably be pleasantly surprised with the results.

There is more about this release to go into and I’ll probably post up on that later, but right now RC1 lis looking almost like it’s ready for prime time.

Posted by: pueblonative | November 20, 2009

Checking the frequency of characters part 2

Last time I talked about using VB to count the frequency of each character that occurred in a string. Now we’re going to go back to the problem that I started with, and that is how to do the same trick in Excel (specifically Excel VBA).

None of the steps have changed, btw. We still have to check which individual letters show up in the individual string. We still need to count their frequency. What is going to change is the details to implement the pseudocode.

For starters, the VBA string is not enumerable. That means that we can’t use the for each ch_letter as char in strSearchString. . .Next trick we used in VB.NET. What we will use here is the mid() and len() function. The latter returns the number of characters in a string and the former returns a substring within the string of a length we set. This is perfect for picking off individual characters. So, the code looks something like this:


Public Sub CountLetters()
Dim strText As String

strText = LCase(ActiveCell.Text)

Dim strSingleString As String
‘this is our string containing unique individual characters within the strText
‘string.

strSingleString = “”
Dim i_inx As Integer

For i_inx = 1 To Len(strText)
Dim strCh As String
strCh = Mid(strText, i_inx, 1)
If InStr(1, strSingleString, strCh) = 0 Then ‘the character is not currently in the string
strSingleString = strSingleString & strCh
End If
Next i_inx

As you can see, we are using a for loop like in the VB.NET. It has a little more work in it (we need to use the mid function to pull off individual characters), but it still works along the same principals.

In this situation, where we used Contains() method of the String object in VB.NET, we use the Instr() function in VBA. The actual declaration of Instr() is:

positionofcharacter = Instr(positiontostart,stringtosearch,substringtosearchfor)

In this case, we are searching from the start of the string. If the character isn’t in the string, it returns 0. strSingleString is initially empty, so the beginning characters are going to go straight on in. But when it does encounter a duplicate Instr() will return the position of that character in strSingleString. At that point, we just skip the character and move on.

Once we’ve built up our string of individual characters that are in the word, we’re now going to count them. We will still use the Split() method described in my previous blog but with a couple of changes. First off Split() is a standalone function rather than a method of string. Second, since there is no array object in VBA we will use another method, Ubound(), in place of Count().

UBound() returns the index for the last item in the array. It is also zero-based. So with an array consisting of 0,3, and 5, UBound will return 2. It is one less than the number of elements in the array. Remember what we said about Count() and finding the number of occurences in a string? It was one greater than the number. Since UBound is also one less than the number of elements, we can use that to find the frequency. So the finishing code ends up like this


i_row = ActiveCell.Row
i_cell = ActiveCell.Column
Dim i_curRow As String
Dim i_curCol As String

For i_inx = 1 To Len(strSingleString)
ActiveSheet.Cells(i_row + i_inx, i_cell).Formula = Mid(strSingleString, i_inx, 1)
ActiveSheet.Cells(i_row + i_inx, i_cell + 1).Formula = UBound(Split(strText, Mid(strSingleString, i_inx, 1)))

Next i_inx

End Sub

End result compared to the VB program:

side by side comparison

There is some clipping because of the datagridview, but the results are the same. The spreadsheet is located in the box widget as stringbreak.zip. To run it, make sure macros are enabled, type text into any cell, make sure the cell is selected, and run the CountLetters macro.

In these two blogs we’ve shown how to count the frequency of letters. In future blogs we will go over how we can use this technique to create a frequency counter, charts, and even a frequency counter of words.

Update: My boxnet widget isn’t quite working the way that I thought so here are direct links to the two projects from my 4shared account:

I listened to Bill Jelen’s Mr. Excel podcast today (and, btw, it’s a great podcast) and he presented a problem of counting the occurrence of each character in a particular word.  In this case he used antidisestablishmentarianism, which is a word that I believe everybody should work into their vocabulary at least once a day.  The person wanted to know how many times a occured in that word, how many times n occured, and so on and so forth.  Bill presented two solutions to this problem, but both had their problems.  The first solution provided the correct count, but it repeated letters.  The second (also with the correct count) didn’t repeat any letters, but it left some rather annoying blanks.  So I decided to give this a shot.

You can pretty much break this problem up into two parts.  Part one is getting all of the unique characters in a word.  For instance, if I had the word madman the unique characters are “madn”.  So what would be the steps:

  1. Look at each character in the string.
  2. Check if it’s the first time that we have encountered the character. If it is, we note that character. If not, we ignore it.

Iterating over the string is slightly different in VBA (Excel) than it is in VB.NET. VB.NET is more robust and therefore easier so we’ll go over that first. A string can be thought of as an array of characters (in fact in many languages that’s exactly how it is stored). Being an array, it can be iterated over with the For. . .Each construct.

For each chLetter as Char in strSeachString
. . .
Next

Before we get into this a little bit longer, however, we should set up our Visual Basic Program. Fire up your Visual Basic and created a Windows Form application called “CharacterCounter”. This will require the following elements.

Name Type of Component
frmMain Windows.Form
txtWord TextBox
btnCountCharacters Button
dgvFrequencyCount (with two columns, character and frequency in that order) DataGridView (we’re not connecting it to any datasource, but I like the layout anyway)

Set it all up the way you want. Here’s a suggestion:

character counter program

I’m not all that into having the form exactly the way I want. That’s not the point of this little exercise. The big thing is to name the items exactly as I did so that the code works (or you can be intelligent enough to sub in your own).

Now, for this exercise we’re going to be working on the assumption that we want a case-insensitive search. In our search, “A” and “a” are the same thing. So, we’ll transfer this into a lowercase version (it really doesn’t matter if it’s upper or lower as long as it’s all the same case).

Now, while we are iterating through the string we need to a way to store off characters as we come across them for the first time. There are many places to store it but for simplicity’s sake we’ll use. . .another string. The code goes something like this:


Private Sub btnCountCharacters_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCountCharacters.Click
Dim strIndividualChars As String
strIndividualChars = “”
Dim strLowerCaseSearchString As String
strLowerCaseSearchString = txtWord.Text.ToLower()

dgvFrequencyCount.Rows.Clear()
For Each chLetter As Char In strLowerCaseSearchString

If Not strIndividualChars.Contains(chLetter) Then
strIndividualChars = strIndividualChars + chLetter
End If
Next

The string object in VB.NET is far more flexible than it is in VBA and contains a number of useful functions. One of which is (coincidentally) Contains(). Contains returns a boolean value indicating if the parameter, in this case chLetter, is in the string object from which we are calling the function, in this case strIndividualChars. If it isn’t, we concatenate that letter onto strIndividualChars. If it is, we move onto the next character.

We have the single letters in a string, strIndividualChars. In the case of antidisestablishmentarianism strIndividualChars contains “antidseblhmr”. Every unique character that is in the former with no duplicates. Now onto the next part, finding out the unique count of each character of strIndividualChars in the original string. Again, we’re going to use a for each loop, this time on strIndividualChars. But onto determining the count.

The String object has several interesting functions. One of which is called Split(parameter). Split takes the string and returns and array. An array of what, you may ask? Well, it’s an array of the string divided by the parameter. For instance, given the following code.


dim strSentence as String
strSentence = “The quick brown fox jumped over whatever”
dim strArray() as String = strSentence.Split(” “)

strArray() now contains {“The”,”quick”,”brown”,”fox”,”jumped”,”over”,”whatever”}. As an array object it has several properties, one of which is count. Count tells you how many elements are in the array (in this case seven). Quick Question: how many spaces were in the string? 6, which is one less than then count. That holds true for whatever character you use in any type of string. The count of an occurance of a substring in a string will always be one less than the number of elements in the array created by using split on that string with the substring as the parameter. Follow? Probably easier to show with code:


For Each chLetter As Char In strIndividualChars
Dim row() As String = {chLetter, CStr(strLowerCaseSearchString.Split(chLetter).Count – 1)}
dgvFrequencyCount.Rows.Add(row)

Next

row() is a string array, btw, that we will use to feed in the results to output. The output will end up being something like this

final output of character counter

The project is in the box widget on this site so you’re free to look through the code. That was the simple part. Tomorrow we’ll go through the VBA code, which throws a few more curves to us.

Posted by: pueblonative | November 19, 2009

A follow up to the St. Louis Editor

After yesterday’s post, I followed my own advice and wrote to the editor asking that this guy be removed. From the response received I think I can sense that won’t happen, but it has generated some discussion.

Thanks for visiting STLtoday.com and taking the time to write.

I’ve forwarded your note to our Editors.

As you can probably imagine, they have received a lot of email on this
topic.

In case you do not get a personal reply to your note,

I want to make sure that you know that it will indeed be read

and your opinions considered in future decisions regarding operations of
our website.

If you want to comment on this story, you can do so here:

http://www.stltoday.com/blogzone/the-editors-desk/the-editors-desk/2009/

11/follow-up-the-case-of-the-vulgar-comment-and-the-school/

Thanks,

STLtoday.com

Sitehelp

Note from Deputy Managing Editor regarding

blog posting policy:

At STLtoday, we work to build trust and credibility with our customers.

When someone posts profane or vulgar material on our site, we work to
remove it immediately.

When someone persists in posting profane or vulgar material, we will
attempt to contact them

and warn them to stop or risk losing the privilege of posting to
STLtoday.

When it becomes impossible to contact them because they have lied about
their contact information,

we may contact the source at the IP address to let them know that their
access to

STLtoday may be blocked and we will explain the reasons why it is
blocked.

If we can’t identify the source at the IP address, we may block the
address without notification.

This is the procedure we have followed in the past,

and the procedure we will follow in the future.

It does not involve sharing any private customer information.

Bob Rose

Deputy Managing Editor

St. Louis Post-Dispatch

STLtoday.com

My response:

  • I could go with that, if Mr. Greenbaum hadn’t had the gall to write about shooting down a former school employee. Exactly what is he trying to prove with that little comment, other than the fact that he holds all the cards on his blog?
  • Mr. Greenbaum says that he deleted the comment, then “a few minutes later” the guy posted again. Okay, the guy could have been an oxnoxious jerk, but he could have also just wondered why his comment didn’t come up the first time. Boneheaded, true, but still a possibility. From the the column it certainly doesn’t look like a spam flood.

Again, he may have had the right to do it, but that doesn’t mean he was right to do it the way he did it (especially in the context of what he wrote the following day). If you’re gonna delete a comment and ban the user, don’t proceed to crow about the thing like you’re some sort of king of the mountain. There are a whole lot of peaks and summits on the Internet range.

Posted by: pueblonative | November 18, 2009

Hopefully the editor soon follows this guy on the unemployment line

Tattle-Tale Newspaper Costs Vulgar Commenter His Job – Kurt Greenbaum – Gawker

A St. Louis schools employee made a juvenile, vulgar joke in the comments section of the St. Louis Post-Dispatch website, anonymously. Soon, he was out of a job because an offended newspaper editor hunted him down and called his bosses.

Way to win reader trust, Post-Dispatch!

And just to complete this discussion, here is the original column and here is the guy’s justification and the ensuing response.

Look, we can go round and round about the fact that this guy said something that as a public employee he should not have said using a public computer, let alone a school computer (a fact which he tries to hang onto like the edge of a cliff). But the fact is he tracked down a person for what was at best an immature comment on a stupid question of the day.

I might cut Mr. Greenbaum some slack if what the man had said was illegal (posting up child porn, for instance). And I will cut him some slack in the fact that the guy tried to post it twice (that at least, could have warranted an e-mail along the lines of “we’re banning your account and we know that you posted this from the school’s ISP”. But what this was was a writer who had way, way too much time on his hands and sending a chilling statement to its readers: if we don’t like what you say we’ll get your bosses to fire you or put you in a position where you have to resign. Maybe that’s not the message that they thought they would send, but it’s the message that they did send nonetheless.

BTW, if anybody wants to e-mail Mr. Greenbaum’s boss and tell him how you feel, send an e-mail to either SiteEditor@stltoday.com or generalmanager@stltoday.com. And feel free to comment on this entry. I definitely won’t be writing any of your bosses. Promise.

Older Posts »

Categories

Follow

Get every new post delivered to your Inbox.