tonybaldwin | blog

non compos mentis

Posts Tagged ‘tcl/tk

Fren.Tcl and Frendi.Sh

with 3 comments

Friendika

Friendika

So, those who know me know that I’ve been playing on Friendika, a decentralized, federated, free/open source, privacy protecting, and, well, pretty amazing Social Networking application.

Friendika is pretty awesome in various ways, including, first, you have complete control over who can or cannot see your content.  You own your content and your privacy is completely yours to control.  Also, you can follow contacts from many other networks, including twitter, any status.net installation, Diaspora and Facebook, plus rss feeds, even, so, it becomes sort of a social networking aggregator.  Not only that, but it has friend groups similar to Diaspora Aspects or Google+ Circles.  These groups are very handy.  I follow my Diaspora and Facebook contacts, plus my identi.ca contacts, plus a large number of twitter accounts on my friendika, and have them grouped into local friends, family, haxors (fellow foss hackers, tech blogs, etc.), friends (not local, people I met online), tradus (translation colleagues, work related, polyglots), and one more group for news which includes mostly twitter feeds from a number of news outlets (Al Jazeera, BBC, NPR, Alternet, etc.).  So, it has really helped me to organize my social networking.

So, these past couple of days I, being the geek that I am, have been playing with means of posting to Friendika remotely, first from the bash cli.  Now, I had posted earlier a quick-n-dirty update type script, but I have one now that will toggle cross-posting to various other services (statusnet, twitter, facebook), and will open an editor (vim) to allow you to write longer posts.  I posted it on the wiki here, but will also include the code in this post:

#!/bin/bash

# update friendika from bash with curl
# I put this in my path as "frendi"

# here you enter your username and password
# and other relevant variables, such as whether or not
# you'd like to cross post to statusnet, twitter, or farcebork

read -p "Please enter your username: " uname
read -p "Please enter your password: " pwrd
read -p "Cross post to statusnet? (1=yes, 0=no): " snet
read -p "Cross post to twitter? (1=yes, 0=no): " twit
read -p "Cross post to Farcebork? (1=yes, 0=no): " fb
read -p "Enter the domain of your Friendika site (i.e. http://friendika.somesite.net): " url

# if you did not enter text for update, the script asks for it

if [[ $(echo $*) ]]; then
	ud="$*"
else
	read -p "Enter your update text: " ud
fi

# and this is the curl command that sends the update to the server

if [[ $(curl -u $uname:$pwrd  -d "status=$ud&statusnet_enable=$snet&twitter_enable=$twit&facebook_enable=$fb"  $url/api/statuses/update.xml | grep error) ]]; then

# what does the server say?

	echo "Error"
else
	echo "Success!"
	echo $ud
fi

# this next is optional, but I made a dir in ~/Documents to keep the posts.
# You can comment it out, you can change where it is storing them (the dir path)
# or, even, if you don't want to save the posts (they will pile up), you could
# change this to simply
# rm $filedate.fpost or rm -rf *.fpost, or some such thing.

mv $filedate.fpost ~/Documents/fposts
exit

But I have also now written a graphical application in tcl/tk to write posts to Friendika, Fren.Tcl

Fren.Tcl

Fren.Tcl - tcl/tk Friendika posting application

Find me on Friendika here.

./tony

Advertisements

Written by tonybaldwin

September 14, 2011 at 8:27 am

eXp0stulate – moving right along!

leave a comment »

I’ve already made a few changes to eXp0stulate, primarily in the gui.
Rather than have a menu with options for posting to the 3 relevant services (livejournal, insanejournal, and dreamwidth), I have made buttons, and placed the “Post to: (which journal?)”(so you can post to a community, etc.) at the bottom of the interface.

Here’s a new screenshot:

