Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Tuesday, November 25, 2008

vimrc

Ryan just did a post asking to expose our VI settings to the world (wait, you all use VI, right?). I'm going to follow suit and throw mine out here. Surprisingly, for the amount of time I have spent in that editor, and how much I enjoy using it, my vimrc is rather sparse.

" Stop me from accidentally doing things when I click the stupid scroll-wheel
map
map <2-middlemouse>
map <3-middlemouse>
map <4-middlemouse>

" Prefer unix format
set fileformats=unix,dos
set fileformat=unix

" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible

" allow backspacing over everything in insert mode
set backspace=indent,eol,start

set cindent shiftwidth=4
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
set expandtab " Spaces, not tabs :-)
set autoindent
set smartindent
set nobackup " Live dangerously
set tags=$init\tags " Tags - the secret to life

Wednesday, July 2, 2008

Now I know I've lost my mind

Yep - it's gone. I've gone off the deep end into the esoteric world of geekdom. Even true geeks now laugh at how far gone I am.

I love learning new computer languages, I should do it far more often than I do. Practicality often gets in the way of my true self. I of course almost always learn with some form of a hello world. If you don't know what that is, quit reading. Seriously, you will only find yourself in pain from this point forward. Just quit.

While waiting for a backup to finish tonight, not particularly wanting to do anything else, I stumbled upon a Brainfuck page. I had actually been here before after linking there from Eric Raymond's (ESR) INTERCAL webpage (don't ask - it's easier that way).

So - I decided to write a hello world in Brainfuck...and I enjoyed it. I'm sick. Here it is:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
++++++++++++++++++++++++++++++++
>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
+++++++++++++++++++++++++++++++++
>
+++++++++++++
>
++++++++++
>
<<<<<<<<<<<<<< [.>]
Hopefully Blogger doesn't screw up the format. You'll probably think it did anyway, it basically just looks like line noise. I kid you not though, compile this bad boy (here's a link to the compiler I used), and it will output "Hello World!\r\n" (rendered appropriately by your terminal).

Only after I was finished did I go check out the wiki for Brainfuck, and see that they had their own version of a hello world.

Anyway, if you are sick like me, seek help. Otherwise, follow these steps to validate I'm not lying to you:

1. Download the compiler from the link above. Rename from bf.asm.txt to bf.asm.
2. Look at the assembly source and verify there is no voodoo trickery going on - it really is a compiler.
3. Run "nasm bf.asm" to create the bf executable (your compiler). Make it executable.
4. Copy my source into a file named HelloWorld.b or something similar.
5. Run "cat HelloWorld.b | bf > hell.elf
6. Run "./hell.elf"
7. Run screaming from the room as you realize what you have become.

Tuesday, April 22, 2008

Static Variables in Shared Libraries

I haven't posted for a while, and this isn't really a deserving post, so I apologize for that.

This is however, something I can never seem to keep straight in my head, so I'm throwing it out here to keep track of it for myself and possibly others.

How Static Variables within Shared Libraries (C or C++) Work Under Linux
Static variables within shared libraries for the most part work exactly as they do directly in an executable, on a per process basis. There is no consistency of value between multiple processes using the same shared library.

Each process will have all static data within these shared libraries initialized to zero, and then their scope will be maintained throughout the lifetime of that process, independent of other processes.


I have tested this empirically and found it to be true, and in line with how I theorized that it worked. If you know otherwise and can explain it to me (and shatter my understanding of the world) - I would love to hear it.

Wednesday, December 26, 2007

Super-cool web goodness

I always like when I run across some new web technology (no, I won't call it web 2.0). I'm still amazed daily at some of the stuff people can pull off. It's especially great when it does something very useful, in a very intuitive and clean way, and then a bonus when it is applied as a fairly old technology.

Lifehacker pointed me today to a site that allows you to take fully-interactive snapshots of any website. By snapshot, I mean it is literally as if you snagged a piece of the site verbatim. The throwback part is that it possible to create it as an image map, not just an actual graphic. All hyperlinks and images, as well as layout, are completely retained.

Obviously, there are some copyright issues to consider here. This is substantially different than just linking to a page. However, if you own the content, this is awesome. Here's a snapshot from this blog to show as an example:



I was initially just going to add this to my Google Reader shared items, but decided it was just too good and needed to be posted. However, I thought I would throw in here how much I am digging Google's new feature that shows your friend's shared items right in reader. It lets me basically have a feed of things I probably wouldn't run across, and they are from people who have mostly similar interests to my own. A very nice addition.

Tuesday, April 10, 2007

You Don't Care About This

I used to have a website where I posted random tidbits of information. I haven't bothered to resurrect it after I changed hosts, so I'm going to post something here instead. Thaddeus has posted random coding snippets in the past, so it must be cool.

Earlier today I found myself asking the question, "How do I tell if a statically linked application was built with glibc or uclibc?" The answers of course is:

"nm | grep _main | grep __"


Since you didn't ask, I've just told you.