Skip to content


MATLAB: Set working path at startup

Many times when MATLAB is started there is a certain program that you want to work on. In order to work on this program, the current directory or path of that program must be changed or set.  This little script here will prompt the user for the module to work on and then add that directory to the path listing. When MATLAB is terminated, that path will not be saved.

% startup.m

% Set Production Directoryprod='~/MATLAB/Production/';

% Prompt user for module namemodule=input('What module do you want to work on? ','s');

% If module is set, add to top of path. Otherwise don't addif ~isempty(module) path([prod,module],path);end
Place the startup.m in your MATLAB work directory.

Posted in Code, Matlab. Tagged with , .

Woah, October 10, 2010

Today I had a mind blowing realisation that any geek would appreciate. Not sure if its well known but it soon will be. The number 42, which in case you didn’t know, is the answer to everything, the universe and life, referring to The Hitchhiker’s Guide to the Galaxy (see here).

Next year, October 10, 2010 will be here and it can be written as 10/10/10. Or removing the slashes, 101010 which converting from binary to decimal form is 42. Woah. Yeah, woah. Will the answer to life appear on October 10, 2010. I dont know, but someone will make mad money making t-shirts.

I think the meaning will come from the web comic xkcd.com. In case you did not know, the ordinal values of xkcd add up to 42.

Get your tinfoil hat ready.

Posted in Thoughts.

MATLAB: Don’t ‘, transpose(it)

Doing a little homework for ME 7040, I discovered that there is more to transposing a matrix than just rows becoming columns and vice versa. I was doing a simple stress, strain, displacement analysis of a beam under static load. The code snippet in question is when the elemental stiffness matrix needed to be calculated by:

k = int(int(B'*D*B,r,-0.5,0.5),s,-0.5,0.5)

B is a 3xn matrix of shape functions and D a 3×3 relationship of Modulus of Elasticity and Poisson’s ratio. There is obviously more to this code, including the calculations of stress and strain and the writing of an output file.

Running the code using the prime (‘), the code took 143.106 seconds to run. I was initally confused by how long it took because the matrices were not that large. I then heard about the function transpose() and decided to use that. In code form:

k = int(int(transpose(B)*D*B,r,-0.5,0.5),s,-0.5,0.5)

This took only 19.735 seconds to run. So digging a little further, the operator ‘, also checks for complex conjugates of the matrix as well.

In conclusion, if you know that you are not dealing with complex numbers, you may want to use the transpose function and not its operator.

Tip: To time the running time of your code, put tic on the top line and toc on the last line.

Posted in Code, Matlab.

SCP + SSH: Copying files from Windows to Linux

At the university I attend, it is mostly all about Windows and there is no support for linux so many things have to be done by the user to get anything done. However, most linux users are used to trying this on your own. Here I will show you how to successfully transfer files from your linux box at home to a windows computer at work/school. Linux commands refer to Ubuntu. Please see your distro’s guide on installing packages.

Software Required:
Windows: Cygwin
Linux: openssh
Configuring linux box:
To install openssh, in terminal type
sudo apt-get install openssh-server
If the linux box is behind a router, please open the port corresponding to ssh. Default is 22. For more information please visit portforward.com.
To test the installation of ssh type:
ssh localhost
If everything works, then that should be up for setting up the linux box.
Configuring Windows:
After downloading setup.exe from the link above, double click to run. The important part of the installation is “Selecting Packages” diaglog box.
Expand the Net tree by pressing the +. Scroll down and look for openssh and click on “Skip” to change it to “Install”. You will notice a check box under column B. Click Next when finished and complete the installation.
Operating the Windows Box:
After installation, open cygwin and a terminal will appear. The syntax for scp is:
scp [options] [[user@]host1:]filename1 ...  [[user@]host2:]filename2
To copy ‘report.pdf’ from your Fall 2008 folder on your home directory, you would type:
scp report.pdf user@serverip:"/home/user/Fall 2008/" .
This will save report.pdf into your home directory. Notice the “.”
More Information:
Good Luck.

Posted in Tutorials, Ubuntu.

Conky: Display Last Pidgin Message

Recently, I removed the gnome-panels, added awn, and had a conky bar at the top. However, I missed having a system notification of when I would receive a message via Pidgin. So I browsed the pidgin wiki and create somewhat of a hack to display the last IM that received from Pidgin. This method is probably not the best way however I had some diffuculty.

The DBus method that listens for the received messages was chocking conky and not allowing the conky script to load correctly. So I had to create two files. getim.py would run at startup, listen for a new message and then write that message to a data file. lastim.py would be executed within conky and check the data file for the new message. I know its not real efficient and redundant but it just works. If you have any brilliant ideas please let me know.

Here is the getim.py file:

#!/usr/bin/python

# ----- GETIM.PY // LISTEN FOR AN RECEIVED MESSAGE ------------#
################################################################
# MOST OF THIS SCRIPT  WAS TAKEN FROM THE PIDGIN DEVELOPER WIKI#
# PLEASE VISIT http://developer.pidgin.im/ FOR MORE INFORMATION#
################################################################

def conky_im(account, sender, message, conversation, flags):
reg = '<(.|\n)+?>'                  # REGEX FOR HTML TAGS
message = re.sub(reg,'',message)    # REMOVE HTML TAGS
sender = sender.split("@")[0]       # GET GCHAT NAME
message = message[0:24]             # LIMIT TO 25 CHARS
file = ' '                          # LOCATION OF DATA FILE
fim = open(file,"w")
IM = sender + " said: " + message
fim.write(IM)
fim.close()

import dbus, gobject, re
from dbus.mainloop.glib import DBusGMainLoop
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()

bus.add_signal_receiver(conky_im,
                dbus_interface="im.pidgin.purple.PurpleInterface",
                signal_name="ReceivedImMsg")

loop = gobject.MainLoop()
loop.run()

Copy and paste the following and save as lastim.py:

#!/usr/bin/python

# SHOW LAST IM
f=" "                  # REPLACE WITH YOUR DATA FILE. ie.CONKYIM.DAT
fim = open(f,'r')
im = fim.read()
print im
fim.close

Finally, add this to your .conkyrc script

${execi 1 python ~/scripts/lastim.py}

Any questions/comments let me know. Here is a screen shot of what my conky looks like:

Posted in Code, Ubuntu.

Top Ten Radiohead Songs

My first experience with Radiohead, besides hearing Creep on the radio, was my brother playing The Bends album for me. At first I wasn’t a real fan, probably because the first song I heard I didnt like so didnt give them the time of day. I would randomly listen to their songs here and there but it wasn’t until this past year that I came to appreciate them more. I find myself listening to them the most and never get tired of them.

I decided to compile a list of top ten Radiohead songs with a link to a video and a listing of their lyrics. I bolded lyrics that particulary strike a chord with me. Enjoy!
  1. There There
  2. in pitch dark i go walking in your landscape.
    broken branches trip me as i speak.
    just because you feel it doesnt mean it’s there.
    just because you feel it doesnt mean it’s there.

    there’s always a siren
    singing you to shipwreck.
    (don’t reach out, don’t reach out)
    steer away from these rocks
    we’d be a walking disaster.
    (don’t reach out, don’t reach out)

    just because you feel it doesn’t mean it’s there.
    (there’s someone on your shoulder)
    just because you feel it doesn’t mean it’s there.
    (there’s someone on your shoulder)

    there there

    why so green and lonely?
    heaven sent you to me.

    we are accidents
    waiting waiting to happen.

    we are accidents
    waiting waiting to happen.

  3. Karma Police
  4. Karma police
    arrest this man,
    he talks in maths,
    he buzzes like a fridge,
    he’s like a detuned radio.

    Karma police
    arrest this girl,
    her Hitler hairdo
    is making me feel ill
    and we have crashed her party.

    This is what you get,
    this is what you get,
    this is what you get,
    when you mess with us.

    Karma police
    I’ve given all I can,
    it’s not enough,

    I’ve given all I can
    but we’re still on the payroll.

    This is what you get,
    this is what you get,
    this is what you get,
    when you mess with us.

    For a minute there
    I lost myself, I lost myself.
    Phew, for a minute there,
    I lost myself, I lost myself.

    For a minute there
    I lost myself, I lost myself.
    Phew, for a minute there,
    I lost myself, I lost myself.

  5. House of Cards
  6. I don’t want to be your friend
    I just want to be your lover

    No matter how it ends
    No matter how it starts

    Forget about your house of cards
    And I’ll do mine
    Forget about your house of cards
    And I’ll do mine

    Fall off the table,
    Get swept under
    Denial, denial

    The infrastructure will collapse
    Voltage spikes
    Throw your keys in the bowl
    Kiss your husband goodnight

    Forget about your house of cards
    And I’ll do mine
    Forget about your house of cards
    And I’ll do mine

    Fall off the table,
    And get swept under

    Denial, denial
    Denial, denial
    Your ears should be burning
    Denial, denial
    Your ears should be burning
    Denial, denial

  7. Fake Plastic Trees
  8. A green plastic watering can
    For a fake chinese rubber plant
    In the fake plastic earth

    That she bought from a rubber man
    In a town full of rubber plans
    To get rid of itself

    It wears her out, it wears her out
    It wears her out, it wears her out

    She lives with a broken man
    A cracked polystyrene man
    Who just crumbles and burns

    He used to do surgery
    On girls in the eighties
    But gravity always wins

    And it wears him out, it wears him out
    It wears him out, it wears him out

    She looks like the real thing
    She tastes like the real thing
    My fake plastic love

    But I can’t help the feeling
    I could blow through the ceiling
    If I just turn and run

    And it wears me out, it wears me out
    It wears me out, it wears me out

    And if I could be who you wanted
    If I could be who you wanted
    All the time, all the time

  9. Paranoid Android
  10. Please could you stop the noise, I’m trying to get some rest
    From all the unborn chicken voices in my head
    What’s that…? (I may be paranoid, but not an android)
    What’s that…? (I may be paranoid, but not an android)

    When I am king, you will be first against the wall
    With your opinion which is of no consequence at all
    What’s that…? (I may be paranoid, but no android)
    What’s that…? (I may be paranoid, but no android)

    Ambition makes you look pretty ugly
    Kicking and squealing gucci little piggy
    You don’t remember
    You don’t remember
    Why don’t you remember my name?
    Off with his head, man
    Off with his head, man
    Why don’t you remember my name?
    I guess he does….

    Rain down, rain down
    Come on rain down on me
    From a great height
    From a great height… height…
    Rain down, rain down
    Come on rain down on me
    From a great height
    From a great height… height…
    Rain down, rain down
    Come on rain down on me

    That’s it, sir
    You’re leaving
    The crackle of pigskin
    The dust and the screaming
    The yuppies networking
    The panic, the vomit
    The panic, the vomit
    God loves his children, God loves his children, yeah!

  11. Everything in its Right Place
  12. Kid A, Kid A
    Kid A, Kid A
    Everything
    Everything
    Everything
    Everything in its right place
    In its right place
    In its right place
    In its right place

    Yesterday I woke up sucking a lemon
    Yesterday I woke up sucking a lemon
    Yesterday I woke up sucking a lemon
    Yesterday I woke up sucking a lemon

    Everything
    Everything
    Everything
    Everything in its right place
    In its right place
    In its right place
    Right place

    There are two colours in my head
    There are two colours in my head
    What, what is that you tried to say?
    What, what was that you tried to say?
    Tried to say
    Tried to say
    Tried to say
    Tried to say

    Everything in its right place…

  13. True Love Waits
  14. I’ll drown my beliefs
    To have you be in peace
    I’ll dress like your niece
    To wash your swollen feet

    Just don’t leave
    Don’t leave

    I’m not living
    I’m just killing time
    Your tiny hands
    Your crazy kitten smile

    Just don’t leave
    Don’t leave

    And true love waits
    In haunted attics
    And true love lives
    On lollipops and crisps

    Just don’t leave
    Don’t leave

    Just don’t leave
    Don’t leave

  15. High and Dry
  16. Two jumps in a week,
    I bet you think that’s pretty clever don’t you boy?
    Flying on your motorcycle,
    watching all the ground beneath you drop
    You’d kill yourself for recognition,
    kill yourself to never, ever stop
    You broke another mirror,
    you’re turning into something you are not

    Don’t leave me high, don’t leave me dry
    Don’t leave me high, don’t leave me dry

    Drying up in conversation,
    you’ll be the one who cannot talk

    All your insides fall to pieces,
    you just sit there wishing you could still make love
    They’re the ones who’ll hate you
    when you think you’ve got the world all sussed out
    They’re the ones who’ll spit on you,
    you’ll be the one screaming out

    Don’t leave me high, don’t leave me dry
    Don’t leave me high, don’t leave me dry

    Oh, it’s the best thing that you ever had,
    the best thing that you ever, ever had.
    It’s the best thing that you ever had,
    the best thing you have had has gone away.

    Don’t leave me high, don’t leave me dry
    Don’t leave me high, don’t leave me dry
    Don’t leave me high,
    Don’t leave me high, don’t leave me dry

  17. Idioteque
  18. Who’s in a bunker?
    Who’s in a bunker?
    Women and children first
    And the children first
    And the children
    I’ll laugh until my head comes off
    I’ll swallow till I burst
    Until I burst
    Until I

    Who’s in a bunker?
    Who’s in a bunker?
    I have seen too much
    I haven’t seen enough
    You haven’t seen it
    I’ll laugh until my head comes off
    Women and children first
    And children first
    And children

    Here I’m alllowed
    Everything all of the time
    Here I’m allowed
    Everything all of the time

    Ice age coming
    Ice age coming
    Let me hear both sides
    Let me hear both sides
    Let me hear both
    Ice age coming
    Ice age coming
    Throw it on the fire
    Throw it on the fire
    Throw it on the

    We’re not scaremongering
    This is really happening
    Happening
    We’re not scaremongering
    This is really happening
    Happening
    Mobiles skwrking
    Mobiles chirping
    Take the money run
    Take the money run
    Take the money

    Here I’m allowed
    Everything all of the time
    Here I’m allowed
    Everything all of the time

    Here I’m allowed
    Everything all of the time
    Here I’m allowed
    Everything all of the time

    The first of the children

  19. Bodysnatchers
  20. I do not
    Understand
    What it is
    I’ve done wrong
    Full of holes
    Check for pulse
    Blink your eyes
    One for yes
    Two for no

    I have no idea what I am talking about
    I am trapped in this body and can’t get out
    Ooooohhhh

    You killed the sound
    removed backbone
    A pale imitation
    With the edges
    Sawn off

    I have no idea what you are talking about
    Your mouth moves only with someone’s hand up your ass
    Ooooohhhh

    Has the light gone out for you?
    Because the light’s gone for me
    It is the 21st century
    It is the 21st century
    It can follow you like a dog
    It brought me to my knees
    They got a skin and they put me in
    They got a skin and they put me in
    All the lines wrapped around my face
    All the lines wrapped around my face
    And for anyone else to see
    And for anyone else to see

    I’m a lie

    I’ve seen it coming
    I’ve seen it coming
    I’ve seen it coming
    I’ve seen it coming

    We’re not scaremongering
    This is really happening
    Happening
    We’re not scaremongering
    This is really happening
    Happening
    Mobiles skwrking
    Mobiles chirping
    Take the money run
    Take the money run
    Take the money

    Here I’m allowed
    Everything all of the time
    Here I’m allowed
    Everything all of the time

    Here I’m allowed
    Everything all of the time
    Here I’m allowed
    Everything all of the time

    The first of the children

Perhaps you can enjoy Radiohead as much as I do.

Posted in Uncategorized.

Dear NBC, I run Linux

After seeing the amazing comeback by Jason Lezak in the 400 free relay last night, I was eager to watch it this morning and relive the experience. However, I was disappointed when I clicked on “play video” and was unwelcomed with:


I run linux and am very very happy with it, but there are times where I feel almost neglected because of the operating that I use. Who knows, maybe there could be some discrimination suit against them.

But seriously, can someone enlighten me as to how hard it would be for them to make it available on linux systems?

Posted in Ubuntu.

Find Files in BASH

This is really just a reminder to me so I dont have to keep looking it up. Who knows, maybe you will find it useful.

To search folder and subfolders for python scripts.

find . -name “*.py”

Sweet now I wont forget.

Posted in Uncategorized.

Twitter Search: Because you want to know

Now you can find out specifically what everyone in the world is doing. Twitter has released its new search page. So of course, mad people are reading fourlovesfour.

Just another way to know what everyones doing.

Posted in Twitter.

The End of a Year: What I Learned

As some of you know, I have just returned home from a year of Volunteering in Chicago. As I reflected on this past year at the end of year retreat, I wrote this little essay:

When looking back at what I wrote at orientation for “Who am I” I noticed a few things. Many of the items listed were things and people who I loved, schools I attended, and even TV shows I enjoyed to watch. Yes all these things shaped me, but they weren’t who I was. Like many of the things listed, their importance are bounded by time. Time seems to be the hardest part to accept, especially for someone who’s undergraduate career was so technical and could predict failure over time in a design based on certain initial conditions. When I look around at the physical world, I believe everything is defined by an equation. Some are algebraic, while others are non-linear time independent polynomials which with some work can be solved and the result can be known beforehand. There is comfort for me in knowing this and it almost gives me a sense of power to have this ability.

My mind analyzes everything and systematically gives me results of perfection or how things should be. I grew up in a pretty safe environment and things always went my way. My brothers paved a wave for me growing up and I had a self confidence that sometimes bordered on cockiness and controlling.

I entered this year pretty excited about the work I was to do at St. Rita and I enjoyed every moment with those Rita men. Coaching flag football and swimming allowed me to see and listen to them outside of school. Being the sacristan of the chapel allowed me to show the students that mass is not always boring and what the parts of the mass actually mean. Retreats were my favorite part of my job, especially the senior kairos retreat, because of the transformation that I saw in them over four days.

Enough about what I did and my work. Being in ministry I know that I wont see the result of the work that I did which leads me to what I learned about myself, or more importantly how I changed. I mentioned earlier how I like to know or solve everything. I loved to hold the steering wheel of my journey with both hands. In my commitment statement during orientation I said I wanted to better understand myself through my community and to grow in faith, a faith which was already strong.

My community and this volunteer year has taught me something that is 22 years too late: Patience. Its the same thing that I wrote on my stone at mid-year. I know that everyone has trouble in their life but listening to my house mates at dinner and at community meetings was what I needed. Also going through some personal rejections myself helped. How about the patience that Amanda showed when Ms. Lee forgot to put the Christmas gift list in for her clients. The patience of Brett in dealing with students who misbehaved and the development of his prayer life. Claire’s patience with applying to graduate schools, the service club and the cancellation of the much anticipated car wash. Jeannie’s patience in dealing with the frustrations of turning a room with boxes full of books and dusty shelves into a welcoming library. Finally, the patience of Susan in dealing with those bratty eighth graders and the train so she could finally come home.

Patience fort me was something that I needed but I would not have been able to receive it with out a strong faith. With out my faith and patience, I would not have been able to deal with the losses and rejections that I had in my future goals that I thought were perfect. Fr. Tom, our site supervisor in one of his homilies said, “if you want to make God laugh, tell him your plans.” It was almost as if it was just me and him and he was saying to directly to me. I began to think about my own life and realized how things won’t always go the way you want it to, even though all the initial conditions are perfect. My mind, no matter how technical or practical it is, cannot possibly grasp the understanding of the future and its relation to time. Time seems to have the final word and the best way to deal with it is with patience.

At St. Rita’s commencement I heard the following quote which will help me come down the mountain of this volunteer year: “When you have come to the edge of all light that you know and are about to drop off into the darkness; Faith is knowing one of two things will happen. There will be something solid to stand on or you will be taught to fly.”

It was fun year, now welcome to the good life I guess.

Posted in Thoughts.