There are some methods that allows you to change the timezone of the PHP (5.1+) scripts (ie, when the date is not shown due to a different timezone of the server).
The first one is by modifying the php.ini file of the web server (if you are allowed to). We just need to add the following line:
date.timezone = "America/Lima"
Other method is using the ini_set() function directly on your script (at the beginning of it), this way:
ini_set('date.timezone', 'America/Lima');
And the third method consist on the use of the function date_default_timezone_set() (also, directly on your script):
I found a very handy SQL script on this post, that allows you to enable or disable all constraints on a database. The only problem I had was that my database uses schemas to organize the tables, so the script failed to work.
I made a modification on the script to solve the problem, so here it is:
/************************** DISABLE ALL TABLE CONSTRAINTS **********************************
This script will enable or disable all constraints on all tables within the database
that it is run in.
********************************************************************************************/SET NOCOUNT ONSET ROWCOUNT 0DECLARE @COUNTINTDECLARE @String nvarchar (1000)DECLARE @ConstraintName VARCHAR(128)DECLARE @TableName VARCHAR(128)DECLARE @SchemaName VARCHAR(128)--Find all constraints and their respective tables from the sysobjects table and place into a temp table.--Primary Key and Unique Constraints via Unique Indexes are not disabled through this command--You should use the ALTER INDEX...DISABLE command in SQL Server 2005SELECT
o.name AS ConstraintName,
sc.name AS SchemaName,
object_name(o.parent_obj)AS TableName
INTO #Const_Table
FROM sysobjects o, sys.schemas sc
WHERE xtype IN('F')AND o.uid = sc.schema_id
SELECT @COUNT=COUNT(*)FROM #Const_Table
--Setting the rowcount to one allows for one row from the temp table to be picked off at a time.--Used as an alternative to a cursor.SET ROWCOUNT 1--Loop until all rows in temp table have been processed.
WHILE @COUNT>0BEGIN--The rowcount of one ensures that only one tablename and constraint name is picked.SELECT @TableName = TableName, @SchemaName = SchemaName, @ConstraintName = ConstraintName
FROM #Const_Table
--Comment or uncomment the following statements according to your needs--Build execution string to enable constraint.SET @String ='ALTER TABLE ['+ @SchemaName +'].['+ @TableName +'] WITH CHECK CHECK CONSTRAINT ['+ @ConstraintName +']'--Build execution string to disable constraint.--SET @String = 'ALTER TABLE ['+ @SchemaName + '].['+ @TableName + '] NOCHECK CONSTRAINT [' + @ConstraintName +']'--Execute the SQLEXEC sp_executesql @string
--Remove this row from the temp table, since it has now been processed.DELETEFROM #Const_Table
WHERE ConstraintName = @ConstraintName AND TableName = @TableName AND SchemaName = @SchemaName
SET @COUNT= @COUNT-1END-- LoopDROPTABLE #Const_Table
SET ROWCOUNT 0
/************************** DISABLE ALL TABLE CONSTRAINTS **********************************
This script will enable or disable all constraints on all tables within the database
that it is run in.
********************************************************************************************/
SET NOCOUNT ON
SET ROWCOUNT 0
DECLARE @Count int
DECLARE @String nvarchar (1000)
DECLARE @ConstraintName varchar(128)
DECLARE @TableName varchar(128)
DECLARE @SchemaName varchar(128)
--Find all constraints and their respective tables from the sysobjects table and place into a temp table.
--Primary Key and Unique Constraints via Unique Indexes are not disabled through this command
--You should use the ALTER INDEX...DISABLE command in SQL Server 2005
SELECT
o.name AS ConstraintName,
sc.name AS SchemaName,
object_name(o.parent_obj) AS TableName
INTO #Const_Table
FROM sysobjects o, sys.schemas sc
WHERE xtype in ('F') AND o.uid = sc.schema_id
SELECT @Count = Count(*) FROM #Const_Table
--Setting the rowcount to one allows for one row from the temp table to be picked off at a time.
--Used as an alternative to a cursor.
SET ROWCOUNT 1
--Loop until all rows in temp table have been processed.
WHILE @Count > 0
BEGIN
--The rowcount of one ensures that only one tablename and constraint name is picked.
SELECT @TableName = TableName, @SchemaName = SchemaName, @ConstraintName = ConstraintName
FROM #Const_Table
--Comment or uncomment the following statements according to your needs
--Build execution string to enable constraint.
SET @String = 'ALTER TABLE ['+ @SchemaName + '].['+ @TableName + '] WITH CHECK CHECK CONSTRAINT [' + @ConstraintName +']'
--Build execution string to disable constraint.
--SET @String = 'ALTER TABLE ['+ @SchemaName + '].['+ @TableName + '] NOCHECK CONSTRAINT [' + @ConstraintName +']'
--Execute the SQL
EXEC sp_executesql @string
--Remove this row from the temp table, since it has now been processed.
DELETE FROM #Const_Table
WHERE ConstraintName = @ConstraintName AND TableName = @TableName AND SchemaName = @SchemaName
SET @Count = @Count - 1
END -- Loop
DROP TABLE #Const_Table
SET ROWCOUNT 0
To be allowed to show Nginx graphs on the Munin report, it is required to enable nginx status and to listen on:
http://127.0.0.1/nginx_status
To do this, we just need to add the following code on /etc/nginx/sites-enabled/default or into any other site file (like create a new one /etc/nginx/sites-available/status and then make symbolic link to site-enabled directory):
Today, I decided to try the VMWare ESXi, the free bare metal virtualization product of VMWare, on an old Pentium 4 3.2GHz PC (with 2.5GB of RAM), and run on top of it, some Ubuntu servers.
I was not able to use the latest version (4.x) of the ESXi as it only works on 64-bit boxes. Instead, the version 3.5 does work on 32-bit processors as the one I’m using.
As I didn’t want to burn a CD with the installer, I chose to use an USB stick to make the installation. So, the first thing to do was converting the ISO installer into a USB, using this software. I had a little problem, that I solved in some minutes with the help of Google.
After that, the installation ran without problems (there is a nice ESXi installation guide here) and the server was up and running some minutes later.
Then, I just unplugged the monitor, keyboard and mouse from that PC, as they are not gonna be needed anymore. I installed the VMWare vSphere Client on my main machine to manage the server.
So far, I have installed two Ubuntu Linux servers and they are running with not bad performance, at least, enough for testing and development.
The Trim method on C# only removes whitespaces at the beginning and at the end of a string, but it does not remote duplicated whitespaces inside the string (like the Trim function on VB for Apps), which is very handy sometimes.
One of the ways to do it on C#, is using Regular Expressions. This method will not only remove whitespaces but also tabs and line breaks, and will replace them with one whitespace.
string s1 ="He saw a cute\tdog.\nThere\n\twas another sentence.";
Regex r =new Regex(@"\s+");string s2 = r.Replace(s1, @" ");// The result would be: He saw a cute dog. There was another sentence.
string s1 = "He saw a cute\tdog.\nThere\n\twas another sentence.";
Regex r = new Regex(@"\s+");
string s2 = r.Replace(s1, @" ");
// The result would be: He saw a cute dog. There was another sentence.
You will need to add the reference to System.Text.RegularExpressions to your namespace.
Source: Dot Net Perls
There is no operator to concatenate two strings in NVelocity (the .Net version of Velocity) like we can do on other languages like C# or PHP, with the plus (+) operator for the first one and dot (.) for the second one. For example, in C# we would do:
string strHello ="Hello "+"World";
string strHello = "Hello " + "World";
And in PHP:
$hello="Hello "."World";
$hello = "Hello " . "World";
But in NVelocity, what we must do if we need to do this same thing would be:
#set ($str1 = "Hello ")
#set ($str2 = "World")
The concatenated string would be: $str1$str2
#set ($str1 = "Hello ")
#set ($str2 = "World")
The concatenated string would be: $str1$str2