#development

1 messages Β· Page 60 of 1

warm sleet
#

and an ArrayList is like an array, but its can automatically resize itself

spring pond
#

^

#

since you want to sort by goals you could use something like quick sort, insertion sort, selection sort, or any other algo

warm sleet
#

wat

#

@spring pond bro

#

let me enlighten you

quick meadow
#

Man

#

I need help with ue4

warm sleet
quick meadow
warm sleet
#

java has a much different sorting algo

#

and if you have other datastructures, what you'll find, is that it uses a different algorithm depending on the size of the list

spring pond
#

oh i saw tim sort when i was looking up algos

#

didnt really know what it was

warm sleet
#

@spring pond every List inherits this:

#
    default void sort(Comparator<? super E> c) {
        Object[] a = this.toArray();
        Arrays.sort(a, (Comparator) c);
        ListIterator<E> i = this.listIterator();
        for (Object e : a) {
            i.next();
            i.set((E) e);
        }
    }
#

and that Tim Sort

#

is that code I just showed you, thats Arrays.sort()

exotic jungle
#

hello, there is this script that i wont to be activated with autoit, if I double click the left mouse button. Ihave found this HotKeySet ( "key" [, "function"] )

#

how can i put this in a script ??

warm sleet
#

@spring pond if you have intellij, you can just ctrl click on a type from the standard library

#

and itll just show you the source code

#

so you can figure out how java does this stuff

spring pond
#

yeah ik

warm sleet
#

lol my first embedded project, I built a serial protocol

#

in essence, I built an RGB controller

spring pond
#

nice

warm sleet
#

that could dim 512 channels between values of 0-255

#

lemme see if I can find the screenshot of the UI

spring pond
#

@exotic jungle i dont really know much about autoit, but i'd recommend ahk for stuff like key-based scripting if you are still just starting out

warm sleet
spring pond
#

forms project i see

warm sleet
#

yeah the hardware was in C

#

and the UI was with WinForms

spring pond
#

cool

warm sleet
#

and they communicated over usb serial

spring pond
#

i think i messed around with serial a little while ago, definitely not my favorite thing to code for lol

warm sleet
#

xD

exotic jungle
#

I know about that but I am looking to us a autoit script that activats an other script when a key combo is pressed. @spring pond

warm sleet
#

@spring pond .NET actually has an ok API

#
        /// <summary>
        /// Initializes a new instance of a SerialConnector. Can be used to communicate with an Arduino with DMX shield.
        /// </summary>
        /// <param name="port">The COM port</param>
        /// <param name="speed">The speed in baud</param>
        public SerialConnector(string port, int speed)
        {
            this._port = port;
            this._baudrate = speed;
            //Initialize serial port
            _serial = new SerialPort(port, speed, Parity.None, 8, StopBits.One); 
            //Add event handler to print an error from arduino
            _serial.DataReceived += new SerialDataReceivedEventHandler(_serial_DataReceived);
            _serial.Open();

            //Start thread to handle requests and timing.
            _connection = new Thread(new ThreadStart(HandleRequests));
            _connection.Start();
        }
#

you just have an event handler

#

that handles incoming data

spring pond
#

i was a bit obsessed with c++ at the time so i used the qt serial stuff

#

i just starting using c# for more stuff and it is a very nice lang

warm sleet
#

@spring pond I use DMX for the lighting controller

#
        /// <summary>
        /// Sends a dmx request through the serial port, it will must be ran on a seperate thread.
        /// </summary>
        /// <param name="channel">The channel that is affected</param>
        /// <param name="fixture">The fixture of the affected channel</param>
        /// <param name="instruction">The instruction for the request, valid instructions are: Set, Clear.</param>
        private void DmxSend(ushort channel, byte fixture, Instruction instruction) {
            if (channel > 512) throw new ArgumentOutOfRangeException("channel", channel, "Channel has to be in DMX Spectrum, 1-512");
            switch (instruction)
            {
                case Instruction.Set:
                    byte[] chan = BitConverter.GetBytes(channel);
                    byte[] message = { (byte)instruction, chan[0], chan[1], fixture, (byte)Instruction.Stop };
                    _serial.Write(message, 0, message.Length);
                    UpdateBuffer(channel, fixture);
                    break;
                case Instruction.Stop:
                    throw new ArgumentException("Invalid instruction", "instruction");
                case Instruction.Clear:
                    _serial.Write(_clearMessage, 0, _clearMessage.Length);
                    _localDmx.Clear();
                    break;
            }
        }
spring pond
warm sleet
#

@spring pond oh I lied

#

it was C++

exotic jungle
#

okay then thanks anyway

warm sleet
#

whelp, its arduino

#
#include <DmxSimple.h>

int dmxMessage [3] = { 0, 0, 0};

const unsigned int MAX_CHANNEL = 7;

void setup() {
  initializeSerial(9600);
  DmxSimple.maxChannel(MAX_CHANNEL);
  
}

void loop() {
  if (!handleSerial(dmxMessage)) return;

  switch (dmxMessage[0]) {
  case 2: //SET
    DmxSimple.write(dmxMessage[1], dmxMessage[2]);
    break;
  case 3: //CLEAR
    for (int i = 1; i <= MAX_CHANNEL; i++) {
      DmxSimple.write(i, 0);
    }
  }
}
#

xD

#
  //Instruction
  byte data = Serial.read();
  switch(data) {
    //53 = S (SET)
  case SET: 
    message[0] = 2;
    break;
  case CLEAR:
    message[0] = 3;
    break;
  default:
    clearSerial();
    return false;
  }

  //Channel
  byte ch1 = Serial.read();
  byte ch2 = Serial.read();
  int channel = ch1 + (ch2 << 8);
  //Fixture
  byte fixture = Serial.read();

  //Stop
  if (Serial.read() != STOP) {
    Serial.print("ERR");
    Serial.println();
    clearSerial();
    return false;
  }

  message[1] = channel;
  message[2] = fixture;
#

most of this is quite mundane

#

but yeah, bytes not so scary after all

spring pond
#

well handling serial on the device end wasn't too hard for me, it was doing it on the client side and doing it in a somewhat automatic fashion that was difficult

warm sleet
#

@spring pond for this other project

#

we had a rpi with 4 sensor modules connected over usb

#

and I had to make some feature that could autodiscover what device it was

prime bough
#

I'm started using Zig and it's pretty good language

warm sleet
#

and it was designed to be flexible, support multiple baudrates

prime bough
warm sleet
spring pond
#

i should really start flowcharting lol

warm sleet
#

this is an activity diagram

#

that black bar

#

is a fork node

#

so it does both at same time

#

sends magic data, and waits for a magic response

spring pond
#

makes sense

warm sleet
#

those diamonds

#

are decision nodes

#

and each branch has a tag with a guard, that has the condition

#

ofc, this is all numbered, and there's a written description that goes with it

#

@spring pond formally, this is all UML

#

The Unified Modeling Language (UML) is a general-purpose, developmental, modeling language in the field of software engineering that is intended to provide a standard way to visualize the design of a system.The creation of UML was originally motivated by the desire to standardize the disparate notational systems and approaches to software design...

#

