this time went ahead with Gtk2 + Haskell [Gtk2Hs]. First GUI program… so.. thought to make simple Notepad 😛
wasn’t a waste anyway.. learned quite a few things.
code might not be pure Haskellish.. but I’m slowly getting used to use Haskell.. 🙂
This is how it looks –
and you can download source [.hs + glade file] from my skydrive or have a quick look at source on hpaste
I’ve been trying to spend some time with Haskell for long but college.. assignments … etc..were keeping me away. Finally got time + kick + excitement last night and decided to code something meaningful.
Thought to solve this challenge one more time > http://punetech.com/apply
Its quite simple. Read from input.txt [which is actually a twitter feed] > remove duplicate id entries > sort in descending order of Timestamp and save to output.txt.
Took pretty long time though. I was also reading relevant pages from RWH. had to read some things like Monads twice/thrice to understand. Then talking to folks in IRC #Haskell.. Still have to go through alot.
but it was fun. yeah! my first Haskell program that works as expected 😀
here’s the code. It still requires alot of cleaning and will do that after posting this. but this is the final v1.0 that works. So wanted to share this one only 😀
Here’s a way to fetch twitter feed on form.
Twitter provides RSS feed of every account, provided account visibility is Public.
If you are using New twitter, you’ll have to find out your twitter feed link by
1] either leave new twitter preview and find RSS links on right sidebar, or
2] click on the RSS Feed icon in browser addressbar. It will probably show your favorites feed. Note the userid from URL.
Now, use that userid in this fashion :
Once you get your twitter feed rss url, its simple to fetch entries.
Sample code using my twitter feed :
You’ll need a RichTextBox and a Button on form. Keep default names.
Dim items As Xml.XmlNodeList = FetchTwitterFeed("http://bit.ly/hbsM7i")
'Iterate and print each title
For Each item As System.Xml.XmlNode In items
RichTextBox1.AppendText(item.ChildNodes(0).InnerText & vbCrLf)
'childNodes(0) gives title
'for rest node indices like link,time etc
'check source string
Read more for FetchTwitterFeed() Function –
Public Class Form1
Private Sub CopyDirectory(ByVal SourcePath As String, ByVal DestPath As String, Optional ByVal Overwrite As Boolean = False)
Dim SourceDir As DirectoryInfo = New DirectoryInfo(SourcePath)
Dim DestDir As DirectoryInfo = New DirectoryInfo(DestPath)
' the source directory must exist, otherwise throw an exception
If SourceDir.Exists Then
' if destination SubDir's parent SubDir does not exist throw an exception
If Not DestDir.Parent.Exists Then
Throw New DirectoryNotFoundException _
("Destination directory does not exist: " + DestDir.Parent.FullName)
If Not DestDir.Exists Then
'copy all the files of the current directory
Dim ChildFile As FileInfo
For Each ChildFile In SourceDir.GetFiles()
If Overwrite Then
ChildFile.CopyTo(Path.Combine(DestDir.FullName, ChildFile.Name), True)
' if Overwrite = false, copy the file only if it does not exist
' this is done to avoid an IOException if a file already exists
' this way the other files can be copied anyway...
If Not File.Exists(Path.Combine(DestDir.FullName, ChildFile.Name)) Then
ChildFile.CopyTo(Path.Combine(DestDir.FullName, ChildFile.Name), False)
' copy all the sub-directories by recursively calling this same routine
Dim SubDir As DirectoryInfo
For Each SubDir In SourceDir.GetDirectories()
CopyDirectory(SubDir.FullName, Path.Combine(DestDir.FullName, _
Throw New DirectoryNotFoundException("Source directory does not exist: " + SourceDir.FullName)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
CopyDirectory("C:\zipMe", My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\Folder1", False)
Copy folder using Shell32 :-
If Screen.FromPoint(Me.Location).Primary Then
Get device name on which form is currently on :
Get Screen resolution of display, your form is currently on :
Dim rect As Rectangle = Screen.FromPoint(Me.Location).Bounds