Archive for the 'Programming' category

Using TextMate to process text lines

Aug 25 2010 Published by aaron under Apple, Programming

Recently I have been using one my favorite text editors on my mac to process some text lines. Below is a list of some commands I found useful:

Lowercase every character: tr [:upper:] [:lower:]
Sort the lines: sort
Show only unique lines: uniq

No responses yet

Modifying the Trac email notification file to show a custom date format

Jul 20 2010 Published by aaron under Programming, Sysadmin

I really like the Trac project management software. Recently I have been using it very much and customizing it to fit my needs at work. In regards with the notification system, I found that the default format was not acceptable and a custom one was desired. I added the following code to the file "/usr/lib/python2.4/site-packages/trac/ticket/templates/ticket_notify_email.txt" to have a nice date in the template:

{% python

    from genshi.builder import tag
    from trac.util.datefmt import format_datetime
    import time

    def custom_time(value):
        return format_datetime(t=value, format='%H:%M:%S', tzinfo=PST)

%}

${custom_time(ticket.time)}

My entire file looks like the following:

{% python

    from genshi.builder import tag
    from trac.util.datefmt import format_datetime
    import time

    def custom_time(value):
	return format_datetime(t=value, format='%Y-%m-%d %H:%M:%S', tzinfo=PST)

%}
{% choose ticket.new %}\
{%   when True %}\
On ${custom_time(ticket.time)} PST, a ticket with the summary of '$ticket.summary' was created by '$ticket.reporter' and assigned to $ticket.owner .
{%   end %}\
{%   otherwise %}\
{%     if changes_body %}\
${_('Changes (by %(author)s):', author=change.author)}

$changes_body
{%     end %}\
{%     if changes_descr %}\
{%       if not changes_body and not change.comment and change.author %}\
${_('Description changed by %(author)s:', author=change.author)}
{%       end %}\
$changes_descr
--
{%     end %}\
{%     if change.comment %}\

${changes_body and _('Comment:') or _('Comment (by %(author)s):', author=change.author)}

$change.comment
{%     end %}\
{%   end %}\
{% end %}\

--
${_('Ticket URL: <%(link)s>', link=ticket.link)}
$project.name <${project.url or abs_href()}>
$project.descr

No responses yet

Looping through multiple select list box items in a Microsoft Access form and inserting the values into a table using VBA

May 11 2010 Published by aaron under Programming

The Setup

You have two multiselect list boxes and you want to insert their combined values into a table. Here is an example:

  • List box 1
    • birds
    • trees
    • frogs
  • List box 2
    • type a
    • type b

When you select "birds, trees" and "type a" the following select statements will be executed:

  1. "INSERT INTO tableA (name, value) VALUES ("birds", "type a")"
  2. "INSERT INTO tableA (name, value) VALUES ("trees", "type a")"

Here is the following VBA Script to do the above:

Private Sub Command4_Click()
Dim varRoles As Variant
Dim varRole As String
Dim varUserNames As Variant
Dim varUserName As String

Dim strSQL As String

For Each varRoles In Me.Role.ItemsSelected
'MsgBox "we got one role!"
varRole = Me.Role.ItemData(varRoles)

For Each varUserNames In Me.UserName.ItemsSelected
varUserName = Me.UserName.ItemData(varUserNames)
'MsgBox "we got username: " & varUserName & ", mapped to role: " & varRole

'execute statement
CurrentDb.Execute "INSERT INTO jointable (names, roles) VALUES ('" & varUserName & "', '" & varRole & "')"
Next varUserNames
Next varRoles

End Sub

No responses yet

Undo a change in emacs

Apr 29 2010 Published by aaron under Programming

How to undo an emacs change:

C-_

No responses yet

Setting your proxy server variable in Emacs

Apr 21 2010 Published by aaron under Programming

To set your proxy server in Emacs, type the following in a empty buffer:

(setenv "http_proxy" "http://your.proxy.server.com:8080")

Then execute the lisp code in the current buffer with:

M-x eval-current-buffer

No responses yet

Older posts »