add blogs, move pictures to local + much more
This commit is contained in:
43
content/blog/how-i-made-my-site-fast.md
Normal file
43
content/blog/how-i-made-my-site-fast.md
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
title: How I made my site fast
|
||||
description: How I made my social media site fast
|
||||
img: /images/how-i-made-my-site-fast.png
|
||||
alt: how i made snowball fast
|
||||
writer: juls07
|
||||
date: 2022-05-22
|
||||
tags:
|
||||
- web dev
|
||||
- fullstack development
|
||||
- angular
|
||||
- nodejs
|
||||
- redis
|
||||
---
|
||||
So yesterday I talked about my social media site that I'm working on. Today I implemented redis, a memory store that I used to reduce requests at most by 48ms. First when I tried to use redis I just used the `redis` package off of npmjs because it only makes sense but when I tried to get a key with the name of `user-cache-[userId]` It failed for some reason, I still dont know why it failed but using the `ioredis` package and everything started working, not user data processing, what I used redis to cache since it's a terrible for loop that executes database requests for every post, but now it's all stored in memory. I still want to add TTL since my VPS that I intend on deploying my site on for production only has 1GB of RAM but I'm not sure how to do that. If you saw my blog post from [yesterday](/blog/what-ive-been-doing) then you'll know what my user code used to look like, now it looks like this.
|
||||
|
||||
```js[post.js]
|
||||
for (let i = 0; i < replies.length; i++) {
|
||||
await redisClient.get('cache-user-' + replies[i].creator, (err, reply) => {
|
||||
if (reply == null || err) {
|
||||
usermodel.findById(replies[i].creator, '-password -__v -email', async function(err, user) {
|
||||
if (err) {
|
||||
return res.status(500).json({
|
||||
message: "Fetching posts failed"
|
||||
});
|
||||
}
|
||||
replies[i].creator = user;
|
||||
redisClient.set('cache-user-' + replies[i].creator._id, JSON.stringify(user))
|
||||
})
|
||||
} else {
|
||||
replies[i].creator = JSON.parse(reply)
|
||||
}
|
||||
})
|
||||
if (i === replies.length - 1) {
|
||||
return res.status(200).json({
|
||||
message: "replies fetched successfully",
|
||||
replies: await replies
|
||||
});
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
With this you can see first it checks for the user data in cache if there is nonde then it will grab the data from mongodb and then write it to the redis cache. Next time, I want to cache replies and posts but I'm still worried about memory constraint on my VPS. After all of the redis caching I still want to speed up my site more, I want to replace JWT because I dont like it that much and I still want to find a workaround to Opengraph tags. After everything If you want to hear about it more often follow me on [@julie4055_](https://twitter.com/julie4055_), I'm also thinking about writing a blog daily-ish rather than just posting every other month or so, and that'll be it have a great rest of your day!
|
||||
74
content/blog/nuxtjs-trpc-fullstack.md
Normal file
74
content/blog/nuxtjs-trpc-fullstack.md
Normal file
@@ -0,0 +1,74 @@
|
||||
---
|
||||
title: My nuxtjs + trpc fullstack web app
|
||||
description: My experiences with nuxtjs 3 and tRPC
|
||||
img: /images/how-i-made-my-site-fast.png
|
||||
alt: how i made snowball fast
|
||||
writer: juls07
|
||||
date: 2022-09-20
|
||||
_draft: true
|
||||
tags:
|
||||
- web dev
|
||||
- fullstack development
|
||||
- nuxtjs 3
|
||||
- tRPC
|
||||
- redis
|
||||
---
|
||||
|
||||
Recently I've been working with nuxtjs 3 and tTRPC. I've heard a lot of things about nuxtjs 3 and tRPC lately, mostly bad with nuxtjs 3 and mostly good with trpc. These are not technoligies I've been interested in working with for a while
|
||||
|
||||
## JS Code Block
|
||||
|
||||
```js
|
||||
const a = 5;
|
||||
```
|
||||
|
||||
## One liners
|
||||
`here` `and here` `count` you don't even know what you're asking me to confess
|
||||
|
||||
## Vue Code Block
|
||||
|
||||
```vue
|
||||
<template>
|
||||
<input v-model.lazy="message"/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { watch, ref } from 'vue'
|
||||
|
||||
const message = ref('');
|
||||
|
||||
const saveMessage = () => {
|
||||
// do anything with the message
|
||||
}
|
||||
|
||||
watch(message, (newMessage) => {
|
||||
saveMessage(newMessage) // only called on change events
|
||||
})
|
||||
</script>
|
||||
```
|
||||
|
||||
## Vue Code Block With Line Highlighting
|
||||
|
||||
```svelte
|
||||
<script>
|
||||
{#if tags.length > 0}
|
||||
{#each tags as tag}
|
||||
<Tag {tag} />
|
||||
{/each}
|
||||
{:else}
|
||||
<p>This release has no tags</p>
|
||||
{/if}
|
||||
</script>
|
||||
```
|
||||
|
||||
```lua {2,6-10}
|
||||
local name = "juls07"
|
||||
```
|
||||
|
||||
## Vue Code Block With Filename
|
||||
|
||||
```vue [pages/[...slug.vue]]
|
||||
<template>
|
||||
<input v-model.lazy="message" />
|
||||
</template>
|
||||
```
|
||||
19
content/blog/running-bittorent-webserver.md
Normal file
19
content/blog/running-bittorent-webserver.md
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
title: Running a qbittorrent webserver!
|
||||
description: My experience with a qbittorrent webserver
|
||||
img: /images/qbittorrent-web.png
|
||||
alt: running bittorrent webserver
|
||||
writer: juls07
|
||||
date: 2022-03-07
|
||||
tags:
|
||||
- Linux
|
||||
- Bittorrent
|
||||
- Docker
|
||||
- Web server
|
||||
---
|
||||
|
||||
Recently, I started running a qbittorrent webserver on my raspberry pi 4B+ using [this docker image](https://hotio.dev/containers/qbittorrent/), It has been quite a journey. First, I started looking for a way to run a qbittorrent in a container, this is how I run all the applications on my raspberry pi and I inevibly asked in the [Arch linux discord server](https://discord.gg/3m6dbPR) and I got a reply from @runsamok on discord and they reccomend the docker image I mentioned earlier. Then I started seeding linux distros (obviously) and I started with a batch of about 7 give or take, Ubuntu 18.04, Ubuntu 20.04, Ubuntu 21.04, Arch Linux (duh), Rocky Linux, and tails linux. I shotly realized that Rocky and tails are baren wastelands when it comes to people wanting to torrent them so I eventually Scrapped them.
|
||||
<br class="article"/>
|
||||
So after about 10 or so days I wanted to automatically download Arch linux and ubuntu updates using RSS, the qbittorrent webserver has thought of that so you can easily so so in the RSS tab. However, When downloading the latest Arch Linux version it worked fine but I added an ubuntu feed that I accidentally downloaded the 10 most recent torrents, but I deleted them and moved on. Later down the road I was trying to download the march patch of the Arch Linux torrent but I could not, after a while of wondering why I realized my storage was full, my raspberry pi doesnt have a lot of storage but not a little, it turns out that the torrents I deleted from the Ubuntu RSS were still on the raspberry pi, this isnt the fault of the developers because I didnt check the "delete on disk" button but there was not "not enough space warning" message when I tried to download the Arch Linux torrent.
|
||||
<br class="article"/>
|
||||
Finally, after everything you're probably asking yourself if you should also host a bittorrent server, you should just as long as you have the free bandwidth and some extra computing power available. The Docker image I choose only takes about 30% cpu max so if you have a raspberry pi laying around it might be the perfect time to setup a bittorrent server. Thanks for reading if you havent already go ahead and follow my twitter [@julie4055_](https://twitter.com/julie4055_) and that'll be it have a great rest of your day!
|
||||
38
content/blog/what-ive-been-doing.md
Normal file
38
content/blog/what-ive-been-doing.md
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
title: What I've been doing
|
||||
description: Stuff I've been doing recently
|
||||
img: /images/what-ive-been-doing.png
|
||||
alt: what ive been doing
|
||||
writer: juls07
|
||||
date: 2022-05-21
|
||||
tags:
|
||||
- web dev
|
||||
- fullstack development
|
||||
- angular
|
||||
- nodejs
|
||||
- mongodb
|
||||
---
|
||||
|
||||
So I have been working on a social media site I am currently calling snowballsocial, so far I have users, posts, replies, and likes. Expressjs not having HTTP/2 is slightly annoying and I have kind of thought migrating all of my code to hapi but I'm too lazy to migrate all my code right now, especially since I just "asyncified" it, remaking my code rather than making all new code would probably be easier but I'll do that later. This project I again used mongoDB, I fist used mongodb in my [vuefullstack](https://github.com/juls0730/vuefullstack) app, and I loved it, it's much easier for the kind of projects I use than mySQL. Actually targeting a production site rather than just having fun like with my vuefullstack app or my rails-forum, etc. make me worry about alot more thigs like SEO, I tried to add OG tags to the post-show tag just showing post data but it doesnt work because the tags are added after the data loads.
|
||||
<br class="article"/>
|
||||
I've gotten a VPS from [linode](linode.com) so I could expose my non-static only page to the internet without exposing my home IP address, making me vulnerable to being doxxed and DDoS attacks. Using nignx I have reverse-proxied my api from port 3001 to 2087, and added ssl certs, and I have used it to server my static site on port 80, I have used nginx before and it's pretty simple to use. Optimizing has been the bain of development so far, making api requests faster, and reducing bundle size, I'm going to focus on api optimizations since its the harder one. My main worry for more than a couple requests is getting posts, since I do a for loop to change userId's to usernames
|
||||
```js
|
||||
for (let i = 0; i < posts.length; i++) {
|
||||
usermodel.findById(posts[i].creator, '-password -__v -followers -following -email', async function (err, user) {
|
||||
if (err) {
|
||||
return res.status(500).json({
|
||||
message: "Fetching posts failed"
|
||||
});
|
||||
}
|
||||
posts[i].creator = user;
|
||||
if (i === posts.length - 1) {
|
||||
return res.status(200).json({
|
||||
message: "Posts fetched successfully",
|
||||
posts: await posts,
|
||||
maxPosts: await maxPosts
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
```
|
||||
seen here is the code to change the userId's in get `/api/posts` so making at most 15 database requests per request, maybe a caching solution like redis might be applicable but I have never used something like that but I think I will definitely deploy something like that for caching. After everything If you want to hear about it more often follow me on [@julie4055_](https://twitter.com/julie4055_) and that'll be it have a great rest of your day!
|
||||
18
content/blog/why-i-chose-arch.md
Normal file
18
content/blog/why-i-chose-arch.md
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
title: Why I chose archlinux
|
||||
description: All of my reasons for choosing archlinux
|
||||
img: /images/archlinux.png
|
||||
alt: why I chose arch
|
||||
writer: juls07
|
||||
date: 2022-03-07
|
||||
tags:
|
||||
- Linux
|
||||
- archlinux
|
||||
---
|
||||
|
||||
I started using linux about 3 years ago, I started with Pop!_OS but after that I switched to fedora, then Zorin which is still the most beautiful out of the box linux distro I have ever used. After that howerver, I switched to arch and I've been on my misadventure's with arch for about 2 years now. I have a very minimalist approach to linux, trying to save as much space as possible save as much computer power as possible, arch being an extremely minimal install of linux was great for me. Next, being able to customize the install of arch is great, dont like systemd because of the company behind it, try runit or openrc, want btrfs so you can compress your files, go ahead, dont want grub, try systemdboot, etc. It's just the way arch lets you do whatever you want. Then, its the support from the [community discord](https://discord.gg/3m6dbPR) or the [arch wiki](https://wiki.archlinux.org/title/Main_page) if someone has had that problem theres a good chance you can get it fixed.
|
||||
<br class="article"/>
|
||||
Overall, I know that arch isnt good for industrial applications since it doesnt scale well, its definitely for enthusiasts who have the time to work on their computer and not for linux novices. I love arch for its simplicity and flexibility and I think you should try it if your used to linux and want something new to play with. Using arch over the years has taught me so much about linux in general and if your a seasoned linux user give it a change, maybe you'll find the same love for it I did all the years ago.
|
||||
<br class="article"/>
|
||||
Thanks for reading, if you liked it go ahead and follow me on twitter [@julie4055_](https://twitter.com/julie4055_) or maybe just tell me how bad I am at
|
||||
making banners for my blogs, peace.
|
||||
Reference in New Issue
Block a user