once you get into more complicated systems

#

this stuff becomes useful

spring pond
#

yeah that looks complicated

warm sleet
#

@spring pond activity diagram and component diagrams are my favorites

#

those are the ones I primarily use to describe software

warm sleet
#

so this program defines a simple fuction called print_pressed_keys, think of this as a bit of code that you can ask your program to execute

#

and underneath on line 15

#

it hooks itself to the keyboard and every keystroke is then registered to that function

#

and all the information of the keystroke event, is in that variable e

#
"""
Prints the scan code of all currently pressed keys.
Updates on every keyboard event.
"""
import sys

sys.path.append('..')
import keyboard


def print_pressed_keys(e):
    line = ', '.join(str(code) for code in keyboard._pressed_events)
    # '\r' and end='' overwrites the previous line.
    # ' '*40 prints 40 spaces at the end to ensure the previous line is cleared.
    print('\n' + line, end='')
    print('\n')


keyboard.hook(print_pressed_keys)
keyboard.wait()
#

well

#

there's high level APIs that you should use

#

because then it works on all operating systems

#

python is full of libraries to do small simple things

#

one you know how to define a function

#

and know how to write basic procedural code its actually not that hard

#

maybe 1-2 days of fiddling around

#

if you've never done this stuff

#

thats how I started xD

#

I mostly use python for data processing

#

simple dataprocessing

#

when doing prototyping

astral garnet
#

hey.... anyone have any decent python tutorials for building a discord bot? i made one but it wont talk to me :<

exotic jungle
#

can someone help please, its autoit

#

HotKeySet("{ESC}", "_ExitScript")
While 1
If _IfPressed("02") Then
run ("AutoIt_Script_5.au3", ["C:\Users\JADI\Desktop"])
WEnd

#

the while 1 is not connected to the wend

astral garnet
#

so what are you asking? it reads "when key 2 is pressed run a specific script" ya?

exotic jungle
#

yes

#

the script is not runnnig

#

this is the original

#

#include <Misc.au3>
HotKeySet("{ESC}", "_ExitScript")
While 1
If _IsPressed("01") Then MsgBox(0, "Message", "Mouse Clicked")
WEnd
Func _ExitScript()
Exit
EndFunc

astral garnet
#

~LButton::
MouseGetPos, begin_x, begin_y
while GetKeyState("LButton")
{
MouseGetPos, x, y
ToolTip, % begin_x ", " begin_y "`n" Abs(begin_x-x) " x " Abs(begin_y-y)
Sleep, 10
}
ToolTip
return

#

close the loop in {}

exotic jungle
#

i won't to run it something like this

#

#include <Misc.au3>
HotKeySet("{ESC}", "_ExitScript")
While 1
If _IsPressed("02") Then run ("AutoIt_Script_5.au3", ["C:\Users\JADI\Desktop"])
WEnd
Func _ExitScript()
Exit
EndFunc

astral garnet
#

my example is from the site

exotic jungle
#

I am just looking for a script that runs in the background with autoit an when key combo is pressed a other script lauches.

astral garnet
#

wait auto hot key or is autoit something else?

#

@spring pond thank you. idk why it wont talk to me 😐

#

such is my life 😐

spring pond
#

could be a problem with your tokens

exotic jungle
#

autoit is a like program to auto hot key

#

Hey if you can make it happen with autohotkey please help

#

just looking for a script that runs in the background an when key combo is pressed a other script lauches.

spring pond
#
~LButton::
    If (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 200)
        Run [put your command here]
Return
#

not tested

#

but should work

exotic jungle
#

while this loop, so that everytime i press keycombo it runs the script?

spring pond
#

this is for a double click

exotic jungle
#

oh nice

spring pond
#

fsr thats what i thought you needed, but you can rewrite it to work with any combo

exotic jungle
#

is this correct ??

#

@spring pond ?

astral garnet
#

that looks right but i know auto hotkey not autoit

exotic jungle
#

is there a why to do this in autohotkey

#

$target_window = "2.txt - Kladblok"
$source_window = "1.txt - Kladblok"
; end of user input
WinActivate($target_window, "")
WinWaitActive($target_window, "")
sleep (100)
Send("^v")
sleep (200)
WinActivate($source_window, "")
WinWaitActive($source_window, "")

#

also can there be a copy cmd being instead in the other script so when i double click the copy of the text is made and then it launches the other script

#

???

#

@astral garnet

astral garnet
#

Send, {CTRLDOWN}c{CTRLUP} eh?

spring pond
#

@exotic jungle remove the brackets

exotic jungle
#

I did this

#

~LButton::
If (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 200)
Run, "C:\Users\JADI\Desktop\AutoIt_Script_5.au3"
Return

#

@spring pond how do I make it copy the selected text as I double click??

spring pond
#

you just read from the %Clipboard% variable

#

wait

#

nvm

#

unsure

#

i havent use ahk in a while

charred blade
#

Anyone here has experience with blender? :/

midnight wind
#

@charred blade yeah kinda

charred blade
#

@midnight wind any idea how can I extract the material from an already make .blend file? I have some exports from valorant and I want to change the weapons color but I have no idea how to export only the image

midnight wind
#

huh

#

I don't really understand

#

so the texture?

#

That would be better to do in photoshop/substance painter/quixel mixer

charred blade
midnight wind
#

yeah so the texure

#

I see it is already UV mapped so t hat's good

#

@charred blade so open the image in image editor

charred blade
midnight wind
#

no

#

actually idk

#

been a while since I used blender

bleak breach
tired juniper
#

hey how do I align text anyway I want in CSS? I mean I know the transform:translate works but for the entire enclosure the text is in,if it's in a table with borders around it just doesn't work. Is there some way to apply it to text only in a table?

#

i tried it on the TH element but this moves the whole thing not just the text,the border with it moves as well(<TH> in the table,the title text element)

bleak breach
#

There's a number of ways to move text. Text-indent, margin, padding, and all sorts of fun flex statements which I haven't been bothered to memorise off by heart yet

hollow basalt
#

use Β 

proven wolf
#
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .title {
        text-align: center;
        padding-top: 50px;
        font-family: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS",
          sans-serif;
        font-size: 50px;
      }
      .titleBackground {
        width: 100%;
        height: 200px;
        background-color: lightblue;
      }
      .titleBackground :hover {
        background-color: yellow;
      }
    </style>
  </head>
  <body>
    <div class="titleBackground"><div class="title">Test</div></div>
  </body>
</html>

