technology and zen of life

“A heisenbug (named after the Heisenberg Uncertainty Principle) is a computer bug that disappears or alters its characteristics when an attempt is made to study it.”

.htaccess tips and tricks

If you have a webhosting you have to have basic know how of tips and tricks you can do with htaccess. So here is a list of basic actions that can be done via htaccess and how to use them.

 

Disable Directory Browsing

Options All -Indexes

Enable Directory Browsing
In the remote case that you want to list your directories:

Options +Indexes
## block a few types of files from showing
IndexIgnore *.wmv *.mp4 *.avi

Customize Error Messages

ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html

Change Default Page

The pages are searched in the order specified.

DirectoryIndex index.html index.htm index.php fallback.html

Forward all http://www.techmonks.net to http://techmonks.net (Good for removing duplicate links)

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.techmonks\.net$ [NC]
RewriteRule ^(.*)$ http://techmonks.net/$1 [R=301,L]

Redirect to a new URL

Redirect oldlocation.html http://www.techmonks.net/index.html
Redirect /subdamain http://www.techmonks.net/navin

Disable access to images from other websites (Hot linking)

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?techmonks.net/.*$ [NC]
RewriteRule \.(gif|jpg)$ - [F]

You can also replace it with a static/warning image:

RewriteRule \.(gif|jpg)$ http://techmonks.net/warningmessage.jpg [R,L]

Allow only local users

order deny,allow
deny from all
allow from 192.168.0.0/24 (replace with local subnet)

Block Users from accessing the site

order deny,allow
deny from 1.1.1.1 (deny subnet / ip)
deny from .blockeddomain.com
allow from all

Stop .htaccess (a file) from being viewed

order allow,deny
deny from all

Grant CGI (perl) Access in a directory

Options +ExecCGI
AddHandler cgi-script cgi pl

Enable Gzip compression

# BEGIN GZIP

AddOutputFilterByType DEFLATE text/html text/xml text/css application/x-javascript application/javascript

# END GZIP

 

Get SQL Agent service starting

Today I was struggling with Microsoft’s SQL Server. I could not get the SQL Agent service starting. Maybe my experiences can help you.

Introduction

Sometimes the SQL Agent service will not start, and it is quite hard to get the cause of this when the Error log doesn’t show much. The hints below were gathered from various websites and online forums, and some of them were tested with a Microsoft SQL Server 2008 R2 stand-alone instance running on Windows 7.

General testing

To get some idea of what is wrong, do this in a command shell:

C:
cd C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn
SQLAGENT.EXE -c -v

Error when editing SQL Agent settings

When in the SQL Server Configuration Manager, you might get an error like “the process terminated unexpectedly” after changing the SQL Agent settings.

Check the Windows Event log, Security. If there is a Event ID 6281, maybe with a file called l3codeca.acm, then maybe you are using Remote Desktop (RDP) and you have audio forwarding enabled. Disable it.

ErrorLogFile location

A wrong ErrorLogFile location could also result in an error like “the process terminated unexpectedly” after changing the SQL Agent settings in the SQL Server Configuration Manager.

The ErrorLogFile registry key must point to an existing file location.

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\SQLServerAgent]
"ErrorLogFile"="C:\\MyBigDataStore\\MSSQLSERVER\\MSSQL10_50.MSSQLSERVER\\MSSQL\\Log\\SQLAGENT.OUT"

Registry key permissions

The Windows user account that is being used to start the SQL Agent service must have full rights on the same registry key:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\SQLServerAgent]

I experienced some problems even after setting the permissions right. Consider giving the “Users” group (all users) full permissions (read & write). If you don’t like that, you could at least try that to see whether it’s a registry key permission issue.

Windows Groups

When the user being used to start the SQL Agent service is not a member of the local Administrators group or not the LocalSystem account, then you need to be sure that the user is a member of the SQLServerSQLAgentUser$SERVERNAME$MSSQLSERVER group. Note that you need to set SERVERNAME to your specific server name.

Furthermore, this group might need to have permissions on various folders, and also needs a SQL login on the SQL database with sysadmin permissions.

SQL login

The user being used to start the SQL Agent service needs a matching SQL login on the SQL database with sysadmin permissions.

If you migrate the master database to another computer or a new domain, then the SIDs of the Windows accounts will probably be different, even although the usernames and group names are the same. You need to create new SQL logins and map them to proper SQL user permissions.

For example, when using a Windows user “sqlagent” to start the service, you need:

CREATE LOGIN [MYSERVER\sqlagent] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english]
GO
EXEC sp_grantlogin [MYSERVER\sqlagent]
EXEC sp_addsrvrolemember @loginame = [MYSERVER\sqlagent], @rolename =  'sysadmin'

Virtual Host or Alias

When in clustered mode, then the virtual host or alias name for the SQL Agent service needs to match the one of the SQL Server service. Check the properties in the SQL Server Configuration Manager.

Enable Agent XPs

This seems to be needed in some scenarios.

sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Agent XPs', 1;
GO
RECONFIGURE
GO

Broker

Some broker functionality was mentioned on a forum. It was rumored that the broker should be enabled. You can check that with:

SELECT is_broker_enabled FROM sys.databases WHERE name='msdb'

But I’m not sure whether this is needed.

 

(Original article first published at my personal weblog.)

