#development

1 messages · Page 75 of 1

warm sleet
#
    public static void login(Request request, Response response) {
        StringBuilder sb = new StringBuilder();
        for (String qp : request.queryParams()) {
            sb.append("&").append(qp).append("=").append(request.queryParams(qp));
        }
        if (sb.length() > 0) {
            sb.replace(0, 1, "?");
        }
        response.redirect("/login?target=" + request.pathInfo() + "&qp=" + Base64Coder.encodeString(sb.toString()));
    }
#

login helper ^

hollow basalt
#

yeaaa, the "after" target

warm sleet
#

yeah

#

it encodes any additional parameters

#

as base64

hollow basalt
#

"You also get all the benefits of running your application on the JVM, where libraries aren’t deprecated every day."
lol, the quote on spark website

warm sleet
hollow basalt
#

i feel like we do have way too many js libraries

hollow basalt
#

oh, i see your knockturn is spark

warm sleet
#

cool eh?

hollow basalt
warm sleet
#

currently..

#
package com.knockturnmc.panel.mvc;

public enum RequestMethod {
    GET, POST
}
#

This is all it supports

#

for simple web stuff, this is good 'nuf

hollow basalt
#

yea, I like lightweight frameworks

#

and let the users do the rest

warm sleet
#

@hollow basalt I also wrote some other helper functions

#

like this:

#
    @GET
    @Path("minecraft")
    @RequiresLogin
    public ModelAndView getMinecraftServerStatus(Request request, Response response) {
        Map<String, Object> models = new HashMap<>();
        ServiceAPIClient client = session(request).getClient();
        ServerInfo info = client.getServerInfo(request.queryParams("server"));
        models.put("server", info);
        models.put("page", "Server Information");
        models.put("page_desc", info.getName());
        return new ModelAndView(models, "status/minecraft");
    }
#

if a method has @RequiresLogin

#

inside the body, you can use session(request)

#

and then you can do session(request).getClient()

#

which gives you a handle to the backend API

#

which has session tokens and such

#

I wrote this with the intention to write a minimalists' webservice

#

and I think, I can't get my controllers any more "compact" than this

hollow basalt
#

hmmm

#

with MVC, i think i don't really get the "service" thingy

warm sleet
#
        <div class="box-body">
            <dl class="dl-horizontal">
                <!-- Information -->
                <dt>Server Name</dt>
                <dd>{{ server.name}}</dd>
                <dt>Minecraft Version</dt>
                <dd>{{ server.minecraftVersion }}</dd>
                <dt>Bukkit Version</dt>
                <dd>{{ server.bukkitVersion }}</dd>
                <dt>Build ID</dt>
                <dd>{{ server.buildID }}</dd>
                <dt>Uptime</dt>
                <dd>{{formatTimeElapsed server.uptimeMinecraft }}</dd>
                <dt>Total Memory</dt>
                <dd>{{convertToMegaBytes server.maxMemoryBytes}}MB</dd>

            </dl>
hollow basalt
#

oh no

#

templating

warm sleet
#

@hollow basalt correction. lightweight templating

hollow basalt
#

still templating

warm sleet
#

those fields like server.minecraftVersion

#

@hollow basalt this is why I wrote a minimalists webservice

#

because I just needed a templating layer

hollow basalt
#

so you wrote the templating?

warm sleet
#

no

#

Check out that lib ^

hollow basalt
#

you used handlebars

warm sleet
#

Yep.

hollow basalt
#

i see isee

warm sleet
#
    /**
     * Compiles and returns a final HTML DOM.
     *
     * @return String value containing a HTML DOM.
     */
    @Override
    public String render(ModelAndView modelAndView) {
        if (modelAndView == null) {
            return null;
        }
        String viewName = modelAndView.getViewName();
        try {
            Template template = handlebars.compile(viewName);
            return template.apply(modelAndView.getModel());
        } catch (IOException e) {
            logger.debug("Failed to render object", e);
            throw new RuntimeException(e);
        }
    }
hollow basalt
#

i see, handlebars is available as java library?

warm sleet
hollow basalt
#

great

#

I need a templating engine

#

what a good time to suggest one

warm sleet
#

Thats the "glue" code I wrote

#

You need only this file

#

@hollow basalt this class expects you to use spark though.

#

it implements this interface:

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package spark;

public abstract class TemplateEngine {
    public TemplateEngine() {
    }

    public String render(Object object) {
        ModelAndView modelAndView = (ModelAndView)object;
        return this.render(modelAndView);
    }

    public ModelAndView modelAndView(Object model, String viewName) {
        return new ModelAndView(model, viewName);
    }

    public abstract String render(ModelAndView var1);
}
#

Spark has an interface to add your own template engine

hollow basalt
#

Spark has an interface to add your own template engine
I usually like libraries that are lightweight, or like simple wrapper that uses standard libraries

#

this is why I don't like nodejs ecosystem that much

#

you want a simple server?
congrats now you have a cli-coloring library

warm sleet
#

xD

#

tell that to my employer

#

I have to learn Angular

#

*ngFor="blaaah"

hollow basalt
#

yea, the ng ptsd

#

i do like react though

#

or vue

#

over angular

#

or the library you recommded

warm sleet
#

mithril

#

yeah

#

mithril gives you really fine grained control over the DOM

hollow basalt
#

yea, you wanna know where I used it?

warm sleet
#

Angular kinda already expects you to build a webpage

#

mithril gives you more freedom

hollow basalt
#

yea, different philosophies

warm sleet
#

the FormsModule in Angular is gigantic

#

It does a lot of stuff behind the scenes

nocturne galleon
#

I'm working on my authentication system, is this a good idea or has it some kind of breach that I didn't think of (probably, it does):

login -> client sends mail, password etc he wants to login with
  if login successful -> server responds with token and a successful login
  then: client encrypts the current ISO date with the token and sends date and hash back
  --> server stores hash and token, client stores date and token

re-login (page reload)-> client encrypts the stored date with the stored token and sends the hash
  --> server checks if the hash is matching
