#development

1 messages · Page 66 of 1

marble hedge
#

what suck ass am I

marsh cobalt
#

I mean, can't you just get openjdk-9-jre with apt?

umbral saffron
#

so i made a thing with TensorFlow Lite on my pi

#

how would I do a command like

if Human = in_frame:
  #unlocks the rest of my code
else:
  print("Please put face in frame")```
spring pond
#

im no ml expert but i think you need to train a model

#

you can find them around the internet

#

just search something like "tensorflow face detection model"

urban flint
#

Also one equal is assignment two is comparison in python

umbral saffron
spring pond
#

you need to ask someone with more experience

#

i have 0 with ml

#

but if you need to do your own face then thats a lot more complicated

#

you need a completely new model

#

with your face in it

midnight wind
#

@umbral saffron what you would want to do is use callbacks

#

So when tensor flow detects face it will trigger a callback you specified

umbral saffron
#

oh

#

how would I do that

#

@midnight wind

umbral saffron
#

python

midnight wind
#

Basically you give a function to a function and that function will call that function depending on when you want it to

umbral saffron
#

well

#

my issue is

#

writing code that interacts with the video feed

spring pond
#

what library are you using for video input

umbral saffron
#

the built in rpi stuff

#

i have decided

#

thonny is the worst IDE

spring pond
#

i usually use something like opencv for camera stuff

midnight wind
#

@umbral saffron have you looked at documentation and examples

#

that's the best way

#

it's usually more complicated then you think

lament cave
# umbral saffron thonny is the worst IDE

if you have a separate computer you can run pycharm on it, I don't really recommend using pycharm directly on the rpi unless you have the newer model with at least 2gb ram (since it uses quite a lot of ram in my experience)

warm sleet
#

@umbral saffron you can just mount the program directory on your rpi to your local development environment, with sshfs

#

sshfs user@host:/path/to/dir /mnt/rpi

#

this would mount your raspberry pi to /mnt/rpi

#

if you then also spawn a regular shell, you can remotely debug too

umbral saffron
#

Ah ty

warm sleet
#

@umbral saffron just connect as root and mount sshfs root@ip:/ /mnt/rpi

#

make sure the directory /mnt/rpi exists on your system, and is empty.

#

you can unmount with

#

umount /mnt/rpi

#

now you can view the entire device

#

all its files

#

and everything

#

so settings would be in

#

/mnt/rpi/etc

#

@umbral saffron this is one of the big things that i like, and windows has a lack of. Sure, you can do network sharing

#

but its all so overcomplicated and nonreliable to immediately work

#

There's also this

#

allows you to map a windows network drive, to sshfs

#

instead of \\192.168.88.10\bla

umbral saffron
#

Just to make it more simple to understand

#

Tysm

peak acorn
#

hey lol i just learned about ssh fs

#

using it to do my schoolwork on their machines

pliant siren
#

can I use an rsa/dsa key? :?

peak acorn
#

idk

midnight wind
#

yeah why not?

pliant siren
#

yeah, it's a bit hidden, you have to use
\sshfs.kr[LOCUSER=]REMUSER@HOST[!PORT][\PATH]

#

and that forces you to use %LOCALUSER%/.ssh/id_rsa

midnight wind
#

oh on linux it's just normal

peak acorn
#

LaTeX is baad

errant tapir
#

Im so mad

#

All my arduino unos just pick up trash on the pins

errant tapir
#

Its stupid weird

warm sleet
#

@errant tapir like random values?

#

floating pins you should tie to ground through a resistor

#

@rancid nimbus that's the same in essence, scp is just a subset of ssh

#

@errant tapir for buttons and such on an arduino, you'll always want to tie those pins to ground

#

only when you press the button, the resistance changes, and can you register a button press

#

If you don't reference those pins to ground, you'll have floating values randomly going up and down

midnight wind
#

you know, arduino is just an easy to use microcontroller, you kind need to wire it correctly for it to work

vital blaze
errant tapir
#

idk what my problem is

#

i wire the ground to the other side of the pin and it doesnt work but same side it does

#

thats what i was going on

#

but

#

doesnt work

#

resistor has to be on other side with the pin

midnight wind
autumn swan
# errant tapir resistor has to be on other side with the pin

Yes. When it's like you're picture, the pin is connected to nothing (is "floating") still. You need the pin to be "pulled" gently to ground at all times, and then when the button is pushed, 5V goes through but has no resistance so the pin sees basically the full 5V.

#

The onboard/software pull-up is good too, but if you're just learning this, then there's value in doing it with the hardware instead of just the software so you can see what's going on and make sense of it.

honest sleet
#

Hey there! So I don't talk about it much, but I co-founded a non-profit 2 years ago to work on bigger open source projects, it's called AUPYA. We just released a video to present our main project for the moment, it's a firefox add-on called minimal, go check it out https://www.youtube.com/watch?v=Gtf9DYDtsHw

Minimal is a browser extension to experience a minimal, less attention grabbing internet experience. Internet should be a tool, not a trap.

🦊 Get Minimal: https://addons.mozilla.org/firefox/addon/minimal-internet-experience/
ℹ️ More information: https://minimal.aupya.org/
🟪 Contribute or report issues: https://gitlab.com/aupya/minimal

▶ Play video
weary veldt
#

can anyone help me out. I'm trying to use python to grab json from a url. Every time i get an "SSLError" specifically "(Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))"

weary veldt
#

I am using anaconda it has "openssl","requests" installed
requests.get(url)

spring pond
#

have you tried using pip

weary veldt
#

it says already installed

spring pond
#

can you give a screenshot of the output of pip install requests

umbral saffron
#

It’s an arduino it would be pip3 right

spring pond
#

you cant program an arduino with python much less use requests

#

this is a different issue

weary veldt
#

(trading) C:\Users\James>pip install requests
Requirement already satisfied: requests in c:\users\james.conda\envs\trading\lib\site-packages (2.25.1)
Requirement already satisfied: chardet<5,>=3.0.2 in c:\users\james.conda\envs\trading\lib\site-packages (from requests) (4.0.0)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\james.conda\envs\trading\lib\site-packages (from requests) (1.26.3)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\james.conda\envs\trading\lib\site-packages (from requests) (2020.12.5)
Requirement already satisfied: idna<3,>=2.5 in c:\users\james.conda\envs\trading\lib\site-packages (from requests) (2.10)

spring pond
#

well that looks correct

#

give a dump of your code

midnight wind
#

arduino is C or Cpp

#

pip is python

weary veldt
#

i forgot the "

#

but its in the code

spring pond
#

i just ran the code and executes fine

#

its something within your pc's configuration

weary veldt
#

f

peak acorn
#

i am day 1 into this course and discrete structures or logic or whatever is kicking my ass lmfao

umbral saffron
#

Let’s try speech recognition for a third time

#

But on a rpi this time

errant tapir
#

So it shouldnt matter what side its on aslong as its on the same pin right?

#

Well obviously it does matter

autumn swan
#

If you're absolutely certain the top right and bottom right corners are electrically connected. I have some that aren't like that.

errant tapir
#

Idk might test it and see if its open or closed

#

Yes i am

#

i metered it

#

Positive its connected

autumn swan
#

Do you know it's all properly connected once in the breadboard? I cannot tell you how many deceiving flaky breadboards I came across as a lab monitor

urban flint
errant tapir
woeful rapids
#

ok so i bought some raspberry pi picos to use as HID devices. i need to make a 2-key and a 4-key keypad.
Since i got 2 125mhz cores, will it be faster (or even a good choice) to handle USB in core 0 and input in core 1?

autumn swan
#

I think that's a good case to just chose the simplest option, since your max poll rate will likely be overkill even on just one core

woeful rapids
#

hmm yeah 100hz is way less than 125mhz and theres no calculations on the device so it'll be fine

#

hmm

weary veldt
#

should they

woeful rapids
#

i wouldnt trust it

#

guys does anyone have dev environment set up i cant install gdb latest cuz 404 error

#

for pi pico

nocturne oyster
#

what do you guys recommend for a newbie to game development , godot or unity?

woeful rapids
#

unity

nocturne oyster
#

why?

woeful rapids
#

thats what i went for. i already knew C# so it was fairly easy

#

i'm on arch so sudo pacman -S gdb. yeah but i get 404 not found

#

yeah already done with sudo pacman -Syu

#

tried upgrading everything

#

kernel 5.9.1 experimental

rancid nimbus
#

I also realize that is not the best solution

peak acorn
#

ofc u shouldnt trust that wtf

woeful rapids
#

ok now it works

#

kinda of

#

everything is installed but i cant build

#

you know what

#

VM time

#

new environment in a VM and screw that

peak acorn
#

That obfuscated code

urban flint
#

Yeah that has to be against tos

peak acorn
#

well idk about that

urban flint
#

Shouldn't set the standard that something like that is okay. That one might be a meme or something but the next one might not be

peak acorn
#

what what are you talking about

urban flint
#

What do you think I'm talking about? I have no idea what that script does do you? Why would mods allow something like that it's begging for some one to post malware that wipes your harddrive

peak acorn
#

No thats why I said I wouldnt trust obfuscated code, lmao

urban flint
#

Yeah and it should be removed

peak acorn
#

eh ig

urban flint
#

@rancid nimbus lol. I'm not saying you're posting malware I just saying starting the precedent of posting obfuscated code is begging for someone to post malware

peak acorn
#

rm -rf / --no-preserve-root

#

hehee im a hacker

urban flint
#

On a lighter topic;

peak acorn
#

lol isnt that just a flight controller or something

#

like a yoke or something

peak acorn
#

im really confused like is that just basically a yoke?

#

what is a margic carpet

urban flint
#

It's a easter egg lol

#

Like the magic carpet from aladdin?

#

Is that boomer knowledge now

urban flint
#

I have not! I do remember there was a time I would check out all of the 404 pages on the websites I went to because they sometimes had easter eggs/funny text lol

peak acorn
#

do u know that russian construction site lol

#

idk if the site still exists

#

just a funny 404 page

#

how

#

this was the song the website played

#

banger

#

its just a funny 404 page loll

#

wanna know what is not not not fun

#

propositional logic

tepid relic
#

Hi, I'm having trouble cutting down on latency with ffmpeg, this is basically something that streams the screen into the stdout which gets piped into a web server to be streamed to the client, I've been playing with some options to try to cut down on lag, and have managed to get it to about 5 seconds of delay, can someone help me cut it to at least one second of lag if possible because I will be adding a feature to give mouse control. Part of the slowness might be because I'm running this in a linux vm since i'm going to be deploying to a linux machine. I based this off a npm package called stream-screen.
Note: although haste says so the language is javascript, I'm not planing to add types any time soon
http://haste.aboutdavid.me/mabuvaketu.typescript

#

not exactly sure if VM is a bottleneck I've run a windows vm with remote desktop smoothly before

wind oracle
#

Hey

#

I need to determine the biggest maths exposant using a maximum value and a "base" so by example, if someone inputs 2 for the base, and 100 for the maximum value, the closest value would be 64 and it'd be 2 exposant 6

#

how can I do that

warm sleet
#

@wind oracle exposant?

#

you ment exponent?

#

highest value in base2 you can calculate as such: 2^n - 1

#

for base10, it'd be: 10^n - 1

#

@wind oracle if you want it the other way around

#

you're looking for logarithms

#

10-log of your highest value, divided by the n-log of your base (binary is 2, decimal 10)

#

ofc, fractions would be rounded up

nocturne galleon
#

hey guys whats the best laptop for programing, ill be doing CS at uni soon. My budget is 1300

#

usd

midnight wind
#

especially for smaller projects

#

I myself when I need to buy a laptop will probobly get a pinebook or somthing similar

nocturne galleon
hollow basalt
nocturne galleon
#

i just looked at pinebook

#

what kind of a joke is it

midnight wind
#

why is it a joke?

#

for school notes and just a normal laptop for myself it would be perfectly fine for me

#

but as a main

#

idk

nocturne galleon
#

it will be my main laptop for 4-5 years

midnight wind
#

dell xps?

#

idk

nocturne galleon
#

i dont want to end up getting a mid laptop, as i will be spending hella time with

wind oracle
#

True

nocturne galleon
midnight wind
#

yeah I get you

wind oracle
#

I bought an intel Mac book pro 2020 and I’m very nice with it

midnight wind
#

idk about macs

#

kinda eh

#

also depends what you are working on

nocturne galleon
#

uhh idk. if the new m chips will be out soon

#

i will not hesitate

nocturne galleon
midnight wind
#

CS is a bit general

#

do you know what exactly?

#

ML takes a bit of gpu power

craggy current
#

maybe he's studying

nocturne galleon
#

yeah

#

i am goign to attend university

#

took CS major with AI

craggy current
#

anything is fine actually in this case

midnight wind
#

for school, idk. Most of my college programming classes are a joke tbh

nocturne galleon
craggy current
#

you won't run a cluster of nodes

nocturne galleon
#

hmmm

midnight wind
nocturne galleon
#

macbook is tempting, lot of my frineds got them and seniors recommend it too

hollow basalt
#

probably the intel macbooks

#

the arm, Idk

nocturne galleon
#

in india esp

#

but i havent ventured too far from normal school stuff

midnight wind
#

I don't like apple, so I guess I have a bit of bias. Linux would be the best for me tbh

nocturne galleon
#

i want to get deeper into programming in uni

midnight wind
#

nice me too

nocturne galleon
#

baaka

hollow basalt
#

but yea linux

craggy current
#

get an used thinkpad and save the money, by the time you finish the university you can get one

#

also you will have a better idea of your needs

midnight wind
#

yeah thinkpads are nice

#

don't they have pretty descent linux support as well

nocturne galleon
#

im not that broke lol,

hollow basalt
#

So saving money is broke now

#

I didn't know that

nocturne galleon
#

so ill just buy a new one lol

nocturne galleon
#

i ll just go with a new one

#

2nd hand is kinda a bad market here

#

also kinda hard to locate one

midnight wind
#

ebay?

craggy current
#

get a mac if you like those devices, it's ok if you want the touchbar and the os

spring pond
#

i may be getting into the convo a bit late, but i didnt like macs before i started using them but their unix compatibility is amazing

craggy current
#

for a CS a mac is wasted money, you can have a better deal

spring pond
#

its expensive but imo its worth it

#

especially if you can get the apple silicon version

#

which is in your budget

craggy current
#

when I was a student there was no benefit to use a mac

spring pond
#

well the battery life is insane

#

i do python and swift development on a mac and its a very nice experience

#

if you do get a mac id personally wait if you can until the next M revision because they're supposed to be really good

#

i have a M1 MBP

midnight wind
#

well battery life on ARM is nice

nocturne galleon
craggy current
#

any thinkpad, even used ones, xps, hp zbook

nocturne galleon
nocturne galleon
spring pond
#

i have 16 GB ram 8 core graphics and 1 TB drive (though i may have overspecced on the drive)

nocturne galleon
#

okay thats great

#

must have cost a chunk tho

#

air or pro

spring pond
#

it was about $2500, i have a pro

#

i could have made an air work tho

#

they're very similar

nocturne galleon
#

ah right

#

i really wish the next gen ones support an egpu

spring pond
#

yeah that would be nice, but the gpu is pretty good

nocturne galleon
#

in the current model?

spring pond
#

yes, im planning on doing some ml projects on it eventually

#

if you dont need ml you really only need 6 cores

nocturne galleon
#

a friend of mine has a intel mac, he bought 4 yrs ago and uses a egpu to render his unity games on it

nocturne galleon
spring pond
#

then go 8 core

nocturne galleon
#

and AI related software

spring pond
#

the M1 is extremely AI accelerated

nocturne galleon
#

idk what is there tho

#

okay thats nice to hear

spring pond
#

it has dedicated ML cores + the GPU

nocturne galleon
#

the gpu isnt that great yeah

#

its like average gpu

#

it can run all normallstuf

#

but cant run games right

#

i mena it can run games but not too well right

spring pond
#

well it can but it got really hot

#

the frame rate was decent on Beyond A Steel Sky

#

but it got too hot for my liking so

#

use an external kb while gaming

#

but it doesnt even get warm when compiling

#

unlike my old intel mac that burned my hands

nocturne galleon
spring pond
#

yeah, just get a cheap usb c to usb a hub

nocturne galleon
#

yeah i def need that if im getting a amac

#

also how is the windows boot up thing

#

people said the intel ones load up windows much easier

spring pond
#

there is no boot camp support on M1 until MS releases Windows for Arm

nocturne galleon
#

compared to the m1

spring pond
#

people have gotten it working (and it works well) but you need to put in a lot of work

nocturne galleon
spring pond
#

ok

spring pond
#

once MS releases it it will be a lot better

#

i personally have a USB-C to HDMI/USB-A adapter with the USB going to a KVM switch so i can use my kb/mouse on my pc and my mac

nocturne galleon
#

yeah i will buy a dongle/adapter

#

if im getting the mbp

spring pond
#

mba also has the same compatibility

nocturne galleon
#

yeah true, but if im buying a mb ill buy a pro

spring pond
#

beware M1 only has support for one external display at this time

nocturne galleon
#

yeah i know that, but it doenst matter

spring pond
#

ok

nocturne galleon
#

how many dispalys will i use lol

spring pond
#

i personally have 2 external displays and it took me a while to figure out why one wasnt working

nocturne galleon
#

we are talkign abt the m1, the m next gen gonna be better

spring pond
#

yeah 100%

spring pond
#

early adopter stuff and all that

nocturne galleon
#

i think ill wait for mbp next gen

spring pond
#

good idea

nocturne galleon
#

but when do you think it will comeout

spring pond
#

it should be coming out around end of Q1/start of Q2 looking at Apple's previous releases

#

but that is ofc an estimation

#

not too far from now

nocturne galleon
#

idek

#

lol

#

cz 2021 q1 end is too mear

spring pond
#

hopefully 2021

nocturne galleon
#

i expct it to be out by nov

#

just liek this year

#

but intel was refreshed during q1 yeah

spring pond
#

yeah, there will definitely be a next gen this year but its hard to know when

nocturne galleon
#

alright

#

thanks for your help

spring pond
#

np

nocturne galleon
#

im just super confused if i should get the mbp or t14s, i think mbp is a good choice

shy helm
#

I'd expect they'll release a new AS computer Q1/Q2 this year

nocturne galleon
#

as?

spring pond
#

Apple Silicon

shy helm
#

Apple Silcon

spring pond
#

from what ive seen its most likely gonna be something like a 0.5 rev like M1X not M2

#

but we'll see

shy helm
#

mmm not sure

#

I think it'll have to be different

spring pond
#

yeah, its hard to tell

#

¯_(ツ)_/¯

shy helm
#

the M1 is basically an iPad chip

#

16" MBP is the next to be refreshed

spring pond
#

oh youre right

#

ok yeah then a M2 seems pretty likely then

shy helm
#

I mean, they may call it an M1X LOL

nocturne galleon
#

likely for q1/2

#

?

spring pond
#

yeah

shy helm
#

but it wont be the same underlaying chip with modifications

nocturne galleon
#

ahh right

#

if it comeout by q1/2

#

istg its sexy

shy helm
#

worst case it should come out over the summer

#

if they want to keep their timeline

nocturne galleon
#

oh thats fine

shy helm
#

Again, just me guessing though

#

MBPs are great for uni if you're doing CS from my experience

nocturne galleon
#

anyways my uni is starting septemebrish, i thought if i had it a bit earlier i could do some stuff with it to get familiarized

nocturne galleon
#

squid helped me a lot

shy helm
#

Most CS unis are Unix-centric, so you'll have an easier time doing stuff

nocturne galleon
#

thanks my g

shy helm
#

Windows is hell trying to do anything on

spring pond
#

i have a burning hatred for cmd

shy helm
#

WSL 2.0 is shit

nocturne galleon
#

ahh ool thansk a lot

#

im out

#

i spent over 6 hours trying to figure out if a mb is worth it for cs

#

i went to sal

#

ltt

shy helm
#

Your millage may vary

nocturne galleon
#

davecord

#

techs

shy helm
#

I got tons of friends (myself included) who loved ours

#

most of my friends who had XPSs upgraded to a mac during our degree

nocturne galleon
#

python, and coding hub

#

i was super confusd

#

now i got the answer

shy helm
#

👍

nocturne galleon
shy helm
#

Whatever you do dont get a gaming laptop

nocturne galleon
#

hahahah

#

belive me or not

spring pond
#

worst mistake of my life to get one

nocturne galleon
#

2 days ago i decided to not get a gaming laptop

spring pond
#

like 4 years ago

nocturne galleon
#

cz the tuf f 15 had low power suply for the gpu

#

what is the issue with gaming laptops?

#

the battery is too short?

#

is it too bulky?

#

only those 2 major issues yeah

spring pond
#
  • heat, loud fans
nocturne galleon
#

ah right'

shy helm
#

you'll. h8 urself

nocturne galleon
#

i wish

#

really really wish

#

next gen m chips

#

shoudl support egpu

#

ill save up soem money and get a egpu within 1 yr of buying the laptop

craggy current
#

@nocturne galleon check if your mac will support opencl and other low level api

nocturne galleon
hollow basalt
#

It can't find .net core sdk

nocturne galleon
#

how i can fix it?

shy helm
#

Apple is pushing for people to use Metal, which makes sense because they’re using custom hardware now

spring pond
#

yeah the entire Metal library is just a replacement for Open[Insert letter here]L

warm sleet
#

@nocturne galleon .NET framework and .NET Core are two different runtimes

#

.NET Core is entirely opensource

#

you need a different SDK for that platform

nocturne galleon
#

witch one?

warm sleet
#

You have the one for .NET Framework

#

lemme find you a link

#

get the one on the right

#

.NET Core is for stuff that runs on linux and OSX too

nocturne galleon
warm sleet
#

no it isnt

#

look at that version

#

5

#

thats the one on the left

#

oh, wait

#

in your case its the middle one

#

cough this is why I develop on linux :3 apt install dotnet-core

nocturne galleon
nocturne galleon
#

i didint understand u

#

can u explain from the bagging

warm sleet
#

if you need debugging

#

Then you need the .NET Core SDK

#

that's what it is saying.

wind oracle
#

hi

#

I need help with string.format in java

peak acorn
#

what abt it

#

@wind oracle

hollow basalt
peak acorn
#

you know, if you have a question, just ask it right away dont wait for someone to acknowledge ur need to ask first

hollow basalt
#

People just can't do that lol

#

they love asking to ask

peak acorn
wind oracle
#

sorry lol I got busy

#

alright so I need to print out something like this

#

using a for loop

#

the maximum dividend (Which is 5 in this current situation) is set by an input form the console

spring pond
#

you could use a nested loop and multiply the two indicies (plus one on each)

wind oracle
#

the teacher asked us to use string.format

#

I do not know why

hollow basalt
#

so this is your homework

wind oracle
#

not really

#
        for (int i = 1; i <= valMax; i++) {
              System.out.println(valMax + "x" + i + " = " + (valMax * i));
          }
    }```
