Add new files to repository
svn status | grep "^\?" | awk '{print $2}' | xargs svn add
2012-06-12
2012-04-12
Linux Command Line Kill a Process by Process Name
kill $(pgrep PROCESS_NAME)
killall -v PROCESS_NAME
pkill PROCESS_NAME
kill `ps -ef | grep PROCESS_NAME | grep -v grep | awk '{print $2}'`
2011-12-29
Django "SMTPServerDisconnected Connection unexpectedly closed"
- Check mail server by "telnet servername port(25)"
- Check IMAP server (e.g. deovecot)
2011-04-20
How To Install Python JCC
Ubuntu 8.04 Server
- sudo install sun-java6-jdk python-distutils-extra build-essential
- svn co http://svn.apache.org/repos/asf/lucene/pylucene/trunk/jcc jcc (revision 1090549)
- cd jcc/jcc
- sudo python setup.py build install
- require Python2.5.2, Visual Studio 2003, Java-JDK1.6.0u17
- add Path
- C:\Program Files\Java\jdk1.6.0_17\bin
- C:\Program Files\Java\jdk1.6.0_17\lib
- C:\Program Files\Java\jdk1.6.0_17\jre\bin\client
- C:\Python25
- checkout jcc from subversion http://svn.apache.org/repos/asf/lucene/pylucene/trunk/jcc (revision 1090549)
- open command prompt
- in jcc directory >>> python setup.py build install
2009-02-14
How to Change JOptionPane font
Use JTextArea component to render in JOptionPane.
Example:
JTextArea txtArea = new JTextArea(errMsg);
txtArea.setFont(GuiUtils.getThaiFont(Font.BOLD, 22));
txtArea.setOpaque(false);
txtArea.setEditable(false);
txtArea.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
JOptionPane.showMessageDialog(this, txtArea);
Example:
JTextArea txtArea = new JTextArea(errMsg);
txtArea.setFont(GuiUtils.getThaiFont(Font.BOLD, 22));
txtArea.setOpaque(false);
txtArea.setEditable(false);
txtArea.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
JOptionPane.showMessageDialog(this, txtArea);
2009-01-26
SQL History in Django
Use django.db.connection to get SQL history.
Example:
from django.db import connection
connection.queries
Example:
from django.db import connection
connection.queries
2008-12-04
Certificate expired when package AIR appication
Solution: Change your date and time formats on your computer to US format before create certificate file.
2008-11-20
Add datetime in MySQL
Example: plus datetime 31 days;
- update table_name set datetime_field = ADDDATE(datetime_field, 31);
- update table_name set datetime_field = ADDDATE(datetime_field, -31);
2008-11-04
Calculate DPI for Monitor
Use this formula.
dpi = sqrt(resolutionWidth ^ 2 + resolutionHeight ^ 2) / inches
dpi = sqrt(resolutionWidth ^ 2 + resolutionHeight ^ 2) / inches
2008-06-23
Add KeyListener On Swing JPanel
Use code like this
JFrame frame = new JFrame();
JPanel pnl = new JPanel();
pnl.addKeyListener(keyListener);
pnl.setFocusable(true);
frame.add(pnl);
frame.pack();
pnl.drawing.requestFocus();
JFrame frame = new JFrame();
JPanel pnl = new JPanel();
pnl.addKeyListener(keyListener);
pnl.setFocusable(true);
frame.add(pnl);
frame.pack();
pnl.drawing.requestFocus();
2008-06-04
How to minimize and restore Java Swing JFrame
1. Minimize -> use this method frame.setState ( Frame.ICONIFIED );
2. Restore -> use this method frame.setState ( Frame.NORMAL );
frame is instance of JFrame
2. Restore -> use this method frame.setState ( Frame.NORMAL );
frame is instance of JFrame
2008-05-20
Add KeyListener on Java Swing JFrame
Use a code like this
AbstractAction act = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
//Action that you want to do.
}
};
getRootPane().getActionMap().put("nameThatYouWant", act);
InputMap im = getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
// KeyEvent.VK_F10 or any key that you want.
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_F10, 0), "nameThatYouWant");
AbstractAction act = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
//Action that you want to do.
}
};
getRootPane().getActionMap().put("nameThatYouWant", act);
InputMap im = getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
// KeyEvent.VK_F10 or any key that you want.
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_F10, 0), "nameThatYouWant");
2008-01-27
Install Flex Builder 2.0.1 on Vista
I'm try to install Flex Builder on Vista and found a problem that I don't know why this error happen after a few hours I find the solution at http://office.realeyesmedia.com/blogs/jun/?p=13 thank for that post it help me to solve problem.
How to:
1. Run cmd with admin.
2. Go to your home directory (c:\Users\yourname).
3. Run rmdir "My Documents".
4. Run mklink /d “My Documents” Pathtoyourdocument
How to:
1. Run cmd with admin.
2. Go to your home directory (c:\Users\yourname).
3. Run rmdir "My Documents".
4. Run mklink /d “My Documents” Pathtoyourdocument
2008-01-16
DISPLAY error matplotlib
When error occur about this "$DISPLAY not set" when you run python code that use matplotlib this happened because your matplotlib backend is set to FltkAgg, GTK, GTKAgg, GTKCairo, TkAgg , Wx or WxAgg they required a GUI that why error occur.
To solve this you must specific other backend that not required GUI (Agg, Cairo, PS, PDF or SVG) when use matplotlib like this
Remember when call savefig('filename') don't give it extension this will handle by backend that you specific e.g Agg will create file filename.png
source from --> http://matplotlib.sourceforge.net/backends.html
To solve this you must specific other backend that not required GUI (Agg, Cairo, PS, PDF or SVG) when use matplotlib like this
- In code
import matplotlib
matplotlib.use('Agg')
- In command line use -d option
Remember when call savefig('filename') don't give it extension this will handle by backend that you specific e.g Agg will create file filename.png
source from --> http://matplotlib.sourceforge.net/backends.html
2008-01-14
Change import file size for phpMyAdmin
Charge this two variable in php.ini file.
- upload_max_filesize
- post_max_size
2007-11-20
How to set font properties in matplotlib create graph
1. Create font dict like this
- font = { 'fontname':'Tahoma', 'fontsize':16 }
2. When you want to change font for example in title use like this
- matplotlib.pylab.title(u'some text', **font)
- font = { 'fontname':'Tahoma', 'fontsize':16 }
2. When you want to change font for example in title use like this
- matplotlib.pylab.title(u'some text', **font)
2007-11-01
Install Webmin on Ubuntu
1. Add
2. sudo apt-get update
3. sudo apt-get install webmin
deb http://download.webmin.com/download/repository sarge contrib to /etc/apt/sources.list file. (make sure that you have uncommented all universe repository)2. sudo apt-get update
3. sudo apt-get install webmin
2007-10-25
How to integrate reCAPTCHA with Django
1. Sign up with reCAPTCHA for get public and private key.
2. Download reCAPTCHA for Python.
3. Copy captcha.py to location in your PYTHON_PATH so that you can import it. (e.g /usr/local/python2.5/Lib/site/packages)
4. Now your Django site can use reCAPTCHA.
in your view use reCAPTCHA like this.
import capcha
2. Download reCAPTCHA for Python.
3. Copy captcha.py to location in your PYTHON_PATH so that you can import it. (e.g /usr/local/python2.5/Lib/site/packages)
4. Now your Django site can use reCAPTCHA.
in your view use reCAPTCHA like this.
import capcha
def captcha_view(request):
captcha.displayhtml(RECAPTCHA_PUB_KEY) # use for display reCAPTCHA in template.
captcha_obj = captcha.submit( request.POST['recaptcha_challenge_field'],
captcha.displayhtml(RECAPTCHA_PUB_KEY) # use for display reCAPTCHA in template.
captcha_obj = captcha.submit( request.POST['recaptcha_challenge_field'],
request.POST['recaptcha_response_field'],
RECAPTCHA_PRIVATE_KEY,
request.META['REMOTE_ADDR'] ) # use for create captcha object for check result.
if captcha_obj.is_valid:
return success
else:
return error
RECAPTCHA_PRIVATE_KEY,
request.META['REMOTE_ADDR'] ) # use for create captcha object for check result.
if captcha_obj.is_valid:
return success
else:
return error
2007-10-06
How to use MySQL RegExp
You can use RegExp in MySQL like this.
- SELECT column_name FROM table_name WHERE column_name COLLATE utf8_bin REGEXP '^.* [a-zI]$'
Note: COLLATE is use for use case sensitive in SQL.
2007-09-29
Java jar file.
1. You can extract it and edit "manifest.mf" for edit class path.
2. You can use class inside jar file after extract it to include in one project (you may want to build project in one jar file).
2. You can use class inside jar file after extract it to include in one project (you may want to build project in one jar file).
Subscribe to:
Posts (Atom)