Formats Date in YUI

January 18, 2012 Leave a comment

Formats date to YYYY-MM-DD:

var new_date = YAHOO.util.Date.format(new Date(current_date), { format: "%Y-%m-%d"});

Categories: Javascript, YUI

How to Get Difference Between Dates in YUI

January 18, 2012 Leave a comment

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.

Categories: Javascript, YUI

Sticky Sidebar

August 25, 2011 Leave a comment

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>

Categories: Javascript

Importing PostgreSQL in Windows

July 20, 2011 Leave a comment

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!

Categories: PostgreSQL

To Kill an Application in Ubuntu

July 6, 2011 Leave a comment

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

Categories: Ubuntu

Installing VirtualHosts in Apache2 Using Ubuntu

May 2, 2011 Leave a comment

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

Categories: Apache, Symfony, Ubuntu

Change Password in Ubuntu

April 29, 2011 Leave a comment

In the terminal, type:

passwd

For the root password, type:

sudo passwd <profile>

Categories: Ubuntu

Hosts file in Ubuntu

April 28, 2011 Leave a comment

GUI

gksudo gedit /etc/hosts

Command line:

sudo vi /etc/hosts

Or

[gk]sudo <your favorite editor> filename


credit.

Categories: Ubuntu

Apache Stuff

April 27, 2011 Leave a comment

To restart Apache server:

sudo /etc/init.d/apache2 restart

Categories: Apache

JS Date

April 23, 2011 Leave a comment

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;

Categories: Javascript
Follow

Get every new post delivered to your Inbox.