Good vs. Evil

  • FTB will be shutting down this forum by the end of July. To participate in our community discussions, please join our Discord! https://ftb.team/discord

duckfan77

Popular Member
Mar 18, 2013
80
683
118
10 I might have to do that, but it'll be a bit because I have finals in a few weeks. I'll have more time after finals, as I have almost a month between school ending and my summer job starting.
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
11 to be honest, its probably something very easy. Like a bug in that asynchronous recursive function that I'm using.

And yes, you read that right, its not only a function that calls itself it also does so asynchronous. I can probably remove the recursive aspect as its pretty much a forEach loop but I'm actually not sure that would improve readability.
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
10 alerts are pretty much done now, just need to clean them up a bit.

On the client the alerts have a generic implementation thus for as long as new alerts don't introduce new variables it will display correctly.
Also, alerts now have links inside of them. So, lets say you get an alert about a new character in a RP you are in you get
A character has been made for AOD called Astra

Both AOD and Astra are links, AOD going to the roleplay page and Astra going to the corresponding character sheet
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
11 turns out fixing both of those problems that where still present with alerts was easier than I thought. This also added a nice whitespace around the bottom of each alert, so even that got fixed.
 
  • Like
Reactions: GamerwithnoGame

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
12 so... about that problem that made php slow.
Turns out it wasn't php at all and instead was the nodejs server that ran out of database connections it could use as for various reasons the function that releases one of the connections back into the pool didn't work properly/was not always executed.

Either way, rewrote it a bit so that database connections are getting prepared and released automatically and repaired the release function so that that hopefully will never happen again.
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
12 if that is what its called when connections don't go back to their pool, then yes a connection leak.
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
12 in that case, happy birthday
Have some python3 code that shows "fireworks" on your screen. It needs pygame to run though
Code:
#!/usr/bin/python3
import pygame
import random
import time
import sys
import os
import signal
pygame.init
fireworks = []
explosions = []
stopped = False
#screenInfo = pygame.display.Info()
pygame.display.set_mode((0,0)) #

clock  = pygame.time.Clock()
screen = pygame.display.get_surface()
w,h  = screen.get_size()
ident = os.environ.get('XSCREENSAVER_WINDOW')
if ident is None:
  pygame.display.toggle_fullscreen()
def createFireworks():
  fireworks.append({
  "rect" : pygame.Rect(
  random.randint(0,w),
  800,
  10,
  10
  ),
  "color" : (random.randint(0,255),random.randint(0,255),random.randint(0,255)),
  "maxHeight" : random.randint(0,800)
  })
def explode(firework):
  for i in range(random.randint(0,40)):
  explosions.append({
  "rect"  : firework["rect"].copy(),
  "color" : (random.randint(0,255),random.randint(0,255),random.randint(0,255)),
  "dirr"  : (random.randint(-10,10),random.randint(-10,10)),
  "life"  : random.randint(30,32)
  })
while not stopped:
  screen.fill((0,0,0))
  lastFrame = clock.tick(30) #get the time since last frame and set the FPS correctly
  #call update here.
  if len(fireworks)<10:
  if random.randint(0,1):
  createFireworks()
  newFireWorkList =[]
  for firework in fireworks:
  firework["rect"].y -=5
  if firework["maxHeight"] >= firework["rect"].y:
  explode(firework)
  else:
  newFireWorkList.append(firework)
  pygame.draw.rect(screen,firework["color"],firework["rect"])
  fireworks = newFireWorkList
  newExplosionList = []
  for explosion in explosions:
  explosion["rect"].x += explosion["dirr"][0]
  explosion["rect"].y += explosion["dirr"][1]
  explosion["life"] -=1
  if explosion["life"] >=0:
  newExplosionList.append(explosion)
  pygame.draw.rect(screen,explosion["color"],explosion["rect"])
  #draw all the elements to the screen
  for event in pygame.event.get():
  if event.type == pygame.QUIT:
  stopped = True
  if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
  stopped = True
   
  pygame.display.update()
  #pygame.display.flip() #create the frame
#clean exit
pygame.quit()
quit()
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
12 to be honest, it isn't worth it. The "fireworks" are just colored blocks spawning randomly on the floor, going up a random height and exploding into more colored blocks after some random time.

Its a semi nice screen saver though
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
14 so... I just discovered that there is an OS that takes the "Everything is a file" to even higher levels and even has files to interact with the network.

If I understand it correctly it means you can write and read to a file to interact with the network instead of needing a language that is able to make requests natively.
So, instead of lets say php's curl_ functions to make http requests you could instead write the correct data to a file in /net/tcp and read it a bit later.

Of course, this means that you need to be able to understand how http works under the hood as its at a much lower level than the curl functions but it does mean you can much more easily write your own curl_ implementation in php. It also opens the door of networking to languages that by default don't have access to network requests but are able to write and read files like lua.

Also, the simpler the protocol the easier it is to use by writing/reading those files. So, maybe something like http may be a pain to implement but there are probably easier systems you could make use of anyway. Especially if that OS caught on I would've suspect someone coming up with a simple way to share data when using those files.
 

duckfan77

Popular Member
Mar 18, 2013
80
683
118
13
if that is what its called when connections don't go back to their pool, then yes a connection leak.
No idea, I was just going on memory leak, because it seems like the same thing, just with connections instead of memory.