#

it's a small part of it

ebon viper
#

Has anyone ever worked on Unity’s A* or navmesh by any chance?

peak acorn
#

The string formatting is for the gaps between numbers

#
For c in each col
  for r in each row
    printf("%5d", r*c)
#

format as you need

#

and for java that'd be System.out.printf("%5d", r*c);

#

I come across a problem

#

how do you do like "%5d" but with a variable instead of 5

#

2 string formats?

spring pond
#

personally i'd use interpolation but that would also probably be possibly as well

peak acorn
#

does java do that

#

I guess u can just break it into string additions

spring pond
#

yeah it doesnt exist in java

#

the highest upvoted answer is a string.format() call for interpolation lol

#

*on SO

peak acorn
#

yea so like

#
                System.out.print(" X | ");
                for(int i = 0; i < rows; i++)
                {
                        String s = String.format("%%%dd",maxLength);
                        System.out.printf(s, i);
                }
                System.out.println();
#

%%%dd lmao

#

man writing stupid formatting things like that dudes assignment up above is such a pain

wind oracle
#

OHHH

#

huhhhhhh int rows right

peak acorn
#

i suppose int would be a row

hollow basalt
#

there we go, your homework is done

peak acorn
#

im not giving u the code

hollow basalt
peak acorn
#

thats just for trying to set the padding on a string.format dynamically

