This commit is contained in:
Jacob 2017-11-17 15:12:04 +01:00
parent 8385620f09
commit 014d2f5af5
8 changed files with 49 additions and 106 deletions

View File

@ -24,22 +24,36 @@ const layout = "2006-01-02"
var modTime time.Time var modTime time.Time
var postsCollection []Post var postsCollection []Post
func postHandlerRoutine(duration time.Duration) { func InitializeCollection() {
postsCollection = nil
filepath.Walk("./posts", newPost)
fmt.Println(len(postsCollection))
for _, post := range postsCollection {
fmt.Println(post.Title)
}
}
func AcquirePosts(duration time.Duration) {
for { for {
if isFolderModified() == true { if isFolderModified() == true {
postsCollection = nil postsCollection = nil
filepath.Walk("./posts/", newPost) filepath.Walk("./posts", newPost)
for _, post := range postsCollection {
sortPostAccordingToDate(post, postsCollection)
}
} }
time.Sleep(duration * time.Second) time.Sleep(duration * time.Second)
} }
} }
func isFolderModified() bool { func isFolderModified() bool {
f, _ := os.Open("./dir") f, err := os.Open("./posts")
info, _ := f.Stat() if err != nil {
fmt.Println("file-error here: \n", f)
return false
}
info, err := f.Stat()
if err != nil {
fmt.Println("info here: \n", info)
return false
}
_modTime := info.ModTime() _modTime := info.ModTime()
if modTime != _modTime { if modTime != _modTime {
modTime = _modTime modTime = _modTime
@ -49,32 +63,35 @@ func isFolderModified() bool {
} }
func newPost(path string, f os.FileInfo, err error) error { func newPost(path string, f os.FileInfo, err error) error {
postsCollection = append(postsCollection, getPost(path)) content, err := ioutil.ReadFile(path)
if err != nil {
fmt.Println(err)
//return err
}
title := strings.Replace(path, "posts/", "", -1)
if title == ".DS_Store" {
return nil return nil
} }
func getPost(title string) Post {
content, err := ioutil.ReadFile(title)
if err != nil {
fmt.Println(content)
return Post{}
}
s := string(content) s := string(content)
doc, _ := html.Parse(strings.NewReader(s)) doc, _ := html.Parse(strings.NewReader(s))
var p = Post{ var p = Post{
getDate(doc), getDate(doc),
title, title,
spaceToHyphen(title), strings.Replace(title, " ", "-", -1),
template.HTML(string(content[:len(content)])), template.HTML(string(content[:len(content)])),
} }
return p //insertPostAccordingToDate(p, postsCollection)
postsCollection = insertPostAccordingToDate(p, postsCollection)
return nil
} }
func getDate(n *html.Node) time.Time { func getDate(n *html.Node) time.Time {
var t time.Time var t time.Time
if n.Type == html.ElementNode && n.Data == "time" { if n.Type == html.ElementNode && n.Data == "time" {
for _, a := range n.Attr { for _, a := range n.Attr {
if a.Key == "datetime" { if a.Key == "datetime" {
@ -82,18 +99,19 @@ func getDate(n *html.Node) time.Time {
} }
} }
} }
for c := n.FirstChild; c != nil; c = c.NextSibling { for c := n.FirstChild; c != nil; c = c.NextSibling {
t = getDate(c) t = getDate(c)
} }
return t
}
func spaceToHyphen(s string) string { return t
return strings.Replace(s, " ", "-", -1)
} }
func getNewestPosts(numberOfPosts int) []Post { func getNewestPosts(numberOfPosts int) []Post {
var posts []Post var posts []Post
if len(postsCollection) == 0 {
return []Post{}
}
for i := numberOfPosts; i > 0; i-- { for i := numberOfPosts; i > 0; i-- {
post := postsCollection[i] post := postsCollection[i]
posts = append(posts, getPostByURLTitle(post.URLTitle)) posts = append(posts, getPostByURLTitle(post.URLTitle))
@ -110,7 +128,7 @@ func getPostByURLTitle(title string) Post {
return Post{} return Post{}
} }
func sortPostAccordingToDate(post Post, arr []Post) { func insertPostAccordingToDate(post Post, arr []Post) []Post {
for i, p := range arr { for i, p := range arr {
if p.Date.After(post.Date) { if p.Date.After(post.Date) {
s := make([]Post, len(arr)+1, cap(arr)+1) s := make([]Post, len(arr)+1, cap(arr)+1)
@ -119,5 +137,6 @@ func sortPostAccordingToDate(post Post, arr []Post) {
s[i] = post //insert new element into hole s[i] = post //insert new element into hole
} }
} }
postsCollection = append(postsCollection, post) arr = append(arr, post)
return arr
} }

View File

@ -1,66 +0,0 @@
<h2>Takunomi Coffee Reveries, Vol. I</h2>
<p><img src="http://i67.tinypic.com/mv0l95.png" alt="Takunomi Coffee Reveries, Vol. I" title="Cooking"></p>
<h3><a name="index"></a> Contents</h3>
<p><br></p>
<p>1 - <a href="#sec0"><strong>Introduction</strong></a></p>
<p>2 - <a href="#sec1"><strong>Revitalizing the Ancients</strong></a> {<em>Breath of the Wild</em>, <em>Final Fantasy XV</em>}</p>
<p>3 - <a href="#sec2"><strong>Coding for Your Own Sake</strong></a> {<em>Coding</em>, <em>Python</em>}</p>
<p>4 - <a href="#sec3"><strong>LoFi Hip Hop Radio</strong></a> {<em>Musical Interlude</em>}</p>
<p>5 - <a href="#sec4"><strong>Enticing for Computer Science</strong></a> {<em>YouTube</em>, <em>Shōgi</em>}</p>
<hr>
<h3><a name="sec0"></a> 1 - Introduction</h3>
<p><br></p>
<p>So a break for the better part of March apparently extends to most of April. That's fine. It gives time to reflect, struggle with exams, play some video games, all that good Jazz. In regards to reflection, it became apparent that daily updates was a noble goal, but a bit demanding, and my favorite posts were the Saturday recap posts, so why not try to make irregular but meatier Saturday posts only? As the content above shows, I thought it better if a bunch of good content was gathered for some relaxing perusal, coffee in hand.</p>
<p><br><br><center> <a href="#index">Return to contents?</a></center></p>
<hr>
<h3><a name="sec1"></a> 2 - Revitalizing the Ancients</h3>
<p><br></p>
<p>I would be remise not to talk <em>Breath of the Wild</em>. The only problem is, the game pretty much speaks for itself, quality and qualities wise, doesn't it? Yet, since last I posted, I completed <em>Final Fantasy XV</em>, so it's not a bad idea to talk abot how these two ancient giants deal with awakening in today's gaming world.</p>
<p>I wasn't immediately floored by <em>FFXV</em>, but the sort of chill, super-realistic setting of magical pretty-boys and roadtripping in hostile territory quickly won me over. Talking abot it's story is both a laughably sort excercise and a maddingly long one, so I'm going to simply say: It's quite good, and quite incomplete. If you haven't played <em>FFXV</em>, just wait till all the updates and DLC are out, you'll get the full experience.</p>
<p>What <em>FFXV</em> truly was to me, was a fantasy of travelling around a lush green environment and mowing down wildlife and roaming weaponized armor troupes. The open world element, I realized, was simply a part of the mood. I could hardly go wherever I liked, and trying to explore, rarely revealed anything surprising. <em>FFXV</em> was, like so many earlier entried in the series, about it's combat. I'll get to why that's more than ok.</p>
<p>I haven't finished <em>Breath of the Wild</em> yet, but it's not trying to hide where it'll end up, so it doesn't require a lot of confidence to say that I see the bigger picture by now. <em>BotW</em> <strong>gets</strong> open world design. It gets it like no game before it. Everything is traversable and though there isn't a purpose to going all places, neither does it ever feel like a time waste. The level of detail in both the big picture and the smallest iota, is astounding. To be fair, <em>BotW</em> doesn't play much different from so many other games. Instead, it seems to say &quot;<em>This is how you should do open world</em>&quot;, drops a mic and let's you play.</p>
<p>Both <em>FFXV</em> and <em>BotW</em> initially appear to be entering the modern world by seemingly accepting how Western developers design games: Real-time combat, ultra realistic graphics (<em>FFXV</em>) and go-where-ever-you-like, play-how-you-feel-like (<em>BotW</em>). Instead they both end up adhering to their roots in decidedly new ways. The Zelda puzzles, space-comprehension-requiring dungeons, grunting NPCs, tangible environments. It's all there, but in a far greater and smoother scale.</p>
<p>In many ways, it would be easy to call <em>BotW</em> the greater success, but I don't want to seem like I don't appreciate the technology behind <em>FFXV</em>. Consider the first time I entered the wood and monster infested Duscae area. I saw a creature I had a mark for. Me and my bodyguards flung into the fray and started hacking away. As the melee rolled around, we entered the vicinity of nearby monsters who happily obliged and suddenly the brawl was blooming into a war-like scenario. At that moment, a flying tank filled with soldiers came by to have a chat. I realize now, that this is crazy. The number of characters that <em>FFXV</em> supports at one point is mind blowing. No slow-downs, just more and more beasts. <em>BotW</em> on the other hand, nearly cracky my <em>Wii U</em> when I engaged five hulking moblins and a small batch of ice-bats in freezing tree-house. Perhaps <em>BotW</em> could achieve something like <em>FFXV</em>, but it's not the point. To these games, <em>open world</em> means different things. To <em>BotW</em> it's external: Go everywhere, always, whenever. To <em>FFXV</em> it's local: The immediate space is open to the battle system, now, to everyone.</p>
<p><br><br><center> <a href="#index">Return to contents?</a></center></p>
<hr>
<h3><a name="sec2"></a> 3 - Coding for Your Own Sake</h3>
<p><br></p>
<p>Why would you want to learn programming? Maybe the idea just appeals to you, or you have some greater goal in mind for the future. Right now, <em>you just don't have a clue what to code</em>.</p>
<p>Here's a way to find a small project: Just recreate another program, in the simplest way possible, and maybe add a tiny spin on it to give yourself a challenge. Cut out visuals, complicated functionality or even user friendliness. Just make it run.</p>
<p>So recently I thought, how about a music player? I'd like to try my hand at <a href="https://www.python.org/">Python</a>, that seemed like a pleasant langauge to code in.</p>
<p>Reading around a bit, I discovered that Python is all about importing so-called modules that do a lot of the complicated stuff for you. I simply googled various key words and started copy-pasting something together. I learned stuff about how mp3 files being a bit more complicated than I expected, and so I scaled the project back to simply playing .wav files. Currently doing a course about <a href="https://en.wikipedia.org/wiki/Distributed_computing">distributed systems</a>, I thought, <em>maybe I should make it a small radio program?</em> This was bit more complicated, but no more than it all resulted in the following tiny program. Simply start the program with</p>
<blockquote>
<p><em>python3 server.py [name of song].wav</em></p>
</blockquote>
<p>in one terminal window, and start a client in another terminal window with</p>
<blockquote>
<p><em>python3 client.py</em></p>
</blockquote>
<p>and hear the music play. It even works across computers on the same network.</p>
<ul>
<li><p><a href="https://gist.github.com/Sketchwhale/90e3f821fecce5cdfaaf3e84e5bc2970">server.py</a></p></li>
<li><p><a href="https://gist.github.com/Sketchwhale/90e3f821fecce5cdfaaf3e84e5bc2970">client.py</a></p></li>
</ul>
<p><br><br><center> <a href="#index">Return to contents?</a></center></p>
<hr>
<h3><a name="sec3"></a> 4 - LoFi Hip Hop Radio</h3>
<p><br></p>
<p>Hiphop-like music coupled with looping images from amazingly relaxing anime is apparently a thing, and I see no reason not to endorse it one hundred percent. Below you see Shizuku Tsukishima from <em>Whisper of the Heart</em> feeling as relaxed as I hope you do. The image links to one of those previously mentioned hiphop radios.</p>
<p><a href="https://youtu.be/xrbrQhpvn8E"><img src="http://i68.tinypic.com/4vs280.png" alt="ChillHop"></a></p>
<p><br><br><center> <a href="#index">Return to contents?</a></center></p>
<hr>
<h3><a name="sec4"></a> 5 - Enticing for Computer Science</h3>
<p><a href="https://www.youtube.com/watch?v=mohXgVorOBk"><img src="http://i67.tinypic.com/zikqb5.png" alt="ChillHop"></a></p>
<p>The video above is one of <em>toco toco tv</em>'s fantastic interviews with interesting and creative Japanese people. Manao Kagawa is a professional Shogi player, and, as far as I can understand, apparently somewhat uncommon, being female.</p>
<p>Besides being a wonderfully relaxing interview, it features a great part in the beginning where Kagawa-san goes to browse the <em>Shirataki Gofukuten</em> kimono shop. It seems that being a Shogi player requires you to wear somewhat formal wear, and the result is that the players looks insanely dashing.</p>
<p>What's even better though, is the mentioning of the <em>Shirataku Ayumi Hai</em>, a yearly Shogi tournament for female players to win beautiful and (I assume) quite expensive kimono.</p>
<p><a href="http://homes.soic.indiana.edu/nensmeng/files/ensmenger-gender.pdf">A quite well-discussed subject</a>, is how the rate of women joining Computer Science and the IT work force in general, is too low. I won't get into politics here, but what is a fact, is that Computer Scientists are in short supply everywhere in the world. At the same time, it seems the education world is mainly drawing from one of two pools of potential students (men). In other words, there is a whole other, quite untapped, pool of with potential students to draw from.</p>
<p>I've seen some really good initiatives to reverse the current trend, but I think the one seen in the video is a wonderfully aesthetic idea. I don't know if it manages to draw in new Shogi players Japan, but having some sort of algorithm competition aimed at high school age (or younger) girl, with very sought-after, classically feminine prizes<sup class="footnote-ref"><a href="#fn1" id="fnref1">[1]</a></sup>, seems like it could draw in a segment that normally has no interest in this branch of science, despite engaging in similar ones (mathematics, medicine, biology).</p>
<p><br><br><center> <a href="#index">Return to contents?</a></center></p>
<hr class="footnotes-sep">
<section class="footnotes">
<ol class="footnotes-list">
<li id="fn1" class="footnote-item"><p>Big IT companies sponsor lots of things with huge amounts of money. Winning a Chanel handbag for solving algorithmic problems in high school, seems like quite a carrot. <a href="#fnref1" class="footnote-backref">↩</a></p>
</li>
</ol>
</section>

View File

@ -1,10 +0,0 @@
<h2>#Romantic Japanese Christmas Takunomi Saturday Recap</h2>
<iframe width="560" height="315" src="https://www.youtube.com/embed/-dxqlXPyDl4?rel=0" frameborder="0" allowfullscreen></iframe>
<p>Going on a break for exams for a good deal of March, but here is a recap of a lovely week posts (sans friday, that was the start of the break). Above is a video of a girl eating lots of stuff. It's fun.</p>
<ul>
<li>Monday. <a href="http://takunomi.space/post/157773388125/dumb-puzzles-mixes-up-combat-links-awakening"><strong>Dumb Puzzles Mixes up Combat</strong></a>. Looking at the simplicity of game puzzles in a positive light.</li>
<li>Tuesday. <a href="http://takunomi.space/post/157815396772/game-development-essentials-the-terminal"><strong>Game Development Essentials - The Terminal</strong></a>. A talkative introduction to using the terminal, a most useful tool for game developers and others alike.</li>
<li>Wednesday. <a href="http://takunomi.space/post/157864135025/zeruda-no-cm-being-admittedly-quite-hyped-for"><strong>Zeruda no CM</strong></a>. Giving a lot of old Japanese Zelda commercials a look.</li>
<li>Thursday. <a href="http://takunomi.space/post/157913324565/dr-advanced-wargroove-orcs-and-humans-two-days"><strong>Dr. Advanced Wargroove: Orcs and Humans</strong></a>. Talking <em>Wargroove</em> and originality.</li>
<li>Friday. <a href="http://takunomi.space/post/157956984315/march-exam-break-im-going-on-a-short-blogging"><strong>March Exam Break</strong></a>. Break announcement.</li>
</ul>

View File

@ -1,7 +0,0 @@
<h2>Lewd Interlude</h2>
<p><img src="http://i65.tinypic.com/sb26b6.jpg" alt="Lewd Interlude" title="Dipping"></p>
<p>Haradaya is the character designer for the strategy RPG series, Disgaea. Unlike the Matsuno family of that genre, these are, as people know, crazily over the top, with wild ideas and non-sensical stories. I don't really think they're better, but I like the style of gameplay and especially the art style.</p>
<p>Haradaya has a cute little blog where he posts his art, his Comiket zines and indie games he's developing. Give it a look -&gt; <a href="http://blog.livedoor.jp/haradaya_blog/">** Link **</a>. This picture I've posted is great. It's sort of a realistic RPG tile, with a 3D cross-section. The character is Haradaya's Plenair, holding her doll of the character Same-san (Mr. Shark). They've both been in the Disgaea games multiple times. The skimpy bikini is almost a trademark of Haradaya, who is well into doing fanservice and fanservicey stuf in both is dōjinshi works and the professional Disgaea stuff.</p>

View File

@ -1,5 +1,7 @@
<p><img src="http://i65.tinypic.com/sb26b6.jpg" alt="Lewd Interlude" title="Dipping"></p> <p><img src="http://i65.tinypic.com/sb26b6.jpg" alt="Lewd Interlude" title="Dipping"></p>
<time datetime="2017-08-12">2017-08-12</time>
<p>Haradaya is the character designer for the strategy RPG series, Disgaea. Unlike the Matsuno family of that genre, these are, as people know, crazily over the top, with wild ideas and non-sensical stories. I don't really think they're better, but I like the style of gameplay and especially the art style.</p> <p>Haradaya is the character designer for the strategy RPG series, Disgaea. Unlike the Matsuno family of that genre, these are, as people know, crazily over the top, with wild ideas and non-sensical stories. I don't really think they're better, but I like the style of gameplay and especially the art style.</p>
<p>Haradaya has a cute little blog where he posts his art, his Comiket zines and indie games he's developing. Give it a look -&gt; <a href="http://blog.livedoor.jp/haradaya_blog/">** Link **</a>. This picture I've posted is great. It's sort of a realistic RPG tile, with a 3D cross-section. The character is Haradaya's Plenair, holding her doll of the character Same-san (Mr. Shark). They've both been in the Disgaea games multiple times. The skimpy bikini is almost a trademark of Haradaya, who is well into doing fanservice and fanservicey stuf in both is dōjinshi works and the professional Disgaea stuff.</p> <p>Haradaya has a cute little blog where he posts his art, his Comiket zines and indie games he's developing. Give it a look -&gt; <a href="http://blog.livedoor.jp/haradaya_blog/">** Link **</a>. This picture I've posted is great. It's sort of a realistic RPG tile, with a 3D cross-section. The character is Haradaya's Plenair, holding her doll of the character Same-san (Mr. Shark). They've both been in the Disgaea games multiple times. The skimpy bikini is almost a trademark of Haradaya, who is well into doing fanservice and fanservicey stuf in both is dōjinshi works and the professional Disgaea stuff.</p>

View File

@ -1,4 +1,5 @@
<iframe width="560" height="315" src="https://www.youtube.com/embed/-dxqlXPyDl4?rel=0" frameborder="0" allowfullscreen></iframe> <iframe width="560" height="315" src="https://www.youtube.com/embed/-dxqlXPyDl4?rel=0" frameborder="0" allowfullscreen></iframe>
<time datetime="2017-03-04">2017-03-04</time>
<p>Going on a break for exams for a good deal of March, but here is a recap of a lovely week posts (sans friday, that was the start of the break). Above is a video of a girl eating lots of stuff. It's fun.</p> <p>Going on a break for exams for a good deal of March, but here is a recap of a lovely week posts (sans friday, that was the start of the break). Above is a video of a girl eating lots of stuff. It's fun.</p>
<ul> <ul>
<li>Monday. <a href="http://takunomi.space/post/157773388125/dumb-puzzles-mixes-up-combat-links-awakening"><strong>Dumb Puzzles Mixes up Combat</strong></a>. Looking at the simplicity of game puzzles in a positive light.</li> <li>Monday. <a href="http://takunomi.space/post/157773388125/dumb-puzzles-mixes-up-combat-links-awakening"><strong>Dumb Puzzles Mixes up Combat</strong></a>. Looking at the simplicity of game puzzles in a positive light.</li>

View File

@ -1,5 +1,6 @@
<p><img src="http://i67.tinypic.com/mv0l95.png" alt="Takunomi Coffee Reveries, Vol. I" title="Cooking"></p> <p><img src="http://i67.tinypic.com/mv0l95.png" alt="Takunomi Coffee Reveries, Vol. I" title="Cooking"></p>
<h3><a name="index"></a> Contents</h3> <h3><a name="index"></a> Contents</h3>
<time datetime="2017-04-23">2017-04-23</time>
<p><br></p> <p><br></p>
<p>1 - <a href="#sec0"><strong>Introduction</strong></a></p> <p>1 - <a href="#sec0"><strong>Introduction</strong></a></p>
<p>2 - <a href="#sec1"><strong>Revitalizing the Ancients</strong></a> {<em>Breath of the Wild</em>, <em>Final Fantasy XV</em>}</p> <p>2 - <a href="#sec1"><strong>Revitalizing the Ancients</strong></a> {<em>Breath of the Wild</em>, <em>Final Fantasy XV</em>}</p>

View File

@ -22,6 +22,9 @@ var templates = template.Must(template.ParseFiles("blog.tmpl", "blog_roll.tmpl",
func main() { func main() {
InitializeCollection()
go AcquirePosts(100)
http.HandleFunc("/", blogHandler) http.HandleFunc("/", blogHandler)
http.HandleFunc("/post/", postHandler) http.HandleFunc("/post/", postHandler)