I have plans to edit the “Insert” menu, since DW uses slightly different tags than IJ and LJ (which both use stock LJ tags, for cut, user, community, etc.).
I may add more html options to that menu, as well (bold, italic, small, big, headings-h1, h2, etc., horizontal ruler, paragraph, blockquote, lists, etc.).
I also think that html syntax highlighting would be pretty awesome, so one could more readily see errors in html tags in an entry, before posting.
And, of course, spellchecking would be gro0vy.
Beyond that, there’s other work to do. Currently eXp0stulate uses the old, flat post method. I’d like to get it writing out to xml, so it will function with the xml-rpc interface, which will then allow me to add both blogger and wordpress functions (which will also allow me to use it with my baldwinsoftware/blog).
I’d also like to incorporate a few more features, such as downloading and editing older entries. Right now, it only posts an entry.
This is a drawback, because, if the user finds an error in their entry once it’s been posted, they have to edit it on-site, rather than in eXp0stulate.
Not convenient.
If I add in the ftp function from tcltext and tclup, heck, it could be a combo blogging client and html editor…maybe…
So, I have a full TODO list on the eXp0stulate wiki page.

One advantage I do think it has is, once you’ve posted an entry, the text widget does NOT clear (unless you deliberately clear it), so, the entry remains loaded, and you can post to all three current services (IJ, LJ, DW) simply by pressing the three buttons at the bottom of the interface, and, if you like, even x-post to a few communities by modifying the “Post to: [which journal?]” field and pressing said buttons again.
(In Logjam, for instance, one must logout/login to the distinct services, reloading the entry before changing services, in order to xpost…here it’s just, write an entry, and click, click, click…)
That’s convenient, I think.

The user must be certain to make sure that “Post to: [which journal?]” is filled in with the name of the journal to which they are posting (their username if posting to their own journal, the name of a community, if that is what they wish). In TKLJ and Therapy, I had that field default to the user’s username for the relevant service, but, since this program posts to 3 (and hopefully, in the future, 5 or more) services, defaulting to any specific username seemed impractical. I have a username on LJ that differs from that which I use on IJ and DW. I suspect others may have differing usernames, as well, so the field simply defaults to “which journal?”, which means, if the user does not alter the field, they will be trying (unsuccessfully) to post to http://which journal?.livejournal.com/, or ij or dw, as the case may be.

It would be good to load menus with the user’s communities, and also add user icon functionality, but the user icon feature would be useless for blogger and wordpress, of course, so I may just dispense with that.

Some might ask,”Why, Tony? Why make another blogging client for LJ, IJ, and DW?”
To which I answer,”Well…

  1. I keep blogs on several services, and want to make it as convenient and efficient as possible to X-post to all 6 blogs I keep;
  2. I want some features the others don’t have;
  3. Why climb the mountain? because it’s there… (i.e., it was something to do, and I like hacking);
  4. No such blogging client exists written in TclTk, and I like to promote the language;

Anyway, I’ve got to get away from this project at the moment and return to my translation work.

If you want to get on board and hack this thing up with me, let me know!
I’ll add you to the baldwinsoftware.com/wiki, forums, and invite you to the baldwinsoftware googlegroup/listserv.

be well,
tony


posted with eXp0stulate

Written by tonybaldwin

March 26, 2010 at 1:59 pm

eXp0stulate – moving right along…

leave a comment »

I’ve already made a few changes to eXp0stulate, primarily in the gui.
Rather than have a menu with options for posting to the 3 relevant services (livejournal, insanejournal, dreamwidth), and NOW (this is new, just today) deadjournal, too. I have made buttons, and placed the “Post to: (which journal?)”(so you can post to a community, etc.) at the bottom of the interface.

Here’s a new screenshot:

I have plans to edit the “Insert” menu, since DW uses slightly different tags than IJ and LJ (which both use stock LJ tags, for cut, user, community, etc.).
I may add more html options to that menu, as well (bold, italic, small, big, headings-h1, h2, etc., horizontal ruler, paragraph, blockquote, lists, etc.).
I also think that html syntax highlighting would be pretty awesome, so one could more readily see errors in html tags in an entry, before posting.
And, of course, spellchecking would be gro0vy.
Beyond that, there’s other work to do. Currently eXp0stulate uses the old, flat post method. I’d like to get it writing out to xml, so it will function with the xml-rpc interface, which will then allow me to add both blogger and wordpress functions (which will also allow me to use it with my baldwinsoftware/blog).
I’d also like to incorporate a few more features, such as downloading and editing older entries. Right now, it only posts an entry.
This is a drawback, because, if the user finds an error in their entry once it’s been posted, they have to edit it on-site, rather than in eXp0stulate.
Not convenient.
If I add in the ftp function from tcltext and tclup, heck, it could be a combo blogging client and html editor…maybe…
So, I have a full TODO list on the eXp0stulate wiki page.

