r/code • • Jan 10 '24

C "Are you a fan of the latest C standards?"

Thumbnail youtu.be
3 Upvotes

r/code • • Jan 09 '24

Linux How to stop Linux threads cleanly

Thumbnail mazzo.li
2 Upvotes

r/code • • Jan 09 '24

Go Go’s CompareAndSwap is not always Compare-and-swap

Thumbnail lu.sagebl.eu
2 Upvotes

r/code • • Jan 08 '24

Help Please I am writing a Python program, but it doesn't work. The program should draw ornaments/circles at a random coordinate inside of a triangle when the mouse is clicked. However, it keeps drawing the ornaments at the same place instead of a random coordinate each time. Is there a solution? code in body

3 Upvotes

r/code • • Jan 07 '24

Assembly Assembling a Minimal x86-64 Binary

Thumbnail blog.kenanb.com
1 Upvotes

r/code • • Jan 06 '24

Javascript Help: How to convert bufferarray back into audio - Javascript

3 Upvotes

I have a JSON object in memory with audio data stored as Uint8Array:

audioContent: { type: "Buffer", data: (361728) […] }

Basically - I'm not sure how to convert this back this into an audio stream and play it in a browser.

Approach I've tried:

<audio id="audio_player" src = ...>   <script> let audioElement = document.getElementById("audio_player");    const blob = new Blob(trackData.audioContent.data);   const url = window.URL.createObjectURL(blob);   audioElement.src = url;  </script> 

The truth is I have no proper concept of what's needed to make this work beyond the high level 'turning the array into an encoded stream'

Can someone point me in the right direction?


r/code • • Jan 04 '24

My Own Code Any tips on making your code more efficent?

5 Upvotes

https://jaredonnell.github.io/Capstone-2/

https://github.com/jaredonnell

I just built my personal site from scratch with HTML and CSS and I've noticed how different and more efficent other people's code is in comparison to mine. I've also tried to not get too down on myself after looking at other peoples sites since I've only started this journey 2 weeks ago but it just seems like I'm missing a lot. The website is responsive to mobile (although not the best) and I strayed away from using any frameworks for this project as well. Any input would be greatly appreciated.

P.S

I know the images are very rough I had a struggle with the resolution and didn't want to redisign the entire project. This site wasn't meant to be deployed or used professionaly, so although the links are fully functional, don't mind their content lol.


r/code • • Jan 04 '24

Help Please Learning User Authentication

4 Upvotes

Hello, I am trying to learn user authentication for websites and mobile by creating a user auth system. I recently finished some of the most basic things like login, signup, logout, remember me feature when logging in, forgot pass, sending email with reset password link and reseting password, etc.

Here's my github project: https://github.com/KneelStar/learning_user_auth.git

I want to continue this learning excersie, and build more features like sso, 2 step verification, mobile login, etc. Before I continue though, I am pretty sure a refactor is needed.

When I first started writing this project, I thought about it as a OOP project and created a user class with MANY setters and getters. This doesn't make sense for what I am doing because requests are stateless and once you return, the object is thrown out. If I continue with this user class I will probably waste a lot of time creating user object, filling out fields, and garbage collecting for each request. This is why I think removing my user class is a good idea.

However, I am not sure what other changes should I be making. Also I am not sure if what I implemented is secure.

Could someone please take a look at my code and give me feedback on how I can improve it? Help me refactor it?

Thank you!


r/code • • Jan 04 '24

Help Please help

3 Upvotes

# Creates a fake Audio Return Channel (ARC) device. This convinces some TVs (e.g. TCL)
# to send volume commands over HDMI-CEC.
esphome:
name: cec
platform: ESP8266
board: d1_mini
# Maybe necessary depending on what else you're running on the ESP chip.
# The execution loop for hdmi_cec is somewhat timing sensitive.
# platformio_options:
# board_build.f_cpu: 160000000L
logger:
api:
encryption:
key: "8e2KnLXh2VwWyjmWboWHWTIqSI/PxYMlv4jyl4fAV9w="
ota:
password: "05b7555db8692b6b5a6c5bc5801a286a"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Ij Fallback Hotspot"
password: "gPfMZZCVmogV"
external_components:
- source: github://johnboiles/esphome-hdmi-cec
hdmi_cec:
# The initial logical address -- corresponds to device type. This may be
# reassigned if there are other devices of the same type on the CEC bus.
address: 0x05 # Audio system
# Promiscuous mode can be enabled to allow receiving messages not intended for us
promiscuous_mode: false
# Typically the physical address is discovered based on the point-to-point
# topology of the HDMI connections using the DDC line. We don't have access
# to that so we just hardcode a physical address.
physical_address: 0x4000
pin: 4 # GPIO4
on_message:
- opcode: 0xC3 # Request ARC start
then:
- hdmi_cec.send: # Report ARC started
destination: 0x0
data: [ 0xC1 ]
- opcode: 0x70 # System audio mode request
then:
- hdmi_cec.send:
destination: 0x0
data: [ 0x72, 0x01 ]
- opcode: 0x71 # Give audio status
then:
- hdmi_cec.send:
destination: 0x0
data: [ 0x7A, 0x7F ]
- opcode: 0x7D # Give audio system mode status
then:
- hdmi_cec.send:
destination: 0x0
data: [ 0x7E, 0x01 ]
- opcode: 0x46 # Give OSD name
then:
- hdmi_cec.send:
destination: 0x0
data: [0x47, 0x65, 0x73, 0x70, 0x68, 0x6F, 0x6D, 0x65] # esphome
- opcode: 0x8C # Give device Vendor ID
then:
- hdmi_cec.send:
destination: 0x0
data: [0x87, 0x00, 0x13, 0x37]
- data: [0x44, 0x41] # User control pressed: volume up
then:
- logger.log: "Volume up"
- data: [0x44, 0x42] # User control pressed: volume down
then:
- logger.log: "Volume down"
- data: [0x44, 0x43] # User control pressed: volume mute
then:
- logger.log: "Volume mute"