#

which isnt required for the assignment

hollow basalt
#

Agreed

#

Don't give it to him rugg

peak acorn
#

:)

#

dont worry

#

he gotta do it himself

midnight wind
#

reverses blur algorithim

peak acorn
#

Create a program to un-blur in order to complete homework

shy helm
#

They auto aline stuff

peak acorn
#

unnecessary

#

also would that even work

#

cus ur tryna right-align everything

#

\raggedright one might say

shy helm
#

Oh you’re right my b

#

Tired

#

There’s a printf way to do this easily

peak acorn
#

:)

wind oracle
#

I don't understand

peak acorn
#

what in particular

wind oracle
#

well most of it

#

like I usually need stuff to be explained part by part idk

#

what im guessing is ill need 2 for loops

peak acorn
#

Yes you certainly need 2 loops

wind oracle
#

alright

#

but then

#

...

#

that's where im lost

shy helm
#

One hint

#

Start by writing the output row by row

#

Get the basic part of the table built

#

Then, figure out how to write the first row of calculated numbers

wind oracle
#

wdym writing the output row by row

shy helm
#

Well, your output has a bunch of rows right?

#

X | 1. 2. 3. 4. 5

wind oracle
#

yes

#

the maximum value

shy helm
#
    • | - - etc
wind oracle
#

