Thursday, 9 September 2010

Testing Google Instant

Google Instant was released today, for a certain subset of users only. Google announced in their blog post that Google Instant is a new means of "googling". Instant search means that you only have to type a few letters of your search query, and Google search will instantly show you search results (before you press the enter key). As you enter more letters, the search results will instantly update, without having to reload the page. This search system was developed using JavaScript in the front end, along with Google's highly developed and fast search system behind it all. Query times of 0.3 seconds are very significant when your search results are updating as every character is typed!

Please note: This post is a test for Google Instant. I went to google.com, typed in "testing" and one of the top suggestion results was "testing google instant". I'll test and see if this blog post appears in the results quickly.

Tuesday, 31 August 2010

Book Review - The Shadow Of The Bear (Regina Doman)

The Shadow of the Bear

by Regina Doman
The Shadow of the Bear

Description

When Bear, a mysterious young man, lands on Blanche and Rose Brier's doorstep in New York City, the two sisters have conflicting opinions on whether or not he is dangerous. Even as Blanche learns to trust him, her fears that Bear's friendship threatens their family prove terrifyingly true. A modern retelling of the classic Brothers Grimm fairytale.

Read more on Amazon...

Personal Review

This book is a classic - one that I've read many times and will read again. The adaptation of the fairy tale "Snow White and Rose Red" is set in modern New York City, and fits in very well with this environment. But don't think this is just a children's fairy tale - anyone who has read Chesterton or is versed in classical literature will appreciate the quotes that come up throughout the story in casual conversation. The characters are engaging and varied - some are drug dealers, some classical poets, while others appear to be both! And surprisingly all the dialog sounds natural, despite dealing in some depth with many aspects of faith and life.

Some of the topics covered in a unique and realistic manner include modesty, judging people, revenge and peer pressure. You might think that having such a strong Christian moral the storyline would be weak - quite the opposite! The action and events in this story themselves make for a great read, the moral values simply add to this book's appeal.
Anyone from early teens on would definitely enjoy reading this book, although older teens would have a greater appreciation of the relationship aspects. This book is suitable for younger readers than Waking Rose or The Midnight Dancers (which deal with relationships at a higher level).

Violence (6/10) Rating: 6/10

There are some moderately violent scenes in this book. However, the level of violence seems appropriate to the story, and adds a level of realism without being overly graphic.

Some of the violent aspects include:
  • A gang of boys attack a boy and girl, and the girl is thrown to the ground
  • One character is nearly asphyxiated
  • A girl is forced into a car, and held against her will
  • People are held at gunpoint several times
  • One character is shot and wounded (not life-threatening)
  • A character threatens suicide
Anyone from early teens onward should be able to handle the level violence in this book. More conservative parents might wish to read the book first though, to be sure.

Immorality (6/10) Rating: 6/10

One of the major themes of this book is drug dealing. While innocent characters are sometimes suspected of illicit dealings, it's always very clear that using or handling drugs is wrong.

Some high school students are smoking cigarettes without permission or adult supervision. These are students with a bad reputation, and it's obvious that what they're doing is wrong.

In once scence, a boy is alone with a girl and tries to force a kiss (nothing further ensues though). This particular issue is handled very well, and later on in the book the girl gives a marvelous treatise on morality and character.

Language (1/10) Rating: 1/10

The language is exceptionally clean throughout this book, a remarkable achievement considering some of the characters involved.

SN Themes (3/10) Rating: 3/10

The characters' moral struggles feature prominently in this book, but no real supernatural themes. A Catholic church is regarded as "sacred" but this feature isn't dwelt on. There is a brief scene where the number "666" is used by the "bad guy".

Overall, the story is very light on supernatural elements, despite it's strong moral content. It's written as a fairy tale, and can be read as such.

Catholic Perspective

Catholics will love this book. The author has portrayed strong Catholic values in a way that makes sense. Anyone who comes from a Catholic background will find a lot to relate to.

But The Shadow Of The Bear also has strong appeal for Christians of any kind. The characters are current-day teenagers with many of the real-world challenges faced in this role. The specifically Catholic aspects aren't overbearing - they're just part of the characters' lives. Overall, this is a refreshing and energising book for any young Christian. It shows that belief in God is not irrelevant or boring,  and can even lead to adventure!

Read more on Amazon...

Monday, 30 August 2010

Symfony 'String could not be parsed as XML'

I was receiving this error on my symfony project (using the sfWhoIsOnline plugin):

[28-Aug-2010 21:50:54] PHP Fatal error:  Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /home/xxxxxxx/plugins/sfWhoIsOnlinePlugin/lib/sfWhoIsOnlineUserFacade.class.php:38
Stack trace:
#0 /home/xxxxxxx/plugins/sfWhoIsOnlinePlugin/lib/sfWhoIsOnlineUserFacade.class.php(38): SimpleXMLElement->__construct('')
#1 /home/xxxxxxx/plugins/sfWhoIsOnlinePlugin/lib/filter/sfWhoIsOnlineFilter.class.php(14): sfWhoIsOnlineUserFacade::registerUser(Object(myUser))
#2 /home/xxxxxxx/cache/frontend/prod/config/config_core_compile.yml.php(1026): sfWhoIsOnlineFilter->execute(Object(sfFilterChain))
#3 /home/xxxxxxx/plugins/sfDoctrineGuardPlugin/lib/sfGuardRememberMeFilter.class.php(56): sfFilterChain->execute()
#4 /home/xxxxxxx/cache/frontend/prod/config/config_core_compile.yml.php(1026): sfGuardRememberMeFilter->execute(Object(sfFilterChain))
#5 /home/xxxxxxx/cache/frontend/prod/config/config_core_compile.yml.php(990): sfFilterChain->execute()
#6 /home/xxxxxxx/cache/frontend/prod/config/config_core_compile.yml.php(1026): sfRenderingFilt in /home/xxxxxxx/plugins/sfWhoIsOnlinePlugin/lib/sfWhoIsOnlineUserFacade.class.php on line 38
[29-Aug-2010 00:06:48] String could not be parsed as XML
[29-Aug-2010 02:14:47] String could not be parsed as XML

Turns out, SimpleXMLElement can't handle empty strings or badly encoded documents well. As a patch of sorts, I replaced the code at line 38 in the sfWhoIsOnlineUserFacade class with the following lines (original lines in bold):

/* Begin Hack to fix error 'String could not be parsed as XML' */
try {
  $xml = new SimpleXMLElement($xmlString);    // <-- Original line 38   
$instance->fromXml($xml);                // <-- Original line 39
} catch (Exception $e) {
  sfContext::getInstance()->getLogger()->crit('sfWhoIsOnline failed to create SimpleXMLElement');
  sfContext::getInstance()->getLogger()->crit('xmlString: '.$xmlString);
}
/* End Hack */

References:
http://drupal.org/node/541892
http://weierophinney.net/matthew/archives/111-mbstring-comes-to-the-rescue.html
http://www.google.com/search?hl=en&q=String+could+not+be+parsed+as+XML&aq=f&aqi=&aql=&oq=&gs_rfai=
http://ketarin.canneverbe.com/forum/viewtopic.php?id=384

Sunday, 22 August 2010

Undelete a Linux file

Undelete! | Atomic Object, Software Design & Development:
How to undelete a file removed with the 'rm' command on Linux
"grep -a -B 25 -A 100 'some string in the file' /dev/sda1 > results.txt

Thursday, 19 August 2010

Install phploc on openSuSE 11.3 [HOWTO]

Once you've got PEAR installed, run these commands (as root):

pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear install phpunit/phploc


At first I was getting errors:

phpunit/File_Iterator requires PEAR Installer (version >= 1.9.1), installed version is 1.9.0
phpunit/phploc requires package "phpunit/File_Iterator" (version >= 1.2.0)
No valid packages found
install failed


But running:

pear upgrade-all


fixed all the errors.

Monday, 9 August 2010

Use ssh-copy-id on a non-default port

ssh-copy-id has known problems with handling non-standard ports (e.g. connecting to a different port than 22). To overcome this issue, use a command like:

$ ssh-copy-id "user@host -p 6842"