``` In theory, this should be secure unless somebody reads out the stored date and token, right?
maybe instead of the date, I could use the mail address or whatever login method is used
warm sleet
#

@nocturne galleon don't reinvent the wheel

nocturne galleon
#

so what should I use to store a login

#

ok

warm sleet
#

This takes care of handling credentials and generating tokens

hollow basalt
#

use third party auth?

warm sleet
#

Tokens can then be used to identify a person, with one or more services.

#

@hollow basalt nah

hollow basalt
#

use facebook auth

warm sleet
hollow basalt
#

i do like JWT

warm sleet
#

You request a token, to make content requests with

hollow basalt
#

try using that

warm sleet
#

OAuth2 is somewhat standardized

#

so it will work with a wide range of libraries and tools

hollow basalt
#

JWT is popular, so libraries are everywhere

warm sleet
#

@nocturne galleon the idea is that, only the auth service ever handles user credentials

#

the rest of the system uses the token, to ask the OAuth provider if it is a valid token

#

Actual services themselves, never see the user password

hollow basalt
#

never store plain password

warm sleet
#

that too

hollow basalt
#

that is just yikes

nocturne galleon
warm sleet
#

If you need to store passwords, hash them

#

use bcrypt.

warm sleet
#

bcrypt just generates a single string

#

that includes algo, salt & hash

hollow basalt
#

use md5

warm sleet
#

@hollow basalt OUT

hollow basalt
#

so rainbow table would be fun

warm sleet
#

OUT . NOW.

hollow basalt
warm sleet
nocturne galleon
nocturne galleon
#

dumb me

hollow basalt
#

rate limit?

nocturne galleon
#

makes sense

hollow basalt
#

basically, if you want such guards. do it in the server

#

there's only so much you can do in the client side

nocturne galleon
#

@warm sleet I looked more into it and the Scope stuff seems kinda unnecessary for my use, so OAuth2 would just give me an id system, basically?
Couldn't I just use "my own" ids ?

warm sleet
#

@nocturne galleon oauth can run within your own application context

#

its usually just a library you import

#

it contains an auth module, token store and token verifier

#

if you do not require such functionality, yeah. you could generate your own tokens

#

but then you have to write your own token store

#

expiration mechanism, etc

nocturne galleon
#

I won't use it for permissions like Discord bots for example, just for re-login

warm sleet
#

<user,password> generates a <token, expirationtime, renewaltoken>

#

token can be used, until it expires

#

you can use the renewaltoken to renew your token

#

token duration, you can specify yourself

#

20 minutes, 1 hour, 1 day, doesn't really matter for you right now

#

tokens have to expire, otherwise its not secure

fathom anchor
#

Has someone experience with webflow? Can you recommend it?

proper stream
#

hello

#

my pivpn isn't working...

#

idk why

#

anyone?

nocturne galleon
#

Maybe you could try giving a little more info, so others can help you? Also VPN, so you can also try in #networking

safe igloo
umbral saffron
#

Can someone help me with this? I’m trying to make an os

#

It tells me the files there but doesn’t detect it when it’s ran

#

And apparently this is wrong too

pliant siren
#

you're trying to make an os... on something that runs in user space... and are struggling filesystem issues handled by the VM?
hmmmmmm

umbral saffron
#

Well not exactly an os, I’m trying to get an idea of how it would work by making it run in a terminal

#

The User folder does exist

#

But it’s not detected when the code is ran

covert falcon
umbral saffron
#

So what do I do if I’m trying to check if the input was 1

#

@covert falcon

covert falcon
#

==

umbral saffron
#

Well I feel like an idiot

#

Tysm

#

I still have the file issue to fix

covert falcon
#

You're welcome 🙂 ... I recommend looking at an intro to python course if you're really interested. There are tons out there these days that are 100% free and really well writen

#

The directory you're trying to make a file in doesn't exist. The path it's looking at is relative to where the script is being run from. In PyCharm that is probably the same folder your code is in by default. So you need to create the User directory in there as well (or point it at another folder that does exist), then try to write the files.

umbral saffron
#

I have a User folder

#

Which is why I’m confused

covert falcon
#

It's looking inside the KazooOS folder for the User folder, because that's where the script is running from (the project root in PyCharm). You could either move the user folder inside the kazooos folder, or change the path to something like ../User/.

umbral saffron
#

So could there be a way to make python create a file for me and store text in that file?

umbral saffron
midnight wind
#

it's built into python

#

googleing is part of coding

umbral saffron
midnight wind
#

mode x will create a file

#

although mode w should create a new file if it doesn't exist

#

@umbral saffron the issue is that you are using a absoulute path

#

you want a relative path

#

to do a relative path to the python file, you do "./file"

#

if you want like this

#

I think you can do ../User/file.txt

umbral saffron
#

So I should use x?

umbral saffron
midnight wind
midnight wind
umbral saffron
#

Ah

#

So if I’m trying to create a new .txt file under the User folder and add text to it

#

I’m using w+

umbral saffron
midnight wind
#

where's the docs on that

#

ah

umbral saffron
#

If I did open(“User/example”, “w+”) that would create a new file correct?

umbral saffron
midnight wind
#

if it does, then it will create a new

#

idk exactly what + does

umbral saffron
#

That’s what I want

midnight wind
#

the + part doesn't create a new file

umbral saffron
#

What I found was doing w+ creates the file

midnight wind
#

w does

#
  • means "open for updating (reading and writing)"
#

idk what that means tho

umbral saffron
#

Well when I just did w, it said there’s no file or directory

#

So I assumed that meant it was trying to open an already existing file

midnight wind
#

ok

#

just do this ../User/file.txt

#

with w

umbral saffron
#

Ok thanks

#

Still the same error

#

Can’t find the directory

#

It exists though

midnight wind
#

let me try

#

@umbral saffron works fine for me

#

literally just a = open('../User/test.txt', 'w')

#

file structure is just

#

it created test.txt

umbral saffron
#

well then if I do that I can't do py as f: to add to the file

midnight wind
#

that's just a different syntax, with async

#

just to double check I will do it with async syntax

#

@umbral saffron works just fine

#

something on your end is really messed up

#
    print(test)
umbral saffron
#

Oh that makes sense

#

Pythons weird on my end a lot

#

I could never get speech recognition to work either

midnight wind
#

just use vscode

#

don't need some ide

#

and learn cli

#

it's as simple as python3 ./test.py for me

#

idk how it's on macos

#

but python is python 2.x
and python3 is python 3.x
on ubuntu

umbral saffron
#

Ok thanks

pliant siren
#

Has anyone here done any dev work for AWS DeepRacer? Work just sent out an invite for us to participate in it next month, thinking about giving it a go.

nocturne galleon
marsh comet
#

It saves a lot of time too

midnight wind
#

so for beginners it's beneficial to try without one

marsh comet
#

Yeah, it hides whats going on behind the scenes

#

But once you get a good grasp of how it works, its usually worth it to use one

midnight wind
#

yeah

nocturne galleon
#

so, im making a js discord bot, all the commands work besides the mute command, help

#
    name: 'mute',
    description: "mutes lmao",
    execute(message, args){
        const target = message.mentions.users.first();
        if(target){
            let mainRole = message.guild.roles.cache.find(role => role.name === 'Community');
            let muteRole = message.guild.roles.cache.find(role => role.name === 'muted');

            let memberTarget = message.guild.members.chache.get(taget.id);

            memberTarget.roles.remove(mainRole.id);
            memberTarget.roles.add(muteRole.id);
            message.channel.send('<@${memberTarget.user.id}> has been muted');
         } else{
            message.channel.send('Cant find that member');


        }
    }
}```
nocturne galleon
#

forgot how to codeblock

midnight wind
#

on each end

nocturne galleon
#

there u go

midnight wind
#

did you import it

nocturne galleon
#

ping me with answers or questions pls

#

import it to where?

midnight wind
#

you did module.exports

#

that exports the object

#

you need to import it somewhere else

#

for discord.js to actually see it

nocturne galleon
#

gtg

#

later

nocturne galleon
#

like i do the command and nothing

#

btw im hosting this bot on my pc

midnight wind
#

because you need to import this object somewhere

nocturne galleon
midnight wind
#

oof

#

VS for js

#

ohh your doing it like that

#