One advantage I do think it has is, once you’ve posted an entry, the text widget does NOT clear (unless you deliberately clear it), so, the entry remains loaded, and you can post to all three current services (IJ, LJ, DW) simply by pressing the three buttons at the bottom of the interface, and, if you like, even x-post to a few communities by modifying the “Post to: [which journal?]” field and pressing said buttons again.
(In Logjam, for instance, one must logout/login to the distinct services, reloading the entry before changing services, in order to xpost…here it’s just, write an entry, and click, click, click…)
That’s convenient, I think.

The user must be certain to make sure that “Post to: [which journal?]” is filled in with the name of the journal to which they are posting (their username if posting to their own journal, the name of a community, if that is what they wish). In TKLJ and Therapy, I had that field default to the user’s username for the relevant service, but, since this program posts to 3 (and hopefully, in the future, 5 or more) services, defaulting to any specific username seemed impractical. I have a username on LJ that differs from that which I use on IJ and DW. I suspect others may have differing usernames, as well, so the field simply defaults to “which journal?”, which means, if the user does not alter the field, they will be trying (unsuccessfully) to post to http://which journal?.livejournal.com/, or ij or dw, as the case may be.

It would be good to load menus with the user’s communities, and also add user icon functionality, but the user icon feature would be useless for blogger and wordpress, of course, so I may just dispense with that.

Some might ask,”Why, Tony? Why make another blogging client for LJ, IJ, and DW?”
To which I answer,”Well…

  1. I keep blogs on several services, and want to make it as convenient and efficient as possible to X-post to all 6 blogs I keep;
  2. I want some features the others don’t have;
  3. Why climb the mountain? because it’s there… (i.e., it was something to do, and I like hacking);
  4. No such blogging client exists written in TclTk, and I like to promote the language;

Anyway, I’ve got to get away from this project at the moment and return to my translation work.

If you want to get on board and hack this thing up with me, let me know!
I’ll add you to the baldwinsoftware.com/wiki, forums, and invite you to the baldwinsoftware googlegroup/listserv.

be well,
tony

Written by tonybaldwin

March 26, 2010 at 7:01 am

eXp0stulate – x-posting blog client

leave a comment »

I’ve decided to take the code from TclTherapy (insanejournal client), and TkLJ (livejournal client), and join them together, adding functionality for DreamWidth, as well. I have successfully merged the code, and X-posted to all three of the above mentioned blogging services.


I’ll be calling this new bit of hackery “eXp0stulate“, since it x-posts. I’d like to add wordpress and blogger funcationality (especially since THIS blog is WordPress blog), but I believe that will require my learning to get this thing to write out an xml file and play nice with the xml-rpc protocol, rather than just sending a flat entry via http post. Not sure…either way, it’s just a matter of time. I also want to get it to download and edit older posts.

Written by tonybaldwin

March 26, 2010 at 4:31 am

Python v. Tcl/Tk: Denting & Tweeting

with one comment

python v. tcl/tkSo.  I have now made two little denter/tweeter programs (to send updates to twitter.com and identi.ca), one with Tcl/Tk, the other with Python. I figured a little comparison, perhaps, was in order.

If you look at them, of course, they look, well, just about the same.  Tkinter is, after all, analogous to Tk.
The Tcl/Tk program made it incredibly simple to display the response from the remote server, which I haven’t succeeded in doing with the python script, yet.  Both rely on calling an external program (curl) to send updates, rather than relying on the languages’ built-in tools.  I could probably work out HTTP POST in tcl rather painlessly.  I did try to use python’s urllib to post, unfruitfully, and resorted back to calling curl.
the links: iDenTickles (tcl/tk) / iDenTweetyPie (python)
the code for both programs is available at the above wiki links

The Tcl/Tk program, which has the added feature of displaying the server response, has only 47 lines of code, 245 words, 1844 characters.  It took me less than an hour to write it.