which is the 5 in this case

#

is set by an input

shy helm
#

You have to write each of those rows one by one

#

There’s no going “back”

wind oracle
#

OHHH but like how do I know how many rows there needs to be

#

what about the space

shy helm
#

It’s from the input right 😉

wind oracle
#

yessssss

shy helm
#

If there’s 5 numbers, you need the 5 rows for the numbers + the rows you statically (always) have (like the X | row and the - - - row)

wind oracle
#

that's like the only thing im missing to turn my homework in

shy helm
#

Look into how printf strings work

wind oracle
#

yes

wind oracle
#

but like how am I supposed to print the first row by exmaple

#

on a single line

peak acorn
#

hint: dont println

wind oracle
#

okkk

#

printf ?

peak acorn
#

printf will work

#

as it wont automatically add newline

wind oracle
#

huh

#

ive been trying to mess around with print f

peak acorn
#

works good

#

I would always use %d for numbers

#

im not sure what the difference is tho

wind oracle
#

for some reasons

#

it does a new line

peak acorn
#

screenshot?

wind oracle
peak acorn
#

remove %n

#

that is the newline formatting token

wind oracle
#

I'm rarted

#

oh ok thanks

#

works

#

soooooooo

peak acorn
#

%n makes it so on you either get /n or /r/n

