Compare commits
No commits in common. "7fb3c26633ad6e4b98706b5cc569387dd13012f1" and "f719cedc37285af12ae732ca860ab59a4b873d6c" have entirely different histories.
7fb3c26633
...
f719cedc37
82
analyze.rb
82
analyze.rb
@ -1,82 +0,0 @@
|
|||||||
require "pathname"
|
|
||||||
require "set"
|
|
||||||
require "json"
|
|
||||||
|
|
||||||
def resolve_path(bp, p)
|
|
||||||
path = nil
|
|
||||||
if bp.start_with? "."
|
|
||||||
path = Pathname.new(File.join(bp, p)).cleanpath.to_s
|
|
||||||
elsif p.start_with? "blog/"
|
|
||||||
path = File.join("content", p)
|
|
||||||
else
|
|
||||||
path = File.join("content", "blog", p)
|
|
||||||
end
|
|
||||||
if File.directory? path
|
|
||||||
path = File.join(path, "index.md")
|
|
||||||
elsif !path.end_with? ".md"
|
|
||||||
path += ".md"
|
|
||||||
end
|
|
||||||
path.gsub("blog/blog/", "blog/")
|
|
||||||
end
|
|
||||||
|
|
||||||
files = Set.new
|
|
||||||
refs = {}
|
|
||||||
ARGF.each do |file|
|
|
||||||
file = file.chomp
|
|
||||||
files << file
|
|
||||||
arr = refs[file] || (refs[file] = [])
|
|
||||||
File.open(file).read.scan(/< relref "([^"]+)" >/) do |ref|
|
|
||||||
ref = resolve_path(File.dirname(file), ref[0])
|
|
||||||
arr << ref
|
|
||||||
files << ref
|
|
||||||
end
|
|
||||||
arr.uniq!
|
|
||||||
end
|
|
||||||
|
|
||||||
data = {}
|
|
||||||
id = 0
|
|
||||||
files.each do |file|
|
|
||||||
id += 1
|
|
||||||
name = file
|
|
||||||
tags = []
|
|
||||||
group = 1
|
|
||||||
value = File.size(file)
|
|
||||||
url = file.gsub(/^content/, "https://danilafe.com").delete_suffix("/index.md").delete_suffix(".md")
|
|
||||||
File.readlines(file).each do |l|
|
|
||||||
if l =~ /^title: (.+)$/
|
|
||||||
name = $~[1].delete_prefix('"').delete_suffix('"')
|
|
||||||
elsif l =~ /^tags: (.+)$/
|
|
||||||
tags = $~[1].delete_prefix("[").delete_suffix("]").split(/,\s?/).map { |it| it.gsub('"', '') }
|
|
||||||
if tags.include? "Compilers"
|
|
||||||
group = 2
|
|
||||||
elsif tags.include? "Coq"
|
|
||||||
group = 3
|
|
||||||
elsif tags.include? "Programming Languages"
|
|
||||||
group = 4
|
|
||||||
elsif tags.include? "Haskell"
|
|
||||||
group = 5
|
|
||||||
elsif tags.include? "Crystal"
|
|
||||||
group = 6
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
data[file] = { :id => id, :label => name, :group => group, :tags => tags, :url => url, :value => value }
|
|
||||||
end
|
|
||||||
|
|
||||||
edges = []
|
|
||||||
files.each do |file1|
|
|
||||||
# files.each do |file2|
|
|
||||||
# next if file1 == file2
|
|
||||||
# next unless data[file1][:tags].any? { |t| data[file2][:tags].include? t }
|
|
||||||
# edges << { :from => data[file1][:id], :to => data[file2][:id] }
|
|
||||||
# end
|
|
||||||
next unless frefs = refs[file1]
|
|
||||||
frefs.each do |ref|
|
|
||||||
edges << { :from => data[file1][:id], :to => data[ref][:id] }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
edges.uniq
|
|
||||||
# edges.filter! { |e| e[:from] < e[:to] }
|
|
||||||
|
|
||||||
puts ("const nodes = " + JSON.pretty_unparse(data.values) + ";")
|
|
||||||
puts ("const edges = " + JSON.pretty_unparse(edges) + ";")
|
|
@ -3,7 +3,7 @@ title: Learning Emulation, Part 2
|
|||||||
date: 2016-11-23 23:23:18.664038
|
date: 2016-11-23 23:23:18.664038
|
||||||
tags: ["C and C++", "Emulation"]
|
tags: ["C and C++", "Emulation"]
|
||||||
---
|
---
|
||||||
_This is the second post in a series I'm writing about Chip-8 emulation. If you want to see the first one, head [here]({{< relref "/blog/01_learning_emulation.md" >}})._
|
_This is the second post in a series I'm writing about Chip-8 emulation. If you want to see the first one, head [here]({{< ref "/blog/01_learning_emulation.md" >}})._
|
||||||
|
|
||||||
Now that we have an understanding of the physical capabilities of a Chip-8 system, we can write code that will represent such a system on our computer. In this post we'll start writing some basic code - be prepared.
|
Now that we have an understanding of the physical capabilities of a Chip-8 system, we can write code that will represent such a system on our computer. In this post we'll start writing some basic code - be prepared.
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ title: Learning Emulation, Part 2.5 - Implementation
|
|||||||
date: 2016-11-23 23:23:56.633942
|
date: 2016-11-23 23:23:56.633942
|
||||||
tags: ["C and C++", "Emulation"]
|
tags: ["C and C++", "Emulation"]
|
||||||
---
|
---
|
||||||
_This is the third post in a series I'm writing about Chip-8 emulation. If you want to see the first one, head [here]({{< relref "/blog/01_learning_emulation.md" >}})._
|
_This is the third post in a series I'm writing about Chip-8 emulation. If you want to see the first one, head [here]({{< ref "/blog/01_learning_emulation.md" >}})._
|
||||||
|
|
||||||
In the previous part of this tutorial, we created a type to represent a basic Chip-8 machine. However, we've done nothing to make it behave like one! Let's start working on that.
|
In the previous part of this tutorial, we created a type to represent a basic Chip-8 machine. However, we've done nothing to make it behave like one! Let's start working on that.
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ GHC IDE is a Haskell-based program that uses the
|
|||||||
{{< sidenote "right" "lsp-note" "language server protocol" >}}
|
{{< sidenote "right" "lsp-note" "language server protocol" >}}
|
||||||
You don't really need to know what the language server protocol (LSP) is
|
You don't really need to know what the language server protocol (LSP) is
|
||||||
to use GHC IDE. If you are nonetheless interested, I wrote a little
|
to use GHC IDE. If you are nonetheless interested, I wrote a little
|
||||||
bit about it <a href="{{< relref "/blog/haskell_language_server" >}}#prelude-language-server-protocol">in the previous iteration of this post.</a>
|
bit about it <a href="{{< ref "/blog/haskell_language_server" >}}#prelude-language-server-protocol">in the previous iteration of this post.</a>
|
||||||
If you want more information, check out the <a href="https://microsoft.github.io/language-server-protocol/">official Microsoft page on LSP.</a>
|
If you want more information, check out the <a href="https://microsoft.github.io/language-server-protocol/">official Microsoft page on LSP.</a>
|
||||||
{{< /sidenote >}} to communicate with any editor that supports it. Editors
|
{{< /sidenote >}} to communicate with any editor that supports it. Editors
|
||||||
with support the the LSP include Atom, Visual Studio Code, Emacs, and Vim. Thus,
|
with support the the LSP include Atom, Visual Studio Code, Emacs, and Vim. Thus,
|
||||||
@ -61,7 +61,7 @@ export PATH=$PATH:/home/<yourusername>/.local/bin
|
|||||||
On Windows, this is done by
|
On Windows, this is done by
|
||||||
{{< sidenote "right" "path-note" "editing your PATH variable." >}}
|
{{< sidenote "right" "path-note" "editing your PATH variable." >}}
|
||||||
If you need to know how to change your <code>PATH</code>, I wrote
|
If you need to know how to change your <code>PATH</code>, I wrote
|
||||||
about it briefly in the <a href="{{< relref "/blog/haskell_language_server" >}}
|
about it briefly in the <a href="{{< ref "/blog/haskell_language_server" >}}
|
||||||
#installation-of-v0-5-0-0-windows-systems">previous iteration of this post.</a>
|
#installation-of-v0-5-0-0-windows-systems">previous iteration of this post.</a>
|
||||||
{{< /sidenote >}} I don't run Windows,
|
{{< /sidenote >}} I don't run Windows,
|
||||||
so I don't know where `cabal install` will place the executable, but I do know
|
so I don't know where `cabal install` will place the executable, but I do know
|
||||||
|
Loading…
Reference in New Issue
Block a user