Archive for the 'Tip' Category
I occasionally use regular expressions, and when I don’t regret it. But it can be difficult to get the syntax and concepts straight in my head because I only use them occasionally.
The general purpose behind regular expressions is to take a piece of text and find smaller pieces of text within it that match a [...] Read more »
September 20th, 2011 | Posted in Tip | No Comments
When you are creating a plot in R, sometimes you have axis labels on the x axis. You can create custom ones with the axis function. If your labels are long, you can bring them apart using a newline character so they span multiple lines. But when you do this, it centers the text vertically [...] Read more »
August 30th, 2011 | Posted in Tip | No Comments
Let’s say you want to square a numeric value in Python. It’s a really easy solution. You use the ** operator. It works for whatever exponent you want.
x = 2
y = x**2 // 4
x = 10
y = x**2 // 100
x = 10
y = x**3 // 1000 Read more »
December 1st, 2010 | Posted in Tip | No Comments
I was seeing some weird behavior in Mac Mail. Sometimes when I would attach a file to an email message, it would truncate the text of my email message and attach the truncated text as a text file. This is problematic because the recipient may not realize that the text file contained the rest of [...] Read more »
October 14th, 2010 | Posted in Tip | 4 Comments
Sometimes you just need some extra vertical space in a LaTeX document. There are a couple of simple ways to approach this. This first is the vspace command:
\vspace{5 mm}
This approach gives you a lot of flexibility because you can specify exactly how large you want the vertical space to be.
However, sometimes, you simply want a [...] Read more »
January 13th, 2010 | Posted in LaTeX, Tip | No Comments
I came across an interesting summary of research that was performed at Microsoft regarding the effectiveness of commonly used software development practices, including test-driven development, code coverage, small teams, etc. It was interesting that the researchers tried to quantify how well these practices work, rather than rely on what supposed “experts” say. See the summary, [...] Read more »
October 8th, 2009 | Posted in Tip | No Comments
I had an occasion to learn a little about programming in C for the first time. One thing I needed to be able to do was save text to a file, but it was hard to find help for this on the Internet. This may be because it is called something slightly different in C [...] Read more »
September 9th, 2009 | Posted in Tip | No Comments
I am running an application in one location on the file system, and I need to be able to invoke an application that is in a different directory on the file system. Due to personal preference, this other directory is not specified in the PATH variable. So I’m wondering how I can get Linux to [...] Read more »
September 9th, 2009 | Posted in Linux, Tip | No Comments
In Linux, you sometimes want to run a command when the server first starts up. I was doing this recently where I would have to manually go in and run a command each time the server got rebooted. This was a pain, so with a little help from my friend Martin, I learned how to [...] Read more »
September 4th, 2009 | Posted in Linux, Tip | No Comments
In this post, I explain the problem of sorting strings that contain numbers. If you just sort values using the default approach, it will not work properly. For example, it will sort “a10″ before “a2″ even though in your application you may want it to consider the alphabetic characters separately from the numeric ones in [...] Read more »
August 19th, 2009 | Posted in Java, Tip | No Comments
In my last post, I explained a nifty way to invoke a function dynamically when you have the name of the function in a character object (in R). However, this didn’t explain how you could pass parameters to that function. I found a way to do this, which I will explain below, though it is [...] Read more »
August 12th, 2009 | Posted in Tip | No Comments
One way the R programming language has been described is that it is a functional programming language. Whether it would be called this by purists, I don’t know. But part of what this means is that all functions are treated as objects. So you can pass functions around very easily. This might sound strange, but [...] Read more »
August 11th, 2009 | Posted in R, Reflection, Tip | No Comments
LaTeX is a typesetting system that you can use to produce high quality documents. I’m starting to use it now to write my dissertation. It has a bit of a learning curve, but I’m thinking it will probably save me a lot of pain and anguish in the long run in writing my dissertation. I’ll [...] Read more »
August 7th, 2009 | Posted in LaTeX, Tip | No Comments
I recently had a scenario where part of what I wanted to do was in Java, and the other part was in an application that was written in Python. Rather than than rewrite my entire code base in one language or the other, I wanted to find a (quick and dirty) way to invoke the [...] Read more »
June 4th, 2009 | Posted in Java, Linux, Python, Tip | No Comments
In Linux, you have the ability to determine which processes are running at a given time on the server. This post explains how to do this using the top command.
Let’s say you have a process that is not getting as much CPU time as you would like, maybe because it is getting beat out by [...] Read more »
January 7th, 2009 | Posted in Linux, Tip | No Comments
Linux comes in many flavors. If you did not perform the installation (or forgot), you may need to find out which flavor is being run on a given box. In Linux, it is pretty easy to do this. Simply type the following command at the command line, and it will give detail about it:
cat /proc/version Read more »
January 6th, 2009 | Posted in Linux, Tip | No Comments
Sometimes you are working with an object in Python, and because Python is not a strongly typed language, you don’t always know which class it is an implementation of. A quick way to find out is to use the type method, which can be invoked on any object and gives you a String representation of [...] Read more »
December 31st, 2008 | Posted in Python, Tip | No Comments
In popular object-oriented languages such as Java and C#, they have a built-in method to each class that allows you to obtain a String representation of that class. They call these methods toString() or ToString(), respectively. You can use the default implementation, which basically gives you the name of the class (not usually very helpful). [...] Read more »
December 31st, 2008 | Posted in C#, Java, Python, Tip | 1 Comment
Let’s say you are running a query and that there is a one-to-many relationship between one of the columns in one table and a column in another table. You could always retrieve the data from the database and process it using a regular programming language, but sometimes you want to do it all on the [...] Read more »
December 30th, 2008 | Posted in SQL, Tip | No Comments
In Python, there is a bit of functionality that makes it convenient at times to process data while it is being processed inside another method. For example, let’s say you are searching for files within a directory that match a certain pattern, but you don’t want to wait the full time for the files to [...] Read more »
December 30th, 2008 | Posted in Python, Tip | No Comments