<commit_before>package main

import (
	"fmt"
	"net/http"
	"os"
)

func ShowICS(w http.ResponseWriter, r *http.Request) {
	file, err := os.Open("basic.ics")
	if err != nil {
		panic(err)
	}

	defer file.Close()

	buf := make([]byte, 1024)
	for {
		n, err := file.Read(buf)
		if n == 0 {
			break
		}
		if err != nil {
			panic(err)
		}
		fmt.Fprintf(w, string(buf))
	}
}

func main() {
	http.HandleFunc("/calendar.ics", ShowICS)
	http.ListenAndServe(":80", nil)
}<commit_msg>[WIP] add get nippo of all from esa<commit_after>package main

import (
	"fmt"
	"github.com/taroooyan/go-esa/esa"
	"net/http"
	"net/url"
	"os"
	"strconv"
)

func ShowICS(w http.ResponseWriter, r *http.Request) {
	file, err := os.Open("basic.ics")
	if err != nil {
		panic(err)
	}

	defer file.Close()

	buf := make([]byte, 1024)
	for {
		n, err := file.Read(buf)
		if n == 0 {
			break
		}
		if err != nil {
			panic(err)
		}
		fmt.Fprintf(w, string(buf))
	}
}

func saveArticle() {
	// Initialization
	client := esa.NewClient(os.Getenv("ESA_API"))

	searchQuery := url.Values{}
	searchQuery.Add("in", "日報")
	page := "1"
	for {
		query := url.Values{}
		query.Add("page", page)

		postsResponse, err := client.Post.GetPosts("taroooyan", searchQuery, query)
		if err != nil {
			panic(err)
		}

		for _, post := range postsResponse.Posts {
			fmt.Println(post.Number)
		}

		if postsResponse.NextPage == nil {
			break
		} else {
			t := postsResponse.NextPage
			page = strconv.FormatFloat(t.(float64), 'G', 4, 64)
		}
	}
}

func main() {
	saveArticle()
	// http.HandleFunc("/calendar.ics", ShowICS)
	// http.ListenAndServe(":80", nil)
}
{'fraction_non_alphanumeric': 0.18063314711359404, 'fraction_numerical': 0.012414649286157667, 'mean_word_length': 3.2421052631578946, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2284539', 'n_tokens_mistral': 725, 'n_tokens_neox': 650, 'n_words': 139}