Life Updates- and svg

I’ve been doing a lot of  iPhone development, and redid my proof of concept jQuery Mobile website. So no shortage of work. Also had my 2nd child since my last post. :)

In doing all the work I’ve found that there are not to many places that offer svg files of their free icons. Those that do, have very limited packs. Maybe I’m missing a site?

http://davidcrow.ca/article/634/open-source-icons

The above site lists some nice free places to get icons. There is also:

http://blog.twg.ca/2009/09/free-iphone-toolbar-icons/

http://www.greepit.com/open-source-icons-gcons/

http://www.pixelpressicons.com/?p=108

http://brsev.deviantart.com/art/Token-128429570

Anyway, so to be clear I’m looking for monochrome simplistic mobile icons. And since no one seems to offer svg files, I took it upon myself to learn inkscape, trace a couple icons as a proof, and save them out. So granted I’m no designer, but id like to offer what I have, and what I make in the future.

Hopefully the more I make the better I’ll get, but you know how programmers design…

If you have any favorite free icon packs feel free to post them in the comments, especially of they are in svg format.

If you have any corrections of tweaks to my files please post in the comments so I can get the files are share them with everyone.

 

Cloud> http://www.mediafire.com/?d94krj9019j09jq

bell> http://www.mediafire.com/?l2xb5fq5kzk72jy

users>http://www.mediafire.com/?mlbtzdbwdz05ulf

ToggleNic- toggling the enabled network connection in win7

I found this site http://channel9.msdn.com/playground/Sandbox/154712/#Page=1 which ironically had a project under the same title I was using.

I wrote a togglenic app for xp some time ago but it was pretty limited in the features. This week i got a new win7 pc and found my togglenic no longer worked. I found the listed site, got the code, and went to work.

Its now a windows forms application, it will start with windows if you set it (minimized of course), will provide a list of networks, you can refresh this list, choose the network, outputs log to richtextbox, minimized to tray. Warning- i threw this together so its provided with no warranty. Sorry.

Pretty basic. I plan on adding xp support, but haven’t done so yet. So to be clear this should work on vista,7,and 2008 though I’ve only tested in win7.

Also to be clear i have no affiliation with the author of the listed post, we’ve just happened to name it the same thing. I did steal his icon…cuz it was nice.

Im not releasing the source since the working code has already been released. Any ideas for improvements are welcome.

rar – http://www.mediafire.com/?jaj9a1lgw34bv66

Update on char counter (vb.net)

Well my previous post spoke about a char counter. After posting it on a different blog several months ago I followed it with the below post.

Today I went to put it into a program and quickly realized some short comings. Hopefully this fixes them.

sFor previously could only be one character long. Well what if you want to search for an entire string. You need to divide the length by the length of the searching string. Also, If you don’t care about case since the sIn could be mixed case we need to lower that and then lower the sFor, instead of just lowering and upping the sFor. This in theory will slow it down since the string could be longer than lowering the sFor and sIn, but I cant think of a way around that.

Function cnt_occ(ByRef sIn As String, ByRef sFor As String, Optional ByVal casesensitive As Boolean = False) As Integer
If casesensitive Then
Return (sIn.Length – sIn.Replace(sFor, “”).Length) / sFor.Length
Else
Return (sIn.Length – sIn.ToLower.Replace(sFor.ToLower, “”).Length) / sFor.Length
End If
End Function

Char Count Speed Test (vb.net)

A few months ago i posted the below post on a different blog. Since this is my dedicated programming blog, I thought I’d bring it over here. I commonly need to return the number of a specific character in a string, and was never really happy with what i found on the internet. Here are some concepts of different ways to do it.

Function cnt_occ1(ByRef sIn As String, ByRef sFor As String, Optional ByVal casesensitive As Boolean = False) As Integer
Dim startTime As DateTime = DateTime.Now
Dim ts As String = “”
If casesensitive Then
ts = sIn.Replace(sFor, “”)
Else
ts = sIn.Replace(sFor.ToUpper, “”).Replace(sFor.ToLower, “”)
End If
Dim executionTime As TimeSpan = DateTime.Now – startTime
MsgBox(executionTime.Seconds.ToString() & “:” & executionTime.Milliseconds.ToString())
Return sIn.Length – ts.Length
End Function