Source:http://it-ride.blogspot.com/2009/11/use-ssh-copy-id-on-different-port.html

Wednesday, 7 July 2010

[FIX] Migrate Windows Server 2003 to VMWare ESXi fails to boot - white non-flashing curser

I recently used VMWare Standalone Converter to migrate a physical Windows Server 2003 machine to a Virtual machine Infrastructure host. However, the machine would not boot up on ESXi 4. All that appeared on the screen was a white, non-blinking cursor at the top left of the screen.

Turns out, after a lot of troubleshooting, that ESXi can't handle virtual IDE drives - they must be SCSI, either LSI Logic or Bus Logic. After following this guide to setup SSH on ESX server, I then followed the instructions at the VMWare help site to convert the virtual IDE disk to SCSI (with LSI Logic controller). I used vi to edit the required file, as nano is not available on ESXi.

After the conversion was complete, the machine booted perfectly.

Thursday, 24 June 2010

Symfony / sfGuardUser: MySQL errno: 150 Failing Query "ALTER TABLE sf_guard_user......."

I've been trying to link up my symfony project (using Doctrine) to sfGuardPlugin with profiles. However, when trying to rebuild the schema and insert sql, I encountered the following error:

SQLSTATE[HY000]: General error: 1005 Can't create table 'phoenix.#sql-740_d7' (errno: 150). Failing Query: "ALTER TABLE sf_guard_user_profile ADD CONSTRAINT sf_guard_user_profile_user_id_sf_guard_user_id FOREIGN KEY (user_id) REFERENCES sf_guard_user(id)". Failing Query: ALTER TABLE sf_guard_user_profile ADD CONSTRAINT sf_guard_user_profile_user_id_sf_guard_user_id FOREIGN KEY (user_id) REFERENCES sf_guard_user(id)


This isn't an incredibly useful error message. Turns out that it's to do with the way MySQL handles cascading constraints. To cut a long story short, there's more info in the links posted below, but basically you need to remember that "type: integer" does not mean it will be stored as INTEGER in MySQL. As a matter of fact, "type: integer" in a schema.yml file translates into a "BIGINT(20)" in MySQL - which means when you add a constraint to a normal INTEGER field, it fails.

To store an integer value in schema.yml, use "type: integer(4)". This will translate into a type of INTEGER in MySQL.

Explained in a comment I found:
Something you might be interested in, that took me quarter an hour. integer(11) in schema.yml does not result in int(11) in MySQL, but instead you have to write integer(4) in your schema.yml. integer integer int/serial integer(1) tinyint smallint/serial integer(2) smallint smallint/serial integer(3) mediumint int/serial integer(4) int int/serial integer(5) bigint bigint/bigserial However, in my case integer without a number resulted in BIGINT.


More info:
http://trac.symfony-project.org/wiki/sfGuardPluginExtraDocumentation
http://mirmodynamics.com/post/2009/04/02/SQLSTATE%5BHY000%5D%3A-General-error%3A-1005-Can-t-create-table-*-%28errno%3A-150%29 (especially see the last comment)
http://bytes.com/topic/mysql/answers/865699-cant-create-table-errno-150-foreign-key-constraints

Friday, 4 June 2010

WeReward brings incentive advertising to iPhone

This is a Sponsored Post written by me on behalf of IZEA. All opinions are 100% mine.


Chops WeReward (WeReward.com) is a new iPhone app from Izea (the makers of PayPerPost and Sponzai, among various similar services).

Their latest offering is basically a way for iPhone users to make money by performing small, easy-to-do actions on their mobile device. The application integrates with Facebook, Twitter and Foursquare, and offers a variety of incentiv-ized postings.

According the the official website:
Earn WeReward points by completing tasks and checkins at your favorite businesses with your iPhone. Each point is worth a penny, earn 1,000 points and cashout to PayPal.
1000 points is equal to $10 at that conversion rate, which is pretty decent. Of course, it will take a long time to make much money when you're getting paid one penny for each tweet/checkin/share. But it all adds up.

The key to this application succeeding is the location-based relevance. Because offers are tailored to your location, many of the offers you see will actually be useful. In fact, your friends may find your posts helpful, because in many cases they are things that you would already be posting about anyway.

If you can get paid to do stuff that's useful to your friends, and takes little or no extra effort on your behalf, what's the catch? Nothing, really. If you're prepared to take a small amount of time and risk your reputation posting advertisements on your profile, there's nothing else that could really go wrong. Personally I would do it - provided the offers are relevant.

If you have an iPhone you can Download the App today - it only takes a minute. I'd love to hear your feedback (as I don't have an iPhone myself - I use Android). It's something I would definitely use myself, and helps to progress the whole micro-payments infrastructure. Interesting also that they use PayPal for payments. This is a sensible choice, but given MasterCard's entry into the market is something that could change relatively quickly.

Check out the video of how it works in action:

Visit my sponsor: WeReward for iPhone

Wednesday, 2 June 2010

Javascript Card Guessing Game - Sample Code

I've been doing some coding in Javascript lately, and thought I would share some of the code I've been writing. Hopefully some of it will be useful for anyone looking for some sample code in Javascript, or examples of looping, keeping tallies, or writing basic functions.

Without further ado, here is the code. It's a simple playing card guessing game.
Javascript Card Guessing Game

Tuesday, 1 June 2010

Android: Using Accelerometer to Calculate Total Force

I'm in the process of building an app that calculates how far you could throw something, based on the speed you swing your phone. This involves tracking your phone's movement as you swing it, and calculating the total maximum force involved. I couldn't find any examples on how to do this, so I've mocked up a bit of a tutorial below.

How do we get the accelerometer values?

private SensorManager mgr=null;
mgr=(SensorManager)ctxt.getSystemService(Context.SENSOR_SERVICE);
mgr.registerListener(listener,
mgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
SensorManager.SENSOR_DELAY_UI);



private SensorEventListener listener=new SensorEventListener() {
        public void onSensorChanged(SensorEvent e) {
            if (e.sensor.getType()==Sensor.TYPE_ACCELEROMETER) {
                //Total acceleration will be sqrt(x^2+y^2+z^2)
                double netForce=e.values[0]*e.values[0];    //X axis               
                netForce+=e.values[1]*e.values[1];    //Y axis
                netForce+=(e.values[2])*(e.values[2]);    //Z axis (upwards)
               
                netForce = Math.sqrt(netForce) - SensorManager.GRAVITY_EARTH;    //Take the square root, minus gravity
               
                Log.d("ForceCalculator", "Net force:"+netForce+"");
            }
        }
       
        public void onAccuracyChanged(Sensor sensor, int accuracy) {
            // unused
        }
    };


This will create and register an event listener for the accelerometer. This listener then calculates the net force.

This calculation is pretty self-explanatory. It involves three components - X axis, Y axis, and Z axis. To calculate the magnitude of these vector components, we simply take the square root of their combined squares:
netForce = sqrt( x^2 + y^2 + z^2 )
The only point to note is that we then subtract the acceleration due to gravity (approx. 9.8m/s^2). Otherwise we could have a resting acceleration of +9.8.

Full code will be coming later, when I've got some more time to play around with it. For now, this should show you how to get net force using the accelerometer. Still to come is code to calculate maximum force over a specified period of time, with threshold starting and finishing velocities.

Wednesday, 26 May 2010

How to lock & unlock the KDE4 screensaver from command line

Here are two DBUS commands you can use to start or stop the KDE4 screensaver (previously known as kscreensaver or kscreenlock) from the command line.
Enter one of the following two commands into your linux shell (bash):

Lock:
dbus-send --type=method_call --dest=org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSaver.Lock

Unlock without password:
dbus-send --type=method_call --dest=org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSaver.SetActive boolean:false

Both these commands work with the latest KDE 4.3.5

Friday, 14 May 2010

HOW TO Install MetaTrader 4 on Linux

