Change primary key column in SQL Server

Assuming that your current primary key constraint is called pk_history, you can replace the following lines: ALTER TABLE history ADD PRIMARY KEY (id) ALTER TABLE history DROP CONSTRAINT userId DROP CONSTRAINT name with these: ALTER TABLE history DROP CONSTRAINT pk_history ALTER TABLE history ADD CONSTRAINT pk_history PRIMARY KEY (id) If you don’t know what the … Read more

How can I use Prettify with Blogger/BlogSpot?

When you make a new entry in Blogger, you get the option to use HTML in your entry and to edit your blog entries. So type http://blogger.com, log in, and navigate to Posting → Edit Posts → Edit. In there put this at the top: <script type=”text/javascript” language=”javascript” src=”https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.js”></script> <script type=”text/javascript” language=”javascript” src=”https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/lang-css.min.js”></script> <script type=”text/javascript”> … Read more

Isolating Apache virtualhosts from the rest of the system

This can be done by enabling the mod_users module in Apache. You will need to setup UserDir in your apache configuration. I suggest you do this in a separate config file and include it. Wrap the include in <IfModule mod_users.c> Include conf/extra/userdir.conf </IfModule> I can give you the entire tutorial but this should get you … Read more

PHP session lost after redirect

First, carry out these usual checks: Make sure session_start(); is called before any sessions are being called. So a safe bet would be to put it at the beginning of your page, immediately after the opening <?php declaration before anything else. Also ensure there are no whitespaces/tabs before the opening <?php declaration. After the header … Read more

Tuning Apache2 prefork MaxClients ServerLimit

Apache prefork settings, per apache performance tuning guidelines quote: The single biggest hardware issue affecting webserver performance is RAM. A webserver should never ever have to swap, as swapping increases the latency of each request beyond a point that users consider “fast enough”. This causes users to hit stop and reload, further increasing the load. … Read more

Restrict a Linux user to the files he owns

Put a restricted and immutable directory between the outside world and the protected files, e.g. / ├─ bin ├─ home │ └─ joe <===== restricted and immutable │ └─ joe <== regular home directory or /home/joe/restricted/public_html. Restricted means that only the user and perhaps the web server can read it (e.g. modes 0700/0750 or some … Read more