Function cnt_occ2(ByRef OrigString As String, ByVal Chars As String, Optional ByVal CaseSensitive As Boolean = False) As Integer
Dim startTime As DateTime = DateTime.Now
http://www.freevbcode.com/ShowCode.Asp?ID=1025
Dim lLen As Long
Dim lCharLen As Long
Dim lAns As Long
Dim sInput As String
Dim sChar As String
Dim lCtr As Long
Dim lEndOfLoop As Long
Dim bytCompareType As Byte

sInput = OrigString
If sInput = “” Then Return 0
lLen = Len(sInput)
lCharLen = Len(Chars)
lEndOfLoop = (lLen – lCharLen) + 1
bytCompareType = IIf(CaseSensitive, vbBinaryCompare, _
vbTextCompare)

For lCtr = 1 To lEndOfLoop
sChar = Mid(sInput, lCtr, lCharLen)
If StrComp(sChar, Chars, bytCompareType) = 0 Then lAns = lAns + 1
Next
Dim executionTime As TimeSpan = DateTime.Now – startTime
MsgBox(executionTime.Seconds.ToString() & “:” & executionTime.Milliseconds.ToString())
Return lAns
End Function

Function cnt_occ3(ByRef sIn As String, ByRef sFor As String, Optional ByVal casesensitive As Boolean = False) As Integer
Dim startTime As DateTime = DateTime.Now
Dim oc As Integer
Dim pos As Integer
Dim ts As String = “”
Dim lp As Integer
If casesensitive = False Then
ts = sIn.ToLower
sFor = sFor.ToLower
lp = ts.LastIndexOf(sFor)
Else
lp = sIn.LastIndexOf(sFor)
ts = sIn
End If

While 1 = 1
oc += 1
pos = ts.IndexOf(sFor, pos) + 1
If pos >= lp Then
Exit While
End If
End While
Dim executionTime As TimeSpan = DateTime.Now – startTime
MsgBox(executionTime.Seconds.ToString() & “:” & executionTime.Milliseconds.ToString())
Return oc
End Function

Function cnt_occ4(ByRef sIn As String, ByRef sFor As String, Optional ByVal casesensitive As Boolean = False) As Integer
Dim startTime As DateTime = DateTime.Now
Dim oc As Integer

Dim ts As String = “”
If casesensitive = False Then
ts = sIn.ToLower
sFor = sFor.ToLower
Else
ts = sIn
End If
While 1 = 1
oc += 1
ts = ts.Substring(ts.IndexOf(sFor) + 1)
If ts.IndexOf(sFor) = -1 Then
Exit While
End If
End While
Dim executionTime As TimeSpan = DateTime.Now – startTime
MsgBox(executionTime.Seconds.ToString() & “:” & executionTime.Milliseconds.ToString())
Return oc
End Function

I thought that to count the occurrences of a character in a string I could replace it with nothing, then diff the lengths. Indeed it is faster. Surprisingly the 2nd fastest is looping through each character. Next we have the index of the string saved and looking for the next index of. Lastly we have the string cut for each occurrence.

Here’s the results:
Small number of occurrences-
1-0.46
2-0.93
3-0.812
4-5.640

Large number of occurrences-
1-0.31
2-0.93
3-4.843
4-34.508

key:
seconds.milliseconds

conclusion:
My code is not only always faster but it’s also much cleaner and readable. I’m sure someone else has done this but I hadn’t read about it before.

The code can then be reduced to:

Function cnt_occ(ByRef sIn As String, ByRef sFor As String, Optional ByVal casesensitive As Boolean = False) As Integer
If casesensitive Then
Return sIn.Length – sIn.Replace(sFor, “”).Length
Else
Return sIn.Length – sIn.Replace(sFor.ToUpper, “”).Replace(sFor.ToLower, “”).Length
End If
End Function

Android-Like Date Picker with jQuery mobile .2

