#development
1 messages Β· Page 60 of 1
^
since you want to sort by goals you could use something like quick sort, insertion sort, selection sort, or any other algo

@spring pond https://i.imgur.com/aRSDJ7Z.png
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 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()
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 ??
@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
yeah ik
lol my first embedded project, I built a serial protocol
in essence, I built an RGB controller
nice
that could dim 512 channels between values of 0-255
lemme see if I can find the screenshot of the UI
@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
Free keyboard macro program. Supports hotkeys for keyboard, mouse, and joystick. Can expand abbreviations as you type them (AutoText).
@spring pond https://i.imgur.com/tV0aMYJ.png
forms project i see
cool
and they communicated over usb serial
i think i messed around with serial a little while ago, definitely not my favorite thing to code for lol
xD
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
@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
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
@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;
}
}
well i cant really help with autoit but gl
okay then thanks anyway
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
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
@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
I'm started using Zig and it's pretty good language
and it was designed to be flexible, support multiple baudrates
@spring pond https://imgur.com/HBahMYv
i should really start flowcharting lol
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
makes sense
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
yeah that looks complicated
@spring pond activity diagram and component diagrams are my favorites
those are the ones I primarily use to describe software
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
hey.... anyone have any decent python tutorials for building a discord bot? i made one but it wont talk to me :<
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
so what are you asking? it reads "when key 2 is pressed run a specific script" ya?
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
~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 {}
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
my example is from the site
I am just looking for a script that runs in the background with autoit an when key combo is pressed a other script lauches.
wait auto hot key or is autoit something else?
@spring pond thank you. idk why it wont talk to me π
such is my life π
could be a problem with your tokens
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.
~LButton::
If (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 200)
Run [put your command here]
Return
not tested
but should work
while this loop, so that everytime i press keycombo it runs the script?
this is for a double click
oh nice
fsr thats what i thought you needed, but you can rewrite it to work with any combo
that looks right but i know auto hotkey not autoit
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
Send, {CTRLDOWN}c{CTRLUP} eh?
@exotic jungle remove the brackets
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??
you just read from the %Clipboard% variable
wait
nvm
unsure
i havent use ahk in a while
Anyone here has experience with blender? :/
@charred blade yeah kinda
@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
huh
I don't really understand
so the texture?
That would be better to do in photoshop/substance painter/quixel mixer
i'm referring at this
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
like this?
no
actually idk
been a while since I used blender
@charred blade https://youtu.be/v7vdpiPV-3E?t=412
In this Episode I will show you some basics of textures and how to export textures from blender.Sorry for ending lags if you get any problems in the explanation feel free to comment and I will answer in the message.
Hoping it will help some people.
Next week I will talk about going to packing maps and going to ue4.It is already recorded as well ...
Thought y'all might like this video I found in my twitter timeline:
https://www.youtube.com/watch?v=RjEUzCpyWGA
UE4 using niagra
Packed my fluid simulation and renderer into one single Niagara system, which unlocked so many magic tricks
twitter thread:
https://twitter.com/Vuthric/status/1331758077968744452
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)
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
<!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
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.
$(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
@next igloo What issues are you having with it? Do you have styling for the enemy class elsewhere?
It was something like
Width: 16px;
Height: 8px;
Position: Absolute;
Z-Index: 1000;
Background-Color: #444444;
@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
@warm sleet 
hello is this the right channel to get my code rated?
Looking for ppl to stress test my new Twitter bot. It plays any tagged youtube video on an LCD screen inside my computer. Plz send your worst.
https://twitter.com/ShittyVideoBot
Does anyone here know linux command line?
i can print hello world in the command line
what if he wants to know if he can ask
then he is merely asking
but then he is asking to ask
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
@hollow basalt this one is relevant too https://xyproblem.info/
Asking about your attempted solution rather than your actual problem
make a bed
@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
but poor pi if would be used for hypervisor
Yeah lol, some people...
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
I wanted to make a radio but like
They all seem rlly expensive or complicated
Thereβs a lot of videos on rails
or like an actual radio
hmm, interesting
just seems like the pi is unnessacary
true
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
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
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?
I forgot
Develop is a strong word... but you can straight up write python there's apps that let you do it. I don't know about other languages
#development is an even stronger word
Well you can certainly write code in ipados
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
Why use that stupid app when you have termux
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
progress
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
sure
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)
you could make a paper weight
smart
@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
what
@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
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
Pi's have WOL?
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
@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
its for a school project, so i have to use javascirpt html and css
@next igloo you can create a data container, as an object
and add its methods functions as fields properties
k
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
@midnight wind what about a garage door opener using siri
yeah that's would work
i wanted to make a phone thing
gg apple ownz your house
@umbral saffron do you know about DIY home automation
is this what i think it is
yes
kinda
Home assistant can be used with all kinds of DIY projects
and it integrates with many other platforms
mhm
I should deploy that
all you ned to get started
is this what i think it is
is a raspberry pi
wow i have that
@umbral saffron yeah if you then have a controller that say, could talk to your garage door
ik
you can use home assistant to set it up
im asking
should i make it
and
i wanna make a screen display thing
Order today, ships today. AMG240128PR-G-W6WFDW β Graphic LCD Display Module Transflective Black FSTN - Film Super-Twisted Nematic Parallel 4" (101.60mm) 240 x 128 from Orient Display. Pricing and Availability on millions of electronic components from Digi-Key Electronics.
with that
if it works
that ones too big
I have one of these ^
its about the same size of the rpi
and you can get cases for it
yeah but
a helmet
what you linked is just a display
but you still need a display controller
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
@warm sleet
that ones a solid screen
compared to the see through OLED
ok
this one
yeah
so the WH would be better
i have a 4
but that would be too big
for just a remot
remote
so this is better then
with that raspberry pi
and that screen we chose
as a prototype thing
for a school project
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
yea
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
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
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
wait is it the board
they cost like $2
oh
this is a development board
ok
so this would replace the rpi
oh nice
its like 5x faster than the atmega328p that the arduino uses
so what does it run then
i know
you program it via usb
but it has to have a software right
yeah your program
or am i being dumb again
which you compile on your computer, and then upload to the board
oh ok
its fast enough
to handle high framerate displays
as long as you dont go overboard with the size
now i have the issue of what to put on it and how to put it on
but small oled displays, perfect match
@umbral saffron yeah thats why many makers have 3d printer
they make their own enclosure
for their parts
no i mean how to put the stuff on the screen
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
@umbral saffron https://www.youtube.com/watch?v=5mDnKBNl9sY
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...
This is a funny video
first bit is the arduino
and halfway they switch to the stm32
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?
if it works in python then whats the issue
yes i do
can you share a snippet of code?
but my function only works in python. how am i going to call that from javascript?
you dont
@late plank short answer is you don't
huh?
python and java dont link
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
call it through python then
ive tried so using flask
wat
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
lol
yeah, so you want to do this, but in javascript?
if you can..
This is what you use in the browser
i couldnt get the Host to work, googled it and js is blocking that it seems
not sure if you you are using node
nope
@late plank that's probably a CORS rule blocking you
yes..
yeah, the webserver that provides the page that loads the js, has to provide CORS policies in the HTTP header
but the piece of python code worked.. so i wondered if i could call it through python
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
and the fetch request doesnt work if the Host isnt passed through
is there any way its possible to do what i want?
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();
https://github.com/bartmachielsen/SupermarktConnector
The piece of code i sent was created from this, ever since i need to have this working on my website
most of these APIs are just REST apis
you can either use the library they provide
or make your own requests
I can access jumbo's api
albert heijn doesnt have a publicly accessible api if im right
mh
but with the python code you could request a token which allows you to make an api request
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
I need to access their api to look if my barcode is any of their products. (for a school project)
yes, not often
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
i do have it working for jumbo, ean search, barcodeapi, openfoodsearch
wait @warm sleet sorry ur busy with that but what was the final screen u said was the best
@umbral saffron you mean the video?
but I'd like to atleast include plus or ah (or both XD)
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
@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
I currently run on laravel
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
So i should make it back-end?
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
mySql was i thinking of
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
this is now all front end
yeah, but do you really want to query that EAN code everytime?
I dont need to store the entire json file, just a few elements of it
later the arduino should somehow make a request to the server and passing on the barcode
also store a record if it couldnt find it, and add the age to it too
yeah I need to add the date to it too
but i was first working on getting the api's to work
unless you can query the AH api for an EAN directly
i dont see why you wouldn't be able to do this
you first need to gain an access token
yeah as with every other API in existence
somehow jumbo doesnt
Only key outputs
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
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
yeah, just reading out a database mysql
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
yeah sth like that is what i need i think
but im not that good in this as you are, could you help me a little bit with setting up the main bits?
{
"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?
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
Spark Framework - Create web applications in Java rapidly. Spark is a micro web framework that lets you focus on writing your code, not boilerplate code.
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
Or should I use php and laravel to backend fetch the data from ah?
ooo programming. This might be my kind of place
with php, how to i check if this data array is empty?
@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
@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))
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
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
how do i connect a button to an rpi
Connect it like any other button
if(empty($array)) {}
that doesnt help
@umbral saffron give me a bit, it should be the same as arduino, but there are multiple ways
ok thanks
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?
thanks
I've had jquery and a js script linked before to a page, but for some reason, I still have to put the js after the element selected inside $(document).ready(). Every once a while
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
is there more after that
any flutter devs here?
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?
R::
Random, rand, 1, 1000
clipboard := rand
this was written in ahk
this just does numbers but you could add letters pretty easily
how would i do that ? i have no clue on coding
let me look into it
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
damn thats very complex
i just copied the big part from a website lol
oh haha right right
you can change the R:: to any key that you want
Learn details about hotkeys in general, modifier symbols, context-sensitive hotkeys, custom combinations, mouse wheel hotkeys, function hotkeys, etc.
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?
thanks <3
cheers g
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)
https://adventofcode.com In case it wasn't already posted here.
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
well, there is no Sprite or Bullet in this code snipet.
Where is Sprite and Bullet defined in that context? You're saying "create a new Sprite" but this piece of code doesn't know what a Sprite is.
im not exactly sure what the syntax is for spawning a sprite
but Sprite() and Bullet() are not variables
then what are they? that's where the issue is, figure that out and you'll get to the bottom of it.
i tried adapting the code from here https://www.dummies.com/programming/programming-games/how-to-add-missiles-to-objects-in-your-html5-game/
Car dealerships are touchy about installing weaponry in your ride, but thatβs why people become game programmers. So you can add missiles to your HTML5 game objects. If you want missiles in your mini-van, youβll have missiles (at least in the virtual minivan). Lots of video games involve shooting, and thatβs a pretty easy effect [β¦]
so im not sure the specifics of init, new, and a few other things
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)
alright
would there be any way for me to make a button connected to a raspberry pi but not directly connected to a breadboard
what do u want it to do
like whats the end project
using something like this
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
i just googled pc power switch
you could probably find a more robust one if you google for a bit
ok
alibaba and the like are your best friend for these
thanks
this is adafruit but would this work?
@spring pond
yes
ok
those have the resistor built in
so is that better?
@umbral saffron yeah
remember the arduino thing I posted to you
here the resitor is built-in
limit current, you don't want to burn out your pi
also the adafruit is a different curcuit
@umbral saffron the resistor on the adafruit is a pullup resistor. You can read more about it here https://learn.sparkfun.com/tutorials/pull-up-resistors/all
so this is how it would look like
i have no idea what that means
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
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
wdym, you don't just connect breadboard to pi you need to specify what you are connecting. The breadboard is just another way to make solderless connections and makes protyping or diy projects easy
wdym i need to specify
what you connecting and where
i get i need to plug it in to the right hole
you don't need a breadboard if you use those adafruit buttons
why did you think you need a breadboard?
idk
for all the things i saw when they connected the buttons to a breadboard
so what do i do
I'm just clarifying you don't need a breadboard
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
so the buttons connect into the cable and the cable to the rpi 0?
yes
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