wind oracle
#

im gonna have to do a for loop for reach lines ?

#

each*

#

rows*

peak acorn
#

Well, since on the example code you print you all the numbers once

#

that should be its own loop

wind oracle
#

how the fuck

peak acorn
#

I always seem to have this problem

#

idk how you can explain how to code something without just saying how you code it

autumn swan
#

It usually works much better in person unfortunately

wind oracle
#

welllllll explaining it

#

yesssss sadly

#

or like on a screenshare or sum

peak acorn
#

yeah

#

well ill try

#

if you can accurately generate the top line of the sample then ur in a good spot

wind oracle
#

like the first loop x5 ?

peak acorn
#

yeah if you can get that going

#

then its only a slight modification

wind oracle
#

im also there

#

I just need to firgure out the spaces

#

between the numbers

peak acorn
#

For the specific value i got no clue just try them all

#

looks like maybe a total of 4

wind oracle
#

that is quite litteraly what im doing rnç

#

alirght i got it working

peak acorn
#

that first gap might be too big but im not entirely sure

#

doesnt matter, thats an each change

#

I would just continue

wind oracle
#

I am lost

peak acorn
#

Do you know how string format for numbers works?

#

i think what you need to do

#

is use "%4d" or something, what that does is adds blank spaces before your number

#

