Anemone's Blog

Hello World

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

$ hexo new "My New Post"

More info: Writing

Run server

$ hexo server

More info: Server

Generate static files

$ hexo generate

More info: Generating

Deploy to remote sites

$ hexo deploy

More info: Deployment

Code Samples

Java

import java.util.ArrayList;
import java.util.List;

public class Example {
public static void main(String[] args) {
List<String> items = new ArrayList<>();
items.add("alpha");
items.add("beta");
items.add("gamma");

for (String item : items) {
System.out.println("item = " + item);
}

String result = items.stream()
.filter(s -> s.length() > 4)
.findFirst()
.orElse("empty");
System.out.println("result = " + result);
}
}

Go

package main

import (
"fmt"
"strings"
"time"
)

func main() {
now := time.Now()
fmt.Printf("now: %v\n", now.Format(time.RFC3339))

words := strings.Split("hello world from go", " ")
for i, w := range words {
fmt.Printf("%d: %s\n", i, w)
}

ch := make(chan int, 3)
go func() {
for i := 0; i < 3; i++ {
ch <- i * i
}
close(ch)
}()

for v := range ch {
fmt.Println("received:", v)
}
}

TypeScript

interface User {
id: number;
name: string;
email?: string;
}

const users: User[] = [
{ id: 1, name: "Alice", email: "alice@example.com" },
{ id: 2, name: "Bob" },
{ id: 3, name: "Charlie", email: "charlie@example.com" },
];

function greet(user: User): string {
const emailPart = user.email ? ` <${user.email}>` : "";
return `Hello, ${user.name}${emailPart}`;
}

users.forEach((u) => {
console.log(greet(u));
});

const withEmail = users.filter((u) => Boolean(u.email));
console.log(`users with email: ${withEmail.length}`);