hamachi posted: " 『dアニメストア』は月額440円でにて4,400以上の作品が見放題になるアニメ作品専門の動画配信サービスです。 当記事ではこのdアニメストアで2022年1月に配信予定の作品と、2022冬アニメの配信曜日も併せてご紹介しています。 注目は、『進撃の巨人 OAD Lost in the cruel world』、『ドラゴンボールGT』TVシリーズ全64話&TVスペシャル2話、『ドラゴンボールZ』TVスペシャル2作品全4話。そして、2021年冬アニメの配信もスタートしますよ。 dアニメストア 20"
tomaztsql posted: " New Year's eve is almost here and what best way to celebrate with fireworks. Snap, pop, crack, boom. This is the most peaceful, animal friendly, harmless, eco, children friendly, no-fire-needed, educative and nifty fireworks. To get the fireworks"
New Year's eve is almost here and what best way to celebrate with fireworks. Snap, pop, crack, boom. This is the most peaceful, animal friendly, harmless, eco, children friendly, no-fire-needed, educative and nifty fireworks.
To get the fireworks, fire up the following R function.
########################################## # # Tiny fireworks with R for New Year's 2022 # # Series: # Little Useless-useful R functions #31 # Created: December 29, 2021 # Author: Tomaz Kastrun # Blog: tomaztsql.wordpress.com # V.1.0 # Changelog: # - add clean rings ########################################### library(animation) library(ggplot2) set.seed(2908) Fireworks <- function(nof_rockets=10) { if(!is.null(dev.list())) dev.off() if(!interactive()) return() draw.fireworks <- function(x,y,ring) { plot(x, y, xaxt='n', ann=FALSE, yaxt='n', frame.plot=FALSE, xlim=c(0,50),ylim=c(0,500)) title(main = "Happy New Year 2022", col.main= "white") for (i in 1:ring) { ani.options(interval = 0.25) color <- sample(rainbow(ring),8, replace=TRUE) symbols(x,y, circles=0.16+i*1.2,add=T, inches=F, fg=color[i]) ani.pause() } par(new=TRUE) } clear.fireworks <- function(x,y,ring){ plot(x, y, xaxt='n', ann=FALSE, yaxt='n', frame.plot=FALSE, xlim=c(0,50),ylim=c(0,500)) for (i in 1:ring) { ani.options(interval = 0.15) symbols(x,y, circles=0.16+i*1.2,add=T, inches=F, fg="black") ani.pause() } par(new=TRUE) } NewYear.fireworks <- function(){ bgcolor <- par("bg") if (bgcolor == "transparent" | bgcolor == "white") bgcolor <- "black" par(bg=bgcolor) # nof_rockets <- 10 xx <-sample(1:50,nof_rockets) yy <-sample(1:500,nof_rockets) ringy <- sample(7:13,nof_rockets, replace = TRUE) for (i in 1:nof_rockets){ x <- xx[i] y <- yy[i] ring <- ringy[i] draw.fireworks(x,y,ring) # if you don't want rings disappearing, comment this IF statement if (i > 1) { x1 <- xx[i-1] y1 <- yy[i-1] ring1 <- ringy[i-1] clear.fireworks(x1, y1, ring1) } } # if you don't want rings disappearing, comment this IF statement clear.fireworks(tail(xx,1), tail(yy,1), tail(ringy,1)) } NewYear.fireworks() } ################## # Run the function ################## Fireworks(15)
And have your own little private useless R fireworks.
Fireworks with disappearing rings
Fireworks with colourful rings
Enjoy the silence. Observe the colours. Drink some champagne.
satya posted: " Here are the two supporting classes needed by the MailReader class. The first one is the Mailbox class that is used to hold all properties of a mailbox. You will need at least three properties to initialize an instance: pop3 server address, mailbox u"
Here are the two supporting classes needed by the MailReader class.
The first one is the Mailbox class that is used to hold all properties of a mailbox. You will need at least three properties to initialize an instance: pop3 server address, mailbox user name, and mailbox password.
Use setters to override default values of other properties. Please notice that with Sun provider only the default folder name ("INBOX") is supported.
/* * blog/javaclue/javamail/Mailbox.java * * Copyright (C) 2009 JackW * * This program is free software: you can redistribute it and/or modify it under the terms of the * GNU Lesser General Public License as published by the Free Software Foundation, either version 3 * of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this library. * If not, see . */ package blog.javaclue.javamail; import java.io.Serializable; public class Mailbox implements Serializable { private static final long serialVersionUID = 826439429623556631L; private final String userId; private final String userPswd; private final String host; private int port; private String protocol; private String folderName; private int messagesPerRead; private boolean useSsl; private int maxRetries; private int minimumWait; // in seconds private boolean isExchange; public Mailbox(String host, String userId, String userPswd) { this.host = host; this.userId = userId; this.userPswd = userPswd; initDefault(); } void initDefault() { port = -1; // use protocol default port protocol = "pop3"; folderName = "INBOX"; messagesPerRead = 10; useSsl = false; maxRetries = -1; minimumWait = 5; isExchange = false; } public String getFolderName() { return folderName; } public void setFolderName(String folderName) { this.folderName = folderName; } public String getHost() { return host; } public int getMinimumWait() { return minimumWait; } public void setMinimumWait(int minimumWait) { this.minimumWait = minimumWait; } public int getPort() { return port; } public void setPort(int port) { this.port = port; } public String getProtocol() { return protocol; } public void setProtocol(String protocol) { this.protocol = protocol; } public int getMessagesPerRead() { return messagesPerRead; } public void setMessagesPerRead(int readPerPass) { this.messagesPerRead = readPerPass; } public int getMaxRetries() { return maxRetries; } public void setMaxRetries(int retryMax) { this.maxRetries = retryMax; } public String getUserId() { return userId; } public String getUserPswd() { return userPswd; } public boolean isUseSsl() { return useSsl; } public void setUseSsl(boolean useSsl) { this.useSsl = useSsl; } public boolean isExchange() { return isExchange; } public void setExchange(boolean isExchange) { this.isExchange = isExchange; } }
The next class is the MailProcessor class which is used to process the email messages read by the MailReader. This is most likely the class you would customize when building your own back-end mail reader.
/* * blog/javaclue/javamail/MailProcessor.java * * Copyright (C) 2009 JackW * * This program is free software: you can redistribute it and/or modify it under the terms of the * GNU Lesser General Public License as published by the Free Software Foundation, either version 3 * of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this library. * If not, see <http://www.gnu.org/licenses/>. */ package blog.javaclue.javamail; import java.io.IOException; import java.util.Date; import javax.mail.Flags; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.Part; import org.apache.log4j.Logger; /** * process email's handed over by MailReader class. * * @author JackW */ public class MailProcessor { static final Logger logger = Logger.getLogger(MailProcessor.class); static final boolean isDebugEnabled = logger.isDebugEnabled(); protected final String LF = System.getProperty("line.separator", "\n"); private final Mailbox mailbox; private static final int MAX_BODY_SIZE = 150 * 1024; // 150KB private static final int MAX_CMPT_SIZE = 1024 * 1024; // 1MB private static final int MAX_TOTAL_SIZE = 10 * 1024 * 1024; // 10MB public MailProcessor(Mailbox mailbox) { this.mailbox = mailbox; } /** * process messages. * * @param msgs - * array of Messages. * @throws MessagingException * @throws IOException */ public void process(Message[] msgs) throws MessagingException, IOException { if (isDebugEnabled) logger.debug("Entering process() method..."); for (int i = 0; i < msgs.length; i++) { if (msgs[i] != null && !msgs[i].isSet(Flags.Flag.SEEN) && !msgs[i].isSet(Flags.Flag.DELETED)) { processPart(msgs[i]); // message has been processed, delete it from mail box msgs[i].setFlag(Flags.Flag.DELETED, true); } } } /** * process message part * * @param p - * part * @throws MessagingException * @throws IOException */ MessageBean processPart(Part p) throws IOException, MessagingException { Date start_tms = new Date(); // parse the MimeMessage to MessageBean MessageBean msgBean = MessageBeanUtil.mimeToBean(p); // MailBox Host Address msgBean.setMailboxHost(mailbox.getHost()); // MailBox User Id msgBean.setMailboxUser(mailbox.getUserId()); // get message body String body = msgBean.getBody(); // check message body and component size boolean msgSizeTooLarge = false; if (body.length() > MAX_BODY_SIZE) { msgSizeTooLarge = true; logger.warn("Message body size exceeded limit: " + body.length()); } int totalSize = body.length(); if (!msgSizeTooLarge && msgBean.getComponentsSize().size() > 0) { for (int i = 0; i < msgBean.getComponentsSize().size(); i++) { Integer objSize = (Integer) msgBean.getComponentsSize().get(i); if (objSize.intValue() > MAX_CMPT_SIZE) { msgSizeTooLarge = true; logger.warn("Message component(" + i + ") exceeded limit: " + objSize.intValue()); break; } totalSize += objSize; } } if (!msgSizeTooLarge && totalSize > MAX_TOTAL_SIZE) { logger.warn("Message total size exceeded limit: " + totalSize); msgSizeTooLarge = true; } if (msgSizeTooLarge) { logger.error("The email message has been rejected due to its size"); // XXX - add your code here to deal with it } else { // email size within the limit if (msgBean.getSmtpMessageId() == null) { logger.warn("SMTP Message-Id is null, FROM Address = " + msgBean.getFromAsString()); } if (isDebugEnabled) logger.debug("Message read..." + LF + msgBean); // XXX: Add you code here to process the message ... } if (isDebugEnabled && msgBean.getAttachCount() > 0) logger.debug("Number of attachments receibved: " + msgBean.getAttachCount()); long time_spent = new Date().getTime() - start_tms.getTime(); if (isDebugEnabled) logger.debug("Msg from " + msgBean.getFromAsString() + " processed, " + time_spent); return msgBean; } }