use the debugger or console.log the value of client.commands

nocturne galleon
#

yea watched a vid on yt

nocturne galleon
midnight wind
#

VSCode is better for this stuff

#

but just in line 24 you can add

#

console.log(client.commands)

#

this will log the contents of client.commands

#

to the terminal

nocturne galleon
#

Pls mark where that should be

midnight wind
#

in main.js

nocturne galleon
#

Ok

#

Ill be gone for a couple hours but thx for ur help

nocturne galleon
#

lmao

nocturne galleon
#

well it was a bad tutorial then

#

xp

#

can you help me troubleshoot tho

#

when i do a command it does nothing

#

and in console it also sayss nothing

midnight wind
#

add a console.log

nocturne galleon
#

yes

midnight wind
#

and post the output

nocturne galleon
#

on line 24

#

everything works but mute

#

@midnight wind

midnight wind
#

huh

#

oh

#

lol

#

on line 35

#

in main.js

nocturne galleon
#

did i fuck up?

midnight wind
#

you need to but put client.commands.get('mute').execute(message, args)

nocturne galleon
#

SHIT

#

thanks

#

imma test it brb

#

@midnight wind since its in its own server rn it dosent do anything

midnight wind
#

yeah, I'm making a bot too rn

nocturne galleon
#

ooh nice

#

u have a test server?

midnight wind
nocturne galleon
#

ok

#

nice

#

can you join my test server so i can see if itl mute

midnight wind
#

sure

nocturne galleon
#

since i can tmute myself

winter spindle
#

Is anyone here able to help me with an assignment involving jQuery and PHP? I have php written and I need to submit and get data using jQuery.

rotund harness
mystic birch
#

guys can u guys give some ideas for some beginner projects with python

spring pond
#

make a simple discord bot

#

good way to learn async stuff

mystic birch
#

thx

lethal shoal
nocturne galleon
#

nah

nocturne galleon
#

never thought about it as a project

warm sleet
#

@midnight wind I just deleted visual studio code from my machine

#

Each update is ~80MB, and it gets like 3 updates/week

#

and microsoft's repository is so slow, it downloads @ 250KB/s

#

running apt upgrade takes like 5 minutes, because of visual studio code

#

garbage microsoft repositories

nocturne galleon
#

So what do you use now?

warm sleet
#
Get:3 http://packages.microsoft.com/repos/code stable/main amd64 code amd64 1.56.2-1620838498 [76.4 MB]
64% [3 code 3,553 kB/76.4 MB 5%]                                                     117 kB/s 10min 24s

#

10 minutes lol

#

@nocturne galleon just IDEA

nocturne galleon
#

Ah alr

warm sleet
#

@nocturne galleon this is what I hate about microsoft apps

#

you get 1 package

#

and its app + libraries + bunch of media

#

and if it gets updated

#

instead of updating just the binary (couple MB)
it updates the entire package and redownloads everything

#

static linking and electronjs, curse you both.

hallow pilot
#

Is that unique to the .deb distribution? VS Code self-updates pretty quickly on my Mac.

warm sleet
#

Its just that Microsoft's servers are slow af

rotund harness
#

I have used VS code for years now, never an issue with update speeds or updates in general :/

warm sleet
#

@rotund harness downloading it through their regular debian repositories yields ~120KB/s download

#

and its kinda annoying, considering it is updated like 3x per week

#

and each time, slowing down package installation

#

cus its like 80MB

rotund harness
#

Yeah I could see how that sucks, I use a mac so don't have that issue :/

warm sleet
#

@rotund harness imagine doing a brew update, and that taking 15 minutes xD

#

on a 250M link xD

rotund harness
#

Sucks though - I love VS code, I wish everyone enjoyed its awesomeness 😛

warm sleet
#

@rotund harness I tried using it..

#

Just recently, for Angular development

#

But I ran into issues, where IntelliSense isn't always able to fully auto-complete

rotund harness
#

Yeah we talked about it in DMs 😛

warm sleet
#

ahhh

#

yes

#

that was you

rotund harness
#

ITS ALWAYS ME

warm sleet
#

xD

#

week 2 at new job

rotund harness
#

I am everywhere, and no where, all at once, and never

warm sleet
#

I got so many things done already :D

#

Moved them over to gitea

#

and also set up jenkins

#

and today, I managed to do my first automatic deploy

rotund harness
#

Yeah I have been moving my company over to react from Razor - slow going but fun projects

warm sleet
#

Pretty cool that new Declarative Pipeline

#

You can just provide a Jenkinsfile along your project

#

and Jenkins just scans all projects and all branches

#

and if you push code, it picks up that Jenkinsfile and runs it

#

@rotund harness and then i ran into something with my co-worker

#

really silly, and I wasn't sure how to respond

#

but is there any reason not to use localStorage for things like storing auth tokens?

#

especially in SPAs ?

#

if you refresh the page, your token is gone

#

and they just say to me: thats what an SPA does

rotund harness
#

So the problem with storing them in localstorage is that you open yourself up to XSS attacks. Javascript can access localstorage, so putting them there isn't that secure.

#

I will send you an article with information about it one second let me find it.

#

Just losing authentication when you refresh the page... is not "just what an SPA does" if that was the case, you would never be able to refresh pages without having to sign back in lol - sounds like someone didn't want to find a real solution.

hollow basalt
#

ehhh

#

that architecture

warm sleet
#

@rotund harness so what do you suggest, you keep the token in memory, and store the token serverside, attached to cookie?

rotund harness
#

It really depends, there is no "100% secure meets every potential case" solution. There are risks with any solution and downsides to some (such as way over complicated)

#

You "can" just store it in local storage, and eat the XSS risk, depending on your architecture and how your app is designed, it may not be a realistic risk

#

If you do go the cookie route, just make sure to account for CSRF as thats pretty easily to exploit

hollow basalt
#

any alternatives than simply adding more components

warm sleet
#

@rotund harness they already have a broken setup

#

with a bunch of CORS headers forcibly added in their backend

#

and currently tokens not even renewed after 15 mins

#

to annoyance of many

rotund harness
#

Haha - then yeah based on how much you care and how much you are impacted by potential XSS, local storage can be fine

warm sleet
#

@rotund harness I am hoping to get most of the CORS stuff out the door soon

#

I've set up a development pipeline, and set up proxy servers for the frontend and backend bit

#

why they didnt have this, I really don't understand

#

but I guess they should be glad I am there to help them out

severe viper
#

Hi. I'm looking for someone here studying c++ I'm definitely new to the language as I can only make very basic stuff ATM but am exited and very determined to learn and do so much more down the road I want someone to pass notes with basically is what I'm saying

nocturne galleon
warm sleet
#

@severe viper broaden your horizon, as a newcomer there might be better alternatives for you to learn

#

Rust is very promising

honest sleet
#

I updated my Random Audio Stream Player Add-on for Godot Engine, the add-on for Randomized SFX and Audio. I use it in all my games, it's open-source, MIT Licensed and I just made a video about it 😊 https://youtu.be/yyVT8TT7sMw (peertube alternative: https://tilvids.com/videos/watch/6a2759cc-cafb-4aaa-8014-ad584949066c)

