Java String Format
ตุลาคม 30, 2009
Source code
float data = 123.456789f;
String s = String.format(“%.3f %s”,data,”%”);
Output
>>123.457 %
CSS Background StyleSheet
ตุลาคม 24, 2009
body { background:#39F; margin-top:40; text-align: center;}
h1,h2,h3 { margin:0; padding:0;}
div#content { background:#ffffff; -moz-border-radius: 30px; border-radius: 30px; width:65%; padding:50px; margin:0 auto; text-align: left; }
div#footer { width:100%; margin-top:5px; font: 8pt Tahoma, sans-serif; color:#069;}
h1 { font:bold 14pt Tahoma, Geneva, sans-serif; color:#F66 }
h2 { font:normal 8pt Tahoma, Geneva, sans-serif; color:#999; padding-top:50px;}
h3 { font:normal 8pt Tahoma, Geneva, sans-serif; color:#bbb; }
Perl script: Simple but Powerful
กันยายน 21, 2009
#!/usr/bin/perl
print “Simple Best techniques…\n”;
$daystr = “1 2 6 7 11 13 15 16″;
my @numbers = ($daystr =~ /(\d+)/g);
foreach $day (@numbers) {
print $day.”\n”;
}
หยิบของเก่ามาเล่าใหม่
สิงหาคม 20, 2009
Matlab Linear Solver
สิงหาคม 20, 2009
% Simplest Linear solver
% A*X = B
% y = mx+c <– linear formula
% y = 2x+4 <– Answer
A = [0 1;
1 1]
B = [4;
6]
X = linsolve(A,B)
%check result
(A*X==B)
%Reference
%http://www.mathworks.com/access/helpdesk/help/techdoc/ref/linsolve.html
SVN Plugin for Eclipse
สิงหาคม 16, 2009
Open Your Eclipse
-> Help -> Software Updates…
-> Add Site
Location : http://subclipse.tigris.org/update_1.4.x
-> Ok
-> Install

More information: http://subclipse.tigris.org/servlets/ProjectProcess?pageID=p4wYuA
Firefox Configuration
สิงหาคม 16, 2009
Type about:config in address bar and press enter button.

The warning will be appear.

Click “I’be careful, I promise!” and go to configuration page.


For example, If there are many tabs and you don’t want to close a firefox window when
you are closing them with ctrl+W. You can configuration your firefox like this.
1. Search with keyword : browser.tabs.closeWindowWithLastTab

2. double click on “browser.tabs.closeWindowWithLastTab” to switch from “true” to “false“.
After that, your firefox won’t be closed when you use Ctrl+W to close window by mistake anymore.
More information: http://kb.mozillazine.org/Firefox_:_FAQs_:_About:config_Entries
Latex Eclipse plugin
เมษายน 13, 2009
http://texlipse.sourceforge.net/
Java: Memory Usage
เมษายน 6, 2009
JConsole
A graphical user interface monitoring tool for capturing information about performance, resource consumption of applications running on the Java platform.

.

Reference: http://java.sun.com/javase/6/docs/technotes/guides/management/jconsole.html
.
HOWTO: วิธีการตรวจสอบ memory leak ใน Java application
http://www.jhelp.net/article.aspx?id=10067
.
Determining Memory Usage in Java
http://www.javaspecialists.eu/archive/Issue029.html
Java: Saving Images
เมษายน 5, 2009
public static void saveOldWay(String ref, BufferedImage img) {
BufferedOutputStream out;
try {
out = new BufferedOutputStream(new FileOutputStream(ref));
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(img);
int quality = 5;
quality = Math.max(0, Math.min(quality, 100));
param.setQuality((float) quality / 100.0f, false);
encoder.setJPEGEncodeParam(param);
encoder.encode(img);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Saves a BufferedImage to the given file, pathname must not have any
* periods “.” in it except for the one before the format, i.e. C:/images/fooimage.png
* @param img
* @param saveFile
*/
public static void saveImage(BufferedImage img, String ref) {
try {
String format = (ref.endsWith(“.png”)) ? “png” : “jpg”;
ImageIO.write(img, format, new File(ref));
} catch (IOException e) {
e.printStackTrace();
}
}
Reference: http://www.javalobby.org/articles/ultimate-image/#5



