How to run Meta Trader 4 on Linux using WINE.
  1. Sign up for an account at a forex broker, and download their MT4 installer. I used Easy-Forex, but this procedure should work for any version of Meta Trader 4.x.
  2. Install wine on your linux machine (I used wine 1.1.44 on an openSuSE 11.2 machine). Also download winetricks (used to install additional libraries required by MetaTrader).
  3. If you haven't used wine before, run 'winecfg' to create your installation directory. You can then click 'OK' to exit the dialog, or have a look around at the options (I used the defaults).
  4. Start up a Windows computer, and copy all the files in C:\WINDOWS\Fonts into the wine directory (/home/username/.wine/drive_c/windows/Fonts)
  5. Run winetricks to install mfc40 and mfc42:
      sh ./winetricks mfc40 mfc42
  6. Run the MetaTrader installer executable.
       wine ./mt4setup.exe
That's it! You should now be able to run MetaTrader4 by clicking on the icon on the desktop, or running the following command in your Linux shell:

wine /home/username/.wine/drive_c/Program\ Files/yourmt4installdirectory/terminal.exe

If you have any more problems or questions, please contact me by leaving a comment. MetaTrader is running fine for me under openSuSE 11.2 with the latest WINE from the repositories, once MFC40, MFC42 and the correct fonts had been installed.

More information:
http://appdb.winehq.org/objectManager.php?sClass=version&iId=2893
http://www.aboutcurrency.com/university/metatrader/installing_metatrader4_under_linux.shtml
http://easyforextrading4u.com/metatrader-linux/

Appendix:
When you first start MetaTrader4, it might take a while to initialise. You'll see something like the following in the shell output:

fixme:reg:GetNativeSystemInfo (0x58c4c8) using GetSystemInfo()
fixme:toolhelp:CreateToolhelp32Snapshot Unimplemented: heap list snapshot
MetaQuotes Language 4 compiler version 4.00 build 224 (14 May 2009)
Copyright 2001-2009, MetaQuotes Software Corp.

Exp file "Z:\home\david\.wine\drive_c\Program Files\MT4 at easy-forex\experts\MACD Sample.ex4" produced - 0 error(s), 0 warning(s)
Xlib: extension "Generic Event Extension" missing on display ":1000.0".
fixme:reg:GetNativeSystemInfo (0x58c4c8) using GetSystemInfo()
fixme:toolhelp:CreateToolhelp32Snapshot Unimplemented: heap list snapshot
MetaQuotes Language 4 compiler version 4.00 build 224 (14 May 2009)
Copyright 2001-2009, MetaQuotes Software Corp.

Exp file "Z:\home\david\.wine\drive_c\Program Files\MT4 at easy-forex\experts\Moving Average.ex4" produced - 0 error(s), 0 warning(s)
Xlib: extension "Generic Event Extension" missing on display ":1000.0".
fixme:reg:GetNativeSystemInfo (0x58c4c8) using GetSystemInfo()
fixme:toolhelp:CreateToolhelp32Snapshot Unimplemented: heap list snapshot
MetaQuotes Language 4 compiler version 4.00 build 224 (14 May 2009)
Copyright 2001-2009, MetaQuotes Software Corp.

Exp file "Z:\home\david\.wine\drive_c\Program Files\MT4 at easy-forex\experts\indicators\Accumulation.ex4" produced - 0 error(s), 0 warning(s)
Xlib: extension "Generic Event Extension" missing on display ":1000.0".
fixme:reg:GetNativeSystemInfo (0x58c4c8) using GetSystemInfo()
fixme:toolhelp:CreateToolhelp32Snapshot Unimplemented: heap list snapshot
MetaQuotes Language 4 compiler version 4.00 build 224 (14 May 2009)
Copyright 2001-2009, MetaQuotes Software Corp.


Some errors I was encountering before installing the mfc40 and mfc42 libraries:

err:module:import_dll Library KERNELBASE.dll (which is needed by L"C:\\windows\\system32\\MFC42.DLL") not found
err:module:import_dll Library API-MS-Win-Core-Debug-L1-1-0.dll (which is needed by L"C:\\windows\\system32\\MFC42.DLL") not found
err:module:import_dll Library API-MS-Win-Core-ErrorHandling-L1-1-0.dll (which is needed by L"C:\\windows\\system32\\MFC42.DLL") not found
err:module:import_dll Library API-MS-Win-Core-File-L1-1-0.dll (which is needed by L"C:\\windows\\system32\\MFC42.DLL") not found
err:module:import_dll Library API-MS-Win-Core-Handle-L1-1-0.dll (which is needed by L"C:\\windows\\system32\\MFC42.DLL") not found
err:module:import_dll Library API-MS-Win-Core-Interlocked-L1-1-0.dll (which is needed by L"C:\\windows\\system32\\MFC42.DLL") not found
err:module:import_dll Library API-MS-Win-Core-LibraryLoader-L1-1-0.dll (which is needed by L"C:\\windows\\system32\\MFC42.DLL") not found
err:module:import_dll Library API-MS-Win-Core-Localization-L1-1-0.dll (which is needed by L"C:\\windows\\system32\\MFC42.DLL") not found
err:module:import_dll Library API-MS-Win-Core-LocalRegistry-L1-1-0.dll (which is needed by L"C:\\windows\\system32\\MFC42.DLL") not found
err:module:import_dll Library API-MS-Win-Core-Memory-L1-1-0.dll (which is needed by L"C:\\windows\\system32\\MFC42.DLL") not found
err:module:import_dll Library API-MS-Win-Core-Misc-L1-1-0.dll (which is needed by L"C:\\windows\\system32\\MFC42.DLL") not found
err:module:import_dll Library API-MS-Win-Core-ProcessEnvironment-L1-1-0.dll (which is needed by L"C:\\windows\\system32\\MFC42.DLL") not found
err:module:import_dll Library API-MS-Win-Core-ProcessThreads-L1-1-0.dll (which is needed by L"C:\\windows\\system32\\MFC42.DLL") not found
err:module:import_dll Library API-MS-Win-Core-Profile-L1-1-0.dll (which is needed by L"C:\\windows\\system32\\MFC42.DLL") not found
err:module:import_dll Library API-MS-Win-Core-String-L1-1-0.dll (which is needed by L"C:\\windows\\system32\\MFC42.DLL") not found
err:module:import_dll Library API-MS-Win-Core-Synch-L1-1-0.dll (which is needed by L"C:\\windows\\system32\\MFC42.DLL") not found
err:module:import_dll Library API-MS-Win-Core-SysInfo-L1-1-0.dll (which is needed by L"C:\\windows\\system32\\MFC42.DLL") not found
err:module:import_dll Library MFC42.DLL (which is needed by L"Z:\\home\\david\\.wine\\drive_c\\Program Files\\MT4 at easy-forex\\MetaEditor.exe") not found
err:module:LdrInitializeThunk Main exe initialization for L"Z:\\home\\david\\.wine\\drive_c\\Program Files\\MT4 at easy-forex\\MetaEditor.exe" failed, status c0000135

Thursday, 29 April 2010

Dual Monitor VNC on Ubuntu - with scaling

To get dual-monitor remote desktop over VNC working withUbuntu, I had to install x11vnc. With the default VNC server, only half of my desktop would appear with the other half blacked out. Also, the whole two screen layout would not fit within my VNC client window.Ultimately this is the command I came up with the start the VNC server:

x11vnc -xinerama -xwarppointer -scale 3/4 -noxdamage -ncache 10

The first two arguments setup dual screen mode. The next one (-scale 3/4) scales the screen to 3/4 of it's original size (the scaling is done server-side). The -noxdamage argument prevented some annoying server errors that were appearing. And the -ncache 10 option enables client-side pixel caching, which speeds up things considerably.

References:
http://ubuntuforums.org/showthread.php?t=535574
http://ubuntuforums.org/archive/index.php/t-252888.html
https://help.ubuntu.com/community/VNC?action=show&redirect=VNCOverSSH

Friday, 16 April 2010

openSuSE 11.2 sound on HP dv7t-1000 - ALSA, Pulseaudio, and JACK

It took a lot to get this setup. I made the mistake of installing PulseAudio, and had to uninstall it before my sound would work in the slightest. But even then, I had jerky sound. The solution was to make some edits to my /etc/modprobe.d/50-sound.conf so that it appears as follows:
options snd-hda-intel model=hp-m4 enable_msi=1
# u1Nb.Jqboh86TqAC:82801I (ICH9 Family) HD Audio Controller
alias snd-card-0 snd-hda-intel
After making these changes, and restarting my computer, the sound worked again. I could start JACK with Rosegarden with no troubles (after doing the standard realtime permissions fix).