This add-on lets you select multiple samples that are then cleverly pseudo-randomly played to feel organic.
In this video I explain how you can use it and what changed since last time.
After some digging I was able to improve my opensource random audio stream player add-on, and it's UI, for instance by making it so that you can select a folder i...

▶ Play video
warm sleet
#

@honest sleet you should upload this to some app store, under the category "Productivity"

warm sleet
#

@honest sleet ohnvm

#

I saw the thumbnail and thought it was a soundboard 🤣

marsh comet
#

would this be a good place to ask about virtual machines

nocturne galleon
fallen hatch
#

what advice would you give to a 15 y/o that wants to start programming and doesnt know which language to start with?

versed dust
#

Python is always where everyone starts

nocturne galleon
versed dust
#

What is that, I don't know

nocturne galleon
nocturne galleon
hollow basalt
#

Learn c++, no other way.

nocturne galleon
#

C++ is a very big language!

ivory bear
#

learn slowly from the base, you don't need to know all of C++ at once for starter

#

my first programming course when I went to uni was also C++

simple patrol
#

i'm nub can i get some help with java here lol

#

i'm trying to repeat an integer 10000 times, however i don't want to print that out

#

Anything i see online for repeating integers it just has a Print line statement and it physically displays it on the program

old dragon
#

wdym?

#

@simple patrol

late plank
#

I was thinking of using tensorflow and yolo for object detection. Any suggestions/comments?

#

I eventually want to run it on preferably some raspberry pi

pliant siren
#

you want to run tensorflow on a rpi? o_O

gaunt finch
#

that's pretty neat

late plank
bold hornet
#

i learned python first since thats what my uni teaches first, starting my c++ course this fall and i decided to start learning the language early

#

needless to say, learn c++ first

pliant siren
#

I see python as the modern VB equivalent. Holy crap it's horrible.

... and that's coming from someone who's first languages were Delphi and Clipper in the mid 90s.

bold hornet
#

python is easier in some ways, but i found that it oversimplifies a lot of programming concepts

#

i need to do a deep dive into a lot of the older languages that have been mostly phased out, its very interesting

pliant siren
#

Gotta be honest, literally the only reason I predominantly use Java (over C) is that Java has incredible testing tools available, great native integration with good IDEs (C has the latter, but not the test tools), and fantastic repository support of community libraries.

midnight wind
#

c++ is bloated

pliant siren
#

I've started using javascript/node a lot over the past few years more and holy crap there are language features that have just been made so complicated - async and promises mostly.

midnight wind
#

I primarly rn write in js

pliant siren
#

C++ is great if you're using .net, but if you're one those STL purists then bugger off and let's go back to using straight C.

midnight wind
#

async, promises, all that jazz

pliant siren
#

lambda expressions are the other thing that just makes me go why!?? This does not make code more readable!

midnight wind
#

what even are those

#

I never understood it

#

never really needed it

pliant siren
#

That's the thing - everything you can do with a lambda you can do with the previous way we wrote functional code.

bold hornet
#

i dabbled in lambda's while learning python but i didnt really pursue them

#

i plan on learning java at some point in university before i graduate, probably on my own time

pliant siren
#

Java is not without it's problems, and I wish it had C#/.net's threading model.

#

Java provides you no mechanism of knowing whether a thread was polled or timed out, you have to guess. But that's about the only fault I can find in it.

bold hornet
#

lol

#

that sounds fun

pliant siren
#

yeah, it make semaphores uhh... a little problematic.

#

That one in a million chance that actually no, we weren't complete and need to double-check.

hallow pilot
pliant siren
#

what's wrong with writing that in a traditional method - or even just passing an inline function where used in a language that supports it?

warm sleet
#

There's a big argument against lambdas in some languages

#

in Java for example, if you have a complicated pipeline, and you are using lambdas to run methods over a dataset with thousands of records

#

it might be faster writing a regular for loop, as those are better optimized

#

But doing filter and sort operations with streaming pipelines, is generally not a bad practice

#

Just know, that it produces slightly more memory pressure because it creates lot of short-lived objects

hallow pilot
midnight wind
#

ahh

#

I use that a little bit

#

never knew it was called that

warm sleet
#

@pliant siren use a thread pool

#

dont start the threads yourself

#

Gives you far greater control over how and what the system is doing, you can use multiple pools, depending on the specific application

#

You can then use atomic references with the synchronized keyword, or use locks to implement some sort of static state

#

its bit more tricky, works best if you can completely remove the state from your threads

#

and just pass them as parameters

#

be it a value or some kind of socket server doing whatever

#

@hallow pilot pretty sure that C# specifically has two kinds of constructs. There are expressions which are compiled runtime, and functions, which use anonymous classes

#

Java doesn't have this, it has pure interface references through a proxy object that gets woven into the bytecode during compilation

#

so you'll see inner classes with (class) com.bar.Foo$Lambda12321#$() that contains a $ function

#

C#'s approach is much faster, because it is directly handled by the virtual machine

#

in java its basically done during compilation, which yields a larger binary and more cycles

brisk crypt
#

Anyone who knows some php who is willing to help get some little errors out of a small piece of code?

warm sleet
#

I can

brisk crypt
#

