blprnt เขา post source code ที่่ paint รูปต้นไม้
- cherrytree (***** เอาไปห้าดาว)
- birchtree (ตอนที่กิ่งน้อยๆ สวยกว่าตอนกิ่งเยอะๆ)
Javaเร็วส์, Javascript, Erlang, Python, Ruby, Clojure, Groovy, เลี้ยงลูก, วาดภาพ
Quartz timer component ===msg===> Log Component
public class LogComponent extends ComponentSupport {
private Log log = LogFactory.getLog(TraceComponent.class);
public Log getLog() {
return log;
}
public void setLog(Log log) {
this.log = log;
}
public void onMessageExchange(MessageExchange exchange) throws MessagingExce
ption {
// lets dump the incoming message
NormalizedMessage message = exchange.getMessage("in");
if (message == null) {
log.warn("Received null message from exchange: " + exchange);
}
else {
log.info("Exchange: " + exchange + " received IN message: " + messag
e);
}
}
}
public class LogComponent extends ComponentSupport
implements MessageExchangeListener {...}
public class PojoReceiver implements MessageExchangeListener {
public void onMessageExchange(MessageExchange exchange) throws MessagingExce
ption {
NormalizedMessage message = exchange.getMessage("in");
....
}
}
#!/bin/bash
#
# Dump wma to mp3
for i in *.wma
do
if [ -f $i ]; then
rm -f “$i.wav”
mkfifo “$i.wav”
mplayer -vo null -vc dummy -af resample=44100 -ao pcm -waveheader “$i” -aofile “$i.wav” &
dest=`echo “$i”|sed -e ’s/wma$/mp3/’`
lame -h -b 192 “$i.wav” “$dest”
rm -f “$i.wav”
fi
done
One of the (several) goals of Seam is to bring Ruby On Rails style productivity to the Java EE platform

@Name("user")register.register@Name("register")register ให้
public class Person {
private String name;
private int age;
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

public aspect PersonValidate {
declare parents: Person implements Validatable;
public Errors Person.validate() {
Errors errs = new Errors();
if (this.getName() == null ||
this.getName().length() == 0) {
errs.addError("name", "name must not be empty");
}
if (this.getAge() <= 0) {
errs.addError("age", "age must not be negative or zero");
}
return errs;
}
}
declare parents: Person implements Validatable;public static void main(String[] args) {
Person p = new Person();
p.setAge(-1);
Validatable vt = (Validatable) p;
Errors err = vt.validate();
for (int i = 0; i < err.size(); i++) {
System.out.println(err.getError(i));
}
}
name:name must not be empty
age:age must not be negative or zero
create table foo (
id long,
....
parent_id long
)
create table foo (
id long,
..
parent_id long,
left_id long,
right_id long
)
select * from foo where left_id between x and y
Options opt = new Options();
opt.addOption("d", true, "extract only specific date");
opt.addOption("w", true, "extract only week that contain given date");
opt.addOption("m", true, "extract for specific month,year");
program -d yymmdd -w yymmdd -y yymm infile outfileOptions opt = new Options();
OptionGroup grp = new OptionGroup();
grp.addOption(new Option("d", true, "extract only specific date"));
grp.addOption(new Option("w", true, "extract only week that contain given date")
);
grp.addOption(new Option("m", true, "extract for specific month,year"));
opt.addOptionGroup(grp);
PosixParser parser = new PosixParser();
CommandLine cmdline = parser.parse(opt, args);
getOptionValuegetArgs()CommandLine cmdline = parser.parse(opt, args);
File inFile = new File(cmdline.getArgs()[0]);
if (cmdline.hasOption("d")) {
Calendar[] ranges = parseDate(cmdline.getOptionValue("d"));
...
}
if (cmdline.hasOption("w")) {
filter.setWeek(parseWeek(cmdline.getOptionValue("w")));
}
public interface GenericDAO<T, ID extends Serializable> {
T findById(ID id, boolean lock);
List<T> findAll();
List<T> findByExample(T exampleInstance);
T makePersistent(T entity);
void makeTransient(T entity);
}
public interface ItemDAO extends GenericDAO<Item, Long> {
public static final String QUERY_MAXBID = "ItemDAO.QUERY_MAXBID";
public static final String QUERY_MINBID = "ItemDAO.QUERY_MINBID";
Bid getMaxBid(Long itemId);
Bid getMinBid(Long itemId);
}
Thread.currentThread().getContextClassLoader();
public void start(BundleContext context) throws Exception {
super.start(context);
ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(
this.getClass().getClassLoader());
applicationContext = new ClassPathXmlApplicationContext(SPRING_CONFIGS)
;
} finally {
Thread.currentThread().setContextClassLoader(oldLoader);
}
}
<script type="text/javascript" src="logger.js"></script>
<link rel="stylesheet" type="text/css" href="logger.css" />
<div id="fvlogger">
<dl>
<dt>fvlogger</dt>
<dd class="all"><a href="#fvlogger" onclick="showAll();" title="show all" id="abcdef">all</a></dd>
<dd class="debug"><a href="#fvlogger" onclick="showDebug();" title="show debug" id="showDebug">debug</a></dd>
<dd class="info"><a href="#fvlogger" title="show info" id="showInfo">info</a></dd>
<dd class="warn"><a href="#fvlogger" onclick="showWarn();" title="show warnings" id="showWarn">warn</a></dd>
<dd class="error"><a href="#fvlogger" onclick="showError();" title="show errors" id="showError">error</a></dd>
<dd class="fatal"><a href="#fvlogger" onclick="showFatal();" title="show fatals" id="showFatal">fatal</a></dd>
<dd><a href="#fvlogger" onclick="eraseLog(true);" title="erase">erase</a></dd>
</dl>
</div>

<div id="fvlogger"></div>

function foo() {
debug("foo start");
....
}



rvg = RVG.new(width,height)
rvg1 = RVG.new(4.in, 5.in) # หน่วยเป็นนิ้ว
rvg2 = RVG.new(30.cm, 15.5.cm) # หน่วยเป็นเซนติเมตร
incm ของin หรือ cm
RVG::dpi = 72
def dpi=(n)
if !defined?(@dpi)
[Float, Fixnum].each do |c|
c.class_eval do
# the default measurement - 1px is 1 pixel
def px
self
end
# inches
def in
self * ::Magick::RVG.dpi
end
# millimeters
def mm
self * ::Magick::RVG.dpi / 25.4
end
# centimeters
def cm
self * ::Magick::RVG.dpi / 2.54
end
.....
People who love to acquire knowledge on all sorts of topics and, perhaps more importantly, love to tell others about what they've learned (in fact, the word maven comes from Yiddish and means someone who accumulates knowledge).
parseRecord ทำงาน
def parseFile(fileName)
list = Array.new
begin
File.open(fileName, 'r') do |file|
while (! file.eof)
tmp = parseRecord(file.read(648))
wtmp = Wtmp.new(tmp)
list << wtmp
end
end
rescue
end
return list
end
parseRecord ก็จะใช้ method unpack เข้ามาช่วย
def parseRecord(str)
str.unpack("A256A14A64x2Nnx6Nnna256x36")
end