Finding files newer than a certain date / time

October 11, 2011

Today I needed to find all files in a directory tree that had been updated since a specific point in time.

After a few trials this solution worked perfectly.

Create a file “touched” at the date you want to start from.

Then do a “find” that uses this file’s timestamp as a reference.

As simple as:

touch -t 201109130845 start-file.tmp
find messages/ -newer start-file.tmp


Rails 3 on debian with Sqlite 3

October 13, 2010

Decided to move to Rails 3 recently and get up to speed on the new framework version.

I list here the process I followed to install it on Debian (Lenny).

*Note, some of these commands need root / administrator privileges. Notably the apt and install commands. Use sudo, su or a root shell.

Install dependancies

# optional VCS, we use Mercurial Locally and Git for deployments to Heroku (hosting)

apt-get install git-core mercurial

# libmysqlclient15off libreadline5-dev
apt-get install build-essential libreadline5-dev libssl-dev zlib1g zlib1g-dev

#optional Database, I have detail for getting Sqlite3 later
#apt-get install mysql-common mysql-server

Install Ruby

wget ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.2-p0.tar.gz
tar xzf ruby-1.9.2-p0.tar.gz
cd ruby-1.9.2-p0
./configure
make
make install

Install sqlite 3

wget http://www.sqlite.org/sqlite-amalgamation-3.7.2.tar.gz
tar xzf sqlite-amalgamation-3.7.2.tar.gz
cd sqlite-3.7.2/

./configure
make
make install

gem install rails sqlite3-ruby

Create your rails app

rails new Items
rails g scaffold Item name:string detail:text
rake db:migrate
rm public/index.html
vim config/routes.rb

add this line:

root :to => "items#index"

then start the server:

rails s

Open your browser and go to http://localhost:3000/

And that’s it!


Deploying your Rails 3 app to Heroku from Debian GNU/Linux

October 11, 2010

Deploying apps to Heroku is as simple as

git push heroku master

But you need a little bit of setup first.

If you haven’t got git, install it with

apt-get install git-core

You will also need the Heroku gem

gem install heroku

Then set up your app, adding the files to the git repository

cd myapp
git init
git add *
git commit -m 'first commit, using git for pushes to heroku which hosts rails apps free and uses git'

Create a key for secure authentication to Heroku

ssh-keygen -t rsa -C "me@mycompany.com"
heroku keys:add

Create your heroku app

heroku create

And push your new rails app to it

git push heroku master

Now browse to the url you were given in previous steps as feedback from heroku, and you should see your app, now live !


Favicon/URL/Bookmark icon for you website

October 7, 2010

You can easily create a bookmark icon / URL icon / Domain Icon / favicon.ico for your website.

This is usually called favicon.ico, and usually exists in your web root folder (htdocs, public_html, etc).

Why would you do this?

  1. Your Brand is present in the users Browser URL/URI field in browsers and/or on the browser window or tab title
  2. Your Brand is present in the users browser bookmarks
  3. You user can easily find Your Brand in their bookmarks list – from my perspective, this is a big win.
    1. I have a couple of options bookmarked for the types of online service I use most, and in the cases where one of the sites has no favicon and another does, I inevitably end up using the site that has the favicon, simply because their favicon stands out immediatly in my list of bookmarks.

Your favicon can be a .ico, .gif or .png file.

I use .png more and more. I use a 32×32 pixel file but you can use 16×16 also.

http://en.wikipedia.org/wiki/Favicon

Generally, for the simple/default case, you just name the icon as “favicon.ico” and upload it to the root directory of your website. The broswers will check for it there (http://www.yourdomain.tld/favicon.ico).

You can also use this markup, per page, to have a favicon per page.

<link rel=”shortcut icon” href=”/img/favicon.ico”/>

 


Reset Administrator Password on a Mac / Apple Mac

October 7, 2010

Have tried this on a Tiger OS X

  • Reboot
  • Hold down Apple+S when you hear the chime
  • When you see the Aplle on screen, hit the power button once

You should see the text prompt now

Type:

  • mount -uw /
  • passwd
  • reboot

That’s it.
You should be able to log into the administrator user account with the new password you set now.

You keychain will probably be useless no unless you remember the password for that. I had connectivity issues, the airport would not connect to my wireless networks.

Once I deleted the login keychain, the network issues went away.

To delete the login keychain:

  • Open Applications/Utilities/Keychain Access
  • Click the Login keychain
  • Choose Edit -> Delete

Restoring lost icons on Windows 7 Task Bar

September 21, 2010

For the last few days I’ve been annoyed that some of my application icons have been ‘lost’, reverting to some default system icon.

This was particularily prevalent for applications pinned to the Windows 7 Taskbar.

Most detail I found involves rebooting the computer, but I tried a slightly different approach just now and it has worked fine, without the need for rebooting. My applications icons are now restored :)

To restore the application icons using the same process, do the following:

  1. Press and Hold the “Window Key” and press “R” (and then release both!)
  2. type “cmd” and press “Enter”
  3. type “taskkill /IM explorer.exe /F” [ Warning, may cause problems although it was fine for me. Also, if you are not worried about rebooting your system, you may skip this step and reboot after step 6 instead ]
  4. type “del /a %userprofile%\AppData\Local\IconCache.db
  5. type “explorer.exe
  6. type “exit

You’re icons should now be restored. If anything goes wrong - and it hasn’t for me – then just reboot.

You can press “CTRL_ALT_DEL” to get a task manager, and from there you can either reboot, or again try to run explorer.exe


Snap windows to an area of the screen in XP, Vista just like on Windows 7

September 15, 2010

On Windows 7 I very quickly got used to use the widow snap feature.

You can hold the windows-key and then use the direction keys to snap the window to the side of the screen, and it takes up half of your real-estate. I am ofter comparing window content so I find being easily able to quickly have each window take up half the screen to be very useful.

Back on my XP machine I missed this a lot, but thanks to one of the guys at work, I found out about Winsplit Revolution [ http://www.winsplit-revolution.com ] which he uses on Vista.

This little app offers a lot more options for snapping your windows not just to a side of the screen taking up 1/2 of it each, but also to the corners (1/4 screen use) and even into two rows of three small windows. This all in seconds, with a nice use of the numpad/arrows to easily and quickly select where in the screen you want the window to go (7 for top left, 3 for bottom right, etc).

It starts automatically on boot, and sits nice and quietly in the system tray, out of the way.

It really is the little things that make the big differences, and once you start using this app you’ll wonder how you ever lived without it.

Check out their demo video at http://www.winsplit-revolution.com/screenshots/videos-demos


Building direct show filters in Visual Studio 2008

September 9, 2010

First off, make sure you have the latest windows sdk.

The direct show base classes are in there now and not directx sdk.

There are required headers in direct show base classes in the samples directory of the sdk.

Thus, you need to reference the header files in

C:\Program Files\Microsoft SDKs\Windows\v7.0\Samples\multimedia\directshow\baseclasses

You will also to build that solution and link the lib file:

  1. Drop down the Tools menu, and select Options [ from http://www.lavishsoft.com/wiki/index.php/Visual_Studio_Paths ]
  2. In the box on the left is a list of option categories. Select “Projects and Solutions” and then the sub-category “VC++ Directories”
  3. In the upper right hand corner is a drop-down box that selects a particular set of default directories, including “Executable files”, “Include files”, “Reference files”, “Library files”, and “Source files”. Generally, you only want to add to the “Include files” or “Library files” lists. Select “Include files”
  4. In the middle of the right hand side of the window is a list of directories.
    1. Add the include path by pressing the “New Line” button above the window, or by pressing “Ctrl-Insert” or clicking under the last entry.
    2. A blank entry appears for you to either type the path or navigate by clicking the “…” button.
    3. Generally the final path you want will end with a folder called “include”. Enter the path now (e.g., c:\program files\isxdk\include)
      1. For direct show base classes, enter C:\Program Files\Microsoft SDKs\Windows\v7.0\Samples\multimedia\directshow\baseclasses
  5. Select “Library files” in the drop-down box
  6. In the same fashion as done for the include file path, add the path to the library files. (e.g., c:\program files\isxdk\lib\vs80)
    1. Add the direct show path C:\Program Files\Microsoft SDKs\Windows\v7.0\Samples\multimedia\directshow\baseclasses\release_mbcs
  7. You’re done, click OK

These includes need to be before the windows sdk includes, or you will have issues with definitions in refclock.h as there is another header of this name in the sdk.

I ran into this too. I found that you need to have the baseclasses directory (samples/multimedia/directshow) *before* the sdk include directory, since they both have a schedule.h file and refclock.h uses <> not ” for the include. I was slightly surprised to see that no-one else had mentioned this. [ http://social.msdn.microsoft.com/Forums/en/windowsdirectshowdevelopment/thread/5da8f0b8-d2a9-4caf-81e1-7f5788fa1c00 ]

The exact error reads as follows:

WIN32

c1xx : fatal error C1083: Cannot open source file: ‘WIN32′: No such file or directory

 

After I get this error once, I can recompile again, and since the changed file has now been compiled, it goes directly to linking and doesn’t spit this error out again.

I also found reference to other potential causes for this error online:

  • -Make sure the compiler sees /D “WIN32″, without /D it will try to compile WIN32.  Project + properties, C/C++, Command line.
  • -/I “” is your problem, it swallows the next /D.  I tried it and got the same error message. Not sure how you got it, there’s probably something wrong with Project + properties, C/C++, Additional include directories.
  • - I’d added an environment variable which had now been removed, thus creating an empty /I “”.

And that’s about all I took note of.


root user password recovery / resetting on Debian/GNU based linux systems

August 5, 2010

I have had need for this more often than I would like of late, it is a nice and quick way to reset the root password if you can’t remember, or the person who had it isn’t around any more. You need access to the actual console of course, physical access or a remote KVM. I’ve used this on both Debian boxes and Ubuntu boxes recently.

  1. rebooot the machine
  2. interrupt the boot sequence at the GRUB bootloader / LILO screen (I haven’t seen LILO on Deban / Ubuntu in quite a while)
  3. edit the boot line with “kernel” information (select and press e to edit)
  4. add init=/bin/bash to the end of the line
  5. hit enter and then press ‘b’ to boot
  6. when the boot sequence has finished, type the following:

mount -o remount,rw /
passwd root
(enter the new password for the ‘root’ user)
shutdown -r now (to reboot and login as root with the new password)


Hibernation Woes – Sleep after Hibernate on Windows 7

May 31, 2010

I have a laptop (Dell Studio 1557) that I have set to go into hibernation when the lid of the laptop is closed.

I have been annoyed for the last while that when I turn on the computer to resume from hibernate, it would immediately shutdown again, but this time in sleep mode.

Today I had a look at the power options, and saw that sleep was set to occur automatically after a number of hours, specific timing depending on whether it was being powered by the mains or battery at the time.

I have disabled automatic sleep and hibernated the computer. This time, when I resume from hibernate, the computer no longer goes into sleep mode. I would have assumed that waking from hibernate would have reset the sleep count-down, but obviously not. Perhaps this will be fixed in a patch sometime ?


Follow

Get every new post delivered to your Inbox.