Some links:
http://www.alsa-project.org/main/index.php/SoundcardTesting
http://en.opensuse.org/SDB:AudioTroubleshooting
http://en.opensuse.org/HCL/Laptops/HP#dv_7
http://en.opensuse.org/Alsa-update
http://en.opensuse.org/SDB:Intel-HDA_sound_problems
http://hg.alsa-project.org/alsa-kernel/raw-file/5082de4abb26/Documentation/ALSA-Configuration.txt
http://www.alsa-project.org/main/index.php/Matrix:Module-hda-intel
http://akoskm.blogspot.com/2009/01/laptop-extra-keys-howto.html
http://en.opensuse.org/Pulseaudio
http://pulseaudio.org/wiki/BrokenSoundDrivers

Wednesday, 14 April 2010

ebay USB MIDI Interface on Ubuntu Linux (1a86:752d)

I recently bought a USB MIDI interface off ebay. It was just a generic, pretty cheap made-in-china kind of model, with a red, orange and green light. It lit up red when I plugged it into my (Linux) computer, but showed up in lsusb as "Unknown" device:
root@theta:~# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 003: ID 0461:0010 Primax Electronics, Ltd
Bus 005 Device 002: ID 045e:0040 Microsoft Corp. Wheel Mouse Optical
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 003: ID 046d:09b8 Logitech, Inc.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 008 Device 004: ID 1a86:752d Unknown
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Turns out, even though it's listed as an unknown device, it still worked as a MIDI input. I just started up JACK Audio Server, Rosegarden, and ZynAddSubFx for an organ simulation. Then i plugged in the MIDI In and Out ports to my keyboard, hooked up the connections in JACK and it all worked!

Being USB of course, there was some delay, and for some peculiar reason no keys below Middle C would work for me. But it works well on Sibelius!

Wednesday, 7 April 2010

openSuSE 11.2 as Active Directory PDC?

I'm looking at reinstalling my server (currently Ubuntu 8.04 LTS) with openSuSE 11.2. Does anyone know of some way that I can configure openSuSE as an Active Directory domain controller? I would like to configure Samba and LDAP with a GUI preferably, and automatically transfer any modifications I make to the client computers. I also need offline authentication.

I was looking at Novell eDirectory, and it appears to be exactly what I am looking for. Is there a tutorial available for how to setup eDirectory on openSuSE? By default it runs on Open Enterprise Server only.

Tuesday, 23 March 2010

[FIX] Breezy apt-get update returns 404 not found

Today I logged into an old Ubuntu machine, and tried to install a program. However, running apt-get update came up with a whole bunch of "404 file not found" errors, although it was using the standard ubuntu repositories.

Turns out some time ago, the Ubuntu project took down the Breezy Badger repositories. After all, this is an old project. Thankfully there is a way you can update your breezy machines even without this repository. According to this thread, just change the lines "archive.ubuntu.com ..." to "old-releases.ubuntu.com ..." in your /etc/apt/sources.list or using the GUI in Synaptic/Adept.

More info here.

Friday, 5 March 2010

Google Calendar

Google Calendar is a really useful tool for managing time. I've created separate calendars for personal events, work, study, birthdays and more. All of these show up in an easy to navigate web interface, and I can choose to setup SMS reminders for important events.

Perhaps the most useful feature for me is the automatic synchronization with my Android phone. I can add an event to my phone on the go, and when I get back to the computer it will already be there on my calendar. This saves a lot of time and frustration on my behalf.

Another feature that is often overlooked but can be extremely powerful is the sharing features. If someone gives me permission to see their calendar, I can view it alongside my own, and even schedule meetings where all people are free, just like Outlook but in the cloud.

Theres too many features to write about them all, but it's such a useful tool that I highly recommend it to anyone having trouble managing their time. Especially if need to be able to access the same calendar from multiple locations.

in reference to: Google Calendar (view on Google Sidewiki)

Thursday, 4 March 2010

Mounting Filesystems by UUID - Ubuntu

Ubuntu 9.10 automatically mounts hard drives by UUID when it's installed. This means that if you insert a new hard drive, which changes all the /dev/sdxx numbers, your system will still function normally. Linux by examples has a good tutorial on common fstab commands for uuid.

To find all UUIDs:

ls -l /dev/disk/by-uuid/

To check the UUID for a known device:


sudo vol_id /dev/sda1

or this:

blkid /dev/sda1

Wednesday, 17 February 2010

Ubuntu: How to automatically lock & unlock screen with Android phone

Evan Boldt has a useful script: Unlock your screen with ANY USB device. I've modified it slightly to work with my HTC Magic / Google Android device. A script is run every minute, which polls the system log every 2 seconds to determine when the USB device is plugged in in or unplugged. It then forwards the relevant command to GNOME Screensaver. The script is posted below for your interest.

Firstly, run lsusb and locate your phone. In my case, it was the highlighted line:

Bus 002 Device 002: ID 08ff:2580 AuthenTec, Inc. AES2501 Fingerprint Sensor
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 045e:0752 Microsoft Corp.
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 002: ID 045e:0039 Microsoft Corp. IntelliMouse Optical
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 006: ID 0bb4:0c02 High Tech Computer Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


Copy everything from ID to the end of the line (i.e. "ID 0bb4:0c02 High Tech Computer Corp.") This will be the ID used to determine when your device is plugged in & unplugged.

Paste this file into your /home/username/bin folder:

#!/bin/bash

#Replace with the ID of your USB device
id="ID 0bb4:0c02 High Tech Computer Corp." # Example: id="ID 05ac:1292 Apple, Inc"

#runs every 2 seconds
for ((i=0; i<=30; i++))
do
if [ -z "`lsusb | grep "$id"`" ]
then

    echo "Device is NOT plugged in"

    if [ -n "`DISPLAY=:0 gnome-screensaver-command --query | grep "is active"`" ]
    then
    if [ -e /tmp/autoUnlock.lock ]
    then
    #stop locking the screen
    rm /tmp/autoUnlock.lock

fi

elif [ -e /tmp/autoUnlock.lock ]
then

    DISPLAY=:0 notify-send -t 5000 –icon=dialog-info “Device Disconnected” “Bye!”

    #lock the desktop
    DISPLAY=:0 gnome-screensaver-command --lock

    rm /tmp/autoUnlock.lock

fi
else

    echo "Android IS plugged in"
    if [ ! -e /tmp/autoUnlock.lock ]
    then
    DISPLAY=:0 gnome-screensaver-command --deactivate
    DISPLAY=:0 notify-send -t 5000 --icon=dialog-info "Device Connected" "Welcome Back!"
    touch /tmp/autoUnlock.lock

    ##Uncomment the 3 following lines if you would like your computer to remind you if you lock your screen without disconnecting the device
    #echo "Don't forget your device!" > /tmp/androidReminder
    #DISPLAY=:0 festival --tts /tmp/androidReminder
    #rm /tmp/androidReminder
    fi

fi
sleep 2
done


Now you simply add a line to your crontab to run this script every minute:

crontab -e


add the line:

* * * * * bash /home/username/bin/autoUnlock & >/dev/null 2>&1


That's it! Now, when you unplug your Android phone it should lock the screen. When you plug in again, the screen unlocks. Easy!

More information:
http://echowarp.neomenlo.org/2009/scripts/unlock-your-screen-with-any-usb-device
https://help.ubuntu.com/community/UsbDriveDoSomethingHowto

ERROR: Creating templock /var/lock/mrtg/.....: No such file or directory [How to Fix]

I have been running MRTG on Ubuntu server 8.10, and recently it stopped running for no obvious reason. Examining the MRTG log, I found many lines like this:

ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5012: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5020: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5041: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5046: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5074: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5100: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5112: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5121: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5129: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5148: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5173: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5905: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_6004: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_6023: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_6049: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_6065: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_6092: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_6191: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_6247: No such file or directory at /usr/bin/mrtg line 1645.


Turns out there is a bug with running MRTG on Ubuntu/Debian which removes the MRTG lock file on every reboot. To fix this, create a new text file (as root) in /etc/rcS.d/ called "S91mrtg-lock-dir.sh" and paste the following code into it:

#!/bin/sh
# Create the lock directory for MRTG
# This is needed due to a bug for Ubuntu/Debian which erases this directory at shutdown
echo "Creating MRTG lock directory...."
mkdir -m 0755 /var/lock/mrtg


This will create a new /var/lock/mrtg directory every time the computer starts up. You may need to reboot to enable this, or simply run the command mkdir -m 0755 /var/lock/mrtg.

More information:
http://www.enterprisenetworkingplanet.com/netos/article.php/3663941
http://ubuntuforums.org/showthread.php?t=249393
http://www.directadmin.com/forum/showthread.php?t=7843&page=3
http://www.google.com/search?hl=en&q=ERROR%3A+Creating+templock%3A+No+such+file+or+directory&aq=f&aqi=&oq=

Thursday, 11 February 2010

Google Buzz: How to publish to Twitter automatically

At present, Google Buzz has the ability to import, index and display your Tweets. One feature that is notably missing, however, is the ability to tweet from Buzz. You can't export Google Buzz to Twitter. At least, not officially.

I've written a python script to grab your Google Buzz feed (as detailed in the Buzz API), and automatically post your Buzz-es to Twitter. It includes a link back to the original Buzz URL (shortened with Bit.ly) It also uses a local sqlite database to store previous posts, and print bit.ly statistics for your published links.

You'll need to have python installed, and the following modules:
python-twitter
python-bitly
python-sqlite
feedparser
You'll also need a free account at Twitter and Bit.ly, and a Bit.ly API key.

Download the python source code from Google Code, or copy the text below. Please let me know if you found this useful, or have any improvements or modifications to suggest.


Update: To run this script every minute, add the following line to your crontab:
* * * * * /path/to/buzz-twitter-bot.py
This will update Twitter with your Google Buzz posts at least once per minute.

Code:

#!/usr/bin/python
from time import strftime
import sqlite3
import sys
import re

import twitter     #http://code.google.com/p/python-twitter/
import bitly       #http://code.google.com/p/python-bitly/
import feedparser  #available at feedparser.org


DATABASE = "tweets.sqlite"

BITLY_LOGIN = "username"
BITLY_API_KEY = "insert_your_key"

TWITTER_USER = "username"
TWITTER_PASSWORD = "secret"

def print_stats():
conn = sqlite3.connect(DATABASE)
conn.row_factory = sqlite3.Row
c = conn.cursor()

b = bitly.Api(login=BITLY_LOGIN,apikey=BITLY_API_KEY)

c.execute('SELECT title, url, short_url from RSSContent')
all_links = c.fetchall()

for row in all_links:

short_url = row['short_url']

if short_url is None:
short_url = b.shorten(row['url'])
c.execute('UPDATE RSSContent SET `short_url`=? WHERE `url`=?',(short_url,row['url']))


stats = b.stats(short_url)
print "%s - User clicks %s, total clicks: %s" % (row['title'], stats.user_clicks,stats.total_clicks)

conn.commit()

def tweet_rss(url):
print "Opening database...."
conn = sqlite3.connect(DATABASE)
conn.row_factory = sqlite3.Row
c = conn.cursor()
print "Database opened."

#create the table if it doesn't exist
c.execute('CREATE TABLE IF NOT EXISTS RSSContent (`url`, `title`, `dateAdded`, `content`, `short_url`)')

print "Logging in to Twitter...."
api = twitter.Api(username=TWITTER_USER, password=TWITTER_PASSWORD)
print "Logging in to Bitly...."
b = bitly.Api(login=BITLY_LOGIN,apikey=BITLY_API_KEY)

print "Parsing feed...."
d = feedparser.parse(url)

for entry in d.entries:

#check for duplicates
c.execute('select * from RSSContent where url=?', (entry.link,))
if not c.fetchall():
print entry
#Get data from this entry
title = entry.title
content = entry.content[0].value
link = entry.link
updated = entry.updated
#Strip HTML from content
r = re.compile(r'<[^<]*?/?>')
content = r.sub('', content)

print "Found new item"
print "Title: "+title
print "Content: "+content
print "Link: "+link
tweet_text = "Buzz: %s" % content

#Shorten link
print "Shortening link...."
shortened_link = b.shorten(link)
print "Shortened link: "+shortened_link

#Add this entry to the database
t = (link, title, updated, content, shortened_link)
c.execute('insert into RSSContent (`url`, `title`,`dateAdded`, `content`, `short_url`) values (?,?,?,?,?)', t)
print "%s.. %s" % (tweet_text[:115], shortened_link)

#Post to twitter
print "Posting to twitter...."
api.PostUpdate("%s.. %s" % (tweet_text[:115], shortened_link))
print "Post complete."

conn.commit()

if __name__ == '__main__':
tweet_rss(sys.argv[1])
print "Listing stats...."
print_stats()

Special Thanks to Halotis for the RSS Twitter Bot, and love-python.blogspot.com for how to strip HTML tags.

Tuesday, 9 February 2010

How to extract / unzip a .tar.gz file into a different directory

What happens if you need to extract a .tar.gz file, but don't have enough free disk space in the directory? It might show you an error like this:

tar: Wrote only 9216 of 10240 bytes
tar: Skipping to next header
tar: Error exit delayed from previous errors


Tar and Gunzip will only extract into the current directory. Here is a command that will unzip a .tar.gz archive into a new directory.

cd /new-directory
gzip -dc /path/file.tar.gz|tar xvf --

Sunday, 7 February 2010

VFS: busy inodes on changed media or resized disk sr0

(Ubuntu 9.10 Karmic) If you get a lot of error messages like this:

Feb 7 14:38:58 theta kernel: [564762.288036] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:38:58 theta kernel: [564762.297408] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:38:59 theta kernel: [564763.286910] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:00 theta kernel: [564764.288880] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:00 theta kernel: [564764.298198] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:01 theta kernel: [564765.288943] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:02 theta kernel: [564766.287691] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:02 theta kernel: [564766.297007] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:03 theta kernel: [564767.339877] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:04 theta kernel: [564768.288076] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:04 theta kernel: [564768.297457] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:05 theta kernel: [564769.288688] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:06 theta kernel: [564770.292023] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:06 theta kernel: [564770.301389] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:07 theta kernel: [564771.316633] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:08 theta kernel: [564772.287440] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:08 theta kernel: [564772.296807] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:09 theta kernel: [564773.288408] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:10 theta kernel: [564774.288406] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:10 theta kernel: [564774.297774] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:11 theta kernel: [564775.286283] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:12 theta kernel: [564776.288231] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:12 theta kernel: [564776.297599] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:13 theta kernel: [564777.294194] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:14 theta kernel: [564778.288487] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:14 theta kernel: [564778.297790] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:15 theta kernel: [564779.287965] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:16 theta kernel: [564780.288390] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:16 theta kernel: [564780.297835] VFS: busy inodes on changed media or resized disk sr0
Feb 7 14:39:17 theta kernel: [564781.288703] VFS: busy inodes on changed media or resized disk sr0

It means your cdrom drive has been ejected without unmounting. Check this by typing this in your terminal:
mount
If this shows a line like:
/dev/sr0 on /media/cdrom1 type iso9660 (ro,nosuid,nodev,utf8)
then your cdrom has been ejected. Try typing:
sudo umount /dev/sr0
This should unmount the cdrom. If it doesn't work, maybe try:
sudo umount -f /dev/sr0

Thursday, 4 February 2010

How to setup FreeRADIUS to integrate with Active Directory Authentication

I used the tutorial found at http://deployingradius.com/documents/configuration/active_directory.html for FreeRadius Active Directory integration, but modified it slightly to suit my needs, and fixed some errors which I encountered.

You may also want to read how to link Linux to a domain.

Firstly, setup Samba to link your computer to the domain:

Once Samba has been installed on your system, you should edit the smb.conf file, and configure the [global] section to point to your NT server, including hostname and NT domain.
# workgroup = NT-Domain-Name
workgroup = MYDOMAIN
...
# Security mode. Most people will want user level security. See
# security_level.txt for details.
security = ads
# Use password server option only with security = server
password server = nt-server-hostname.company.com
...
realm = realm.company.com
You will also have to edit the /etc/krb5.conf file, to add an entry that points to the Active Directory Server
[realms]
...
realm.company.com = {
kdc = nt-server-hostname.company.com
}
...
Start the Samba and Kerberos servers, and as root join the domain:
$ net join -U Administrator
Enter the administrator password at the prompt.
Next, verify that a user in the domain can be authenticated:
$ wbinfo -a user%password
You should see a number of lines of text, followed by authentication succeeded . The next step is to try the same login with the ntlm_auth program, which is what FreeRADIUS will be using:
$ ntlm_auth --request-nt-key --domain=MYDOMAIN --username=user --password=password
If all goes well, you should see authentication succeeding ( NT_STATUS_OK ). You should also see the NT_KEY output, which is needed in order for FreeRADIUS to perform MS-CHAP authentication.

Next, setup FreeRADIUS with ntlm_auth, and test it:

Configuring FreeRADIUS to use ntlm_auth
Once you have verified that Samba is installed and working correctly, and that the ntlm_auth program works, you can proceed with configuring FreeRADIUS to use ntlm_auth. For initial testing, we will be using the exec module, and will run the exact command line used above.
Create a file /etc/freeradius/modules/ntlm_auth , and put the following text in it:
exec ntlm_auth {
wait = yes
program = "/path/to/ntlm_auth --request-nt-key --domain=MYDOMAIN --username=%{mschap:User-Name} --password=%{User-Password}"
}
This configuration tells the server to run the ntlm_auth program with the user name and password obtained from the Access-Request. You will also have to list ntlm_auth in the authenticate sections of each the /etc/freeradius/sites-enabled/default file, and of the /etc/freeradius/sites-enabled/inner-tunnel file:
authenticate {
...
ntlm_auth
...
}
and add the following text for testing purposes only to the top of the users file.
DEFAULT Auth-Type = ntlm_auth
This configuration says "for all users, if the authenticate method has not been set, set it to use the ntlm_auth program".
Start the server using freeradius -X (you may have to stop the automatic daemon by /etc/init.d/freeradius stop), and wait for the debugging text to stop scrolling by. If all goes well, you should see the following text:
Ready to process requests.
In another terminal window on the same machine, type the following command:
$ radtest user password localhost 0 testing123
If all goes well, you should see the server returning an Access-Accept message, and the window with radtest should print text similar to the following:
rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, length=20
This text means that authentication succeeded. A few lines above this text, the debug output will also show the exact command line used to run ntlm_auth.
Note: You may get this error: radclient: socket: cannot initialize udpfromto: Function not implemented.
This means for some reason it can't resolve the hostname localhost. Change localhost to 127.0.0.1 and it should work.

Then setup MS-CHAP with ntlm_auth:

Configuring FreeRADIUS to use ntlm_auth for MS-CHAPOnce you have the previous steps working, configuring FreeRADIUS to use ntlm_auth for MS-CHAP is simple. First, if you use any other authentication types (such as local UNIX accounts) delete the testing entry used above from the users file, as leaving it in will break other authentication types. Instead, move it to the bottom of the file, so that other authentication types still work.
Then, fine the mschap module in /etc/freeradius/modules/mschap file, and look for the line containing ntlm_auth = . It is commented out by default, and should be uncommented, and edited to be as follows. As before, update the fields in bold to match your local configuration.
ntlm_auth = "/path/to/ntlm_auth --request-nt-key --username=%{mschap:User-Name:-None} --domain=%{%{mschap:NT-Domain}:-MYDOMAIN} --challenge=%{mschap:Challenge:-00} --nt-response=%{mschap:NT-Response:-00}"
Start the server and use a test client to send an MS-CHAP authentication request. The radclient cannot currently be used to send this request, unfortunately, which makes testing a little difficult If everything goes well, you should see the server returning an Access-Accept message as above.

More information:
http://wiki.freeradius.org/Authentication
http://tldp.org/HOWTO/8021X-HOWTO/freeradius.html
http://wiki.freeradius.org/FreeRADIUS_Active_Directory_Integration_HOWTO (Broken)
http://homepages.lu/charlesschwartz/radius/freeRadius_AD_tutorial.pdf
http://ubuntuforums.org/showthread.php?t=151388

Update: Here is my full krb5.conf file (my domain name has been replaced with "domain.local"). Note that this configuration includes many default settings which I haven't bothered to get rid of. All the MIT and standford stuff is unneccessary.


[libdefaults]
default_realm = DOMAIN.LOCAL

# The following krb5.conf variables are only for MIT Kerberos.
krb4_config = /etc/krb.conf
krb4_realms = /etc/krb.realms
kdc_timesync = 1
ccache_type = 4
forwardable = true
proxiable = true

# The following encryption type specification will be used by MIT Kerberos
# if uncommented. In general, the defaults in the MIT Kerberos code are
# correct and overriding these specifications only serves to disable new
# encryption types as they are added, creating interoperability problems.
#
# Thie only time when you might need to uncomment these lines and change
# the enctypes is if you have local software that will break on ticket
# caches containing ticket encryption types it doesn't know about (such as
# old versions of Sun Java).

# default_tgs_enctypes = des3-hmac-sha1
# default_tkt_enctypes = des3-hmac-sha1
# permitted_enctypes = des3-hmac-sha1

# The following libdefaults parameters are only for Heimdal Kerberos.
v4_instance_resolve = false
v4_name_convert = {
host = {
rcmd = host
ftp = ftp
}
plain = {
something = something-else
}
}
fcc-mit-ticketflags = true

[realms]
ATHENA.MIT.EDU = {
kdc = kerberos.mit.edu:88
kdc = kerberos-1.mit.edu:88
kdc = kerberos-2.mit.edu:88
admin_server = kerberos.mit.edu
default_domain = mit.edu
}
MEDIA-LAB.MIT.EDU = {
kdc = kerberos.media.mit.edu
admin_server = kerberos.media.mit.edu
}
ZONE.MIT.EDU = {
kdc = casio.mit.edu
kdc = seiko.mit.edu
admin_server = casio.mit.edu
}
MOOF.MIT.EDU = {
kdc = three-headed-dogcow.mit.edu:88
kdc = three-headed-dogcow-1.mit.edu:88
admin_server = three-headed-dogcow.mit.edu
}
CSAIL.MIT.EDU = {
kdc = kerberos-1.csail.mit.edu
kdc = kerberos-2.csail.mit.edu
admin_server = kerberos.csail.mit.edu
default_domain = csail.mit.edu
krb524_server = krb524.csail.mit.edu
}
IHTFP.ORG = {
kdc = kerberos.ihtfp.org
admin_server = kerberos.ihtfp.org
}
GNU.ORG = {
kdc = kerberos.gnu.org
kdc = kerberos-2.gnu.org
kdc = kerberos-3.gnu.org
admin_server = kerberos.gnu.org
}
1TS.ORG = {
kdc = kerberos.1ts.org
admin_server = kerberos.1ts.org
}
GRATUITOUS.ORG = {
kdc = kerberos.gratuitous.org
admin_server = kerberos.gratuitous.org
}
DOOMCOM.ORG = {
kdc = kerberos.doomcom.org
admin_server = kerberos.doomcom.org
}
ANDREW.CMU.EDU = {
kdc = vice28.fs.andrew.cmu.edu
kdc = vice2.fs.andrew.cmu.edu
kdc = vice11.fs.andrew.cmu.edu
kdc = vice12.fs.andrew.cmu.edu
admin_server = vice28.fs.andrew.cmu.edu
default_domain = andrew.cmu.edu
}
CS.CMU.EDU = {
kdc = kerberos.cs.cmu.edu
kdc = kerberos-2.srv.cs.cmu.edu
admin_server = kerberos.cs.cmu.edu
}
DEMENTIA.ORG = {
kdc = kerberos.dementia.org
kdc = kerberos2.dementia.org
admin_server = kerberos.dementia.org
}
DOMAIN.LOCAL = {
kdc = primaryserver.domain.local
admin_server = primaryserver.domain.local
default_domain = DOMAIN.LOCAL
}
stanford.edu = {
kdc = krb5auth1.stanford.edu
kdc = krb5auth2.stanford.edu
kdc = krb5auth3.stanford.edu
master_kdc = krb5auth1.stanford.edu
admin_server = krb5-admin.stanford.edu
default_domain = stanford.edu
}

