Formats Date in YUI
Formats date to YYYY-MM-DD:
var new_date = YAHOO.util.Date.format(new Date(current_date), { format: "%Y-%m-%d"});
How to Get Difference Between Dates in YUI
To get number of days between 2 dates:
var numnights = dateDiff(new Date(end_date.value),new Date(start_date.value));
new Date() = converts the date value to its raw format.
Sticky Sidebar
CSS Code:
#sidebar-move-wrapper {
position: fixed;
}
Javascript Code:
<script type="text/javascript">
// <![CDATA[
window.onscroll = function() {
if( window.XMLHttpRequest ) {
if ((document.body.scrollTop > 280) || (document.documentElement.scrollTop > 280)) {
document.getElementById('sidebar').style.position = 'fixed';
document.getElementById('sidebar').style.top = '0';
} else {
document.getElementById('sidebar').style.position = 'absolute';
document.getElementById('sidebar').style.top = 'auto';
}
}
}
// ]]>
</script>
Importing PostgreSQL in Windows
In the cmd, go to: C:\Program Files\PostgreSQL\9.0\bin
Then type:
psql -f db_file.sql -U postgres -d dbname
Note: Your database must exist.
–
Thanks Ralph!
To Kill an Application in Ubuntu
In the terminal, search for the application’s ID:
ps auwx | grep -i office
The terminal will return something like:
euri 2447 0.3 5.1 720112 104280 ? Sl 14:19 0:19 /usr/lib/openoffice/program/soffice.bin -calc /home/euri/Desktop/activities_next_release.xls -splash-pipe=5 euri 3288 0.0 0.0 7624 1012 pts/0 S+ 15:46 0:00 grep --color=auto -i office
Then, kill the application using the ID.
kill -9 2447
–
Thanks Pao! :D
Installing VirtualHosts in Apache2 Using Ubuntu
Assuming Apache2 is already installed.
Go to the sites-available directory:
cd /etc/apache2/sites-available
Copy the default, and name it to a new one:
sudo cp default <strong>beyondeternal.com</strong>
Edit that new file you created with it’s Vhost stuff:
gksudo gedit beyondeternal.com
Sample Vhost setting:
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName euri.beyondeternal.com
ServerAlias euri.beyondeternal.com
# Indexes + Directory Root.
DirectoryIndex directory_dev.php
DocumentRoot /home/euri/projects/beyondeternal.com/web/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/euri/projects/beyondeternal.com/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
# sf directory
Alias /sf/ /home/euri/projects/beyondeternal.com/lib/vendor/symfony/data/web/sf/
# Logfiles
ErrorLog /home/euri/projects/beyondeternal.com/log/error.log
CustomLog /home/euri/projects/beyondeternal.com/log/access.log combined
</VirtualHost>
Link the sites-available to the sites-enabled:
sudo a2ensite beyondeternal.com
Note: Do not forget to make your directory /home/euri/projects/beyondeternal.com/ writable. :)
apache2.conf location:
gksudo gedit /etc/apache2/apache2.conf
Change Password in Ubuntu
In the terminal, type:
passwd
For the root password, type:
sudo passwd <profile>
Hosts file in Ubuntu
GUI
gksudo gedit /etc/hosts
Command line:
sudo vi /etc/hosts
Or
[gk]sudo <your favorite editor> filename
–
credit.
Apache Stuff
To restart Apache server:
sudo /etc/init.d/apache2 restart
JS Date
To get new date:
var date = new Date();
To convert YYYY-MM-DD to JS date format:
var cDate = new Date(oDate);
To convert JS date to YYYY-MM-DD format:
cDateY = cDate.getFullYear();
cDateM = cDate.getMonth()+1;
cDateD = cDate.getDate();
if (cDateM < 10) {
cDateM = "0" + cDateM;
}
cDate = cDateY + "-" + cDateM + "-" + cDateD;