In a previous post (http://toddmhorst.wordpress.com/2010/12/24/android-like-date-picker-with-jquery-mobile/) I showed a concept for a date picker for jQuery Mobile. It didn’t work, but I had most of the gui done.

Here is my current sample:
http://managingmeals.com/demos/datepicker/ (Sorry for the slow loading site, I couldn’t find a free place to host the demo, tips?).

Here is the current download:

http://www.mediafire.com/?in88b1f76bufyun

The goal is to get this look (taken from android):

Here is the current look of my app (looks slightly better on android):

Changes since .1:

  • Modal window
  • Set/Cancel work
  • Theme tweaks
  • Centers dialog with orientation changes
  • Button responsiveness (changed from click to tap), this was the slowness i talked about last time. It turned out that removing the date format lib didn’t affect the speed at all.

Future Changes:

  • On a desktop, some browsers show scrollbar on up/down buttons. Need to hide overflow.
  • there should be validation, as users type text into the text boxes
  • currently we roll the dates, so date is 12/31/10, add a month, it takes you to 1/31/11, it shouldnt
  • If there is a value in the text box when you launch the datepicker, start from that date
  • if the keyboard is shown and its landscape, just show the 3 text boxes, or scroll to them
  • if the keyboard is shown and its portrait, lengthen page, move dialog down, and scroll down to hide title bar

Reasons:

I’m still hoping someone can take this sample and run with it. I’m definitely not a pro with jquery yet, and mobile isn’t even out of alpha. If users see this as well as the iphone replica (talked about in last post) we may be able to get some good options out there.

Im not sure what direction jquery mobile will go with a datepicker, who knows maybe they can do something similar and replace this altogether.

 

Side Note:

I tried using the dialogs built into jQuery Mobile, they are separate pages. I didn’t spend a lot of time on it, but i couldn’t get the js to work on the dialog. After that i would need to update the parent page with the date value, so those 2 hurdles were enough for me to go in another direction, at least for now.

Twitter Integration with Twitterizer

I needed to do a small .Net application that could tweet but more importantly send private messages via twitter. Twitterizer makes this extremely easy, if you can get it to work.

I found the following link:
Twitterizer 2 and C# – Namespace could not be found
This explains how to get it to work in VS 2010 in c#, at the bottom I’ve added how to get it to work in vb.net.

Android-Like Date Picker with jQuery mobile

Newer Version:http://toddmhorst.wordpress.com/2010/12/30/android-like-date-picker-with-jquery-mobile-2/

I started working on a mobile web app using jquery mobile this week. I got to a point where I needed a date picker, and noticed that theirs isn’t done yet. In the experiments folder on git they seem to be basing it off of the date picker from jquery ui. Which looks out of place on a mobile browser.

Looking around I found the following site that has an iPhone like date picker. It works well, but could potentially give you invalid dates as it always allows 31 in the day selector without taking into account the current month your in.

http://cubiq.org/spinning-wheel-on-webkit-for-iphone-ipod-touch

Since I’m testing on a droid, I noticed that their picker is simple and clean. I decided to make a web version using jquery mobile.

Here is my sample:
http://managingmeals.com/demos/datepicker/ (Sorry for the slow loading site, I couldn’t find a free place to host the demo, tips?).

Here is a picture:

Here is a pic on the real thing on android:

Here is the package:

http://www.mediafire.com/?in88b1f76bufyun

Reasons:

I’m hoping someone can take this sample and run with it. I’m definitely not a pro with jquery yet, and mobile isn’t even out of alpha. If users see this as well as the iphone replica we may be able to get some good options out there.

Future Fixes:

This page is horribly slow, I have it hosted locally and my droid still has a lot of lag. I would like to get rid of the date formatter and build that into the script. The external script is awsome if your doing a lot of different modifications, but im not.

Needs to be in a pop up similar to dialogs on a desktop, or list items in the mobile framework. I dont really like that dialogs in the mobile framework hide the text of the sceen, they seem more like new pages. Set and Cancel button would then need to work.

Follow

Get every new post delivered to your Inbox.