[domain_realm]
.mit.edu = ATHENA.MIT.EDU
mit.edu = ATHENA.MIT.EDU
.media.mit.edu = MEDIA-LAB.MIT.EDU
media.mit.edu = MEDIA-LAB.MIT.EDU
.csail.mit.edu = CSAIL.MIT.EDU
csail.mit.edu = CSAIL.MIT.EDU
.whoi.edu = ATHENA.MIT.EDU
whoi.edu = ATHENA.MIT.EDU
.stanford.edu = stanford.edu
.slac.stanford.edu = SLAC.STANFORD.EDU
.domain.local = DOMAIN.LOCAL
domain.local = DOMAINL.LOCAL

[login]
krb4_convert = true
krb4_get_tickets = false

Monday, 1 February 2010

How to setup Linux (Ubuntu) Active Directory Authentication with Cached Credentials (Kerberos)

Running Linux, I'm using Kerberos & Samba to authenticate myself using Microsoft Windows Active Directory credentials from our domain controller. I used the guide for Ubuntu to get this setup. However, this would not allow me to login to my computer using AD credentials unless I was connected to the network (and it could access the domain controller). This is how I enabled "credential caching" for offline kerberos / Active Directory authentication on Ubuntu Linux.

I used two tutorials - Ubuntu Community Howto, and Cat in the Red Hat. Basically, since I already had Kerberos authentication working, I just installed the necessary packages:

sudo apt-get install nss-updatedb libnss-db libpam-ccreds

and then edited my /etc/pam.d/common-auth file as per Cat in the Red Hat's instructions.

Listed here is the entire contents of my /etc/pam.d/common-auth file (this allows me to authenticate using first AD credentials, then Unix accounts, then cached credentials):

auth sufficient pam_unix.so nullok try_first_pass
auth requisite pam_succeed_if.so uid >= 500 quiet
auth [default=ignore success=1 service_err=reset] pam_krb5.so use_first_pass
auth [default=die success=done] pam_ccreds.so action=validate use_first_pass
auth sufficient pam_ccreds.so action=store use_first_pass
auth required pam_deny.so
# prime the stack with a positive return value if there isn't one already;
# this avoids us returning an error just because nothing sets a success code
# since the modules above will each just jump around
auth required pam_permit.so
# and here are more per-package modules (the "Additional" block)
# end of pam-auth-update config


Some of the errors I encountered:

Firstly, caching will not work if you have a line like the following:

#Windows Domain Auth
#auth sufficient pam_winbind.so krb5_auth krb5_ccache_type=FILE


This basically skips everything else when a successful kerberos authentication is made. I just commented this line out, and it worked fine.

If you receive an error such as "su: Error in service module" when trying to login, it may be that your file is misconfigured. Check whether /var/cache/.security.db is being created or updated - if it isn't, then most likely PAM isn't reaching the line where pam_ccreds.so is referenced. Check that you don't have any auth sufficient lines where they shouldn't be.

If you're interested, there's also quite a nice GUI for Active Directory integration at Likewise. I haven't used it, but looks like an easy way to setup AD authentication from Ubuntu without editing heaps of config files.

How to connect to MSSQL (ODBC) from Linux PHP

Marcin Gil has an excellent guide about how to setup ODBC drivers on Linux to talk to a Microsoft MSSQl Server running on Windows. This uses the FreeTDS drivers & unixODBC, along with standard PHP/Apache setup.

After following these instructions, I found my database was still giving me the following error:

Warning: odbc_connect() [function.odbc-connect]: SQL error: [unixODBC][FreeTDS][SQL Server]Unable to connect to data source, SQL state S1000 in SQLConnect in /var/www/testdatabase/stdFunctions.php on line 49
Couldn't connect to SQL Server database


This was due to my database code not passing the correct username and password. I had to edit the odbc_connect() line to read as follows:

odbc_connect("database", "DOMAIN\username", "password");

Thursday, 28 January 2010

How to update CyanogenMod on HTC Magic 32A [Ubuntu]


I'm running CyanogenMod on my HTC Magic, and Ubuntu 9.10 (Karmic) on my laptop computer. Most of the upgrade guides & automated tools for upgrading CyanogenMod (i.e. CMUpdater) are based on the 32B kernel. This is a guide to upgrading CyanogenMod with a HTC Magic 32A kernel. Most of the instructions are taken from the CyanogenMod wiki.
  1. Download the latest CyanogenMod (Current Stable Version) from this site.
  2. Download the latest EBI1/32A Kernel from the same page.
  3. Copy both .zip files to your SD and reboot in Recovery Mode (press Home+Power at the same time or fastboot into your recovery) 
  4. Apply Zip: update-cm-xxxx-signed.zip
  5. Apply Kernel Port Zip: rad-4.xxxx.zip or bc-4.xxxx.zip (depends on who released the latest port: rad - Radix999,bc - bcrook ) 
  6. Reboot
  7. Wait. For a long time. =) Seriously, this will take ages to boot after an upgrade.
If you get an orange triangle & exclamation mark when you boot into recovery, just press Home+Power again to access the menu.


Ok, so what if you don't have an option to apply this zip in the recovery? If your phone only gives you the option to "apply update.zip" then you don't have the fancy recovery ROM. Download it from here (scroll down and choose the "H" version), and get the fastboot binary from here. Copy both into your android sdk "tools" directory.


Now, power down your phone, plug it into your computer via USB and press the Back and Power buttons at the same time. This should bring you to the fastboot screen. On your computer, cd into the android sdk tools directory, and type "fastboot boot ./recovery-RA-sapphire-vX.XX.zip". This will reboot the phone into the fancified recovery screen, which should let you update to any chosen zip file.

Oh, and note that this will not wipe your data!!! If you perform these steps completely and nothing goes wrong, all your apps and preferences will remain as they were. Of course, I can't guarantee anything. =) The only time you would wipe your phone is if you applied a full firmware upgrade (DRC83 in the filename, usually.) If you're unsure though, just leave a comment & I'll try to help! Or you could checkout the forums associated with some of the links above.

Wave1 Point to Point Radio (1000 series) Default Password

The default username and password details for Wave1 radios:

username: admin
password: default

Otherwise, try -

username: admin
password: admin01

This works for some of the newer LigoWave stuff.

Reseting a LigoWave Radio to Factory Defaults Using a Ping

Reseting a LigoWave Radio to Factory Defaults Using a Ping
It is possible to perform a factory reset of a LigoWave radio using a ping when you follow the instructions below.
The steps are:

  1. Obtain the Ethernet port MAC address
  1. Create a static arp entry for the Ethernet port MAC address on the same subnet you are on. For example your machine 192.168.2.2, and set radio at 192.168.2.61 (radio Ethernet MAC 00-19-3B-00-06-4A)
    1. arp –s 192.168.2.61 00-19-3B-00-06-4A
    2. you can confirm this entry is in place by looking at your arp table
      arp -a (the static arp entry should exist)
  1. Restart the radio
  1. Send a 40 pings to the radio static arp entry ip address with 369 bytes and every 200ms (ping needs to be started as soon as you restart the radio). 
    1. ping 192.168.2.61 –l 369 –w .2 –n 40
  1. The unit should restart using the factory defaults
  1. Remove the static arp entry
    1. arp –d 192.168.2.61

 


The important thing is to make sure the –w switch is used to increase the ping speed and that you are using the Ethernet MAC address, not the bridge MAC address that is seen you ping it normally.  The bridge MAC address is from the radio, and it will not respond during boot and the reset will not work.  I have put in 40 pings, as you should not send too many, -t, as if you don’t stop the pings in time you will get into a loop.  40 pings looks good from my testing.  