so that the total length of the value is 4 characters

wind oracle
#

ohhhhhhhhhh

#

okkk what about the * tho

peak acorn
#

the *?

wind oracle
#

like 1 * 2

#

1* 5

#

n stuff

peak acorn
#

yeah so instead of printing i

#

you have to print i * n whatever n might be i dunno yet

wind oracle
#

n would be my dividend ?

peak acorn
#

what do u mean by dividend

wind oracle
#

divisor and dividend

#

multiplications yk

peak acorn
#

oh

#

u might have the wrong word

#

idk if language barrier or anything but

#

divisor and divident are for division

wind oracle
#

oh

peak acorn
#

Divisor / Dividend

wind oracle
#

im a french canadian

peak acorn
#

For multiplication it would be, idk multiplicand?

wind oracle
#

oh yeah

peak acorn
#

but as long as i know what u mean now

#

its all good

wind oracle
#

but now you know what i meant

peak acorn
#

yeah'

#

so yeah, N would definitely be dividend

wind oracle
#

okkkkkkkkk

#

and how can I update it every loop ?

peak acorn
#

so for row 1, you multiply by 1, row 2 u do i*2, etc

#

simple

#

Put another loop around your loop for printing the multiplication

wind oracle
#

HMMMMMMMMMM

#

this is kinda complicated

peak acorn
#

maybe at first but its not so bad

#

You can already print 1, 2, 3, 4, 5

#

so now we have to print it multiple times

wind oracle
#

yessss

#

its the multiplicaitons thingy now

peak acorn
#

You can re-use your code for your first line and modify it

#

so copy it and make a new one of it

#

and put a second loop around your printing code

wind oracle
#

huhhh lemme try

#

sum like this ?

peak acorn
#

yep

#

run it and see what happens

#

(it wont be right, but go with it)

wind oracle
#

huh the int i is duplicated

#

so it wont run

peak acorn
#

oh

wind oracle
#

wtf

peak acorn
#

change the outer variable to J

wind oracle
peak acorn
#

little j

#

or thats fine

#

variable names are irrelavent

#

yup

#

so

#

you need a new line

#

after the end of the loops

#

simply system.out.println()

wind oracle
#

I add that to my loop that's in my loop ?

peak acorn
#

you want it at the end of the outer loop

#
loop1{
  loop2{
  
  }
  newline()
}
wind oracle
#

ooooooh

#

it starts to look like something

peak acorn
#

!

wind oracle
#

but the multiplications tho

peak acorn
#

i*n in the print

#

and u got it i believe

wind oracle
#

YESSSSS

#

what about the little lines tho

peak acorn
#

well u gotta print them in somehow

#

look at how you did the very first line

wind oracle
#

yeah thats what I was looking at

peak acorn
#

what do u think u gotta do

wind oracle
#

huhhhhh

#

after the system.out.println();

#

add something

peak acorn
#

for which little lines are you trying to get wokring rn

#

the ------ or the 1 | 1 2 3

wind oracle
#

huhhhhh the ----- must not be complicated I think

peak acorn
#

that sounds simple to me

wind oracle
#

and the 1|123

#

is after the system.out.println(); in my outer loop right ?

peak acorn
#

I would put it before your inner loop actually

#

so you can do 1 | <inner loop>

wind oracle
#

alright buttt it has to have it's own loop nah ?

peak acorn
#

mmmm no

#

that can be a single printf statement

wind oracle
#

huuuuuuuuhhhhh

peak acorn
#

within your loop try to get anything that resembles 1 | 1 2 3 4 going

wind oracle
#

HMMMMM wait lemme try sum

#

hmmm nvm

peak acorn
#

whats the issue

wind oracle
#

I fucked it up lmfaoo

peak acorn
#

yeah not that

#

what you want is for each row, to only print " 1 | " once

#

so it doesnt need to be in the inner loop

#

since the outer loop is for each row, and putting it in another loop would be too much

wind oracle
#

hmmm

peak acorn
#

sure

wind oracle
#

look at my first row tho wtf

peak acorn
#

so somewhere u need a new line

#

to fix that first row

wind oracle
#

hmmmmm

#

I don't have much clue

peak acorn
#

put it after your single loop up top

#

usually thats how u wanna structure it

#

you print out your line, and then move the cursor to the next line

#

so you print out X | 123125151 , and then put a newline

wind oracle
#

hmmmmmmmmm

peak acorn
#

yea

#

like

#
print X | 
print 1,2,3,4,5
print newline
wind oracle
#

I don't understand the print newline

peak acorn
#

by newline i just mean

#

system.out.println()

#

there is a character ("%n", "\r" or "\n" depending) that moves the printing to the next line

#

so if you print something, then print a newline character, then more stuff, it will be on 2 lines

#

System.out.println() just prints a newline character

wind oracle
#

hmm hmmmmmm

#

so what should I print after my single loop up top ?

peak acorn
#

just a new line character

#

so either println() or printf("%n")

#

they are the same

autumn swan
#

Hang on, didn't the assignment or whatever say you need to use String.format?

peak acorn
#

oh sheesh

wind oracle
autumn swan
#

I mean that's not a painful conversion but just asking

wind oracle
#

well he asked us to align our stuff correctly

peak acorn
#

printf probably literally calls string.format anyways

wind oracle
#

yeah it does

#

so wait why does my thing looks cracked now

peak acorn
#

because you havent told the formatter to add padding

wind oracle
#

tf is padding

peak acorn
#

padding is how you can add spaces to make every print the same size

#

so instead of printing
1 1
100 100

#

it would print
1 1
100 100

#

discord isnt monospace so idk if that looks right on ur end

