Welcome to my website, look around if you like. This is a serverless website. I build this all by hand.
This is an aws free tier thing. It uses api gateway and lambda to create a RESTful website powered by python. AWS provides a framework for load-balancing cloud resources and my self-hosted endpoints.
TODO:
I updated my github with a lot of my old programs over @ GitHub.com/NolieRavioli
I made a way to create new posts here that are formatted and dated and things. its quite late at night now so I think Im done for the night.
<script>
// Save the original login form HTML to allow resetting later.
const originalLoginHTML = document.getElementById("login").innerHTML;
function prettyPrintHTML(rawHtml) {
let indent = 0;
const indentSize = 2;
return rawHtml
.replace(/></g, '>\n<').split('\n')
.map(line => {
line = line.trim();
if (line.match(/^<\/\w/)) {
indent = Math.max(indent - indentSize, 0);
}
const result = ' '.repeat(indent) + line;
if (line.match(/^<\w[^>]*[^/]>$/)) {
indent += indentSize;
}
return result;
}).join('\n');
}
// When username or password gets focus, select all text.
document.getElementById("user").addEventListener("focus", function(e) {
e.target.select();
});
document.getElementById("pass").addEventListener("focus", function(e) {
e.target.select();
});
// When pressing Enter in username or password, trigger login()
["user", "pass"].forEach(id => {
document.getElementById(id).addEventListener("keydown", function(e) {
if (e.key === "Enter") {
e.preventDefault();
login();
}
});
});
// Attach event listener to the Submit button
document.getElementById('go').addEventListener('click', function(e) {
e.preventDefault();
login();
});
function login() {
const content = document.getElementById('post').value;
const username = document.getElementById('user').value;
const password = document.getElementById('pass').value;
fetch("https://nolanpeet.us/login/auth", {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password, content })
})
.then(response => {
if (!response.ok) {
throw new Error("HTTP error " + response.status);
}
return response.text();
})
.then(htmlString => {
// Pretty-print, then escape the HTML so it's displayed as code
const pretty = prettyPrintHTML(htmlString);
const escaped = pretty
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">");
// Display the escaped raw HTML in a pre/code block along with a Reset button
document.getElementById("login").innerHTML = `<pre id="login"><code>${escaped}</code></pre><button id="resetBtn">Reset Form</button>`;
// Add click listener to the reset button to restore the original form
document.getElementById("resetBtn").addEventListener("click", function() {
document.getElementById("login").innerHTML = originalLoginHTML;
// Reattach event listeners for focus, keydown, and click to the new inputs and button:
attachInputListeners();
});
})
.catch(error => {
console.error("Error during login:", error);
});
}
// Function to reattach event listeners after resetting the form
function attachInputListeners() {
const userInput = document.getElementById("user");
const passInput = document.getElementById("pass");
userInput.addEventListener("focus", function(e) {
e.target.select();
});
passInput.addEventListener("focus", function(e) {
e.target.select();
});
[userInput, passInput].forEach(input => {
input.addEventListener("keydown", function(e) {
if (e.key === "Enter") {
e.preventDefault();
login();
}
});
});
document.getElementById('go').addEventListener('click', function(e) {
e.preventDefault();
login();
});
}
</script>
I have finished with my temperature monitoring project. It uses a raspberry pi and 433mHz radio hygrometers to record and graph historic tempurature data at my cabin. The data packing was the most interesting part of this project for me. After recieving and validating the radio transmission through the GPIO pins, I pack each datapoint into 94 bits (timestamp, rawTemp, humidity, channel, batterySignal, etc...). These bits are stored in a binary file.
According to my calculations, (3x4x60x24x94 = 1,624,320 bits per day = 203,040 bytes per day = 145 years to fill 10GB of storage), I'll be able to record data forever.
I finished a program to automate the naming of .mp3 files using file signature and acoustid to insert metadata into the tracks. I ran into some issues because of windows naming rules and how tracks are saved. I also ran into some issues retrieving the artists on each track properly, where i had to do some string cleaning and extra requests in some cases. The tracks now include album artwork, artist names, and other metadata. It would be interesting to develop an audio digester for all types of streaming services. The amount of error handling and modulization of micro-services would be more than anything I've attempted before.