Skip to content

Instantly share code, notes, and snippets.

View YujiWongTW's full-sized avatar

Yuji Wong YujiWongTW

View GitHub Profile
@YujiWongTW
YujiWongTW / Xmas.js
Last active December 1, 2017 15:34
Merry Xmas with Micro:bit
function setPic(src: number[][], color: number, device: neopixel.Strip) {
for (let i = 0; i < 8; i++) {
for (let j = 0; j < 8; j++) {
if (src[i][j] === 1) {
if (color < 0) {
device.setPixelColor(i * 8 + j, getRandomColor())
} else {
device.setPixelColor(i * 8 + j, color)
}
} else {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
InputStream caInput = new BufferedInputStream(new FileInputStream("add certificate file path here"));
Certificate ca;
try {
ca = cf.generateCertificate(caInput);
} finally {
caInput.close();
}
String keyStoreType = KeyStore.getDefaultType();
Connection conn = DatabaseHelper.connect();
PreparedStatement pstmt;
System.out.println("" + i);
pstmt = conn
.prepareStatement("select `timestamp` from news where newsid = ?");
pstmt.setInt(1, i);
ResultSet rs = pstmt.executeQuery();
long timestamp = -1;
if (rs.next()) {
AmazonS3 s3Client = StorageHelper.getAmazonS3();
ObjectListing listing = s3Client.listObjects("cp04-final", "news/");
do {
List<S3ObjectSummary> summaries = listing.getObjectSummaries();
for (S3ObjectSummary s : summaries) {
if (s.getSize() == 0) {
long newsId = Long.parseLong(s.getKey().substring(
s.getKey().lastIndexOf("/") + 1));
System.out.println("Reparse news id: " + newsId + " ... ");
News n;
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
String time = "Thu, 18 Jun 2015 13:10:00 +0800";
DateTimeFormatter parser = DateTimeFormat.forPattern("E, d MMM y HH:mm:ss Z");
long unixTime = parser.parseDateTime(time).withTimeAtStartOfDay().getMillis();
System.out.println(unixTime);

News Cloud API

WORD

GET /words

Parameters

Fields Type Default
start long The querying moment
end long The querying day end
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>speakup</display-name>
<filter>
<filter-name>jersey</filter-name>
<filter-class>org.glassfish.jersey.servlet.ServletContainer</filter-class>
<init-param>