• About Me
  • My Slides

WindyGallery's Weblog

~ I am a normal man in quite imperfect little World.

WindyGallery's Weblog

Monthly Archives: April 2009

Latex Eclipse plugin

13 Monday Apr 2009

Posted by windygallery in Developer

≈ Leave a comment

Tags

eclipse, latex, plugin

http://texlipse.sourceforge.net/

Java: Memory Usage

06 Monday Apr 2009

Posted by windygallery in Developer

≈ Leave a comment

Tags

java, Jconsole, Memory

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

05 Sunday Apr 2009

Posted by windygallery in Developer

≈ Leave a comment

Tags

Image, java

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

Perl script: Read website

04 Saturday Apr 2009

Posted by windygallery in Developer

≈ Leave a comment

#!/usr/bin/perl

use LWP::UserAgent;

$url = “http://www.google.com”;
readURL($url);

sub readURL {
($url) = (@_);
$ua = LWP::UserAgent->new;
$ua->agent(“Mozilla/8.0”); # pretend we are very capable browser

$req = HTTP::Request->new(GET => $url);
$req->header(‘Accept’ => ‘text/html’);
$res = $ua->request($req); # send request
if ($res->is_success) { # check the outcome
print $res->content;
}
else {
print “Error: ” . $res->status_line . “\n”;
}
}

Subscribe

  • Entries (RSS)
  • Comments (RSS)

Archives

  • August 2017
  • November 2015
  • August 2015
  • June 2015
  • May 2015
  • April 2015
  • March 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • May 2012
  • February 2011
  • January 2011
  • August 2010
  • June 2010
  • May 2010
  • April 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • April 2009
  • March 2009
  • November 2008
  • October 2008

Categories

  • Developer
  • Events
  • Games
  • IDeas
  • Love
  • Photos

Meta

  • Register
  • Log in

Create a free website or blog at WordPress.com.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Follow Following
    • WindyGallery's Weblog
    • Already have a WordPress.com account? Log in now.
    • WindyGallery's Weblog
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar