"Count the number of files in a folder (on the command line)"

Posted on 2008-10-24 at 17:53:08

ls -1 |wc -l


"How to show line numbers in the vi text editor"

Posted on 2008-09-28 at 17:05:06

I stole this verbatim from http://www.tech-recipes.com/unix_tips402.html

While editing a document (and not inserting text), type the following to turn on line numbers:

:set number

If you tire of the line numbers, enter the following command to turn them off:

:set nonumber


"Fixing the ACPI in Ubuntu on a Samsung Q45 laptop"

Posted on 2008-09-20 at 20:40:08

So I went to the Manchester Linux User Group today and a guy there called Owen graciously offered to fix the ACPI on my (Samsung Q45) laptop. To get Ubuntu to run, I had to shut off the ACPI, but this meant that I had no power monitor and that it wouldn't shut down smoothly (you always ended up having to turn it off manually). Anyway, he fixed it, but at the time, I had no idea how - he sent me this email afterwards explaining what he did:

N.B. - the original video.ko file was in /lib/modules/2.6.24-1-generic/kernel/drivers/acpi

Dear Darren,

I have removed the video.ko module from your current kernel:

(1) I put the module in a tree in /root's home directory to be sure we
still had it if it is needed.
(2) I then did 'depmod -a' to regenerate the kernel dependencies without
video.ko in the dependency list
(3) I then did 'update-initramfs -u -k 2.6.24-21-generic' to make certain
that the initial ramdisk used at boot time does not have this video
module in it.
I tell you this in case you need to do it again with the next kernel.

-- Owen

N.B. This will only fix it until the next kernel update at which point it may need doing again, but you can always repeat what you did if it starts playing up again.


"Uncompressing on linux using the command line"

Posted on 2008-08-29 at 14:20:59

I always forget this stuff, so this is just a quick reminder:

To uncompress a '.tar.gz' file:

tar -zxvf filename.tar.gz

I'll add more to this as I come across them...


"Little script to count the number of unique combinations using matlab"

Posted on 2008-08-09 at 15:55:41

Probably obvious to everyone else on the planet, but it took me a while to work it out, so here it is anyway for an array with 3 elements for which you want to know the number of possible unique combinations:


number = input('Enter number of elements\n>');
x = [1:number];

% Or you can just do x = [1 2 3]; or x = ['a' 'b' 'c']; or whatever you want...

count=0;

for i=1:numel(x)
count = count + size(nchoosek(x,i),1);
end

disp(count);

(Knowing my luck, I'll probably find that there's an existing function to do this somewhere, but I couldn't find it.)

I'm using this for my ion channel variation analysis on my model neurons (work, of course) and am just trying to see how many simulations I'll need to run with every possible combination of channels.
This shows that with three channels, I'll need 7 simulations, with 5 channels, I'll need 31 sims, but by the time I get to nine channels, it'll need 511 sims... oh dear - best get started then.


"This Site"

Posted on 2008-07-06 at 12:28:59

Well, it's been a slow process, but I've almost finished uploading all of my earlier blogs on to this new site. It shouldn't have taken anything like as long as this, but I've had more pressing concerns in the shape of a ever approaching PhD thesis deadline.

As you may also have noticed, I've started a second blog, not because I need some more work to occupy my time, but because I wanted to write about some of the techie stuff I've been up to. I wanted to separate it from my ordinary blog seeing as though I'm importing that one into Facebook (Can't imagine too many people will be interested in the finer points of installing Ubuntu on there for some reason).

And so the GeekBlog is born. Here, I'll be writing about linux and other nerdy topics, basically because they will be things that I have found out how to do and which I'm bound to forget how they were done in a few days time. This is mainly for my own reference, but also because I've found other people's blog's invaluable and hope that I can be of similar use to other people who are walking the same path.

DISCLAIMER: At present I'm a geek-grasshopper in the world of linux. I've only been using it occasionally at work for a couple of years and in that time have switched over from windows to windows/linux dual boot at home, then using linux and only using windows for games and now only buying games that work on linux (I'll mention some of these in later posts).

So, once I learn something, you'll be the first to know.... hell, nobody else will want to!


RSS