wind oracle
#

huhh yeah it does

#

how do I do that

#

im still wondering about the ---+-------------------

#

and the -----------------------

hollow basalt
#

I have this code to help you, though it does have a slight disadvatange

autumn swan
#

you can do monospace.

peak acorn
#
  1   1
100 100
#

woah

#

lol

autumn swan
#
Do
Multiline
peak acorn
#

i know i know

#
print("formatting too")
for i=0,5 do
  print(i)
end
hollow basalt
#

@wind oracle do you want this to solve yourself or do you want to ssee my code

#

you just need to tweak mine to cater to your needs

wind oracle
#

well im close to done

peak acorn
#

I mean i have all the src code to generate it of X by Y size i was just widthholding it

wind oracle
#

I just need to figure out my padding now

peak acorn
#

in favor of education

hollow basalt
#

I don't want to exposse

#

though I do think that my code won't help him that much

peak acorn
#

lel

hollow basalt
wind oracle
#

big help

hollow basalt
#

this looks bad

#

but atleast it works

hollow basalt
autumn swan
peak acorn
#

oh that was the wrong file anywyas

peak acorn
wind oracle
#

the padding

#

and the ----+------------------

hollow basalt
#

looks terrible

peak acorn
#

yes yours is ugly

#

ok, padding

#

its basically printf("%4d", <number>);

#

but test for the numbers

#

thats just how you do it, idk how you could explain it to someone else

#

like a bash script?

#

fuck that

#

eeewww

hollow basalt
#

@peak acorn i'll drop my code here then try to add padding

#

that aite?

peak acorn
#

ok

#

my code is good so im not gonna do that

hollow basalt
#

@peak acorn


public class Main
{
    public static void main(String[] args) {
        int row = 4;
        
        if( row == 1){
            System.out.println("x | 1");
            System.out.println("1 | 1");
        }else if( row == 2){
            System.out.println("x | 1 2");
            System.out.println("1 | 1 2");
            System.out.println("2 | 2 4");
        }else if( row == 3){
            System.out.println("x | 1 2 3");
            System.out.println("1 | 1 2 3");
            System.out.println("2 | 2 4 6");
            System.out.println("3 | 3 6 9");
        }else if( row == 4){
            System.out.println("x | 1 2 3 4");
            System.out.println("1 | 1 2 3 4");
            System.out.println("2 | 2 4 6 8");
            System.out.println("3 | 3 6 9 12");
            System.out.println("4 | 4 8 12 16");
        }
    }
}
#

thanks

peak acorn
#

LOL

#

you now something

hollow basalt
#

my code has some slight disadvantage when the input isn't 1-4

autumn swan
wind oracle
#

thats where we are so fare

peak acorn
#

Look at my O(1) fizzbuzz code @hollow basalt ```java
public class Main
{
public static void main(String[] args) {
System.out.println("1");
System.out.println("2");
System.out.println("Fizz");
System.out.println("4");
System.out.println("Buzz");
System.out.println("Fizz");
System.out.println("7");
System.out.println("8");
System.out.println("Fizz");
System.out.println("Buzz");
}

#

first 10 lines fast as fuck

peak acorn
hollow basalt
#

@peak acorn am I insane when I created a program that generates a source code like that

peak acorn
#

why does your code have curly on a newline once and inline the other time

hollow basalt
#

just to troll fizzbuzz

wind oracle
#

yes

hollow basalt
#

yes isn't a valid answer for why

peak acorn
#

So you could just print a ton of "-" in a loop

wind oracle
#

hmmmm

wind oracle
#

how

hollow basalt
#

how not

peak acorn
#

How to what part

wind oracle
#

the ---+----------

peak acorn
#

Have you seen the enterprise fizzbuzz?

peak acorn
hollow basalt
peak acorn
#

import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.Constants;

#

lmfao

hollow basalt
peak acorn
#

yes!

#

enterprise!

hollow basalt
#

thiss needs more design patternss

#

I don't see singleton

peak acorn
#

(I dont even know what that is) LMFAO

#

im no pro coder man

hollow basalt
#

what if the caller only wants one instance

hollow basalt
#

my ss iss broken

#

damn it

peak acorn
#

is that not just new Foo();

hollow basalt
peak acorn
#

ohh.

#

i dont even know how u would do that

hollow basalt
#

I mean running = instance

#

do you know database connection pooling

peak acorn
#

nop

#

i tell u im no pro

wind oracle
hollow basalt
peak acorn
#

I was thinking of just like i would make a static bool lol

peak acorn
#

I'll leak my src after hes done

#

maybe i should fix up some of the bugs it has

#

or the uglyness

wind oracle
#

the + hmmm

peak acorn
#

My method for that is kinda bad

#

but

#

You could say if you're on the right spot to add the +, add the plus, otherwise, add -

#

its bad cos it adds a conditional that is pretty much not necessary but

wind oracle
#

whatttt

peak acorn
#

you can just play with the numbers until it works now

hollow basalt
#

Yea, I think you jusst need to experiment more so you'll learn more

peak acorn
#

u got it yet?

wind oracle
#

HMMM close

#

im just havving issues with the +

peak acorn
#

Your system rn looks fine so you're close

#

also one thing, up top where you print(" X ") you should remove the first space, so that it lines up with the other numbers

wind oracle
#

yeah I did

peak acorn
#

oh yeah

#

just need the +

wind oracle
#

yessssssssssss

#

I know I need it to be at the third -

peak acorn
#

So you could make it loop 1 less time, and manually insert a +

wind oracle
#

HMMM how

peak acorn
#

loop valMax-1 times

#

and before the loop print --+- or whatever

wind oracle
#

DONE

#

I put int j at 1 so it loops one less time

peak acorn
#

oh fuck i forgot the bottom orw

wind oracle
#

LOL mine is better than you now

peak acorn
#
class Main
{
    public static void main(String[] args)
    {
        int rows = 35;
        int cols = 35;

        Integer maxValue = new Integer(rows*cols);
        int maxLength = maxValue.toString().length() + 1;

        int maxLengthForColHeader = new Integer(rows).toString().length();
        String beginningMessage = String.format(" %%%ds | ", maxLengthForColHeader);
        System.out.printf(beginningMessage, "X");
        for(int i = 1; i <= cols; i++)
        {
            String s = String.format("%%%dd",maxLength);
            System.out.printf(s, i);
        }
        System.out.println();

        for(int i = 0; i < beginningMessage.length() - 1 + cols*maxLength; i++)
        {
            if(i == maxLengthForColHeader+2)
            {
                System.out.print("+");
            }
            else
            {
                System.out.print("-");
            }
        }
        System.out.println();

        for(int row = 1; row <= rows; row++)
        {
            System.out.printf(beginningMessage, row);
            for(int col = 1; col <= cols; col++)
            {
                String s = String.format("%%%dd",maxLength);
                System.out.printf(s, row*col);
            }
            System.out.println();
        }

        for(int i = 0; i < beginningMessage.length() - 1 + cols*maxLength; i++)
        {
            System.out.print("-");
        }
        System.out.println();
    }
}
#

the way that the numbers shade the screen kinda look like log functions

#

ew what the fuck

#

screencap the result?

#

nvm i forgot i have linux

#

cool lol

wind oracle
#

why does my code look simpler tho

peak acorn
#

becos urs is simpler

wind oracle
#
        int valMax = 9;
        System.out.printf("%s", "X |");
        for (int i = 1; i <= valMax; i++) {
            System.out.printf("%4d", i);

        }

        System.out.printf("%n");
        System.out.printf("%s", "--+-");
        for (int j = 1; j <= valMax; j++) {
            System.out.printf("%s", "----");
            
        }
        System.out.printf("%n");
        for (int i = 1; i <= valMax; i++) {
            System.out.printf("%1d %s", i, "|");
            for (int n = 1; n <= valMax; n++) {

                System.out.printf("%4d", i * n);

            }
            System.out.println();

        }
        for (int j = 0; j <= valMax; j++) {
            System.out.printf("%s", "----");
        }
    }```