``` Why is it not all yellow ? I want all the blue to be yellow
vestal glen
#

your selector applies to the .title div on :hover, not .titleBackground, since space means "any child matching what is to the right". So what you want is no space before :hover.

next igloo
#

$(document).ready(function(e) {
$("#stage").click(spawnEnemy);
});

function spawnEnemy(e) {
var enemy = jQuery("<div/>", { class: "enemy" });
enemy.css("top", 50 + "px");
enemy.css("left", 500 + "px");
$("#stage").append(enemy);
}

Can someone help me with this code

#

When you click #stage it will place a div for .enemy

narrow turret
#

@next igloo What issues are you having with it? Do you have styling for the enemy class elsewhere?

next igloo
#

It was something like

#

Width: 16px;
Height: 8px;
Position: Absolute;
Z-Index: 1000;
Background-Color: #444444;

warm sleet
#

@next igloo generally, its easier to prepare styles for each state that your element can be in

#

and then, instead of manually modifying the style inline, you change which classes your element inherits

#

so .css() is generally a bad idea

hollow basalt
#

@warm sleet ping

patent arrow
#

hello is this the right channel to get my code rated?

next igloo
#

I found the problem

#

Bullet.js was not linked in my html

#

And the code works

livid bison
sick dome
#

Does anyone here know linux command line?

hollow basalt
#

i can print hello world in the command line

sick dome
#

I think I figured it out

hollow basalt
#

then he is merely asking

midnight wind
#

but then he is asking to ask

hollow basalt
#

he just asks if he can ask. not asking to ask

#

You're asking people to take responsibility. You're questioning people's confidence in their abilities.
Good quote from the website

midnight wind
hollow basalt
#

yea I got the XY problem from stack over flow

#

since most of the OP are like that

umbral saffron
#

I just got a raspberry pi 4 b

#

What should I make with it

#

Ping me

hollow basalt
#

make a bed

midnight wind
#

@umbral saffron it's a good server

#

You could host some lighter web apps

#

Your own vpn

#

Pi-hole

#

If you really wanted to you could put exsi on it

#

Idk if proxmox supports arm, I think it does

hollow basalt
#

but poor pi if would be used for hypervisor

midnight wind
#

Yeah lol, some people...

unkempt cloak
#

Funny story relating to some python code I was writing.

So I was solving a maths problem through exhaustion and I ended up grabbing a csv with a million lines. It was only 20mb but still thats a lot of lines.

I'm working on an iPad bc... laptops are... idk I just am anywho.

The sheer might of my csv was enough to cripple safari and numbers. Numbers would crash every time i'd try to import it. Safari would stop responding every time i pressed the new tab button (worked fine flipping between existing tabs or by opening them in other ways). I hard reset my device updated it closed every app. Still would not fix it.

I have never seen a 20mb file freak a device out like this without it being malware.

iOS can't handle my big list energy

midnight wind
#

you can develop on ipadOS?

#

or are you using cloud?

umbral saffron
#

They all seem rlly expensive or complicated

midnight wind
#

a radio? that's a new one

#

like as in a smart speaker?

umbral saffron
#

There’s a lot of videos on rails

midnight wind
#

or like an actual radio

umbral saffron
#

A radio

#

Like a ham radio and a pirate radio

#

Look it up on yt

midnight wind
#

hmm, interesting

hollow basalt
#

Yea, as long as you can buy the hw

#

anything is possible

midnight wind
#

just seems like the pi is unnessacary

hollow basalt
#

not really

#

he can use to automate stuff

midnight wind
#

true

hollow basalt
#

or act like a small radio station and spam the neighborhood with his music

#

and wait until the police shows up for broadcasting without permission

midnight wind
#

lol, one of my neighbors did that

#

he broadcast to one of the FM channels so you can listen to the music that his chrismas light show is for

hollow basalt
#

As long as it doesn't reach that far

#

he broadcast to one of the FM channels
Frequency that is reserved for an existing channel or the unused ones?

midnight wind
#

I forgot

unkempt cloak
hollow basalt
crystal tundra
#

Well you can certainly write code in ipados

hollow basalt
#

I mean android has a c++ compiler app

#

so lel

#

what's stopping you

#

it's rather about how fast can you code since onscreen is kinda meh

#

good thing ipad now comes with a keyboard so blurring the lines further

worthy dirge
ivory bear
#

maybe because some of them might not able to run termux due to various reasons... there's many different devices running android and not all of them supported it for one or another or might need workaround etc

next nest
sonic lava
#

I have a general question: I want to make this command line application where it would screen record an iFrame source from a simple html local file, and store it in a designated folder or path. Preferably i would also like to make a scheduled recording feature but I think I could figure that out my self. My question is how to do I get started? I know Java and Python. Any libraries that you guys would recommend for this kind of program? Specifically the iFrame recording, I think I can figure out how to do the rest, but I am really stuck on how to do the recording

hollow basalt
#

sure

umbral saffron
#

if i have a raspberry pi 4 b and a rasbperry pi zero w
what can/should i make

#

(i have no experience with either but i researched it a lot)

hollow basalt
#

you could make a paper weight

umbral saffron
#

smart

midnight wind
#

@umbral saffron make the 4 be a server

#

And the zero needs to send temperature information using http to the server

#

Using the gpio pins and a cheap small temp sensor

#

Later on you could even use databases like influxdb

umbral saffron
#

what

midnight wind
#

@umbral saffron basically have the zero send a temperature sensor reading over a network to the raspberry pi 4 where it can processed in something like a database

#

I'm myself working on something like that, but with an arduino so I have to do some low level network stuff

umbral saffron
#

so like

#

to measure just the temperature?

bleak breach
#

You could do something silly like add a diode that detects light so that if the 4 turns off you automatically restart it with wake-on-lan

midnight wind
#

Pi's have WOL?

bleak breach
#

no 😦

#

You'd have to add something like an esp32 or 8266 to make it happen

next igloo
#
  var bullet = jQuery("<div/>", { class: "bullet" });
  bullet.css("top", ($("#gun").position().top = $("#gun").position().top - 4  + "px"));
  bullet.css("left", ($("#gun").position().left = $("#gun").position().left - 4  + "px"));
  $("#stage").append(bullet);
  var Bulletdirection = (Math.atan2(cursorY - ($("#gun").position().top + 4), cursorX - ($("#gun").position().left + 8)) * 180 / Math.PI);
  $(".bullet").css({transform: "rotate(" + Bulletdirection + "deg)"});
}

//Bullet move

$(document).ready(function(e) {
  gunTimer = setInterval(bulletMove, 1000 / 60);
});

function bulletMove(e) {
  $(".bullet").css("left", ($(".bullet").position().left = $(".bullet").position().left - 5  + "px"));```
#

is anyone good with object oriented js

#

this is for a thing that spawns bullets when you click on screen

#

currently clicking will point the bullet in the direction of the click, and makes it go left since i dont have the formula to make it go in 360 degrees

#

if i fire a second bullet, it will change the direction of the 1st bullet and teleport to it

warm sleet
#

@next igloo javascript isnt object oriented

#

its a dynamic language

#

@next igloo though you can use prototypes for inheritance

#

if you'd like a more powerful language to do OO with, yet still be able to call upon javascript

#

typescript is a good language

next igloo
#

its for a school project, so i have to use javascirpt html and css

warm sleet
#

@next igloo you can create a data container, as an object

#

and add its methods functions as fields properties

next igloo
#

k

warm sleet
#

so think of this

#
var myObject = {
  sound: "bark",
  talk: function() {
    console.log(this.sound)
  }
}

myObject.talk()
#

constructors are much the same way

#

this is useful for creating instances of objects

umbral saffron
#

@midnight wind what about a garage door opener using siri

midnight wind
#

yeah that's would work

umbral saffron
#

i wanted to make a phone thing

warm sleet
#

gg apple ownz your house

warm sleet
#

@umbral saffron do you know about DIY home automation

umbral saffron
#

is this what i think it is

warm sleet
#

Home assistant can be used with all kinds of DIY projects

#

and it integrates with many other platforms

umbral saffron
#

mhm

midnight wind
#

I should deploy that

warm sleet
#

all you ned to get started

umbral saffron
#

is this what i think it is

warm sleet
#

is a raspberry pi

umbral saffron
#

wow i have that

warm sleet
#

@umbral saffron yeah if you then have a controller that say, could talk to your garage door

umbral saffron
#

ik

warm sleet
#

you can use home assistant to set it up

umbral saffron
#

im asking

#

should i make it

#

and

#

i wanna make a screen display thing

#
#

with that

#

if it works

warm sleet
umbral saffron
#

that ones too big

warm sleet
#

I have one of these ^

#

its about the same size of the rpi

#

and you can get cases for it

umbral saffron
#

ok so

#

what i want

#

to make

#

wayyyyyyyyyyy later

#

not rn

#

is a thing

warm sleet
#

yeah but

umbral saffron
#

a helmet

warm sleet
#

what you linked is just a display

umbral saffron
#

with

#

the screen on it

warm sleet
#

but you still need a display controller

umbral saffron
#

yes

#

i know

#

im asking

#

is the screen good

#

i have the other things planned

warm sleet
#

oh yeah, its fine for what it is, and its cheap too

#

the touch isnt the greatest

#

its a bit like the old DS touchscreen

#

finger dont work well

umbral saffron
#

@warm sleet

#

that ones a solid screen

#

compared to the see through OLED

warm sleet
#

I wouldnt get that one

#

drivers are dodgy

umbral saffron
#

ok

warm sleet
#

The ones I have actually have a wiki and documentation

umbral saffron
warm sleet
#

yeah

umbral saffron
warm sleet
#

but thats just the screen

#

again, no controller

umbral saffron
#

ik

#

im gonna try to connect it to a zero w

#

or should i get a 0 WH

warm sleet
#

zero w shouldnt be doing any display stuff ideally

#

its very slow

umbral saffron
#

so the WH would be better

warm sleet
#

WH?

#

Raspberry Pi model B

#

3 or 4

#

4 is nice and fast

umbral saffron
#

i have a 4

#

but that would be too big

#

for just a remot

#

remote

#

so this is better then

warm sleet
#

like

#

what pixel dimensions are you looking for?

umbral saffron
#

idk

#

what i want

#

is a helmet

#

gimme a min

#

lemme find it

#

this helmet

warm sleet
umbral saffron
#

with that raspberry pi

#

and that screen we chose

#

as a prototype thing

#

for a school project

warm sleet
#

I think those controllers use SPI

#

arduinos are kinda underpowered and dont have the stuff you need

#

but most things you can use on an arduino you can do on a raspberry pi

#

rpi has an SPI interface too

umbral saffron
#

yea

warm sleet
#

run home assistant on something like this

#

and then the display program, you just write yourself

#

have it draw directly onto the screen, and then just fetch data from home assistant

umbral saffron
#

so if i have a raspberry pi zero WH
connected to a screen on an arm in front of the left lens
(the screen being the "monitor" running the info)
it would just be that

#

a screen connected to the pi

#

moved over a lens

warm sleet
#

if you wanted an even fancier remote

#

what you could do

#

is get an STM32

#

use that to drive the display

#

stm32 has ultra low power consumption

#

it can idle with micoamperes of current

#

so when you press button

#

you can wake it up

umbral saffron
#

wait is it the board

warm sleet
#

they cost like $2

umbral saffron
#

oh

warm sleet
#

this is a development board

umbral saffron
#

ok

warm sleet
#

but the chip is an arm STM32

#

32 bit microcontroller

umbral saffron
#

so this would replace the rpi

warm sleet
#

yeah it also has all the interfaces

#

and a lot more of them

umbral saffron
#

oh nice

warm sleet
#

its like 5x faster than the atmega328p that the arduino uses

umbral saffron
#

so what does it run then

warm sleet
#

machine code?

#

its an arm microcontroller

umbral saffron
#

i know

warm sleet
#

you program it via usb

umbral saffron
#

but it has to have a software right

warm sleet
#

yeah your program

umbral saffron
#

or am i being dumb again

warm sleet
#

which you compile on your computer, and then upload to the board

umbral saffron
#

oh ok

warm sleet
#

its like arduino

#

but faster and cheaper

umbral saffron
#

ohhh

#

ok

warm sleet
#

its fast enough

#

to handle high framerate displays

#

as long as you dont go overboard with the size

umbral saffron
#

now i have the issue of what to put on it and how to put it on

warm sleet
#

but small oled displays, perfect match

#

@umbral saffron yeah thats why many makers have 3d printer

#

they make their own enclosure

#

for their parts

umbral saffron
#

no i mean how to put the stuff on the screen

warm sleet
#

oh

#

so SPI displays

#

literally you have a pixel coordinate that has some color value

#

and your program just sets that pixel to that color

#

usually you can use a display kit

#

which adds functions for you, so can tell it to draw a line on screen

#

or write text here

#

or display an image

#

but all its really doing is just setting pixels at certain locations to certain color values

#

Generic STM32 board comparison with Arduino Pro Mini or Nano
Currently such cheap STM32 boards (aka "Blue Pill") are available for less than $2.20 on Aliexpress
It is up to 12 times faster than ATMEGA 328 based Arduino, it is even faster than expensive ARM based MCUs like Arduino Duo.

Module specifications:
Model: STM32F103C8T6
Core: ARM 32 Co...

β–Ά Play video
#

This is a funny video

#

first bit is the arduino

#

and halfway they switch to the stm32

late plank
#

Im stuck on a piece of code.. I need to do a function which wont work in js but it does in python but im struggling on calling that pyton function from my javascript. any suggestions?

umbral saffron
#

if it works in python then whats the issue

warm sleet
#

wat

#

@late plank you do realize those are two different languages right?

late plank
#

yes i do

warm sleet
#

can you share a snippet of code?

late plank
#

but my function only works in python. how am i going to call that from javascript?

umbral saffron
#

you dont

warm sleet
#

@late plank short answer is you don't

late plank
#

huh?

umbral saffron
#

python and java dont link

warm sleet
#

but there are some ways to make programs from different languages work with one another

#

common way is using a shell command

#

one program calls the other program

umbral saffron
#

call it through python then

late plank
#

ive tried so using flask

warm sleet
#

wat

late plank
#
import requests

HEADERS = {
    'User-Agent': 'android/6.29.3 Model/phone Android/7.0-API24',
    'Host': 'ms.ah.nl',
}

response = requests.post(
    'https://ms.ah.nl/create-anonymous-member-token',
    headers=HEADERS,
    params={"client": "appie-anonymous"}
    )
print(response.json())

I need to run this in python

warm sleet
#

lol

#

I got albert heijn like 200 meters down the road

late plank
#

lol

warm sleet
#

yeah, so you want to do this, but in javascript?

late plank
#

if you can..

warm sleet
#

This is what you use in the browser

late plank
#