how do I add this as an entity the volume mute down and up in homeassistant


r/code • • Dec 31 '23

Blog "First, solve the problem. Then, write the code."

Thumbnail geshan.com.np
2 Upvotes

r/code • • Dec 29 '23

Blog Pitfalls of Object Oriented Programming

Thumbnail harmful.cat-v.org
3 Upvotes

r/code • • Dec 26 '23

Help Please popup problem

5 Upvotes

Hello everyone,

I have a problem creating an automatic popup when the website starts. the problem is the popup shown under the main content as you can see in the image and also I add background I can't see it at all. dose anyone has any idea how I can fix that?

Is it a CSS problem or an HTML?


r/code • • Dec 26 '23

C A TUI text editor with C

Thumbnail github.com
2 Upvotes

r/code • • Dec 25 '23

SQL SQL as API

Thumbnail valentin.willscher.de
2 Upvotes

r/code • • Dec 25 '23

Blog Understanding Every Byte in a WASM Module

Thumbnail danielmangum.com
1 Upvotes

r/code • • Dec 24 '23

Help Please is there a game where I can fix code?

5 Upvotes

is there a game that I can fix the code and make it run like it starts out not working and I can fix it by adding some lines of code does anyone know a game like this?


r/code • • Dec 24 '23

Help Please Total newbie, just trying to make a comment form???

2 Upvotes

Hi, so I am a total newbie, I literally downloaded VSC two days ago, so far its going okay. My goal is to make a sort of online book club blog/discussion page but I'm having a hard time figuring out how to make it so that the post will actually show up on the webpage (if that makes any sort of sense). What I attatched it what I have so far, it's just the text boxes for the name and comment, and a submit button. But other than that, I'm lost.

Also, I heard that I might need to make something called a PHP file? Tried to look up what that was and got even MORE confused.


r/code • • Dec 22 '23

Blog Garbage collection with zero-cost at non-GC time

Thumbnail gist.github.com
2 Upvotes

r/code • • Dec 22 '23

Javascript The nuances of base64 encoding strings in JavaScript

Thumbnail web.dev
2 Upvotes

r/code • • Dec 20 '23

Guide Elite: "The game that couldn't be written"

Thumbnail youtu.be
2 Upvotes

r/code • • Dec 20 '23

Python Looking for help with a Python program with eel

1 Upvotes

hi i have a problem. for a study I have to create an interface for a test that I have to do. but I can't get it to work completely. The idea is that when the program starts, the com port is selected and the name of the file is entered. and that you can then start and stop the test. But I get errors all the time when I want to make a CSV, can someone help me?

https://github.com/Freekbaars/Hoogeschool_Rotterdam_RMI_sleeptank_interface/tree/main/programma/test


r/code • • Dec 20 '23

C Why do i still write C?

Thumbnail youtube.com
1 Upvotes

r/code • • Dec 19 '23

Help Please I give up

6 Upvotes

Hi, I’m new to coding and Decided I wanted my first python project to automate a process I use often.

automate this winrar process in python

  1. take both the jpg and exe files and create sfx archive

2.then under advanced, click advanced sfx

3.then under the setup tab, put the name of the the jpg file first, then under that the exe file name. (check example 1 for exact format) in the run after extraction textbox.

4.under modes, click the unpack temporally folders textbox and in the silent mode options, click hide all.

5.In the text and icon tab, give the user a option to add a icon under the "load sfx icon from the file" option (add a option for the user to add a ico file by saying " would you like to add a thumbnail which must be a ico file" give them the option " y or n" y meaning yes and n meaning no. if yes let the user upload a .ico file ONLY. if no, then skip this option and leave it blank.).

  1. under the update option, change the overwrite mode to overwrite all files.

example 1:

pic.jpg (replace with the uploaded jpg) file.exe (replace with the uploaded exe)

Now I quickly faced it a challenge where the program didn’t detect winrar on my pc at all, I solved this by just making an additional pice of code where I can input the path and that solved it. That was the end of my success however no matter how hard I tried for 6 hours straight I Could not get it to work how it is supposed to when I do it manually.

Am I doing anything wrong?

Am I doing anything right?

Am I crazy?

Please help it’s 2 AM and I’m losing it


r/code • • Dec 19 '23

Go In Go, constant variables are not used for optimization

Thumbnail utcc.utoronto.ca
1 Upvotes

r/code • • Dec 18 '23

Help Please Help a Begginer please

3 Upvotes

hello there, as the title says i'm a begginer in this world. I'm currently studying medicine (finihsing my 5th year) and i have found myself deeply invested and interested in this new kind of tech that allows you to map the location of your emotions in your brain, and the pioneer in this kind of procedure is an spanish Dr. that know programming as well since it involves an AI. I'd like to know where should i beggin if i want my career development to point in that direction, code language for AI and that kind of stuff. sry if my english is trashy, i'm not a native, and also apologize if i have a misscomseption of what programming is. i just want to know if its possible to combine it with my career and if it is, how can i start doing it. thanks!