Add Printer to CentOS
Add Network Printer to CentOS/Ubuntu
sudo /etc/init.d/cups start
[/sourcecode]
sudo su -
system-config-printer
[/sourcecode]
Showing hisotry of your Linux commands
1. If you want to show wehen the command was issued:
$ export HISTTIMEFORMAT='%F %T '
$ history > file_name
2. Search the history using Control+R
Showing hisotry of your Linux commands
1. If you want to show wehen the command was issued:
$ export HISTTIMEFORMAT='%F %T '
$ history > file_name
2. Search the history using Control+R
Visit websense blocked sites?
Are you tied of the following message?
"Content blocked by your organization
Reason:
This Websense category is filtered: Explicitly Blocked."
If you answer yes, try to visit the site though here:
https://proxy1plus.appspot.com/
Visit websense blocked sites?
Are you tied of the following message?
"Content blocked by your organization
Reason:
This Websense category is filtered: Explicitly Blocked."
If you answer yes, try to visit the site though here:
https://proxy1plus.appspot.com/
Curious which verison of the CentOS you are running?
if you see
Linux XXXXXX 2.6.18-238.19.1.el5 #1 SMP Fri Jul 15 07:31:24 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
Then you are running 64 bit of CentOS.
Command cat /etc/redhat-release will show you the version of theCentOS
Curious which verison of the CentOS you are running?
if you see
Linux XXXXXX 2.6.18-238.19.1.el5 #1 SMP Fri Jul 15 07:31:24 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
Then you are running 64 bit of CentOS.
Command cat /etc/redhat-release will show you the version of theCentOS
Do not update the Creeky Ipad's firmware!
Or you will probably enter the endless "recovery mode" loop. It happened to me one time before while I was updating the firmware. And it happened again. I should never trust AP@LE. To get out the loop I have tried many ways I found online, however all most all of them do not work.
Try the following methods first if it happens to you.
Hold on booth home key and power key for at least 10 seconds, ipad will reboot. If you are lucky it will out of the recovery mode by doing so. ---Good for you.
The upper method works for me last time, but does not work this time. The only way works is do the following:
1. Uninstall old version of the iTunes and reboot your computer
2. Reinstall the most updated iTunes
3. Go to c:\ windows\system32\drivers\etc\ to locate the host file, delete the following two lines from the host file:
74.208.10.249 gs.apple.com
#127.0.0.1 gs.apple.com
4. Open iTunes and redo the recovery.
===============================
Unsuccessful methods:
Here are some others recommended to do with the "endless recovery mode":
1. Enter the DFU mode:
DFU mode as opposed to Recovery Mode, requires a bit of timing and can take practice so if at first you don’t succeed, don’t be afraid to keep trying.
- Plug your iPhone, iPod touch, or iPad into your Mac or Windows PC and make sure iTunes is running.
- Hold down both the Sleep Button (on top of your device) and the Home Button (on the front underneath the screen).
- Keep them both held down from about 10 seconds. (If you see the Apple logo, you’ve held them too long and will need to start again.)
- Let go of the Sleep Button but keep holding the Home Button for about 5 seconds. (If you see the “Plus into iTunes” screen than you held it too long and will need to start again.)
- If the screen stays black, that’s it! Your iPhone, iPod touch, or iPad should now be in DFU mode.
- Download TinyUmbrella (Fix Recovery) for iOS 4.3.x (Windows | Mac)
- Download Zlib1.dll from here and place it in the same directory in which fixrecovery43.exe is present.
- Launch iTunes and plug your iPhone into your PC or Mac via USB cable. Let iTunes run in background and use the following instructions to put your iPhone into DFU mode:
- Hold down the Home+Power button simultaneously for 10 seconds.
- After 10 seconds, release the Power button but keep holding the Home button until iTunes detects your iPhone into DFU mode.
- Do not close iTunes. Let it run in the background.
- Launch fixrecovery43.exe and wait while it kicks your iPhone out of recovery mode loop. Make sure you have an active internet connection because fix recovery will be needing to fetch DFU and firmware image from Apple servers. Whole process usually takes less than a minute.
Do not update the Creeky Ipad's firmware!
Or you will probably enter the endless "recovery mode" loop. It happened to me one time before while I was updating the firmware. And it happened again. I should never trust AP@LE. To get out the loop I have tried many ways I found online, however all most all of them do not work.
Try the following methods first if it happens to you.
Hold on booth home key and power key for at least 10 seconds, ipad will reboot. If you are lucky it will out of the recovery mode by doing so. ---Good for you.
The upper method works for me last time, but does not work this time. The only way works is do the following:
1. Uninstall old version of the iTunes and reboot your computer
2. Reinstall the most updated iTunes
3. Go to c:\ windows\system32\drivers\etc\ to locate the host file, delete the following two lines from the host file:
74.208.10.249 gs.apple.com
#127.0.0.1 gs.apple.com
4. Open iTunes and redo the recovery.
===============================
Unsuccessful methods:
Here are some others recommended to do with the "endless recovery mode":
1. Enter the DFU mode:
DFU mode as opposed to Recovery Mode, requires a bit of timing and can take practice so if at first you don’t succeed, don’t be afraid to keep trying.
- Plug your iPhone, iPod touch, or iPad into your Mac or Windows PC and make sure iTunes is running.
- Hold down both the Sleep Button (on top of your device) and the Home Button (on the front underneath the screen).
- Keep them both held down from about 10 seconds. (If you see the Apple logo, you’ve held them too long and will need to start again.)
- Let go of the Sleep Button but keep holding the Home Button for about 5 seconds. (If you see the “Plus into iTunes” screen than you held it too long and will need to start again.)
- If the screen stays black, that’s it! Your iPhone, iPod touch, or iPad should now be in DFU mode.
- Download TinyUmbrella (Fix Recovery) for iOS 4.3.x (Windows | Mac)
- Download Zlib1.dll from here and place it in the same directory in which fixrecovery43.exe is present.
- Launch iTunes and plug your iPhone into your PC or Mac via USB cable. Let iTunes run in background and use the following instructions to put your iPhone into DFU mode:
- Hold down the Home+Power button simultaneously for 10 seconds.
- After 10 seconds, release the Power button but keep holding the Home button until iTunes detects your iPhone into DFU mode.
- Do not close iTunes. Let it run in the background.
- Launch fixrecovery43.exe and wait while it kicks your iPhone out of recovery mode loop. Make sure you have an active internet connection because fix recovery will be needing to fetch DFU and firmware image from Apple servers. Whole process usually takes less than a minute.
Linux find and replace text within all files within a directory
There is a fast way to replace all the occurrences of one world within a certain directory including subdirectory by using a one line Linux code (by using Perl):
find /path/to/start/from/ -type f | xargs perl -pi -e 's/old_word/new_word/g'
REMEMBER ALWAYS BACKUP BEFORE DOING SOMETHING
Linux find and replace text within all files within a directory
There is a fast way to replace all the occurrences of one world within a certain directory including subdirectory by using a one line Linux code (by using Perl):
find /path/to/start/from/ -type f | xargs perl -pi -e 's/old_word/new_word/g'
REMEMBER ALWAYS BACKUP BEFORE DOING SOMETHING
Install a new version of the Python on CentOS without overwriting the system's python installation
- cd
- wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz
- tar –zvxf Python-2.7.2.tgz
- cd Python-2.7.2
- configure python so it will not overwriting the system’s default python
- make and install
- add the following line to user’s .bashrc to create an alias, so you do not need reboot to start using the alias
- Configure ld to find your shared libs:
2 Install pip
Follow the same operation process for installing setuptools. After installing the pip you may want to make a symbolic link for it in the /usr/bin folder
Reference:
1. Thanks http://thebuild.com/blog/2009/10/17/wordpress-to-djangopostgresql-part-3-installing-apache-python-2-6-psycopg2-and-mod_wsgi/ for tips on overcoming the errors while installing the psycopg2 by link thelibraries to /usr/lib64.
2. http://blog.hackedexistence.com/mediatemple-centos-5-5-ve-server-build-django-1-3-python-2-7-mysql-5-5-php-5-3
Install a new version of the Python on CentOS without overwriting the system's python installation
1. Install epel (extra packages for enterprise linux). This will add the epel repo to yum and give us a running start at some normally unavailable packages. It also provides some updates to existing repo packages:
To install EPEL follow this link: http://b2ctran.wordpress.com/2013/03/08/enable-epel-repository-on-centos/
2. Preinstall dependencies: development tools, ssl and zlib and some other packages which will be needed by python
$ yum -y groupinstall 'Development Tools'
$ yum -y install openssl-devel zlib zlib-devel
$ yum install -y gdbm-devel sqlite-devel tk-devel ncurses-devel bzip2-devel readline-devel db4-devel
3. Prepare python2.7 source code
$ cd
$ wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz
$ tar –zvxf Python-2.7.2.tgz
$ cd Python-2.7.2
Configure the Modules/Setup.dist to enable the gzip and readline support by uncomment the associated entries.
#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib –lz
#readline realine.c -lreadline –ltermcap
4. configure python so it will not overwriting the system’s default python
./configure –prefix= /opt/python2.7 --with-threads --enable-shared
1)--enable-shared is required if you are going to install mod_wsgi. Or you have to rebuild the python library.
2) However, if you choose –enable-shared parameter you may encounter error while you are trying to install pscopg2.
The error message is "ld cannot find lpython2.7".
Here is a solution to that:
$ cd /usr/lib64
$ sudo ln -s /opt/python2.7/lib/libpython2.7.so.1.0 libpython2.7.so.1.0
$ sudo ln -s libpython2.7.so.1.0 libpython2.7.so
5. make and install
$ make
$ sudo make install
6. Now we need to update BASH so that it knows about the new shared libraries that we have put on the system.
$ sudotouch /etc/ld.so.conf.d/opt-python2.7.conf
add put /opt/python2.7/lib in the created file
$ sudo /sbin/ldconfig
7. install setuptools and pip:
$wget https://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
$sudo sh setuptools-0.6c11-py2.7.egg
if you encounter python2.7 could not found error, the following will probably fix it:
$ sudo ln -s /opt/python2.7/bin/python /usr/bin/python2.7
After installing easy_install you can install pip: sudo /opt/python2.7/bin/easy_install pip
Configure mod_wsgi with Apache for running Django project
1. Install mod_wsgi
[sourcecode language="bash"]
#http://code.google.com/p/modwsgi/downloads/list
wget http://modwsgi.googlecode.com/files/mod_wsgi-3.4.tar.gz
tar -zvxf mod_wsgi-3.4.tar.gz
cd mod_wsgi-3.4
#here must define which python to use
#make: *** [mod_wsgi.la] Error 1
./configure --with-python=/opt/python2.7/bin/python
make
sudo make install
[/sourcecode]
if you encounter an error during configure, "checking Apache version... ./configure: line 1704: apxs: command not found"
make sure you have development package of httpd (apache) installed on your machine.
[sourcecode language="bash"]
yum install httpd-devel.x86_64
[/sourcecode]
2. Configure httpd to load mod_wsgi
[sourcecode language="bash"]
#create file mod_wsgi.conf under /etc/httpd/conf.d
sudo vim /etc/httpd/conf.d/mod_wsgi.conf
#save the following line to mod_wsgi.so file
LoadModule wsgi_module modules/mod_wsgi.so
#restart the httpd service
sudo /etc/init.dhttpd restart
[/sourcecode]
Part two: make necessary configuration in /etc/httpd/conf/httpd.conf
In this part of the configuration we are using the Apache VirtualHost to host the django project.
1. Configure apache to serve VirtualHost:
[sourcecode language="text"]
# a. add one more port for listening by Apache which will be specifically used for virtual host:
Listen 8081
# b. uncomment NameVirtualHost *:80 and change the port number from 80 to the port number you defined in step (a), which is 8081 in my case
[/sourcecode]
2. Add the following configuration for virtual host:
[sourcecode language="text"]
ServerName virtual name of your server
ServerAdmin your email address
DocumentRoot /srv/www/...../cmsdj/
WSGIScriptAlias / /srv/www/..../cmsdj/apache/django.wsgi
Order allow,deny
Allow from all
ErrorLog /srv/www/..../cmsdj/logs/error.log
CustomLog /srv/www/..../cmsdj/logs/access.log combined
[/sourcecode]
3. Create django.wsgi file under your app folder
The detail path to your wsgi file is in the upper virtual host configuration file:
[sourcecode language="text"]
/srv/www/...../cmsdj/apache/django.wsgi
[/sourcecode]
The content of this file:
[sourcecode language="python"]import os
import sys
path = '/srv/www/foodborn.nctr.fda.gov/' #do not add the project folder name to this path
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'cmsdj.settings'
os.environ['PYTHON_EGG_CACHE'] = '/srv/www/foodborn.nctr.fda.gov/.python-eggs'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
[/sourcecode]
4. Check your project’s urls.py file to make sure that you are using the full path to the models you are importing and in the urls maps:
[sourcecode language="python"]
a. (r'^$', 'core.views.index') is not the full path since you are omitting the name of the project, which should be changed to (r'^$', 'cmsdj.core.views.index'),
b. “from core import views” is not the full path, you need add project name “from cmsdj.core import views”
[/sourcecode]
Part Three: serving the admin files
Make sure your project’s settings.py file contents this sentence:
[sourcecode language="bash"]
ADMIN_MEDIA_PREFIX = '/media/'
[/sourcecode]
Then you run the following command to collect all the static files needed by admin models into the project admin folder.
[sourcecode language="bash"]
python manage.py collectstatic
[/sourcecode]
References:
1. http://blog.perplexedlabs.com/2008/11/10/setup-python-25-mod_wsgi-and-django-10-on-centos-5-cpanel/
2. https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#module-django.contrib.staticfiles
3. https://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/
Configure mod_wsgi with Apache for running Django project
Bypass views to render a static page/template in Django Project
Bypassing views to render a static template, add this line in "urls.py". For example "About Us" page could be:
(r'^about', 'django.views.generic.simple.direct_to_template', {'template': 'path/to/about_us.html'}),
** please note you have to save the about_us.html into template folder of your project.
Bypass views to render a static page/template in Django Project
Bypassing views to render a static template, add this line in "urls.py". For example "About Us" page could be:
(r'^about', 'django.views.generic.simple.direct_to_template', {'template': 'path/to/about_us.html'}),
** please note you have to save the about_us.html into template folder of your project.
Use Django-registration with Django project
2. un-tar the file and copy the regostration folder into your django project as an app
3. set up the settings.py by adding the 'registration' into the INSTALLED_APPS = ()
4. also adding the followings to the settings.py file:
- ACCOUNT_ACTIVATION_DAYS = 7
- EMAIL_HOST = 'localhost'
- DEFAULT_FROM_EMAIL = 'WEBMASTER@LOCALHOST'
- LOGIN_REDIRECT_URL = '/'
5. copy templates files into the registration folder made in step 4. You can download the templates files hereat https://github.com/vladimir-webdev/django-registration-templates
Has not finished yet....
Use Django-registration with Django project
2. un-tar the file and copy the regostration folder into your django project as an app
3. set up the settings.py by adding the 'registration' into the INSTALLED_APPS = ()
4. also adding the followings to the settings.py file:
- ACCOUNT_ACTIVATION_DAYS = 7
- EMAIL_HOST = 'localhost'
- DEFAULT_FROM_EMAIL = 'WEBMASTER@LOCALHOST'
- LOGIN_REDIRECT_URL = '/'
5. copy templates files into the registration folder made in step 4. You can download the templates files hereat https://github.com/vladimir-webdev/django-registration-templates
Has not finished yet....
Datatable static image not found on the server
When you use ```datatables.min.css``` and ```datatables.min.js``` locally, instead of datatables CDN, you may have encountered that ```sort...
-
Step 1. Install Oracle XE 11g 1. Download Oracle XE (oracle-xe-11.2.0-1.0.x86_64.rpm.zip) from Oracle official website. You need an accoun...
-
I used the following method to hide the extra long column contents when loading the page. The contents will then display when mouse hover th...
-
When you use ```datatables.min.css``` and ```datatables.min.js``` locally, instead of datatables CDN, you may have encountered that ```sort...