i couldnt get the Host to work, googled it and js is blocking that it seems

warm sleet
#

not sure if you you are using node

late plank
#

nope

warm sleet
#

@late plank that's probably a CORS rule blocking you

late plank
#

yes..

warm sleet
#

yeah, the webserver that provides the page that loads the js, has to provide CORS policies in the HTTP header

late plank
#

but the piece of python code worked.. so i wondered if i could call it through python

warm sleet
#

you can set them to allow anywhere

#

@late plank yeah the code in js you have probably works fine with xhr

#

but the webbrowser is blocking it

#

Its to prevent cross-origin-resource-sharing

late plank
#

and the fetch request doesnt work if the Host isnt passed through

warm sleet
#

yes

#

thats normal for HTTP/1.1

late plank
#

is there any way its possible to do what i want?

warm sleet
#
function reqListener () {
  console.log(this.responseText);
}

var oReq = new XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "http://www.example.org/example.txt");
oReq.send();
late plank
warm sleet
#

most of these APIs are just REST apis

#

you can either use the library they provide

#

or make your own requests

late plank
#

I can access jumbo's api

#

albert heijn doesnt have a publicly accessible api if im right

warm sleet
#

mh

late plank
#

but with the python code you could request a token which allows you to make an api request

warm sleet
#

Does AH do some kind of rate limiting?

#

I've had to connect to things like the maps API, which is quite restrictive if you ask it to route calculations

#

was for a ride sharing service, so we actually cached many of our responses

#

then you can provide your own API

#

which your software uses

late plank
#

I need to access their api to look if my barcode is any of their products. (for a school project)

warm sleet
#

right

#

that shouldnt be too hard

#

probably single request

#

to their API

late plank
#

yes, not often

warm sleet
#

but question is, do they require an API key

#

and do they have rate limits

#

caching results locally, is wanted anyways.

#

you don't want to always do a lookup at the source, everytime you scan the barcode

late plank
#

i do have it working for jumbo, ean search, barcodeapi, openfoodsearch

umbral saffron
#

wait @warm sleet sorry ur busy with that but what was the final screen u said was the best

warm sleet
#

@umbral saffron you mean the video?

late plank
#

but I'd like to atleast include plus or ah (or both XD)

umbral saffron
#

noo

#

not the board

#

the screen

late plank
#

but if I look at how this is done:

def get_product_by_barcode(self, barcode):
        response = requests.get(
            'https://ms.ah.nl/mobile-services/product/search/v1/gtin/{}'.format(barcode),
            headers={**HEADERS, "Authorization": "Bearer {}".format(self._access_token.get('access_token'))}
        )
        if not response.ok:
            response.raise_for_status()
        return response.json()

He requests an access token (elsewhere in the code, which doest work in js due to the header error) and then makes a request to the api of ah

warm sleet
#

@late plank you should use nodejs for this to host your app

#

it spawns a small webserver

#

which returns you the page

#

and it can expose your api, while keeping the auth tokens to the API from AH private

late plank
#

I currently run on laravel

warm sleet
#

well

#

if you run this stuff not in a browser

#

but in a local execution environment

#

you wont have that CORS issue

#

has nothing to do with javascript

late plank
#

So i should make it back-end?

warm sleet
#

and everything to do with the browser

#

yeah, things like these, are always backend

late plank
#

in the end itll be anyway ( i think)

#

the idea is that an arduino scans a product, sends the barcode to the server which adds the requested bracode+data to a database

warm sleet
#

yeah something like an sql database

#

or redis

late plank
#

mySql was i thinking of

warm sleet
#

you can use redis

#

and store the entire response from the API in your database

#

add a date to it, everytime you go to look up the data, it checks the age of the hash, if its too old, gets a new one from the source

#

Redis has libraries that allow you to just store json directly

#

and then search that

late plank
warm sleet
#

yeah, but do you really want to query that EAN code everytime?

late plank
warm sleet
#

that's fine

#

then parse & toss in sql

late plank
#

later the arduino should somehow make a request to the server and passing on the barcode

warm sleet
#

also store a record if it couldnt find it, and add the age to it too

late plank
#

yeah I need to add the date to it too

#

but i was first working on getting the api's to work

warm sleet
#

unless you can query the AH api for an EAN directly

#

i dont see why you wouldn't be able to do this

late plank
#

you first need to gain an access token

warm sleet
#

yeah as with every other API in existence

late plank
#

somehow jumbo doesnt

warm sleet
#

yeah not every company has public APIs

#

those APIs cost compute time too ;)

late plank
#

XD

#

So if I shift it all back-end, it should work?

warm sleet
#

did you ever get a successful request from the AH api?

#

in any environment

late plank
#

Only key outputs

warm sleet
#

ok so it has what you need

#

good

#

what you can do is the following

#

provide one web API yourself, which you can give a 'search' with an EAN input

late plank
warm sleet
#

and that, internally, has a list of supermarkets, which it queries the database for

#

if it cannot find a record for a database, or it is outdated, it will query it from the source

#

all this ^ is serverside

#

and then finally

#

your webinterface

#

in html, js and css

late plank
#

yeah, just reading out a database mysql

warm sleet
#

your web api, also has a path like you have / which gives you the .html, and then you have /dist/program.js

#

the program.js is referenced by the html, and it calls the api on /api

#

and /api is dynamic, everything else static

#

usually you keep static stuff in a seperate directory

#

all the images, css styles and crap

#

and the api in /api

#

so you can do /api/search/12321312321312312

late plank
#

yeah sth like that is what i need i think

warm sleet
#

which just returns you a json response, with

#

formatter

#

sec

late plank
#

but im not that good in this as you are, could you help me a little bit with setting up the main bits?

warm sleet
#
{
  "supermarkets": [
    {
      "name": "ah",
      ...bla
    },
    {
      "name": "plus",
      ...bla
    }
  ]
}
#

this kind of response is what you'd want

#

@late plank most of my expertise is in java

#

but all of this is the same other languages

#

what language are you most comfortable with?

late plank
#

ooh, it doesnt matter which supermarket the product is from, I need to find what the product's name is when im being given the barcode

#

java

#

done that the most so far on study

warm sleet
#

This is an incredibly simple webserver

#

I've used that one before to make websites

#

with spark

#
    public void start(Injector injector) {
        service = Service.ignite();
        service.port(properties.getPort());
        service.staticFileLocation("/static");
        provider.getRoutes(injector)
                .forEach(this::register);
    }
#

Yeah this is like the minimal amount of code

#

and all the frontend stuff

#

are in the resources

late plank
#

Or should I use php and laravel to backend fetch the data from ah?

distant tartan
#

ooo programming. This might be my kind of place

late plank
late plank
#

@warm sleet i got it working hehe, i used a backend php script which i called through a get request. I was then able to generate a token and use that in the ah servers

bleak breach
#

@late plank you can just use if($products['data']) because an empty array coerced to a boolean is false. If you want to be super explicit you could do something like if(is_array($products['data']) && count($products['data']) > 0))

tawny sequoia
#

hey, just want to sak. How long does npx create-react-app my app or yarn create react-app my-app usually take?

#

cause I've been sitting here waiting for 20 minutes