<?php
$conn=new mysqli("hostname","username","password","database");
$query=$conn->query("select * from klant;")
$result=$query->fetch_all();
foreach ($result as $value) {
?>

#

This is the code I received

warm sleet
#

okay

#

so the <?php declares the beginning of the document

brisk crypt
#

The second one makes the connection with the db

warm sleet
#

then it declares a variable and assigns a new mysql connection

#

yeah

#

so you got that far?

brisk crypt
#

Yeah

warm sleet
#

did that work

#

ok

#

so next

#

you create a query by running the query() function

#

and then you fetch the result of that query

#

as a rowset

#

and then you basically create a loop

#

and it loops over each record in the result

#

and you can then access these values by doing

#

$value["ColumnName"]

brisk crypt
#

Like this: "echo $value[0]"

warm sleet
#

no, you should use column names

#

I would advise against using SELECT *

#

instead do

#

klant.naam

#

or naam if you are only referencing one table

#

you can join tables together, and then you may have two columns with the same name, so you put the table prefix in front of it

#

SELECT klantid, naam, adres, email FROM klant WHERE klantid = ?;

#

if you leave the WHERE out, then it doesn't filter

#

You also, should never concatenate the sql string together

#

always use prepared statements

brisk crypt
#

The SELECT * is just because it's an example database with only 1 items in: naam and id

warm sleet
#

yeah

#

but for readability

#

just use the names

brisk crypt
#

ah fair enough

warm sleet
#

if say, in the future, you add more columns to your tables

#

then all of this gets messed up

brisk crypt
#

When I run the whole script trough a php codechecker I get an error on line 17

#

saying: "'$result' (T_VARIABLE) in your code on line 17
$result=$query->fetch_all();"

warm sleet
#

oh yeah you need to provide a mode

#

put this in: MYSQLI_ASSOC

brisk crypt
#

after the fetch all right?

warm sleet
#

no that's a parameter of fetch_all

#

it goes inbetween the ()

brisk crypt
#

yeah inbetween the () after the fetch_all

warm sleet
#

functionname(parameter1, parameter2) etc

#

but that's some constant

#

idk, php is garbage in my opinion

#

I've used for a while and i hate it

#

Only to maintain existing programs and fix bugs

#

but new software I wouldn't write in it

#

much better tools exist these days

brisk crypt
#

Hmm, even when I placed the MYSQLI_ASSOC I still get the error

#

ah forgot a ;

next igloo
#

I need some help with Javascript

#

Currently, my program calculates all the render passes, but will only display the final pass

#
let canvas = document.getElementById("canvas");
  var ctx = canvas.getContext("2d");
  let imageData = new ImageData(canvas.width, canvas.height);

  for (var pass = 32; pass >= 1; pass = pass / 2) {
    ctx.putImageData(imageData, 0, 0);

    //render
   
}``` Here is the simplified version of the code
#

and this is what I want to achieve, but the code currently only shows Pass 6

old dragon
hallow pilot
#

can you put a full runnable version on a fiddle?

next igloo
#

me?

marsh comet
#

I believe so

hallow pilot
#

Yes, the Mandelbrot thing. I can't tell from the little code sample what it's doing and what it's supposed to do.

next igloo
#

I use Var at the top, using Let breaks some of the code

hallow pilot
#

Okay, so you'd like to animate slowly getting sharper

next igloo
#

basically

#

rendering the lower resolution passes first so you can see what you are looking at

hallow pilot
#

I think you need some kind of sleep in there, to get off the main thread and let the browser draw. Then ~200ms later or whatever you start the next pass

next igloo
#

k i will try that

hallow pilot
#

lmk if that makes sense

next igloo
#

thanks, that is exactly what i needed

honest sleet
#

After making a room generation algorithm (that I'll talk about in a video on my youtube channel https://www.youtube.com/c/TimKrief/ at the end of the month), I now generate 3D elements, walls flooring, doors etc. on the go to create this endless virtual gallery... Only thing missing now is the artworks! This is a refactoring of an old project https://twitter.com/TimKrief/status/1203507386323030018 and I'm so glad that I'm on my way to get it done. I'm also working on a 2D top down endless runner game that is going to use this basis.

warm sleet
#

Pretty cool concept ^

royal agate
#

Hey guys i have a question about c++, i currently store instances of classes in a vector like this Entity *ca= new class player(x,y) playerlist.push_back(ca); x and y are random values, how do i check whether there is already a player at the given xy values so i dont have two players in the same place? or how do i scan the vector for certain xy values? Im new to c++ so i'd be thankful for help.

hallow pilot
#

are those integers?

#

A few thoughts:

  • there are certainly ways you could scan through that list and find pairs of players that are too close to each other
  • with the right data structure you could find them more efficiently
  • also maybe consider not letting it happen in the first place. (e.g. do a check when updating positions, and reject updates that move a player too close to another) (instead of checking all the players against each other once per tick or whenever)
royal agate
#

Yeah im storing everything in classes with x,y integers. Im actually trying to prohibit a movement that goes to the same x,y value but i cant find the syntax to get those x,y values from a class without just printing the whole vector out

solemn zinc
#

Both generate images using AI

woeful kelp
woeful kelp
woeful kelp
#

I’m actually starting my fourth year in my software development degree and I also tutor for my CS department so yeah, just DM me and I’d be happy to help out

pliant siren
#

@woeful kelp Do they teach AVL trees in your current curriculum?
Had a need for one backed by an array a few weeks ago and found there were surprisingly little literature out there about them, or example implementations, and it just seemed like they were black magic to the people who wrote posts on them - which led me to believe they're no longer something they actually teach in degrees.

woeful kelp
#

Yes they do

#

They should in all data structure curricula

woeful kelp
pliant siren
#

array based are pretty advanced, I might expect a course to touch on array-based b-trees but the concept is the same.

woeful kelp
#

Hmm. I haven't personally gone through many b-trees but an array based implementation doesn't seem too hard if it's based on something like a heap

pliant siren
#

it's just a lot of swapping entries.

#

well, that and shifting.

woeful kelp
#

Yeah, that's the trade off I can see, but doing it by nodes and edges would probably be more efficient

#

Since you don't have to work with dynamic arrays

pliant siren
#

yeah - just that you need much much more memory when you give the nodes address references.

woeful kelp
#

Because all an AVL tree is, is an optimized binary tree so that each branch is of equal height

#

Not neccessaryily

#

I mean sure you have random access but in terms of adding and removing you suffer a Big-O of nlog(n) since you have to copy all of the old values into a new array

#

And you can store every node in a completely different part of memory, whereas in arrays, they need to be in consecutive addresses

#

And from what I'm reading, storing it in an array would require you to have a spot for every element even if it's empty. So your space complexity would turn out to be 2^h elements where h is the max height of the tree

honest sleet
pliant siren
woeful kelp
#

Sure, but you still need spaces in the array for null elements

pliant siren
#

those are just the values you haven't added yet.

woeful kelp
#

Yes but they need locations in the array

pliant siren
#

oh I think I know what you're getting at, where you have a dataset of indeterminate size.

#

yeah, in my use-case I had a known number of elements.

woeful kelp
#

Yeah, in that case it wouldn't be as bad

pliant siren
#

basically I was (am) using this for crypto, where you hash 0-2^k where k = 32+ - so you have an avltree of size 2^32 entries.

#

instead of storing the output hash (76 bytes), you store n

#

so you have an array of about 16GiB.

woeful kelp
#

Are you sure that's right?

pliant siren
#

yes.

woeful kelp
#

because 2^32 is 4294967296

#

Oh wait

pliant siren
#

yeah. 4G values at 4 bytes each.

woeful kelp
#

Never mind that

pliant siren
#

if you go to k33, k34 then you start getting biggers and you have to use a really complicated packed array to save size, you dont want to use a whole byte just for that one extra bit. OR, do it in two trees using the most significant bit.

woeful kelp
#

Right

pliant siren
#

so you can steal some performance improvements by dividing the data set so you end up with say... 2^16 AVL trees of size 2^16 instead of one a AVL tree of 2^32.

woeful kelp
#

Right

#

I will say I'm not a cryptography major so I wouldn't really know too much about that but it does make sense if you know you're going to have a dense tree

pliant siren
#

don't need to know anything about crypto for this, it's all just data structures.

#

but yeah, it's not a data structure you come across commonly so trying to find an implementation of it the other week was like "... where are they all?" and then "but they all use objects and there's no array backed implementations", so I ended up with "screw this, I'll do it myself" 😄

woeful kelp
#

Right

#

And that's honestly the best way to do it

#

When you can't find a standard implementation just make it yourself

pliant siren
#

Yeah, and I guess that's where this conversation began - it just looked like "do they even teach this stuff anymore?" because of all the posts I was finding where people just... didn't get it.

#

But yes, to be fair it's not exactly a data structure people are going to use very often - which explains why there aren't implementations everywhere.

woeful kelp
#

Right. But the thing to remember is that there's a difference between the data structure and it's implementation. Because the data structure is the basic algorithms and properties of an object, whereas the implementation is more developer specific

#

So they teach the data structure for sure, but not really that implementation

pliant siren
#

some of the assignments/projects we had back when I was in uni were competitive type ones where either your grade was based on performance across the whole class, or they were competitive programs (eg, they had to play against each other). Short version: There are about 4 people I did my course with who I could recommend hiring.

woeful kelp
#

Interesting

#

I'm not sure how I feel about that style of grading

pliant siren
#

okay, meeting time 😦

woeful kelp
#

GL!

pliant siren
#

holy crap, we got a stand-up done in 10 minutes.

#

The support team lead in my team doesn't get that stand-ups are not for two-way conversation so they always drag way out.

woeful kelp
#

Dang

#

Although that's the reason why you have them standing up lol

pliant siren
#

Yeah the problem is what's happened is that now we have some people on zoom, or have some of us in a meeting room with others calling in, so the stand-up becomes a sit-down, ugh 😦

woeful kelp
#

Yeah, that's rough

honest sleet
#

That's it the drone is ready! I'll have a complete showcase video out tomorrow on my channel 😉 But here's a little preview in the meantime! It's really close to what controlling a real drone feels like!

#

I had a hard time with the stabilization part but it ended up working ! I had to actually simulate the 4 propellers

midnight wind
#

just click the py file?

#

what do you want to do

#

use batch

#

window's native scripting system

#

you click it

#

it runs

#

what does it do

#

just deletes file?

#

older than a certain time

#

oh

spring pond
#

if you want to turn it into a "native" executable you could make the batch script run the python command

hallow pilot
#

surely a modern python interpreter on windows can be made to execute files on double-click

honest sleet
#

So as I said earlier I made a brand new drone that is directly controlled from the main character's smartphone! This time around the drone is realistic and close to usual drone designs. Even the physics are close to the real thing. Plus, I made a new environment to showcase it 🙂 https://youtu.be/3_rGzksrMsI

The IndieGame that I'm working on, Octahedrone, now has a new feature, a realistic virtual drone! This new drone is way closer to what we usually know, and the funny part is that it's controlled directly from the main character's smartphone. Just by pressing a button you access the smartphone and seamlessly you can start using the drone. Next st...

▶ Play video
craggy acorn
#

is there a good place to learn c++? i found learncpp.com after a few minutes of searching but i wanted to know if theres a better place. im willing to pay for a course

hallow pilot
#

looking mainly online? if you're serious about it, I'd look at any nearby colleges or universities

#
wild delta
#

Yo what programming languages are used for what?

midnight wind
wild delta
#

.___.

#

wut

midnight wind
#

That's a very general answer with everyone having their own options

#

Its more of categories

#

C/cpp/rust are good for compiled things and embedded programming

#

Js is used on web frontend and can be used for backend through node or deno

#

You have c# which idk much about

#

Java

gusty pawn
#

you can use java to make an algorithm to solve a problem

#

or calculate smt

hollow basalt
#

algorithms are language agnostic

midnight wind
gusty pawn
#

i was going to send an example in java but i can't find it

#

🥲

midnight wind
#

Java is apparently good for large programs

gusty pawn
#

here it is

midnight wind
#

Because it's heavily oop

gusty pawn
#

the outputs are in italian but i think you can look over it

hollow basalt
#

i dunno what that code proves

gusty pawn
#

it's a game

hollow basalt
hollow basalt
gusty pawn
#

sorry, i can't remember how those 6 faces things that are use for gamblings called

#

you know what i'm talking about

midnight wind
#

Dice?

gusty pawn
#

yes

hollow basalt
#

yea, but you can create that game in whatever language

gusty pawn
#

i made it for my final exam to show an example of structured programming

midnight wind
#

But anyways there are also some niche languages that are good for a specific purpose

#

Like I heard of erlang

gusty pawn
#

never heared before

#

what is it for?

midnight wind
#

Its meant for ha, scalable, real time systems

#

I think the way it works is that is encourages crashing instead of error handling?

#

Idk

hollow basalt
#

erlang philosophy is unlike any other

midnight wind
#

No

hollow basalt
#

java: please handle this exception
erlang: shut up and try to reboot

midnight wind
#

I think it's elixir I'm thinking of

#

Oh

hollow basalt
#

isn't that called "subset" or something

midnight wind
#

Oh, wait elixir is built on erlang

#

Yeah I'm not familiar with this stuff

#
X-Plane Developer

[This post is a “behind the scenes” look at the tech that makes up the X-Plane massive multiplayer (MMO) server. It’s only going to be of interest to programming nerds—there are no takeaways here for plugin devs or sim pilots.] [Update: If you’re interested in hearing more, I was on the ThinkingElixir podcast talking about […]

still pulsar
#

Ayo I have a question, what's the difference between double and float

wise raft
#

Precision. The former uses twice the memory of the latter to express values.

pliant siren
#

double is typically 64-bit, with float being 32... though some systems don't adhere to this.

thick heron
warm sleet
#

@midnight wind I like that slide

#

It has just the right amount of erlangesque arrogance

#

@still pulsar a double is a 'double-precision' float. Its a 64 bit float (instead of 32)

midnight agate
#

Anyone know how to create custom property fields for files with a custom file type? ie I have a file that ends in .foo, and I want to add a property called category.

#

I'm assuming something has to be done in the registry. I would also like to be able to transfer the files to another os, mac or windows, and retain the values.

warm sleet
#

@midnight agate filetypes are an illusion

#

the file extension is just part of the name

#

a word document like .docx is actually just a zip file with some xml inside

midnight wind
#

to see what's inside a binary

#

binwalk is cool

warm sleet
#

with a hex editor you can usually tell what kind of file it is

#

but extension is irrelevant

midnight wind
#

yeah

warm sleet
#

thats just for the end user

midnight wind
#

and the os

warm sleet
#

so when you double click it, the right program is used to open it

midnight wind
#

yeah

warm sleet
#

@midnight wind even java jar files and war files are just zip compression xD

midnight agate
warm sleet
#

@midnight agate those are metadata tags, id3

#

those are stored inside the file itself

#

but those mostly applies to home use

nocturne galleon
#

Hi do someone know how to "mount" ext4 drive in android?

rancid nimbus
#

I have two ideas. Idea 1 you make yourself some app that can read the file system. Idea 2 you recompile the kernel for your phone with support, and set up your phone to boot using it. Idea 3 you do not mount ext4.

nocturne galleon
#

idea 4, use another FIle system that can be read by android

nocturne galleon
#

It's little ironic, the os saved on ext4

nocturne galleon
warm sleet
#

You need FUSE for this

#

@nocturne galleon android is linux, it can read those filesystems. Problem is you need root

nocturne galleon
#

Ah, alr

warm sleet
#

FUSE is the end-all solution to this sort of stuff

#

allows a non-privileged user to mount a filesystem

dusty isle
#

I have a very common problem that could probably be answered very easy, Ive been working on game cheats using the game “pwnadventures3”, I’ve been doing this for 2 months & I’ve burned myself out. currently Im looking for a side project - does anyone have any good places to look for project ideas I’m not very imaginative & have only tried Twitter 🙂

spring pond
#

look for little things in your daily routine that could be streamlined using a program

cold bear
#

is anyone experienced w python?

midnight wind
#

just ask

cold bear
#

what would i put for an if else statement to have the process move on to the next line

midnight wind
#

it will continue once it finishes running anything in the if, else

cold bear
#

so I have it set up like:

if any(....):
time.sleep(5)
continue

else:

-------------- (end block, need it to move to next)

#

" File "<ipython-input-237-fa258d6802df>", line 24
else:
^
SyntaxError: unexpected EOF while parsing"

midnight wind
#

you need to put something in the else

#

or get rid of the else

#

you can't have an empty statement in python

cold bear
#

what would I put in the else: to have it move on and not just repeat the if part

#

thats what i'm asking

midnight wind
#

I'm confused on what you are trying to do

cold bear
#

I am setting up an if else script to repeat the beginning for the if, and continue to the later parts for the else

midnight wind
cold bear
#

wd = wd.Chrome()
wd.implicitly_wait(10)

wd.get("https://activismimpacts.world")

import time
import requests

while True:
url = "https://activismimpacts.world"

homepage = requests.get("https://activismimpacts.world").text.lower()


   websiteerrorstrings = ['error']

# Check whether the strings are in the text of the webpage
if any(x in homepage for x in websiterrorstrings):
    time.sleep(5)
    continue
    
else:  (dont know what to put here)

......... as far as i've gotten

#

oh i have it backwards i think

#

but still

midnight wind
#

so the else part will only run if you don't have a object in homepage

warm sleet
#

I'm dying at work

midnight wind
#

so only when there is a error

cold bear
#

right

warm sleet
#

A co-worker spent 5 hours today merging 5 files (~200 lines each)

#

I went on screenshare with them, to have a look at why it was taking so long

#

idk how to explain how rediculous it was

midnight wind
warm sleet
#

they used a word document in landscape layout... with a 2 column table, with the source code copy pasted inside

midnight wind
#

?

#

oh

warm sleet
#

Like

#

if you do this

#

use notepad

#

but of all the programs

#

word

#

idk how to respond..

severe viper
#

oh fuck i got an idea for the server

#

imagine having a shitty IDE theme channel xD

warm sleet
#

so people can share their IDE's with anime backgrounds?

hollow basalt
#

i must find one

warm sleet
#

F

hollow basalt
worthy dirge
hollow basalt
#

yea that looks good, but I would think the people at my work wouldn't be too amused to see anime when i present the code

midnight wind
#

idk a bout brightness, any software brightness would be artifical anyway.

#

iirc no

#

although there is a blue light thing I use

#

that automatically adjusts

#

yep

#

I mean, there is probably a way

#

depends on the screen

#

if it's something external

#

or like on a laptop

hallow pilot
slender sand
#

I was hoping someone here could help me with my small coding-problem:

I have really simple python code:

import matplotlib.pyplot as plt

x = [1, 2, 3, 4]
y = [2, 4, 6, 8]

print("Hello, World!")

plt.plot(x, y)
plt.show()

When i run the code via my normal terminal the plot shows up as expected, but when i run it via VSCode (no matter what option i pick) it doesn't show my plots (the rest of the code works as expected).

I'm using anaconda which i guess is what's causing my problem here. The import seems to work correctly as i don't get anny errors, "Hello, World" is the only output i get.

I'm on a fresh install of the latest non-lts ubuntu version.
Plots also don't show up if i run the program via a zsh shell within vscode

I already posted this in the wrong channel, sorry for that.

slender sand
#

Fixed it with the help from a buddy.
We noticed that the code works in vscode if we enter

export DISPLAY=:0

In the shell in vscode.

Enabling Terminal -> Integrated: Inherit Env solved the problem for me.

(I always start vscode from the commandline)

warm sleet
#

@slender sand that's an environment variable that is normally set by your DE when you login

slender sand
#

Yes, but as inherit env was disabled it did not set the env variable.

warm sleet
#

inheriting it, should fix it yes :)

#

normally those things are inherited automatically

#

since they are spawned as subprocesses of the parent environment

slender sand
#

Yea, vscode gave me a warning that i should disable that when i first opened it as it may give me trouble bc of anaconda.

#

I reenabled it and now it works

warm sleet
#

nice

#

@slender sand often these things can be resolved by just doing source /etc/environment

#

that's where the system's environment variables are set

slender sand
#

Yea i know that, but i don't want to do this every time i startup vscode

warm sleet
#

the user context is then loaded from either /etc/profile or ~/.bashrc

slender sand
#

In my case .zshrc 😄

warm sleet
#

yep same here ^^

slender sand
#

This shell looks just way to nice xD

warm sleet
#

ubuntu? :P

slender sand
#

I love the option that you could in theory even add emojis 😄

warm sleet
#

all da purple

slender sand
#

Yea, i pref ubuntu bc it's the easiest distro for the ml-stuff i do

#

OpenAI works just out of the box lol

warm sleet
#
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:    20.04
Codename:    focal
#

^ my laptop

#

Except I got rid of all the ubuntu-esque crap

#

ubuntu dock, all the purple stuff is gone too

slender sand
#

I use manjaro on my crappy laptop, i do the main work on the pc 😄

warm sleet
#

its all grey for me

slender sand
#

Send a screenshot lol

#

That does arguably look better

warm sleet
#

only crappy thing is the title bar of the windows

#

they are too big

#

have yet to figure out how to make it smaller

#

@slender sand my favorite GNOME extension ^

slender sand
#

I know this one from manjaro, really neat 😄

warm sleet
#

toggle for a terminal that drops down

#

with opacity, if you are reading off a webpage and it covers the bit you are trying to read

#

can still see it somewhat

slender sand
#

I have a very very big monitor, i never have anything on full screen xD

warm sleet
#

Yeah 1080 xD

slender sand
#

4k 32 inch

warm sleet
#

yeah 15" laptop lol

slender sand
#

Bigger than my tv

warm sleet
#

images contain doxxable infos, so rip

slender sand
#

really nice for writing code 😄

slender sand
warm sleet
#

company name :P

#

@slender sand da other machine ^ in my attic

#

That machine mostly hosts virtual machines for me

#

@slender sand Cheap $900 machine, but... it has got the goods where it counts

#

16GB ECC memory, and 10G networking xD

slender sand
#

I'm very happy with my pc as well, i'd just like a better gpu but i won't pay like 3x the price

warm sleet
#

Hah. I had that with my GTX570

#

I bought a 980Ti off a friend for 90 bucks

slender sand
#

I'm on a 1050TI

#

With a 3800X

warm sleet
#

@slender sand beast of a chip. Yeah I bought the 2600 as a server chip

#

and I Was so impressed with it, that I bought a 3600 for my desktop

#

$150 for a 6-core chip that decimates all that came before? yes please

#

my old i7 2700k was fast, very fast, but even that one started struggling with the GTX980

slender sand
#

I hate waiting for compiling while coding. This chip just cuts down waiting time by a lot (compared to the shitty i5 i used to have)

#

I sadly don't remember the exact model

warm sleet
#

I was working on a duo-core laptop for the longest time

#

I heavily relied on features of the java VM, like hot-compile

#

to make development expedient

#

reload code while the program is running

slender sand
#

Never knew that was a thing

warm sleet
#

It is :D

#

And if you have proper structure in your software, it works well too

#

Any new instances of a class, get created with the new code

#

old instances, stay alive

#

you cannot rename existing fields/methods, only modify or add new members

slender sand
#

I'm currently working together w a friend and she is still using a very old macbook. I can run all unittests within ~1-2 seconds and for her it takes like up to a minute.

Which is kinda bad for my coding style as i tend to sometimes just brute-force until i figure it out

warm sleet
#

-DskipTests=true

#

ez

slender sand
#

Y but if i wanna know if my tests pass NOW i kinda can't skip the tests

warm sleet
#

thats what I have a pipeline for

#

I don't typically run tests on my development machine, unless I need to

#

because it takes 20 minutes

#

xD

slender sand
#

We are still in university so our projects / tests are not that big

warm sleet
#

Ah yes

#

but even tests can be slow if they are poorly written

#

like

#

starting an entire database pool up to do integration tests

#

spinning up db instance, inserting test dataset

#

execute test, restore transaction safepoint, execute 2nd test

#

and so on

slender sand
#

Yea, luckily we just have very simple ones 😄

#

All tasks we have are just writing a few methods and to test these.

glad glen
#

So I'm using sqlite to create a database. Is there a way to have an array stored in a cell (for each row in a column) and then select all goes which contain a word found in those arrays?

#

Just new to databases so don't burn me

#

Also I'm collecting the data by scraping websites with bs4 and managing the database with apsw if that helps

hollow basalt
#

should be fine to store it like that, but just making sure you store it optimally

glad glen
#

It's gonna be image links scraped off websites like Tumblr and deviantart and I want to find images which match their tags hence the array

hollow basalt
#

you could tag it then

glad glen
#

Wdym?

slate frigate
#

Sounds like it’d be better to store everything in a json object, and have the database be a simple key:value structure, the value being the json string.

hollow basalt
#

for RDS,
could be

glad glen
#

Just there could be thousands of images

hollow basalt
#

then select all those with "human" column for example

glad glen
hollow basalt
#

but yea. json seems fine

hollow basalt
#

so we could suggest based on your data

glad glen
#

One sec

slate frigate
#

And if you are managing that much data, implementing bloom filters could be helpful too with query speed

glad glen
#

What's a bloom filter?

hollow basalt
#

uhh, i thought you're going to give us actual data that can be found in your array

slate frigate
#

Probabilistic way of determining if data exists in a data set

hollow basalt
#

ah yes time to bring out the algo

glad glen
#

Ohhh. I mean I don't have the array right now. Just trying to figure out how to do it

#

But it would just contain the tags for images like that

hollow basalt
#

so like

{
  "link": "https",
  "tags" : [
    "anime",
    "boy"
  ]
}
#

yeaa, json seems fine

slate frigate
#

Plus sounds like he’s doing it in python, and python had a GREAT bloom filter library

glad glen
#

Yea. Just thinking whether json or sqlite would be better

hollow basalt
#

he should definitely do it in assembly

glad glen
slate frigate
#

Although I’d shy away from using SQLite, purely for performance reasons.

hollow basalt
#

😳

glad glen
#

Would it not be slow with json if I have thousands of items?

hollow basalt
#

wdym

#

json is a format

#

are you referring to json-like databases? dynamodb, mongo etc?

glad glen
#

No

#

Just accessing the file from python

#

Would it be slow if there's thousands of items

#

And wouldn't it take up alot of memory space

slate frigate
#

Don’t store in a text file. Put the json in a database.

hollow basalt
#

Don’t store in a text file
Who would do that

#

👀

glad glen
#

So in the database (sqlite maybe), I can have a url column and a tag column which stores the tags in an array (or json)?

slate frigate
#

Yeah, you can.

#

You can also look to use splunk as an endpoint. It’ll handle the data, you just have to http forward everything to it

hallow pilot
#

What kind of program is this? Web app? Command line or gui app you run locally? A database might or might not be worth it

slate frigate
#

He’s already talking thousands of images/datasets. Definitely want a database.

hallow pilot
#

If you want queries and indices and fault tolerance and transactions and other database things then sure. But if it's just a local toy then a data structure in memory might be fine.

For my own projects I would lean toward using a database for future flexibility. I just want to point out that if learning about databases is not one of the goals, and you don't need one badly, there's probably a path forward without.

#

I'm curious what kinds of performance pain you've had with SQLite. What were you using it for?

slate frigate
#

Myself? Web scraper.

#

On a very large scale

#

Also, SQLite can’t be touched off host

hallow pilot
#

Yeah in my mind SQLite is filed under "I want to work with a database, but I'm writing a single-user application that is the sole user of it"

So like, a save file for a game, or persistence for a mobile app

slate frigate
#

I see it more as a prototyping tool.

#

Course, I don’t usually have a table set up any more complicated than key:value. I let bloom filters and json do the real work for me

#

Or if I’m really crunching data, I just offload to splunk.

dim shard
#

Hey, any suggestions as to what I should learn next in Java?

#

Completed Comp Sci I & II

#

And my teacher stopped "teaching" about last September, and there's no Comp Sci III at my School

slate frigate
#

Learn another less masochistic language?

hollow basalt
#

brainfuck

gaunt mountain
#

rust linusHEH

spring pond
#

kotlin if you want java but better

#

or c# if you want java but different

dim shard
#

Well i want to learn a lil more Java rather than just jumping into another lanaguage

shy helm
#

It’s hard to know what to say without knowing what you actually were taught so far

#

Learning programming >> learning a language

spring pond
#

yeah its hard to describe when you should jump to another lang

#

i made the jump a few months after taking AP CS A

sweet ferry
#

If I have an idea what you've done so far

shy helm
#

If you want to be a good engineer focus on the fundamentals, the language shouldn’t matter that much

spring pond
#

i think its always good to experience a low-level language like c/c++ to learn about strict memory management but yeah fundamentals are the most important

sweet ferry
#

I agree, but they're just starting out, and they should learn the fundamentals at least in the most comfortable way for them right now IMO

#

they can switch later

#

especially if additional classes will be in java, it would be better to have more skill at java for them too I imagine

spring pond
#

im curious how long these classes are, because if they're full year classes he has a lot of experience already

sweet ferry
#

comp sci I and II.. probably 2 semesters yeah

spring pond
#

thats the other option, and even then he'd probably have all of the core stuff down and maybe inheritance

#

again very hard to guess without course layout

sweet ferry
#

quite possible yeah

#

related classes

shy helm
#

If these are high school classes I wouldn’t be too certain haha

spring pond
#

if they were hs classes then id assume he's taken 2 years of cs, otherwise only 1

gaunt mountain
#

If you like physics then try game development

shy helm
#

There’s a lot of fundamentals missing in most high school CS, really without knowing what was taught it’s hard to judge

spring pond
#

the ap course i took for cs taught me up through inheritance and arraylists but nothing more

#

generics were a big thing that was left out

shy helm
#

Gotcha, tbf it also depends on what the goal is, so knowing a bit about that is also important