Installing Haiku directly to a disk partition

haiku Installing Haiku directly to a disk partitionIntroduction

Haiku is something like Windows or Linux: an Operating System (OS). Some geeks like to play with alternative operating systems; it you are one of such geeks, you might want to give Haiku a try. Haiku is very fast and easy to use, but currently there are not many applications you can use with Haiku.

Haiku is a new open-source operating system that specifically targets personal computing. Inspired by the BeOS, Haiku is fast, simple to use, easy to learn and yet very powerful.

In this post, I will describe how to install Haiku on a spare harddisk partition directly without using a CD-ROM or USB memory key. I furthermore assume that you already installed Linux on another partition.

I would like to express my gratitude to luroh, a Haiku developer, for providing help on this topic.

Steps to be taken (summary)

  1. Download a Haiku Anyboot image.
  2. Convert Anyboot to a raw image.
  3. Write the raw image to a disk partition.
  4. Make the partition bootable.
  5. Add the partition to your boot loader.
  6. Set the partition type.

Download Haiku

You need to download an Anyboot image from the Haiku website.

Convert Anyboot to a raw image

Anyboot images are a combination of ISO and raw images. They can be written to CD-ROMs, USB memory keys and harddisks. If you need to write the image to a partition, then you must first convert the Anyboot image to a raw image. You can do so using:

dd if=haiku-anyboot.image of=haiku.raw bs=1M skip=$(expr $(od -j 454 -N4 -i -A n haiku-anyboot.image) / 2048)
dd if=/dev/zero of=haiku.raw bs=1 seek=506 count=4 conv=notrunc

Please modify the blue filenames as needed.

Write the raw image to a disk partition

For example, to write the raw disk image to the second partition of “sda2″:

dd if=haiku.raw of=/dev/sda2 bs=1M conv=notrunc

Again, modify as needed.

Make the partition bootable

After the image is written to the partition, it needs to be modified to make it bootable. You need the makebootable program from Haiku. You can also use makebootabletiny with Linux. (If the link to makebootabletiny would no longer work, here is a local copy: makebootabletiny.c download.)

Assuming that you downloaded makebootabletiny, you need to compile and run it:

gcc makebootabletiny.c -o makebootabletiny
./makebootabletiny /dev/sda2

Add the partition to your boot loader

This really depends on which boat loader you are using. For grub (legacy), you need to add these lines to /boot/grub/menu.lst:

title Haiku
rootnoverify (hd0,1)
chainloader +1

Check the documentation of your specific bootloader. Also you can check the Haiku Installation Guide.

Set the partition type

Optionally, you should set the partition type to “BeFS” using fdisk.

If you want to stay updated on alternative operating systems, keep an eye on www.osnews.com.

This howto is now included in the Haiku installation Guides.

10 Must Have Apps for the new Apple iPhone 5

The all new iPhone 5 was launched on September 12, 2012 (watch the keynote here). With a better processor and a bigger screen, iPhone 5 offers few more opportunities to app developers to harness the new hardware features. Although the iPhone 5 (which comes with the new iOS6) has a native integration with Facebook and Twitter, there are a host of other apps (free + paid) that are definitely a must have for the iPhone 5. This article lists out ten must have apps for the iPhone 5. Although the article is particularly directed towards the new iPhone, all of these apps are also compatible with iPhone 3GS, 4, and 4S.

Read the rest of this entry »

Photography now at 1,000,000,000,000 frames per second!

 

Move over high speed camera here comes fem-to camera. Imagine being able to capture frames so fast that you can see light moving a millimeter of a distance and no this is not fantasy but something that actually has been done. Now think about the various scientific capabilities of such a technological wonder; from studying light waves as move and interact with various objects and mediums to seeing around the corner, checking if a fruit is ripe by shining light on it and possibly many more.

The paper on how they use this technology to see around the corners can be found on Nature.com

Here is the TED video: Read the rest of this entry »

Best free productivity Android Apps for S3

Now that you just got yourself one of the best smartphones around the Samsung Galaxy SIII it is time to start installing apps on it. Galaxy S III already comes pre-installed with apps like. Google Search, Maps, Navigator, Gmail, YouTube, Calendar, Google Talk, Picasa integration, Swype, Dropbox etc. Here I have jotted down some more essential free apps for Galaxy SIII to get the most out of your phone. Though this list is focused on S3 most of these apps are good for any android device.

Read the rest of this entry »

Horizontal Scrolling for MySQL queries in Linux

Everyone who works with databases on a linux terminal faces this issue at some point in time — executing select * on a table with too many columns. And in linux since there is no horizontal scrolling, the output is wrapped and hence completely unusable.

You can use

--pager

property to get rid of that text wrap.
Read the rest of this entry »

A simple Timer for Windows

A while ago, I needed a simple desktop Timer application. I didn’t like any of all the existing ones, so I wrote my own. It’s called EvertTimer.

screenshot EvertTimer A simple Timer for Windows

screenshot of EvertTimer

Read the rest of this entry »

Email Subscription

Disclaimer

The views expressed on this blog are personal. We do not claim to be a representative voice of the views of any organisation whatsoever. We are not responsible for the content present on the blogs to which we have linked.Views expressed are solely that of the author and does not reflect a collective opinion of contributors.