peak acorn
#

Do u see this uglyness

wind oracle
#

lol

peak acorn
#
int maxLengthForColHeader = new Integer(rows).toString().length();
String beginningMessage = String.format(" %%%ds | ", maxLengthForColHeader);
System.out.printf(beginningMessage, row);
wind oracle
#

thank you tho

peak acorn
#

yup :)

wind oracle
#

you were of a great help

peak acorn
#

Now i got a challenge for u ppl

#

Are there any elements in the periodic table, where their symbols encoded in any base (using the normal 0-9;A-Z system) are equal value to its atomic number

#

so dos mine

#

oh formatted urs looks much nicer

#

still guy but

#

i have no clue what i just typed

wind oracle
#

why the fuck won't my shit quit

peak acorn
#

i mean tbf its about the same highlighting as vscode gives me

wind oracle
#

ouf my shit is too big

peak acorn
#

and the answer to thatelement thing is no

#

however if u start the encoding for bases as A=0 and Z=numberOfLettersInAlphaBetCantRemember

#

then theres like 4

wind oracle
#

alright

#

I just got done

peak acorn
#

:)

wind oracle
#

OUFF

#

end result

peak acorn
#

thats some big code

#

his homework

#

its definitely extra

#

the multiplication was only maybe 30 lines or something

#

exit

#

bash yucky

#

the fact u have a bash shell discord

#

OH

#

im

#

deaf

#

blind

#

idk

#

dyslexic

#

helen kellerd

#

hes disappearing

#

🧠

warm sleet
#

you can just calculate how many digit spaces you need for a base-10 number :3

#

to string and then length compare seems so.. easy and dirty lol

warm sleet
#

@rancid nimbus yeah but this is java specifically

#

and int to string and then range count is rather expensive

#

10log(value) + 1

#

should give you max column size

#

2log() for binary and 16log for hexadecimal

#

logarithms are just lookup tables, you're not creating a string instance

#

so its generally easier on the system

#

1000 = 10^3

#
  • 1 = 4
#

2log of value = 10log(value) / 10log(2)

#

or other way around, I forget lol

#

10 log is the default in this case

#

though I think Math.* in java has log and log10

#

or 2 log, I forget lmao

#

even java had changes with this, java8 does not declare a log10()

#

@rancid nimbus the reason its efficient to use logarithms is because in java, these are native functions

#
    /**
     * Returns the natural logarithm (base <i>e</i>) of a {@code double}
     * value. Special cases:
     * <ul><li>If the argument is NaN or less than zero, then the result
     * is NaN.
     * <li>If the argument is positive infinity, then the result is
     * positive infinity.
     * <li>If the argument is positive zero or negative zero, then the
     * result is negative infinity.</ul>
     *
     * @param   a   a value
     * @return  the value ln&nbsp;{@code a}, the natural logarithm of
     *          {@code a}.
     */
    public static native double log(double a);
#

and the native implementation, within the runtime is probably a lookup table

#

as they do with pocket calculators and such

#

before calculators, there were literal log tables

#

would be a decently sized book

#

with a lot of pages full of numbers

#

strings are objects

#

int maxlength = (int) Math.log(rows) + 1

#

string is an array of char

#

you just count the length of the array

#

Look, in C this would be fine

#

since you can directly check memory space

#

null-terminated string would be harder

#

since you have to iterate

#

Intel even has library extensions for their processors

#

to do logarithm calculations in the hardware