Here's two things you can do if you have tortilla chips and no salsa:
1. Buy some salsa
2. Open a can of corn and use it as dip. Tortilla chips are delicious with canned corn.
No joke, try it.
Saturday, February 6, 2010
Wednesday, January 20, 2010
Vim tabbed browsing settings
I've recently switched over from Windows 7 to Linux (Ubuntu), and I quite enjoy it. I have only on rare occasion booted up my Windows partition to play Half Life 2.
As for my text editor, I was originally using gedit, but now I've switched over to using vim. I found the shortcuts to be confusing at first but I'm slowly getting used to them. Very recently, I learned about how to open up multiple files and switch between them in a Vim session. You can use the command ':e filename' to open a file into a new "buffer" within your Vim session. To switch between the open files (buffers), you can use the commands :bn (buffer next), and :bp (buffer previous). You can close an open file with the command :bd (buffer delete).
Among many other settings, Vim lets you map/remap keys to commands. So, after typing :bp, :bn, and :bd for several days, I figured I would map a few keys so that manipulating the Vim buffers would feel just like using a tabbed program like Google Chrome or Notepad++.
Here are the settings if you wish to use them yourself:
noremap <silent> <C-Pageup> :bp<CR>
noremap <silent> <C-Pagedown> :bn<CR>
noremap <silent> <C-W> :bd <CR>
Ctrl-PageUp is always used to go left in a tab bar, so I have assigned it to open the previous buffer. Ctrl-PageDown is always used to go right in a tab bar, so I have assigned it to open the next buffer. Ctrl-W is always used to close a tab, so I have assigned it to delete the current buffer.
If you do not know how to set Vim settings, or what these settings mean, read on. To set these settings persistently (so that they are present every time you open vim), you can place them in your ~/.vimrc file. If that file doesn't exist, create it and paste those three lines in there. If it exists, just append them to the end of the file (and make sure these key mappings don't conflict with any existing key mappings).
To explain the settings:
As for my text editor, I was originally using gedit, but now I've switched over to using vim. I found the shortcuts to be confusing at first but I'm slowly getting used to them. Very recently, I learned about how to open up multiple files and switch between them in a Vim session. You can use the command ':e filename' to open a file into a new "buffer" within your Vim session. To switch between the open files (buffers), you can use the commands :bn (buffer next), and :bp (buffer previous). You can close an open file with the command :bd (buffer delete).
Among many other settings, Vim lets you map/remap keys to commands. So, after typing :bp, :bn, and :bd for several days, I figured I would map a few keys so that manipulating the Vim buffers would feel just like using a tabbed program like Google Chrome or Notepad++.
Here are the settings if you wish to use them yourself:
noremap <silent> <C-Pageup> :bp<CR>
noremap <silent> <C-Pagedown> :bn<CR>
noremap <silent> <C-W> :bd <CR>
Ctrl-PageUp is always used to go left in a tab bar, so I have assigned it to open the previous buffer. Ctrl-PageDown is always used to go right in a tab bar, so I have assigned it to open the next buffer. Ctrl-W is always used to close a tab, so I have assigned it to delete the current buffer.
If you do not know how to set Vim settings, or what these settings mean, read on. To set these settings persistently (so that they are present every time you open vim), you can place them in your ~/.vimrc file. If that file doesn't exist, create it and paste those three lines in there. If it exists, just append them to the end of the file (and make sure these key mappings don't conflict with any existing key mappings).
To explain the settings:
- noremap this is the command which tells vim we are performing a key-mapping. This particular command means that Vim will attempt to make the key mapping work in all modes other than INSERT. Meaning that it will work when you are in command mode, visual mode, and operator pending mode.
- <silent> means that Vim will execute the command without printing it on the command line (at the bottom of the screen) or putting it in your command history.
- <C-Pageup> this is the keyboard command we want to map. C stands for Ctrl.
- :bp this is the Vim command we want to execute when the key command (e.g. Ctrl-Pageup) is pressed.
- <CR> We add this for convenience. This executes a carriage return right after our command. Without this, we would have to press Enter after pushing our keyboard command (e.g. Ctrl-PageUp) to have the Vim command get executed.
Friday, November 6, 2009
Terrible idea for generating random numbers
The Operating Systems course I am taking has just finished going over threading and concurrency, and it introduced me to multiplexing and thread scheduling. For whatever reason, I was thinking about random number generation the other day, and I thought: what if random numbers could be produced by making use of the nondeterminism of thread concurrency?
My idea:
To produce a random integer from 1 to N, create one global variable and run N threads in parallel. Each thread has a unique ID number ranging from 1 to N, and at each iteration of the thread's while loop, it tries to write its ID number to the global variable. In this way, the global variable's value will keep changing nondeterministically. To get a random number, just read the value of the global variable.
Result:
It works! It's an utterly horrible way to generate random numbers, but hey, it was just an experiment.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
UPDATE:
After running the program for around 10 hours, and generating random numbers from 0-9 (inclusive) at around 3-4 numbers per second (over 100,000 numbers), the average of all the numbers was around 4.38. This isn't bad considering the target average for this range of numbers is 4.5.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Source code (Java 1.6) can be found here:
http://www.romanstolper.com/files/RandomThreads.java
My idea:
To produce a random integer from 1 to N, create one global variable and run N threads in parallel. Each thread has a unique ID number ranging from 1 to N, and at each iteration of the thread's while loop, it tries to write its ID number to the global variable. In this way, the global variable's value will keep changing nondeterministically. To get a random number, just read the value of the global variable.
Result:
It works! It's an utterly horrible way to generate random numbers, but hey, it was just an experiment.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
UPDATE:
After running the program for around 10 hours, and generating random numbers from 0-9 (inclusive) at around 3-4 numbers per second (over 100,000 numbers), the average of all the numbers was around 4.38. This isn't bad considering the target average for this range of numbers is 4.5.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Source code (Java 1.6) can be found here:
http://www.romanstolper.com/files/RandomThreads.java
Monday, November 2, 2009
Analysis of a word game
There is a word game which is played like this: When it's your turn, you say a word that starts with the last letter of the previously said word as quickly as you can. The player to start the game can choose any word to say. This is a noncompetitive game, and there is no real winner or loser, you just play until you don't feel like playing anymore. I used to play this with my mom when I was young.
I played this game with a few friends earlier in the semester, and during the game we noticed that we kept saying words that end with 'E', and soon enough we began having difficulty thinking of words that start with 'E'.
I got to thinking about the patterns we encountered and decided to take a look at what Wikipedia knows about letter frequencies:
Wikipedia - Relative frequencies of letters in the English language
The article shows that 'E' is the most common letter in the English vocabulary, followed in second place by 'T'. However, this only describes the frequency of appearance of a letter, irrelevant of a letter's location within the word.
I was specifically interested in pinpointing the frequencies of letters appearing at the beginning and at the end of words, so I decided to do some quick scripting on a dictionary file. I got the following results on a ~32,000 word dictionary file (Source: http://wordlist.sourceforge.net/):
Top 5 letters at the END of a word:
E (5866)
N (2907)
T (2865)
Y (2772)
R (2026)
This seems to follow, somewhat, with the data in the Wikipedia article: E is the most common appearing letter, and T is very close to second place.
Top 5 letters at the BEGINNING of a word:
S (3590)
C (2921)
P (2481)
A (1886)
D (1855)
'E' is nowhere near being in this Top 5 list. I don't show it here, but it's in 13th place with a measly count of 1205. That means that there are around: 5866/1205 = ~5 times as many words that end with E than start with E.
This data gives some indication as to why we had a lot of words ending with E, and why we had more trouble thinking of words starting with E.
Of course, if we look at absolute numbers, 1205 words beginning with E is more than enough to choose from, so I guess we don't have too good of an excuse.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Some more fun letters to compare:
K-end (621) vs. K-start (209). K words are pretty tough.
The situation is even worse for X...
X-end (120) vs X-start (9). Wow, only 9! I could spend some time learning words that end with X and then no one will ever want to play this game with me again.
Z is pretty cool. Unlike most of the other letters, more words start with Z (48) than end with Z (30).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Source code (PHP) for the code script can be found here (includes the dictionary file - but please be aware of its original source):
http://www.romanstolper.com/files/lettercount.zip
I played this game with a few friends earlier in the semester, and during the game we noticed that we kept saying words that end with 'E', and soon enough we began having difficulty thinking of words that start with 'E'.
I got to thinking about the patterns we encountered and decided to take a look at what Wikipedia knows about letter frequencies:
Wikipedia - Relative frequencies of letters in the English language
The article shows that 'E' is the most common letter in the English vocabulary, followed in second place by 'T'. However, this only describes the frequency of appearance of a letter, irrelevant of a letter's location within the word.
I was specifically interested in pinpointing the frequencies of letters appearing at the beginning and at the end of words, so I decided to do some quick scripting on a dictionary file. I got the following results on a ~32,000 word dictionary file (Source: http://wordlist.sourceforge.net/):
Top 5 letters at the END of a word:
E (5866)
N (2907)
T (2865)
Y (2772)
R (2026)
This seems to follow, somewhat, with the data in the Wikipedia article: E is the most common appearing letter, and T is very close to second place.
Top 5 letters at the BEGINNING of a word:
S (3590)
C (2921)
P (2481)
A (1886)
D (1855)
'E' is nowhere near being in this Top 5 list. I don't show it here, but it's in 13th place with a measly count of 1205. That means that there are around: 5866/1205 = ~5 times as many words that end with E than start with E.
This data gives some indication as to why we had a lot of words ending with E, and why we had more trouble thinking of words starting with E.
Of course, if we look at absolute numbers, 1205 words beginning with E is more than enough to choose from, so I guess we don't have too good of an excuse.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Some more fun letters to compare:
K-end (621) vs. K-start (209). K words are pretty tough.
The situation is even worse for X...
X-end (120) vs X-start (9). Wow, only 9! I could spend some time learning words that end with X and then no one will ever want to play this game with me again.
Z is pretty cool. Unlike most of the other letters, more words start with Z (48) than end with Z (30).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Source code (PHP) for the code script can be found here (includes the dictionary file - but please be aware of its original source):
http://www.romanstolper.com/files/lettercount.zip
Wednesday, August 19, 2009
A bold space
A piece of code I just ran into: <strong> </strong>.
Hah.
I'm not very fond of WYSIWYG html editors - from what I've seen, they produce ugly and bloated code. Perhaps recent versions of such products are intelligent enough to produce quality code. Dreamweaver CS4 will run you $399 by purchasing from the Adobe website, and I sincerely hope that it produces some darn clean code for that price.
Until then, I'll be using a glorified text editor and PHP/SSI includes.
Saturday, August 8, 2009
RSS Addiction (Part 2)
In my previous post about RSS addiction, I talked about how I can't stop adding feeds to my reader. I finished off the post by mentioning that my total count of unread items is so huge that it makes me feel hopeless about ever reading everything I've subscribed to. Since the time of that post, I have subscribed to more feeds, and my unread count has grown significantly. Right now, I don't even know how many unread items I have. No, really; the feeling of helplessness had gotten so unpleasant that I have turned off display of unread counts. If I don't see how large the number is, it can't disappoint me as much. This is my first step towards enjoying my feeds more.
Unfortunately for me, the intimidating unread count is merely the tip of the iceberg. I'm the type of person who feels that the proper way to a read a blog is chronologically, which means that my number of unread items is more probably in the thousands. I believe in reading chronologically for two main reasons:
- Blog writers will often reference their previous blog posts (such as my link at the top of this post). If an earlier blog post is referenced, this usually implies that the user could benefit by reading (or having read) it. If you're reading reverse-chronologically, and decide to follow a reference, your flow is broken - your reading of the current post gets interrupted. Furthermore, you're jumping to some point in the blog which is (most likely) not near your previous location, and you begin to lose an understanding of how much and what part of the blog you've actually read (OK, this might be an indication of slight OCD). And then, what if the referenced post references another post? You make another jump. And what if the writer references several posts?
- Often, my intent is to read every blog post, to exhaust everything a blog has to offer. Or, to be more specific, I don't want to miss anything. It's like reading the "choose your own adventure" novels as a child - you can't just follow one path and stop reading, you read through all the endings so that you don't miss any possibilities. Now I'm all grown up and I can't get into a blog without first finishing its archives. So, given that I wish to not miss a single article, let's assume that I will indeed finish reading all the articles. If I'm going read every post, it clearly makes more sense to read the articles in the order that they were posted, rather than in reverse (especially for the reasons mentioned in point #1).
The problem, however, lies in the assumption in point #2 that I will finish reading all the articles. Some blogs have such extensive archives that finishing them is too daunting a task. I've recently started reading the Coding Horror archives. Today I took a look at the task ahead of me, and I was shocked to find that the archive list was gigantic. The scrollbar was tiny (that was the first thing I noticed). The archives begin around the start of 2004, and the post frequency is almost daily. I was disappointed by the realization that it would take me far too long to finish this blog's archives.
Now, I want to consider my reaction upon seeing the blog's archives, as well as my regard for reading the archives as a "task ahead of me." I notice that when I am reading through a blog's archives I am not enjoying myself. I feel like I am performing a chore - doing something that needs to be completed before I can do what I want to do. Although I desire to read through the archives before I can follow the new content, this desire is not spawned by enjoyment that the task brings me. Rather it is spawned as an attempt to avoid the unsettling feeling of incompleteness. The entire time I spend going through archives, I am only waiting for them to be over, to be able to just keep up with the latest updates. For this reason I was disappointed at seeing the extensive Coding Horror archives; it meant that I had a lot of work ahead of me before I could enjoy the blog.
This is not a healthy way to approach and read a blog - I have to rethink my methods. I need to scrap my desire to read chronologically. I need to suppress the feeling brought about by following a blog I haven't "completed." I recognize that what I enjoy about a blog is keeping up with updates, and what I don't enjoy is putting that off until I can finish the archives. What I have just done (I did it just now while writing this post) is I have marked everything in my Google Reader as read. Zero unread count! Yay. This will help me see recent updates, and keep up with them as I enjoy doing. As for archives, they'll be sitting on the backburner, to be read after I've seen the latest updates, bit by bit.
What a simple solution! Now to wait and see if it works...
Friday, June 5, 2009
RSS Addiction
Just last week I started using Google Reader. I had always seen the little orange symbols on blogs and webcomics, but I had never taken the time to figure them out. RSS? Atom? What? I hadn't felt a need to figure these out, and so I didn't bother.
I started reading webcomics a few years ago. It began with a single comic - xkcd. Once I had finished the xkcd archives and was at the point of waiting on updates, I was hungry for more. I found Questionable Content by Jeph Jacques (through Randall's "Comics I enjoy" paragraph at the bottom of his page), and Nothing Nice To Say by Mitch Clem (which I have no idea how I found). And when those archives were exhausted, I went on to find more comics. Fast forward to this summer, and I'm going crazy with the webcomics. My comic bookmarks have exploded to number more than 20, and I'm starting to forget which ones I have checked for updates and which ones I hadn't. Some of the comics update once a week, some twice a week, most three times a week, and others every day. And what if I accidentally missed an update! What then? Well, I would press the 'previous' button every time I checked for updates to make sure I hadn't missed any.
This process began to grow very tedious, and so I looked into something I had faintly heard of before - RSS readers. Satisfied with Google products, I checked out Google Reader. It was so easy to use! So simple to understand! I could drag and drop links from my bookmarks and there they would sit in my reader, just yearning to show off their updates to me. Gone were the days of trying to remember which comics were updated when, and gone were the worries of missing updates.
Unfortunately, this has recently grown into an addiction. Nowadays when I visit a webcomic or a weblog that I enjoy, or even just think I would enjoy, I'll add it to my reader. This creates a terrible feeling of hopelessness; I have 175 unread items, and they grow faster than I can read them. But that doesn't stop me from relentlessly hoarding more and more feeds. I mean, I could always unsubscribe if I wanted to.
I started reading webcomics a few years ago. It began with a single comic - xkcd. Once I had finished the xkcd archives and was at the point of waiting on updates, I was hungry for more. I found Questionable Content by Jeph Jacques (through Randall's "Comics I enjoy" paragraph at the bottom of his page), and Nothing Nice To Say by Mitch Clem (which I have no idea how I found). And when those archives were exhausted, I went on to find more comics. Fast forward to this summer, and I'm going crazy with the webcomics. My comic bookmarks have exploded to number more than 20, and I'm starting to forget which ones I have checked for updates and which ones I hadn't. Some of the comics update once a week, some twice a week, most three times a week, and others every day. And what if I accidentally missed an update! What then? Well, I would press the 'previous' button every time I checked for updates to make sure I hadn't missed any.
This process began to grow very tedious, and so I looked into something I had faintly heard of before - RSS readers. Satisfied with Google products, I checked out Google Reader. It was so easy to use! So simple to understand! I could drag and drop links from my bookmarks and there they would sit in my reader, just yearning to show off their updates to me. Gone were the days of trying to remember which comics were updated when, and gone were the worries of missing updates.
Unfortunately, this has recently grown into an addiction. Nowadays when I visit a webcomic or a weblog that I enjoy, or even just think I would enjoy, I'll add it to my reader. This creates a terrible feeling of hopelessness; I have 175 unread items, and they grow faster than I can read them. But that doesn't stop me from relentlessly hoarding more and more feeds. I mean, I could always unsubscribe if I wanted to.
Subscribe to:
Posts (Atom)