tonybaldwin | blog

non compos mentis

Posts Tagged ‘tcl

Preview of Xpostulate Improvements

leave a comment »

A preview of what’s to come…

Thinking of UI enhancements, I added the Xpostulate little icon thingy right into the GUI.

What do you think?

Other items on their way:

  • Posterous support. I have interacted with the posterous api via bash with curl, so, just need to translate my scripting for that to tcl with http. Cake, but requires time. I thought I would have that done this past week, but, no joy…too much work (somebody’s gotta pay the rent around here).
  • Blogger support. – The great and benevolent Google® has granted me an API key, and I have looked at the API, but not yet played with it, but this is likely to come this season…soon, me dro0gies.
  • Read your statusnet public timeline or updates from a specific person. This I have, again, done in bash, so just a matter of coding it into tcl. Although, I question if this is appropriate for Xpostulate, and whether it might not be better to do this with iDenTickles only, since iDenTickles is a microblogging client, and Xpostulate is intended for crossposting to blogs, not reading others’ updates.
  • Download, edit, & republish older entries. This is on my todo list, but for each blogging service I have to look at how their API handles this, and then code stuff in, and develop new GUI elements for housing various functions, and blah, blah, blah. It will be work..heavy lifting…but it’s on my TODO list.

posted with Xpostulate

Written by tonybaldwin

September 24, 2011 at 10:16 pm

Fren.Tcl and Frendi.Sh

with 3 comments



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 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 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:


# 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. " url

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

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

# 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"
	echo "Success!"
	echo $ud

# 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

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


Fren.Tcl - tcl/tk Friendika posting application

Find me on Friendika here.


Written by tonybaldwin

September 14, 2011 at 8:27 am

Get me some learnin' (MIT Open Courseware)

leave a comment »

So, I decided,”Enough with the tinkering with the hackery…Time to start learning for real.”, and started to take this course (Introduction to Computer Science and Programming) through MIT’s Open Courseware.

So far, I haven’t even “attended” the first lecture (watch a video), but skipped ahead to the first assignment, being like that, and jumped right to solving it. The assignment was to create a program, in any language, that asks the user for their last name, then first name, then prints back the first name, then last name. I did it in 6 different languages, just for fun. 😀

First python:

#!/usr/bin/env python

# first assignment for MIT intro comp sci class.
# Problem Set 0
# Name: Tony Baldwin
# Collaborators: none
# Time: 0:30

last = raw_input("Please enter your last name:  ")
first = raw_input("Please enter your first name: ")
print("Hello, " + first + " " +  last + "!")

Then bash:


# MIT Intro to CS & Programming, assignment 1
# by tony baldwin

read -p "Please enter your last name: " last
read -p "Please enter your first name: " first
echo Hello, $first $last!

Then lisp:


; MIT Intro to CS & Programming, assignment 1
; tony baldwin

(format t "Please enter your last name: ")
    (let ((last (read)))
(format t "Please enter your first name: ")
     (let  ((first (read)))
     (format t "~%Hello, ~A ~A!" first last)))

Then tcl:

#!/usr/bin/env tclsh8.5

# MIT Intro to CS & Programming, assignment 1
# by tony baldwin

puts "Please enter your last name: "
gets stdin last
puts "Please enter your first name: "
gets stdin first
puts "Hello, $first $last!"

Then perl:

#!/usr/bin/perl -w
use strict;
# MIT Intro to CS & Prog
# assignment PS0

print "Please enter your last name: ";
chomp($last = );
print "Please enter your first name: ";
chomp($first = );
print "Hello, $first $last!\n";

And now, some ruby:


# MIT Intro to CS & Programming
# assignment ps0

puts "Please enter your last name: "
last = gets
puts "Please enter your first name: "
first = gets
puts "Hello, " + first.chomp + " " +  last.chomp + "!"

I do know that eventually I will have to attend the lectures, but this first assignment seemed rather straightforward.

I was motivated to start really learning my hackery when, a couple of nights ago, I started to look at lisp.  Something in the sparse efficiency of lisp struck me as, well, striking. Beautiful, even. Weird…


Written by tonybaldwin

September 1, 2011 at 6:18 am

Bashful, Ticklish Snoozing (sleeping with bash and tcl)

leave a comment »

So, sometimes you want to take a snooze, or, maybe time something else (like that bacon explosion in the oven).  We can use the bash command “sleep” to help us out.  Something as simple as:

sleep 600 ; echo ‘Hey, get the bacon out the oven, d00d’ &

That will wait 10 minutes (600 seconds), and then print ‘Hey, get the bacon out the oven, d00d’ to your terminal.  The only thing is, that terminal is waiting, and you can’t do anything else in it, so you open another, and then never see the message.  Useless, really… But, say we’re going to take a nap, and we just want to be awakened in an hour.  We won’t be using the terminal (and a printed message isn’t going to wake us up).

Let’s play tunes, instead then!  This one will require mplayer.

sleep 3600 ; mplayer ~/Music/roxors/opeth/blackwater_park/08_blackwater_park.ogg

That’ll get you going!  In one hour, mplayer will pipe up with Opeth’s BlackWater Park! (If that doesn’t wake you, you’ve probably died in your sleep).

Clearly, the path to YOUR Opeth collection may be different, but you get the point.

Now, you could facilitate the whole process with a little script. I have:

# snooze time
echo “How long ya want, pal?”
read m
secs=$(($m * 60 ))
echo Okay, that gives us about $secs seconds
echo Then we will play the Imperial March.
echo Make sure the speakers are on and turned up.
echo That will get you going.
sleep $secs ; mplayer ~/tunes/starwars/03-star_wars_the_empire_strikes_back-the_imperial_march.mp3 &

Or, we can wrap that up in a little gui with some tcl/tk.


# sleep timer with musical wake-up

# set vars

global count
global secs
global tunage

set count “0”
set mins “0”
set secs “0”
set tunage “none”

set filetypes {
{“All files” * }
{“MP3” {.mp3}}
{“OGG” {.ogg}}

# gui

wm title . “Snooze Timer”

grid [ttk::label .secs -text “Minutes:”]\
[ttk::entry .min -textvariable mins]

grid [ttk::button .bu -text “seconds: ” -command sex ]\
[ttk::label .bn -textvariable secs ]

proc sex {} {
if {[catch {
set ::secs [ expr {$::mins * 60} ]
}]!=0} {
set ::secs “?”

grid [ttk::button .chtune -text “Choose song:” -command chutu]\
[ttk::entry .tuna -textvariable tunage]

grid [ttk::button .go -text “SNOOZE” -command snooze]\
[ttk::button .stop -text “QUIT” -command exit]

proc calcu {} {
exec tcalcu

proc chutu {} {
global tunage
set tunage [tk_getOpenFile -filetypes $::filetypes -initialdir “~/Music”]

proc snooze {} {
set snooz “sleep $::secs ; mplayer $::tunage”
exec sh -c $snooz &

That gives you a little gui that sets the time, and even allows you to pick a song (in the image, I picked Ministry’s “Jesus Built My Hot Rod“).  It has a file chooser to pick the song.  You just feed it a number of minutes (press the button to calculate seconds), pick a song, click snooze, and kick back.  After your chosen time interval, your chosen tune will come on and wake you! (or remind you to get the bacon explosion out of the oven).


Written by tonybaldwin

February 2, 2011 at 7:59 am

Posted in free software, gnu/linux, hacking

Tagged with , , , ,

iden.tcl v. 1.0 released

leave a comment »

Moments ago, I released a new version of IdenTickle, the tcl/tk and twitter status update tool..

Now it saves your login information, so you don’t have to enter it every time.
Additionally, I built installers for Windows and Linux.
(Mac and BSD folks, etc., will still have to install from source…sorry).

Written by tonybaldwin

May 20, 2010 at 8:06 pm

dent, tweet, xpost – all in one

leave a comment »

Tweeting and Denting are now incorporated within the eXpostulate interface, so you can really annoy all your online friends, by x-xposting to 4 distinct blogging services, & denting and tweeting to announce your new articles!

At this moment, the denting/tweeting is still using curl, however, which is only native to * nix systems (should work on lin/bsd/mac without further configuration, but win users will have to install curl, which can be done, of course).

I will be attempting to work out tweeting/denting with tcl’s own http post method. I’ve tried a few times, but unsuccessfully, so far. Need to log on to #tcl at freenode and get some help, or something.
Additionally, I have also added some additional html tag insertion tools and insertion of dreamwidth specific user and cut tags.


Written by tonybaldwin

March 27, 2010 at 12:00 pm

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
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 25, 2010 at 9:29 pm