Source: http://www.wirelessdata.com.au/Wiki/tabid/385/Default.aspx?topic=LigoWave+Factory+Reset+Ping

Tuesday, 26 January 2010

Green Cars

This is a Sponsored Post written by me on behalf of Hyundai. All opinions are 100% mine.

You've probably read about how Hyundai recently won the Global Green Challenge with their latest "ToughR" cars. Well they've now got their own Youtube channel, where you can check out videos of their prize-winning trip from Darwin to Adelaide.

Hyundai's Santa Fe R claimed the title of the biggest improvement in fuel efficiency, 5.1l/10km, against contenders including Ford, Holden and Suzuki. During the Eco challenge, contestants were allowed to implement standard fuel-saving techniques such as driving without air-conditioning, despite high mid-Australian temperatures. Most also did the trip at average speeds of 75km/h which is well under the normal speed for the Stuart Highway of 130km/h in the Northern Territory and 100km/h in South Australia.

Hyundai is setting the standard in an increasingly competitive market for fuel-efficient, low-carbon "green" cars. Their Youtube videos are certainly worth checking out. They are presented in an semi-comedy style, very easy to watch and present some interesting and useful information about the challenges this competition presented.

There were also some other prizes awarded for the Global Green Challenge, based on different metrics:
On fuel efficiency improvement: 1 HSV Maloo 48.7 per cent improvement, 7.74l/100km average, official fuel rating 15.1l/100km; 2 Ford XR6 turbo Falcon  39.8%, 7.04l/100km, 11.7l/10km; 3 Skoda Superb 33.5%, 4.59l/100km, 6.9l/100km

On actual fuel consumption:  1 Ford Fiesta ECOnetic 3.13l/100km, 2 Mini D 3.42l/100km, 3 Mini D 3.49l/100km.

Visit my sponsor: Hyundai Santa Fe - AU 2

Thursday, 21 January 2010

Microsoft Exchange 2003 Incremental Backups with NTBackup.exe

When performing an incremental backup of a Microsoft Exchange Storage Group with NTBackup.exe, you may encounter the following error:

Backup Status
Operation: Backup
Active backup destination: File
Media name: "incremental_exchange.bkf created 21/01/2010 at 3:55 PM"


Error: SERVER\Microsoft Information Store\First Storage Group is not a valid drive, or you do not have access.


----------------------


This is a very obscure error message, and is almost impossible to decipher at face value. I spent many days trying to fix this error, and eventually discovered that you cannot create an incremental (or differential) backup when circular logging is enabled.

Turning off circular logging will enable an incremental backup to be created.

Another symptom encountered with this problem, was whenever I started an incremental backup it would continuously prompt me "Insert the following media: incremental_exchange.bkf created 21/01/2010 at 4:46pm Media #1. Do you want to continue?" When I clicked "Yes", it prompted me again. When I eventually clicked "No", the backup failed. The report showed the error message detailed above.

More information about circular logging:
http://www.computerperformance.co.uk/exchange2003/exchange2003_circular_logging.htm
How to disable circular logging:
http://technet.microsoft.com/en-us/library/bb331968%28EXCHG.80%29.aspx
Other similar threads:
http://www.ureader.com/msg/118930.aspx
http://www.ureader.com/msg/118930.aspx
How to create Exchange backups with NT Backup:
http://www.msexchange.org/tutorials/Exchange-2003-Backup-Restore-NTBACKUP.html

Tuesday, 19 January 2010

How to open Microsoft Word files in VIrtualBox Windows from Ubuntu

There's a great article about how to setup your system to you can double click a file in Ubuntu, and have it open in a Windows machine within VirtualBox. This, along with the seamless display technology built into the latest VirtualBox release, allows some pretty amazing integration scenarios.

Saturday, 16 January 2010

How to convert a directory of videos using ffmpeg

Here is a simple command useful for using a wildcard (not a regular expression) to select filenames to convert from one video format (or audio, for that matter) to another using FFMPEG on Linux.

The command below will convert a directory of .flac files into .mp3s:

for f in *.flac; do ffmpeg -i "$f" -acodec libmp3lame -ab 320k  "${f%.flac}.mp3"; done

To convert videos, we could use this command:

for f in *.flv; do ffmpeg -i "$f" "${f%.flv}.avi"; done

This converts a directory of .flv video files into .avi files.

Source: http://ubuntuforums.org/showthread.php?t=1096665

Monday, 4 January 2010

How to reset a Deliberant AP to Factory Defaults (CPE 2n)

From the manual available at the Deliberant Support Site:

Resetting to Factory Defaults
Deliberant products have the capability of being reset to defaults by pinging the device with a certain
packet size when the radio is booting.
During the startup of the device, when the drivers of the ethernet interfaces are loaded, the discovery
daemon is started. The daemon suspends startup process for 3 seconds and waits for ICMP "echo
request" packet of length 369 bytes. If the packet received, the discoveryd resets the device to default
configuration.
Steps to reset to default settings:
Step 1. Power off the device.
Step 2. Obtain the device MAC address.
Step 3. Connect a PC to the same physical subnet as the device.
Step 4. Execute 'arp -s' command to assign the IP address (IP address should be from the same
subnet as PC) to the device MAC address:
      arp -s [ip address to assign] [device address]
Step 5. Start pinging the device:
  For linux users:
      ping [ip address] -s 369
  For Windows users:
      ping [ip address] -l 369 -t -w 0.2
Step 6. Power up device and wait about 30sec or more (depends from device hardware).

I tested these steps with Deliberant AP Solo, Duo & CPE 2-N. Sometimes it takes a long time, but eventually will work.

Sunday, 3 January 2010

Fix: Firefox 3 runs slowly keeps pausing and not responding on Ubuntu 9.10 Dual core

When I installed Ubuntu 9.10 "Karmic" on my new HP Dual-core computer, I found that Firefox was having a lot of issues. It would startup alright, and load pages pretty fast. But mainly whenever I tried to open a new tab, or had a lot of tabs open, it would randomly stop responding for a few seconds at a time. Since I have compiz enabled, Firefox would "grey out" and stop responding to mouse clicks. CPU usage never exceeded 50% of both cores though.

I trued using the CPU Frequency Scaler applet on the panel to increase the CPU speed with no effect. Also, reducing the threshold at which the CPU frequency is raised had no effect either. It turns out that Firefox just doesn't like running across multiple CPUs for some reason. The solution was to restrict Firefox to run on a single core.

This can be accomplished using the linux utility "taskset". The command I used is shown below (run as root):

taskset -c -p 1 `pidof firefox`

An explanation:
  • The -c says to use a zero-based number to identify cores (Core 1 is "0", Core 2 is "1", etc). The default is to use a bitmask (more advanced).
  • The -p says to reuse the existing pid, and not start a new task.
  • Then we specify the core (Core 2 in this case, we could separate them with commas such as "0,1" if we wanted both cores to be used). 
  • Then we have another command, between backticks (` not ') that finds us the pid (Process ID) of the running Firefox.

This command has to be run every time Firefox starts. I'm looking for a way to change this automatically when Firefox is run - perhaps by changing the menu entry? Any suggestions are welcome!

Saturday, 2 January 2010

Free Sheet Music Scanning software for Linux - Audiveris

I've been using Sibelius on Windows, along with PhotoScore Lite to scan and transcribe sheet music to date. Recently I set out to find a Linux alternative.

Audiveris is a Java-based open source (therefore free) sheet music notation scanner. It will import a PDF or image file (single page as far as I can see) and automatically transcribe the notes into an on-screen digital version. You can then export to MIDI or MusicXML files, which can be edited in another program such as Rosegarden or MuseScore.

While this program is cross-platform and runs on Windows, Linux and Mac OS, it's advanced OCR features are limited to the Windows platform due to a dependency on Microsoft's C++ libraries. This may change in the future if more developers commit time to the project, but for now I have found it to be a very capable Linux alternative to some of the commercial Optical Music Recognition software. I particularly like the fine-grained reports and control you have over the entire process. In fact, you can examine any stage of the transcription in detail thanks to the multi-step procedure. Not the prettiest display, but then who wants pretty - so long as it gets the job done?