The Python program, however, which does precisely the same exact thing as the tcl/tk program, without displaying the server response, has 104 lines of code, 564 words, and 4073 characters.  It took me the better part of a day to write it.  Oh, but the python program tells you if your update is too long.
One must ask oneself, of course, is this a testament to the power and simplicity of tcl/tk?  Or, is it simply an indication of my lack of skill with python?
I can’t answer that defnitively, but, to me, it really looks like tcl/tk is a bit more efficient.  Admittedly, I’m not a very skilled programmer at all, in truth.  Timewise, of course, I have been writing tcl/tk for a couple of years, and only just now delving into python. As such, I was able to throw the tcl/tk program together quickly, while, my efforts to “translate” my tcl/tk program into python required a bit of research on the syntax for writing tkinter guis, and other elements.  It just really looks to me as though Python/Tkinter takes a lot more code to do the same thing.  I really have drawn that conclusion.  Especially building a gui, it seems, is more cumbersome with tkinter than with simple, good old tcl/tk.  I know there are other means of building a gui with python (wxwidgets, pygtk, pyqt, etc.), but I wanted to try the one most similar to that with which I am already familiar, and, I believe it is a fairer comparison when using a similar gui ToolKit.
At this juncture, I do have to say, I feel a great loyalty and deep affinity for tcl/tk.  I don’t understand why it isn’t in wider use, frankly.  It is an incredibly powerful language, used for a vast array of purposes, and, in my opinion, is probably the easiest programming language to learn (of course, I haven’t tried them all), especially for a beginning programmer.  One can be up and running, creating useful programs in a relatively short time.  I also feel the need to give kudoz to the tcl/tk community and the tcl.tk wiki, which is replete tons of example code, detailed explanations, and great resources for learning how to program in tcl/tk.  The tcl-ers that hang out at #tcl on irc.freenode.net, additinoally, are extremely helpful, and patient.  They won’t hold your hand, but they’ll tolerate a newbie, and point them in the right direction, without any snobbishness or derision.
I can’t say the same for my experiences with pythonistas.  Their irc channel was a little less friendly, imho.  Maybe I just caught them on a bad day, or maybe I was having a bad day.  After all, Pythonistas are known for having a sense of humor.  Admittedly, I was frustrated when I finally went to their channel for a bit of support, and frustrated, whiny n00b is no fun to play with, any way.  Moreover, the python community does have a lot of documentation available online. Nonetheless, to me, it seems that it is written for other programmers, not for the uninitiated, so, is not so easily read as much of the tcl/tk resources.  Their sample code is not well explained, where someone new to programming can really make sense of it. This may also be a function of time, since tcl/tk has been around a bit longer than python.

I do want to make it very clear: I’m really not here to pick on python.  I know that it’s a powerful language with a great many uses, and a favorite of a great many real hackers who know a lot more about programming than I do.  I will continue to learn to write it, and believe it will serve me quite well for various purposes, and I believe I will continue to have fun learning it.  But, I think I might continue to point out how tcl/tk is much easier and seemingly efficient, too…

Written by tonybaldwin

March 23, 2010 at 3:30 am

Python v. Tcl/Tk (denting & tweeting)

leave a comment »

python v. tcl/tkSo.  I have now made two little denter/tweeter programs (to send updates to twitter.com and identi.ca), one with Tcl/Tk, the other with Python. I figured a little comparison, perhaps, was in order.

If you look at them, of course, they look, well, just about the same.  Tkinter is, after all, analogous to Tk.
The Tcl/Tk program made it incredibly simple to display the response from the remote server, which I haven’t succeeded in doing with the python script, yet.  Both rely on calling an external program (curl) to send updates, rather than relying on the languages’ built-in tools.  I could probably work out HTTP POST in tcl rather painlessly.  I did try to use python’s urllib to post, unfruitfully, and resorted back to calling curl.
the links: iDenTickles (tcl/tk) / iDenTweetyPie (python)
the code for both programs is available at the above wiki links

The Tcl/Tk program, which has the added feature of displaying the server response, has only 47 lines of code, 245 words, 1844 characters.  It took me less than an hour to write it.