hollow basalt
#

so it's not reacting at the right time

tawny sequoia
#

ya

#

it just sits at
Installing 'react', 'react-dom', (blah blah blah)

umbral saffron
#

how do i connect a button to an rpi

#

like i know how using a breadboard

#

but how would i put it on something else

#

like for example if i was making a remote

#

pls dm me bc im going to bed and by then ill have to scroll rlly far

#

gn

hollow basalt
#

how do i connect a button to an rpi
Connect it like any other button

distant tartan
wind oracle
#

hi

#

I need help

#

in java

midnight wind
#

@umbral saffron give me a bit, it should be the same as arduino, but there are multiple ways

umbral saffron
#

ok thanks

next igloo
#
60 $(document).ready(function(d) {
61   $("#stage").click(spawnBullet);
62 });
63 
64 function spawnBullet(d) {
65   if (ammo >= 1) {
66     ammo--;
67     var bullet = { bulletMove: function(e) {
68       this.css("top", ($("#gun").position().top = $("#gun").position().top - 4  + "px"));
69       this.css("left", ($("#gun").position().left = $("#gun").position().left - 4  + "px"));
70       $(this).css({transform: "rotate(" + (Math.atan2(cursorY - ($("#gun").position().top + 4), cursorX - ($("#gun").position().left + 20)) * 180 / Math.PI) + "deg)"});}, class: "bullet" };
71     $("#stage").append(bullet);
72   }
73 
74 $(document).ready(function(e) {
75   gunTimer = setInterval(bulletMove, 1000 / 60);
76 });
77
78 function bulletMove(e) {
79  $(".bullet").css("left", ($(".bullet").position().left = $(".bullet").position().left - 5  + "px"));
80 } }```
#

when you click on screen, a should spawn

#

at the location of the gun, and it will point at the cursor

#

then it will move left forever

#

but it wont spawn, can someone help?

midnight wind
umbral saffron
#

thanks

silver furnace
#

I just go with it because frontend

#

Then again, it's on click.

#

Check your browser console. Do you get Uncaught ReferenceError: ammo is not defined

#

Or did you just not paste the entire code

next igloo
#

i did not paste the entire thing

#

which is why its starts at line 60

umbral saffron
#

is there more after that

next igloo
#

no

#

before is a script handling a hud showing the time, health and ammo of the user

tepid orchid
#

any flutter devs here?

nocturne galleon
#

anyone know how to code a script which when a button is pressed it will generate a random combo of letters and numbers and copy it to clipboard?

spring pond
#

this just does numbers but you could add letters pretty easily

nocturne galleon
#

how would i do that ? i have no clue on coding

spring pond
#

let me look into it

nocturne galleon
#

cheers

spring pond
# nocturne galleon cheers
R::
    clipboard := UUIDCreate()
    
UUIDCreate(mode:=1, format:="", ByRef UUID:="")
{
    UuidCreate := "Rpcrt4\UuidCreate"
    if InStr("02", mode)
        UuidCreate .= mode? "Sequential" : "Nil"
    VarSetCapacity(UUID, 16, 0) ;// long(UInt) + 2*UShort + 8*UChar
    if (DllCall(UuidCreate, "Ptr", &UUID) == 0)
    && (DllCall("Rpcrt4\UuidToString", "Ptr", &UUID, "UInt*", pString) == 0)
    {
        string := StrGet(pString)
        DllCall("Rpcrt4\RpcStringFree", "UInt*", pString)
        if InStr(format, "U")
            DllCall("CharUpper", "Ptr", &string)
        return InStr(format, "{") ? "{" . string . "}" : string
    }
}

Generates strings like 1e3ceb5c-75ae-4e5b-9e07-1f824339963d

nocturne galleon
#

damn thats very complex

spring pond
#

i just copied the big part from a website lol

nocturne galleon
#

oh haha right right

spring pond
#

you can change the R:: to any key that you want

nocturne galleon
#

oh right so when i press R that will auto copy?

#

so i can make a macro that goes

#

R + ctrl v

#

and that will paste? the code looking thing?

spring pond
#

thats what you currently have to do

#

yes

nocturne galleon
#

thanks <3

spring pond
#

if you want you could make it any key combo you want

#

np

nocturne galleon
#

cheers g

nocturne galleon
#

looking for a fairly experienced person who knows how to write scripts/macros for a fun lil project im doing :D dm me! (it should be quite simple)

viscid parrot
next igloo
#
61 $(document).ready(function(d) {
62   $("#stage").click(spawnBullet);
63 });
64
65 function spawnBullet(d) {
66
67   function bullet(){
68     this.bullet = new Sprite();
69     this.bullet.hide();
70     this.bullet.fire = function(){
71     this.show();
72     this.move($(this).css("left", ($(this).position().left = $(this).position().left - 5  + "px")));
73     this.setPosition(($("#gun").position().left = $("#gun").position().left - 4  + "px").x, ($("#gun").position().top = $("#gun").position().top - 4  + "px").y);
74     this.setAngle($(this).css({transform: "rotate(" + (Math.atan2(cursorY - ($("#gun").position().top + 4), cursorX - ($("#gun").position().left + 20)) * 180 / Math.PI) + "deg)"}));
75     } 
76   };
77  
78   function init(){
79     bullet = new Bullet();
80   };
81  
82   function update(){
83     bullet.update();
84   };
85  
86   function bulletMove(e) {
87     bullet.move
88   }
89 };
91
92 $(document).ready(function(e) {
93   gunTimer = setInterval(bulletMove, 1000 / 60);
94 });
#

did i code this right

#

lines 61-65 run and 92-94 correctly

#

function spawnBullet(d) will run but there seems to be a runtime error in the code there

#

Sprite() on line 68 is being detected as an undeclared variable

#

along with Bullet() on line 79

#

the purpose of the code is that when you click a bullet will appear, and you are able to shoot multiple bullets

vestal glen
#

well, there is no Sprite or Bullet in this code snipet.

fluid kernel
next igloo
#

im not exactly sure what the syntax is for spawning a sprite

#

but Sprite() and Bullet() are not variables

fluid kernel
#

then what are they? that's where the issue is, figure that out and you'll get to the bottom of it.

next igloo
#
#

so im not sure the specifics of init, new, and a few other things

vestal glen
#

those are constructors, so a thing you can create an instance off. They may either look like functions (with a prototype for methods) or use the class syntax. Either way, they're a thing you need to have somewhere (or something like a library needs to provide)

next igloo
#

alright

stiff rose
#

how to add rss feed in Gmail? is jt possible?

#

I can't find any proper answers

umbral saffron
#

would there be any way for me to make a button connected to a raspberry pi but not directly connected to a breadboard

umbral saffron
#

like whats the end project

umbral saffron
#

oh ok

#

so for example if i wanted a button in a glove i'd just connect it and run it down the arm

#

cool

#

whats that called

spring pond
#

i just googled pc power switch

#

you could probably find a more robust one if you google for a bit

umbral saffron
#

ok

spring pond
#

alibaba and the like are your best friend for these

umbral saffron
#

thanks

#

this is adafruit but would this work?

#

@spring pond

spring pond
#

yes

umbral saffron
#

ok

spring pond
#

those have the resistor built in

umbral saffron
#

so is that better?

midnight wind
#

@umbral saffron yeah

#

remember the arduino thing I posted to you

#

here the resitor is built-in

umbral saffron
#

what does it do

#

the resistor

midnight wind
#

limit current, you don't want to burn out your pi

#

also the adafruit is a different curcuit

umbral saffron
#

i have no idea what that means

midnight wind
#

read up on that site

#

you have to learn a little bit of electrical engineering

#

basically you would hook up vcc to 5v, gnd to gnd, and the signal pin to your pi with those adafruit buttons

umbral saffron
#

couldnt i just connect the button to the cable and the cable to a breadboard and the breadboard to the pi?

#

or if thats what u said i dont know what u meant

midnight wind
umbral saffron
#

wdym i need to specify

midnight wind
#

what you connecting and where

umbral saffron
#

i get i need to plug it in to the right hole

midnight wind
#

you don't need a breadboard if you use those adafruit buttons

umbral saffron
#

oh

#

cool

midnight wind
#

why did you think you need a breadboard?

umbral saffron
#

idk
for all the things i saw when they connected the buttons to a breadboard

midnight wind
#

yeah, because it's easy

#

but a connection is a connection

umbral saffron
#

so what do i do

midnight wind
#

I'm just clarifying you don't need a breadboard

umbral saffron
#

oh ok

#

so how do i connect it then

midnight wind
#

I would reccomend you use a breadboard

#

but you could crimp some of these on

#

and connect to gpio

#

the adafruit thing comes with male connectors

umbral saffron
#

so the buttons connect into the cable and the cable to the rpi 0?

midnight wind
#

you could, there are many options

#

I may be confusing you

umbral saffron
#

yes

next igloo
#

Does anyone know if discord bots can type a command into a text channel, and have it be read and excuted by a different bot

umbral saffron
#

bots cant interact with other bots

#

their text is just that

#

text

hollow basalt
nocturne galleon
pliant siren
# umbral saffron bots cant interact with other bots

Really? Wouldn't your bot see it as a message? I haven't tried but I don't remember seeing anything in the API that specifies that a message sent by a bot won't be interpreted by other API users as a message.

#

I use discord.js so I'm not sure how much of it is abstracted away but I would think it would appear just as any other message:

discord.on('message', message => {
if (message.channel && message.channel.name) {

umbral saffron
#

it doesnt work

fervent orbitBOT
umbral saffron
#

oooooo

#

cool

next igloo
#

can humans interact with humans?

umbral saffron
#

i cant

nocturne galleon
#

Can air interact with air?

umbral saffron
#
umbral saffron
#

or couldnt i just use the microHDMI to HDMI port?

stiff rose
proven lodge
#

I don't know if u have ever used playsound, in python, but it works fine alone but doesn't work when it's in a class

#

How do i define it or give it an attribute in a class?

umbral saffron
#

(idk if github has an import thing considering how large it is)

stiff rose
#

I can write code for that but it's available in outlook so I thought Gmail will have it and then I will add gmail widget to the screen that way I can see it right on home screen

umbral saffron
#

so email urself in outlook

stiff rose
#

πŸ˜‚ I don't like outlook ads, and personal subscription cost is too high for individual and my family don't care about this things so family plan is not good for me.

umbral saffron
#

i dont have to pay for it?

astral garnet
#

k.. i give up... why

#

apt-get install python-bs4 pip install beautifulsoup
SyntaxError: invalid syntax

#

😐

umbral saffron
#

r u using python>

#

?

astral garnet
#

yes

umbral saffron
#

what are u trying to do

astral garnet
#

its in the consol

umbral saffron
#

ah

#

what r u trying to do

astral garnet
#

install the package

stiff rose
#

apt-get install python-bs4 && pip install beautifulsoup

#

try this

astral garnet
#

apt-get install python-bs4 && pip install beautifulsoup
File "<stdin>", line 1
apt-get install python-bs4 && pip install beautifulsoup
^
SyntaxError: invalid syntax

umbral saffron
#

what are u trying to install

astral garnet
#

beautifulsoup

stiff rose
#

just fire pip install beautifulsoup

astral garnet
#

pip install beautifulsoup4
File "<stdin>", line 1
pip install beautifulsoup4
^
SyntaxError: invalid syntax

#

like idk why it wont work

stiff rose
#

pip3 install beautifulsoup

#

you have python3 probably

astral garnet
#

keeps saying "install" is invalid syntax

stiff rose
#

try pip3 install beautifulsoup

astral garnet
#

maybe it doesnt exist...

stiff rose
#

oh

umbral saffron
#

wouldnt it be

import beautifulsoup
Beautifulsoup_API = beautifulsoup.Client("apigoeshere")```
stiff rose
#

