15 changed files with 238 additions and 55 deletions
@ -1,22 +0,0 @@
|
||||
--- |
||||
title: "FoxNet: " |
||||
date: 2021-09-02 |
||||
author: CPunch |
||||
tags: ["C++", "networking"] |
||||
repo: "https://github.com/CPunch/FoxNet" |
||||
draft: true |
||||
--- |
||||
|
||||
Recently I've been trying to find a lightweight networking library for another project. I had looked at several other libraries (RakNet namely) and wasn't impressed. RakNet hasn't been maintained in over 7 years and also included lots of features that weren't needed and unnecessarily made the library FAT. Such as specific reserved packets for consoles like the XBOX and a built-in team balancer. It's pretty obvious that RakNet was geared towards gaming-related applications. After seeing the state of things, I thought it'd be easier to write a minimal networking library that had just the very basics of features and left the rest to be extensible by the user. |
||||
|
||||
## Enter: FoxNet |
||||
|
||||
After spending about a month of trying different styles and ways of making the protocol extensible by the user, I finally landed on something that seems to have the best of both worlds. Let's walk through an example. |
||||
|
||||
First things first, lets clone the repo and setup our CMake environment |
||||
|
||||
```bash |
||||
mkdir FoxNetExample && cd FoxNetExample && git clone https://github.com/CPunch/FoxNet.git |
||||
``` |
||||
|
||||
```CMakeList |
@ -0,0 +1,37 @@
|
||||
--- |
||||
title: "Site Rewrite: From theme to lean" |
||||
date: 2021-12-02 |
||||
author: CPunch |
||||
tags: ["hugo"] |
||||
draft: false |
||||
--- |
||||
|
||||
I recently rewrote my Hugo site. I'd be lying if I said this was a spur-of-the-moment thing. The thing that really kicked me into finally starting from scratch was [this recent PR](https://github.com/XXIIVV/webring/pull/643) where I submitted my site to XXIIVV's webring. It was closed rather quickly, with the site ultimately being rejected from the webring. Neauoire's reasoning was simply put, it read: |
||||
|
||||
{{< img pull.png "900x q100 jpg" "It's nice to see a PR from you, but your website in its current state does not qualify for the webring. There are no projects documented on-site(besides the site-builder itself), also using such a standard Hugo template goes against the hand-crafted requirement of the webring. Sorry, feel free to open another one when the site is further down the line" >}} |
||||
|
||||
This didn't come as a surprise, in fact after I had submitted my PR I was reviewing other closed PRs and saw that my site somewhat fit-in with the rejected sites. While I had made several modifications to the theme it was still fairly generic and 'template-y.' The theme in question was this [lovely theme by adityatelange](https://github.com/adityatelange/hugo-PaperMod). There was nothing inherently wrong with the theme, but it didn't quite fit my needs any more. |
||||
|
||||
## The woes of using a theme |
||||
|
||||
There were many, *many* features of that theme I didn't have a use for or just completely disagreed with. For example, the theme had integration for google analytics. My site has never and will never use such an analytics tool, instead relying on nginx log parsers like [GoAccess](https://goaccess.io). All of these unused features were just that, unused. This made my site full of features I didn't even know I had. My site should only have things that I explicitly enable and added. |
||||
|
||||
Another thing about using a Hugo theme is it doesn't force you to *learn* Hugo. Immediately after starting the rewrite I had learned more in 20 minutes from reading the docs and writing my own layouts than I had in the year I spent modifying that theme. Being forced to really *know* your tooling is always a plus. |
||||
|
||||
## The rewrite and some nice-to-haves |
||||
|
||||
After deciding to get rid of my Hugo theme, I was forced to learn a lot more about Hugo than I had before. Writing my own [shortcodes](https://git.openpunk.com/OpenPunk/openpunk/src/branch/main/layouts/shortcodes), [section parsers](https://git.openpunk.com/OpenPunk/openpunk/src/branch/main/layouts/section), and of course the actual rendered HTML and CSS. |
||||
|
||||
[One such shortcode](https://git.openpunk.com/OpenPunk/openpunk/src/branch/main/layouts/shortcodes/img.html) enables me to compress images into a more friendly format for your web browser automagically. This made sharing photos (and ultimately [/places/](/places)) a lot more intuitive and friendly for my servers bandwidth and yours! Having to compress my images manually is such a chore, but Hugo and this shortcode makes it as easy as adding |
||||
|
||||
```md |
||||
{{</* img image.png "q70 jpg" "alt-text" */>}} |
||||
``` |
||||
|
||||
This even lets me selectively compress images, ignoring images I'd like to keep raw. |
||||
|
||||
Another main point was the lack of JavaScript. Not to say JS is inherently bad, but this keeps compatibility with some more privacy-focused web browsers like the Tor Browser. Speaking of Tor, my Tor mirror link is no longer hidden behind some obscure blog post, instead its in plain view as a clickable link in the site's footer. |
||||
|
||||
## Addressing the PR |
||||
|
||||
My immediate decision was made to rewrite my site from scratch, ditching the Hugo theme. I had debated writing my own static site generator but I did this a couple weeks before finals so I scrapped that almost immediately since I wanted to get this done rather quickly. Another note of importance was the lack of on-site project documentation. So, I've created a new section called ['Software'](/software). This section is pretty lackluster right now, however eventually I plan to document *most* of my projects here. This also might force me to finish some projects so that they're in a nice presentable state. |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 73 KiB |
@ -0,0 +1,63 @@
|
||||
--- |
||||
title: "Cosmo" |
||||
author: CPunch |
||||
date: 2020-10-28 |
||||
tags: ["C", "scripting-lang", "cosmo"] |
||||
repo: "https://git.openpunk.com/CPunch/Cosmo" |
||||
--- |
||||
|
||||
Cosmo is an eccentric scripting language, taking inspiration from [Lua](https://www.lua.org/), Cosmo is easily extensible through the use of 'Proto-objects,' which describe the behavior of Objects. For example the following is a simple Vector Proto which describes behavior for a Vector-like object. |
||||
|
||||
```lua |
||||
proto Vector |
||||
function __init(self) |
||||
self.vector = [] |
||||
self.x = 0 |
||||
end |
||||
|
||||
function __index(self, key) |
||||
return self.vector[key] |
||||
end |
||||
|
||||
function push(self, val) |
||||
self.vector[self.x++] = val |
||||
end |
||||
|
||||
function pop(self) |
||||
return self.vector[--self.x] |
||||
end |
||||
end |
||||
|
||||
var vector = Vector() |
||||
|
||||
for (var i = 0; i < 4; i++) do |
||||
vector:push(i) |
||||
end |
||||
|
||||
for (var i = 0; i < 4; i++) do |
||||
print(vector:pop() .. " : " .. vector[i]) |
||||
end |
||||
|
||||
``` |
||||
|
||||
Output: |
||||
|
||||
``` |
||||
3 : 0 |
||||
2 : 1 |
||||
1 : 2 |
||||
0 : 3 |
||||
``` |
||||
|
||||
Usage: |
||||
|
||||
```sh |
||||
$ cosmo script.cosmo |
||||
``` |
||||
|
||||
or a REPL can be opened by providing no arguments. |
||||
|
||||
{{< img REPL.png "720x q100 jpg" "" >}} |
||||
|
||||
|
||||
Full documentation on language features can be found [here](https://git.openpunk.com/CPunch/Cosmo/src/branch/main/docs) |
@ -0,0 +1,88 @@
|
||||
--- |
||||
title: "LuaPytecode" |
||||
author: CPunch |
||||
date: 2019-09-15 |
||||
tags: ["lua", "python"] |
||||
repo: "https://github.com/CPunch/LuaPytecode" |
||||
--- |
||||
|
||||
A Lua5.1 cross-platform bytecode deserializer. This module pulls int and size_t sizes from the chunk header, meaning it should be able to deserialize lua bytecode dumps from most platforms, regardless of the host machine. |
||||
|
||||
For details on the Lua5.1 bytecode format, I read [this PDF](https://archive.org/download/a-no-frills-intro-to-lua-5.1-vm-instructions/a-no-frills-intro-to-lua-5.1-vm-instructions_archive.torrent) as well as read the [lundump.c](https://www.lua.org/source/5.1/lundump.c.html) source file from the Lua5.1 source. |
||||
|
||||
```lua |
||||
total = 1 |
||||
|
||||
function setTotal() |
||||
for i=1,10 do |
||||
total=total*i |
||||
end |
||||
end |
||||
|
||||
setTotal() |
||||
print(total) |
||||
``` |
||||
|
||||
Compile our example script with |
||||
|
||||
```sh |
||||
$ luac -o example.luac -- example.lua |
||||
``` |
||||
|
||||
Now disassemble it |
||||
|
||||
```python |
||||
import luac |
||||
|
||||
lc = luac.LuaUndump() |
||||
chunk = lc.loadFile("example.luac") |
||||
|
||||
lc.print_dissassembly() |
||||
``` |
||||
|
||||
``` |
||||
|
||||
==== [[example.lua's constants]] ==== |
||||
|
||||
0: [STRING] total |
||||
1: [NUMBER] 1.0 |
||||
2: [STRING] setTotal |
||||
3: [STRING] print |
||||
|
||||
==== [[example.lua's dissassembly]] ==== |
||||
|
||||
[ 0] LOADK : 0 1 |
||||
[ 1] SETGLOBAL : 0 0 |
||||
[ 2] CLOSURE : 0 0 |
||||
[ 3] SETGLOBAL : 0 2 |
||||
[ 4] GETGLOBAL : 0 2 |
||||
[ 5] CALL : 0 1 1 |
||||
[ 6] GETGLOBAL : 0 3 |
||||
[ 7] GETGLOBAL : 1 0 |
||||
[ 8] CALL : 0 2 1 |
||||
[ 9] RETURN : 0 1 0 |
||||
|
||||
==== [[example.lua's protos]] ==== |
||||
|
||||
|
||||
==== [['s constants]] ==== |
||||
|
||||
0: [NUMBER] 1.0 |
||||
1: [NUMBER] 10.0 |
||||
2: [STRING] total |
||||
|
||||
==== [['s dissassembly]] ==== |
||||
|
||||
[ 0] LOADK : 0 0 |
||||
[ 1] LOADK : 1 1 |
||||
[ 2] LOADK : 2 0 |
||||
[ 3] FORPREP : 0 3 |
||||
[ 4] GETGLOBAL : 4 2 |
||||
[ 5] MUL : 4 4 3 |
||||
[ 6] SETGLOBAL : 4 2 |
||||
[ 7] FORLOOP : 0 -4 |
||||
[ 8] RETURN : 0 1 0 |
||||
|
||||
==== [['s protos]] ==== |
||||
|
||||
``` |
@ -0,0 +1,15 @@
|
||||
{{ define "main" }} |
||||
|
||||
<div class="main"> |
||||
<h1>Software</h1> |
||||
{{ range .Pages.ByPublishDate.Reverse }} |
||||
<p> |
||||
<a href="{{ .RelPermalink }}">{{- if not .Date.IsZero -}} |
||||
{{- (slice (.Date.Format (default "January 2, 2006" .Site.Params.DateFormat))) }} |
||||
{{- end -}}<br>- {{ .Title }}</a> |
||||
</p> |
||||
{{ end }} |
||||
<br> |
||||
</div> |
||||
|
||||
{{ end }} |
Loading…
Reference in new issue