The Python program, however, which does precisely the same exact thing as the tcl/tk program, without displaying the server response, has 104 lines of code, 564 words, and 4073 characters.  It took me the better part of a day to write it. Oh, but the python program does tell you if your post is too long, something I neglect to program into the tcl/tk script. That’s a bonus.
One must ask oneself, of course, is this a testament to the power and simplicity of tcl/tk?  Or, is it simply an indication of my lack of skill with python?
I can’t answer that defnitively, but, to me, it really looks like tcl/tk is a bit more efficient.  Admittedly, I’m not a very skilled programmer at all, in truth.  Timewise, of course, I have been writing tcl/tk for a couple of years, and only just now delving into python. As such, I was able to throw the tcl/tk program together quickly, while, my efforts to “translate” my tcl/tk program into python required a bit of research on the syntax for writing tkinter guis, and other elements.  It just really looks to me as though Python/Tkinter takes a lot more code to do the same thing.  I really have drawn that conclusion.  Especially building a gui, it seems, is more cumbersome with tkinter than with simple, good old tcl/tk.  I know there are other means of building a gui with python (wxwidgets, pygtk, pyqt, etc.), but I wanted to try the one most similar to that with which I am already familiar, and, I believe it is a fairer comparison when using a similar gui ToolKit.
At this juncture, I do have to say, I feel a great loyalty and deep affinity for tcl/tk.  I don’t understand why it isn’t in wider use, frankly.  It is an incredibly powerful language, used for a vast array of purposes, and, in my opinion, is probably the easiest programming language to learn (of course, I haven’t tried them all), especially for a beginning programmer.  One can be up and running, creating useful programs in a relatively short time.  I also feel the need to give kudoz to the tcl/tk community and the tcl.tk wiki, which is replete tons of example code, detailed explanations, and great resources for learning how to program in tcl/tk.  The tcl-ers that hang out at #tcl on irc.freenode.net, additinoally, are extremely helpful, and patient.  They won’t hold your hand, but they’ll tolerate a newbie, and point them in the right direction, without any snobbishness or derision.
I can’t say the same for my experiences with pythonistas.  Their irc channel was a little less friendly, imho.  Maybe I just caught them on a bad day, or maybe I was having a bad day.  After all, Pythonistas are known for having a sense of humor.  Admittedly, I was frustrated when I finally went to their channel for a bit of support, and frustrated, whiny n00b is no fun to play with, any way.  Moreover, the python community does have a lot of documentation available online. Nonetheless, to me, it seems that it is written for other programmers, not for the uninitiated, so, is not so easily read as much of the tcl/tk resources.  Their sample code is not well explained, where someone new to programming can really make sense of it. This may also be a function of time, since tcl/tk has been around a bit longer than python.
I do want to make it very clear: I’m really not here to pick on python.  I know that it’s a powerful language with a great many uses, and a favorite of a great many real hackers who know a lot more about programming than I do.  I will continue to learn to write it, and believe it will serve me quite well for various purposes, and I believe I will continue to have fun learning it.  But, I think I might continue to point out how tcl/tk is much easier and seemingly efficient, too…

Written by tonybaldwin

March 22, 2010 at 8:28 pm

iDenTweetyPie

leave a comment »

iDenTweetyPie

iDenTweetyPie: python/tkinter tweeter/denter

I hacked up a little more python/tkinter silliness.

iDenTweetyPie sends a dent/tweet(update) to twitter or identi.ca.

That’s all, really.

I have no plans to make a full-blown client for either site, just a quick-n-dirty updating tool. I would like, however, to figure out the pubsubhub thingy to send buzzes to google/buzz.

That would take some additionaly work, since, at the moment, iDenTweetyPie tells you that you talk too much and refuses to proceed if your update is longer than 160 characters, which, of course, isn’t necessary for buzz, since buzz tolerates longer updates.

I might work on that.  I don’t know.  This was just a little exercise, really.

I had already written a similar little program in tcl/tk, iDenTickle, which initially only did dents, but I have updated that one to send tweets, too.

my dents :  my tweets

./tony

Written by tonybaldwin

March 22, 2010 at 7:02 am