oh on you have to exit first

#

exit() then on normal terminal

#

try pip3 install beautifulsoup

astral garnet
#

exit just closes the console

umbral saffron
#

import beautifulsoup
Beautifulsoup_API = beautifulsoup.Client("apigoeshere")

#

its this

#

it should be

#

oh wait

#

like that

stiff rose
#

yes open normal terminal and then install beautifulsoup first tgen open python terminal and do whatever you want

astral garnet
#

yeah idk doesn't work

#

i give up

#

imma try a different tutorial

umbral saffron
#

what is ur end goal

stiff rose
#

it should work

umbral saffron
#

you did import

#

but did u check the package was installed

#

and did u ever call it or use any of it?

#

@astral garnet

#

and yj going back to ur thing could u just make a bot to email to ur gmail acc a specific github feed?

astral garnet
#

doesn't work gives me same errors

#

wont let me import

#

something else may be wrong

umbral saffron
#

@astral garnet go to settings, go to the name of the project near the bottom, go to project interpreter, then hit the plus and type in BeautifulSoup

#

THEN run the command i gave u

astral garnet
#

what settings?

#

its a console

umbral saffron
umbral saffron
astral garnet
#

i'm uninstalling python and reinstalling

umbral saffron
#

ok but under file, theres a setting option

stiff rose
umbral saffron
#

oh

#

idk then

stiff rose
umbral saffron
#

ye

#

just make sure u fully installed it

stiff rose
#

just let me know what you want

#

python tutorials are popular anyways

umbral saffron
#

its not that hard

#

open settings

#

open project settings

#

go to interpreter

astral garnet
#

there isn't a "settings"

umbral saffron
#

do u know where the file option is at the top

#

ah

astral garnet
umbral saffron
#

nvm then

#

idk then

stiff rose
#

it's so easy

astral garnet
#

doesn't work

stiff rose
#

ok so only one possible reason

#

while installation you didn't checked

astral garnet
stiff rose
#

add python to path

#

wait

#

I'll tell you

#

C:\Python34\Scripts\pip install beautifulsoup

#

try this

#

instead of python 34 use your directory

#

Python39 I suppose

#

issue is your pip isn't in path

#

check if it's installed or not using

#

py -m pip --version

spring pond
#

@astral garnet what are you trying to do

warm sleet
#

@astral garnet you can manage dependencies to libraries from within your pycharm environment

#

Its under File -> Project Settings