Does this seem good for developing a job scheduler
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) {
it doesnt work
Bots can in-fact interact with other bots.
can humans interact with humans?
i cant
Can air interact with air?
ok so question:
for this
https://www.adafruit.com/product/3400?gclid=EAIaIQobChMIv-HVv4ir7QIVDY_ICh0TOALtEAQYASABEgJHzvD_BwE
to interact with this
https://www.adafruit.com/product/1590
do i need a breadboard @midnight wind
If you didn't think that the Raspberry Pi Zero could possibly get any better, then boy do we have a pleasant surprise for you!Β The new Raspberry Pi Zero W offers all the benefits of ...
or couldnt i just use the microHDMI to HDMI port?
Like I receive github updates in Gmail forums I want to have certain feeds
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?
couldnt u import the API of github into a bot that emails u the things u want
(idk if github has an import thing considering how large it is)
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
so email urself in outlook
π 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.
i dont have to pay for it?
k.. i give up... why
apt-get install python-bs4 pip install beautifulsoup
SyntaxError: invalid syntax
π
yes
what are u trying to do
its in the consol
install the package
apt-get install python-bs4 && pip install beautifulsoup
File "<stdin>", line 1
apt-get install python-bs4 && pip install beautifulsoup
^
SyntaxError: invalid syntax
what are u trying to install
beautifulsoup
just fire pip install beautifulsoup
pip install beautifulsoup4
File "<stdin>", line 1
pip install beautifulsoup4
^
SyntaxError: invalid syntax
like idk why it wont work
keeps saying "install" is invalid syntax
try pip3 install beautifulsoup
oh
wouldnt it be
import beautifulsoup
Beautifulsoup_API = beautifulsoup.Client("apigoeshere")```
oh on you have to exit first
exit() then on normal terminal
try pip3 install beautifulsoup
exit just closes the console
import beautifulsoup
Beautifulsoup_API = beautifulsoup.Client("apigoeshere")
its this
it should be
oh wait
like that
yes open normal terminal and then install beautifulsoup first tgen open python terminal and do whatever you want
what is ur end goal
have you tried installing beautifulsoup from normal terminal
it should work
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?
doesn't work gives me same errors
wont let me import
something else may be wrong
@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
yes I can do that easily
ur in python right
then whats the issue
i'm uninstalling python and reinstalling
ok but under file, theres a setting option
I don't want rss feed of gihub I want rss feed of apple developers updates and apache foundation
that isn't going to do anything
I can make a tutorial video for you on this
just let me know what you want
python tutorials are popular anyways
there isn't a "settings"
doesn't work
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
@astral garnet what are you trying to do
@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
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
Pycharm is still my preferred editor
ye thats what i use
vscode is good too, I don't know why everyone suggests pycharm
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
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 generally I try to set up my IDE environment in a way, that I can use terminal if I wish
such a pain
but its rewarding
bc that means im not stuck to an ide anymore
Is anyone doing Advent of Code this year??
nope
is there an online tool where you can type a list and it will convert it to an array
each cell is supposed to hole 1 string, thats it
that one does not seem to do the specific task i had
wait nvm
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
@next igloo ```json
"thing":[
"thing1",
"thing2"
]
In js ```js
var thing = {
thing : [
1,
2,
"string",
false
]
}```
@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.
-> getImages will run a request and return the value that was there when the request was started, instead of the value when the request was done. There's no way to go from async JS to sync JS. The classic starter is https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises
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.
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)
hey guys whats pippity poppin
no
python
no
python
yes
@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?
Being TCP is the app initiating the connection I assume?
yup it is
what i'm guessing now is
the emulators IP is not static
or its different from the network I'm on
Emulators IP shouldnβt need to be static... only the address of the server needs to be
Servers IP is static
Did you see this? https://developer.android.com/studio/run/emulator-networking
I'll be checking that out
done, so its all setup correctly now
But still no help
let me paste some of these codes
Maybe dm me? No point spamming everyone
@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
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
how can i get a node terminal in vs code?
i have node.js installed
interesting
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
just type node
to run the script just do node file.js

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}"
}
]
}
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 you have to be in the right folder too
didnt work even with the correct and incorrect slash
can you show your terminal then
are you in the vscode terminal?
yes
time to screenshot