#

or use pip manually to install the packages

astral garnet
#

don't worry about it. i got them installed

#

there isn't a project settings and all that because i'm using the python ide

warm sleet
#

Pycharm is still my preferred editor

umbral saffron
#

ye thats what i use

stiff rose
#

vscode is good too, I don't know why everyone suggests pycharm

midnight wind
#

vscode isn't a full ide

#

I like it myself

#

but that leads to people not really understand what is happening behind the scenes

#

"In works in my IDE"

#

setting up a cpp enviroment for vscode was a pain

#

but I learned a lot

spring pond
#

i've set up a fair amount of environments for c++ and i get that its good to know whats happening but at a point it just becomes a pain. tbh the horrors of cmake have kinda turned me off from writing c++

midnight wind
#

yeah

#

after a point I understand

#

but it's good to once set it up yourself

warm sleet
#

@midnight wind generally I try to set up my IDE environment in a way, that I can use terminal if I wish

crystal tundra
#

but its rewarding

#

bc that means im not stuck to an ide anymore

shy helm
#

Is anyone doing Advent of Code this year??

west perch
next igloo
#

is there an online tool where you can type a list and it will convert it to an array

midnight wind
#

this looks nice

next igloo
#

each cell is supposed to hole 1 string, thats it

#

that one does not seem to do the specific task i had

#

wait nvm

next igloo
#

how can i declare a JSON array?

#

will Thing = [] work?

midnight wind
#

anyone know javascript well? I'm kinda a noob and for some reason this code isn't working. Specifically, on line 64, it says localImage is undefined. I have tried debugging and all sorts of stuff but it still says it's undefined. The getImages() function works and it's doing it function, the problem is that it's not passing it's data on. imagesFunc object does have the correct values since I check thought the debugger. I'm really stuck right now and I looked everywhere. Some JS tips would be appreciated. I know the naming is terribly. Maybe this is an xy question issue idk. Here is the link to my github gist: https://gist.github.com/PresentMonkey/2d12522c5599e873ea336ca65354586c

Gist

GitHub Gist: instantly share code, notes, and snippets.

#

@next igloo ```json
"thing":[
"thing1",
"thing2"
]

#

In js ```js
var thing = {
thing : [
1,
2,
"string",
false

]

}```

vestal glen
#

@midnight wind well, localImages has the value of this.images, which is probably undefined with your code. It seems there's some bits that would change that, but the code would still not work, since you're trying to access a property of this.image and then a subproperty of that, so you'd need that object structure there.

#

I guess the core issue is treating async code as sync.

pliant siren
#

uhh... when is update() called? From what i can see that code might be getting called thousands of times over.

#

You're adding an event for on state change every time you call update().

#

I can't see anywhere that update() is called so I assume it's called externally?

#

also, why are you defining getImages inside your constructor? YOu have a lot of async calls in there, so when getImages returns, imagesFunc won't be populated.

#

Basically, you're calling getImages, making an async call off to fetch the path passed in, returning an object that at that time is likely empty (unless it miraculously completes insanely quick - not gonna happen), THEN populating the variable only once that async call comes back.

marsh oasis
#

hey guys whats pippity poppin
so this is what I'm trynna do and I need help lmao
Got a python script that does some basic GPIO mainpulation on my RPi
simple stuff turns a switch on/off
I got a python server as well that sends and receives TCP packets from what should be an app
the goal here is someone clicks a button on the "app", the app sends TCP packet to python server, server receives the packet and notifies my script on the RPi of the switch status
Currently, using android studio to simulate the app which is in java
Problem I'm facing is that its not receiving/sending anything to the python socket
The sockets working all good and fine and receiving and sending messages like it should be, but goddam Android Studio isnt receiving them OR sending anything when a click is initiated by the user
Is there another alternative here? Something I can use beside stupid Android Studio to make this app work in sync with the py server
kinda on a crunch here with ha tight deadline, the easier and more straightfoward it is the better
ah, one last thing, the server and the script read and write data to/from a cloud in the middle
So lets say you click a button on the app, App sends message to server, server receives the message and writes the status of the switch on the cloud, py script locally on the RPi reads the status from the cloud and does what needs to be done (aka flip a switch lol)

hollow basalt
#

hey guys whats pippity poppin
no

pliant siren
#

python
no

hollow basalt
#

python
yes

bleak breach
#

@marsh oasis you’d have to be wayyy more specific about the parts for anyone to be of any help to you

#

When you say you’ve confirmed the socket works, how did you confirm it and from which end? Send or receiving end?

marsh oasis
#

Sending end

#

not receiving anything

#

@bleak breach

bleak breach
#

Being TCP is the app initiating the connection I assume?

marsh oasis
#

yup it is

#

what i'm guessing now is

#

the emulators IP is not static

#

or its different from the network I'm on

bleak breach
#

Emulators IP shouldn’t need to be static... only the address of the server needs to be

marsh oasis
#

Servers IP is static

bleak breach
marsh oasis
#

I'll be checking that out

#

done, so its all setup correctly now

#

But still no help

#

let me paste some of these codes

bleak breach
#

Maybe dm me? No point spamming everyone

midnight wind
#

@vestal glen @pliant siren thanks, yeah I had a suspicion it was something to do with async/sync. I'm too used to the c/cpp way of doing things

umbral saffron
#

would it be worth it to buy a watch controller for the helmet

#

it would just swap between the cameras, turn on the flashlight, and i guess connect the screen

next igloo
#

how can i get a node terminal in vs code?
i have node.js installed

hollow basalt
#

you do it like a python terminal

next igloo
#

?

#

im not using python

#

the setup i have is for discord.js

hollow basalt
#

interesting

next igloo
#

right now i cant get the bot to go online or the code to make it work to work

#
const Discord = require("discord.js");
const client = new Discord.Client();

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`)
});

client.login(aaaaaaaaaaaaa);
#

and i have both json packages installed

next igloo
#

thanks

#

it was that easy? lol

midnight wind
#

to run the script just do node file.js

hollow basalt
midnight wind
#

if you want to be more advanced create a launch.json for vscode

#

so you can debug as well

#

instead of doing console.log

#

this is my launch json for example:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Server",
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "program": "${workspaceFolder}\\server.js"
        },
        {
            "name": "Launch localhost",
            "type": "firefox",
            "request": "launch",
            "reAttach": true,
            "url": "http://localhost:3000/",
            "webRoot": "${workspaceFolder}"
        }
    ]
}
next igloo
#

unexpected identifier

#

node app.js
"app"

midnight wind
#

oh

#

node .\app.js

#

try that

umbral saffron
#

would it be worth it to buy a watch controller for the helmet
it would just swap between the cameras, turn on the flashlight, and i guess connect the screen

midnight wind
#

@next igloo you have to be in the right folder too

next igloo
#

didnt work even with the correct and incorrect slash

hollow basalt
#

can you show your terminal then

midnight wind
#

are you in the vscode terminal?

next igloo
#

yes

hollow basalt
#

time to screenshot

next igloo
hollow basalt
#

I see

#

you are inside the actual node

#

that doesn't work cause you need to execute node in the terminal

#

however you are inside node REPL