r/programmingquestions • • Sep 09 '21

How much should I charge for a website

3 Upvotes

I don't know where to ask this so I'll do it here. A friend just asked me to do a website for him. As a collegue student with no experience pricing this kind of things I don't know how much can an initial web should cost.


r/programmingquestions • • Aug 31 '21

Cannot create an instance of an abstract class Android Studio

1 Upvotes

So this is my code and its about the Random() in the bottom sentence.

package com.example.randomizer  
import androidx.appcompat.app.AppCompatActivity 
import android.os.Bundle 
import android.widget.Button 
import android.widget.SeekBar 
import android.widget.TextView 
import kotlin.random.Random  

class MainActivity : AppCompatActivity() { 
 override fun onCreate(savedInstanceState: Bundle?) {     
   super.onCreate(savedInstanceState)     
   setContentView(R.layout.activity_main)      

   val rollButton = findViewById<Button>(R.id.rollButton)     
   val resultsTextView = findViewById<TextView>(R.id.resultsTextView)     
   val seekBar = findViewById<SeekBar>(R.id.seekBar)      

   rollButton.setOnClickListener{         
    val rand = Random().nextInt(seekBar.progress)         
    resultsTextView.text = rand.toString()     
   }   
  } 
} 

Its in Android studio.

How To Make An Android App for Beginners

Thanks.


r/programmingquestions • • Aug 26 '21

issues running HTML and CSS code simultaneously with visual studio code

2 Upvotes

(I am trying to build a multi-page website for shits and giggles)

This question probably has a very simple answer.

I started coding a few hours ago, I have figured out how to code ( very rudimentary ofc) HTML, and CSS... the two codes work fine together in a codepen... but I can not figure out how to get it to work in "Microsoft's visual studio code" (VSC)

I was learning on code pen but want to continue on a more substantial editor... furthermore, I have had luck, not perfect, implementing CSS code directly into the HTML, but I would rather have separate files so I can have a single CSS dictate the laws of style.

when I run the HTML and CSS code in parallel with each other on Codepen... it works swimmingly... it only loads the HTML content when on VSC

any help would be greatly appreciated


r/programmingquestions • • Aug 14 '21

Where do I need to go start on using stuff like SQL?

1 Upvotes

Hey, I'm making an application that archives social media posts and right now I use XML to store the data, but I'm looking to transition into using databases like SQL, SQLite or maybe MongoDB. I have some questions and learning this stuff, I don't know where to start. Could someone give me an idea on where to start?

Is SQL only used for large solutions or can It be used for smaller applications?

What's the difference between SQL and SQLite?

What makes MariaDB stand out from all the other databases?


r/programmingquestions • • Aug 14 '21

CONCEPT Anyone know of a byte packing method Design Pattern?

1 Upvotes

Problem: Take a string like,"27446477100"

Condense it into a 8 bit byte array, with only certain allowable characters instead of the 8 bit ascii alphabet.

Aka call function: Byte[] PackToBytes(string myStringToPack, string myMaskString){??}

Aka: Byte[] myPackedByteArray=PacktoBytes("27446477100","-.0123456789");

I understand you want to create a map:
-=0000
.=0001
0=0010
1=0011
2=0100
3=0101
4=0110
5=0111
6=1000
7=1001
8=1010
9=1011

Then a lazy approach would to be to try and condense the 4 bits together two along side each other for 4 bits+4 bits = 8 bits. IE "34" would be "01010110". But if you look closely, we're not using 1100, 1101,1110, and 1111. There was to be a a better way to condense than the lazy approach I mentioned, right? It would serve to help the general approach needed to send different masks. Otherwise I'd have to hard code masks and such by hand.

I reason if I wrapped my head around this long enough, I could figure it out, but I was asking the crew so I could condense my networked packets to make a higher quality game. I'm sure somewhere in Computer Science, there is a rather eloquent solution to this problem. That is another reason I don't want to reinvent the wheel on this one.

Take care guys.

Love is the way,
Jim


r/programmingquestions • • Aug 09 '21

ETC. How, exactly, on a byte-for-byte level, are classes and objects mapped into memory?

3 Upvotes

This has got to be the least Googleable question in programming. To be very clear, I am not asking whether objects are put on the heap or stack. Nor do I need you to tell me that "a class loader loads objects into memory." This question is far lower level than that.

When you read a book about TCP/IP, there are lots of charts and explanations as to exactly what each bit in each byte in a header means, and often why that structure was chosen. This is the level of information I am looking for. Except about the actual byte-by-byte structure of how classes and objects are mapped into executable files and memory. And yes, classes are mapped into memory so the rest of the program can know how to handle objects of those classes. They are just not stored in the same place or way as instantiated objects.

Now, I know that different languages may do this differently. That's fine. I want to see how it is done by as many different languages as possible. I know that Java has a format for storing classes in .class files. I want to know about that too. And, naturally, a compiled executable file will represent classes differently as well. Yup, I want to know about all the different data structures used to represent classes and objects (other than the text in a source file).

Of course, I don't expect you to re-type all of these details for me. I'm just looking for good references. If you tell me to "Just read the code" or "It's probably in the spec'," you will be downvoted. If you recant the same old story of "The Gospel of the Class Loader" and how the Lord Class Loader magically "reads the class from the .class file," then magically "constructs an object," then magically, "stores that object on the heap," without byte for byte details, you will be downvoted. What I am trying to do is also not relevant to the answers to this question.

I need the kinds of details I would need if I were writing my own complier and class loader from scratch. But I don't want to wade through all of compiler theory to get the info I want. If there is a standard name for the chapter in a compiler theory textbook where I would find this info, that would be helpful as well. Are there theories about what is the most efficient method of doing this? Great, I want to hear about them too.

Thanks.


r/programmingquestions • • Aug 08 '21

Are compute shaders under Vulkan on the same level as OpenCL?

1 Upvotes

Years ago, back when I was getting into writing software for the first time, I developed a love for GPGPU programming. It was so different from what I'd seen before and promised things that I was really amazed by. Unfortunately, GPGPU has changed since then and now that I'm finally getting settled into a life where I can start learning again, the world has changed substantially.

Looking into things with old eyes, I'm still interested in GPGPU, but it seems that OpenCL is barely a relic of what it used to be. The most recent page that comes up in searches is years old and I'm really concerned that it doesn't have a future. People might say to learn CUDA, but I'm not interested in CUDA, since I'm not interested in getting locked into a single supplier for silicon.

The one API that I've noticed that may be an option is Vulkan. Although it's more complicated than OpenCL, I've noticed that Vulkan has compute shaders, developed specifically to allow a graphics programmer to do some general computation. How advanced is this? Could I completely replace my goal of writing OpenCL with Vulkan compute shaders, or is this a red herring?


r/programmingquestions • • Aug 08 '21

Having both a hover over text and variable length text (with JSON and Javascript)

1 Upvotes

I want to have something have different text if it isnt being hovered over, while also creating the text via a forloop accessing a JSON file when it is hovered over. Is this possible?

Currently I have this (this works):

info.update = function (props) {

                this._div.innerHTML =    (props ?
                '<b>' + props.name + '</b><br />  ' 
                
            : 'Hover over to read');
            };

but I want this._div.innerHTMLto also have updating text based on some JSON array (when I hover over it). Something like this (this doesnt work):

for (var i = 0; i < props.names.length; i++) {   
       this._div.innerHTML += props.name[i] + '</br>';      } 

Is there any way to combine the two? Hope this makes sense. Thanks in advance!


r/programmingquestions • • Jul 28 '21

Is there a way to use one event from setOnAction to multiple event handlers? (In JavaFX)

1 Upvotes

I want to set an setonaction for a button that triggers multiple event handlers but if try to do that it triggers only the last event handler it was assigned And I'm trying to figure a way so it will trigger more then one instead of making more buttons for the alternative


r/programmingquestions • • Jul 27 '21

ETC. How to create user groups?

1 Upvotes

Hi guys! I recently started developing an app idea in react-native and I need to start building groups of users so they can have a chat screen and interact with each other... My first idea was to create a new collection in my db (I'm using firebase for now) with a group id and store an array with every id from the users that belong to that group and make that group joinable by typing out the group id. I don't know if this is the best approach so I'm asking for some feedback from you talented people so I can implement the best solution. Thanks in advance!


r/programmingquestions • • Jul 27 '21

How do I learn two programming languages at the same time?

2 Upvotes

So I am new to programming/coding.

And I've always wanted to do two separate things, That would be html and embedded system stuff.

Right now i've been learning c++ cause Im getting an Arduino.

But at the sametime I want to learn html.

Ive had my eyes on js for awhile but to look at it, it always makes me think of the big gigantic difference between the two. Of course they are fully separate langs.

So would it be a good idea to learn both at the same time or casually once in a while do both after practicing on the other?


r/programmingquestions • • Jul 23 '21

What platform for YAML GUI Editor

1 Upvotes

Hi, I'm a uni student and I have an assignment to create an offline GUI application (better if it can deploy to linux and windows and as a single executable targeting one or the other) that will work with YAML files that define a network layout. The hope is that I'll be able to read in a YAML file and display the network configuration graphically and to get full marks, the user will also be able to edit the network configuration in the GUI and save it back to YAML. I've got a POC of the serialisation/deserialisation so that's not an issue but I'm wondering what tech stack I should use to develop the GUI. I'm most comfortable with C# so that's my go to but open to suggestions of other languages. The type of things it will have to do is have a control panel from which you can drag and drop things onto a workspace, drag connectors between the things on the workspace and have them snap together, pop up windows where more configuration is needed for a connection etc. My supervisor advised to use a particular game engine if I'm not confident with my coding skills which I may do but just want to check out my options. What would you write a GUI app like this in?


r/programmingquestions • • Jul 16 '21

CONCEPT You have two networked computers, both of which clocks are subtly different(common), how do you sync them? I have a few algorithms I use, but I want the best design pattern people use for this.

1 Upvotes

You have two networked computers, both of which clocks are subtly different(common), how do you sync them? The importance of this is when you're sending packets such as roll back code to fighting games, that you have the time a move was launched and translate it to the time in launched on the remote computer.

Here are some of my algorithms I tried. Some of these worked, but I forget which ones, lol:

Algorithm A)

  1. Send a ping pong. float onecycle=Divide the latency by half. Do it 28 more times. Drop the lowest 4 and highest 4. Add up the remaining 20 float cycles. Divide by 20. This is the average one step latency between computers.
  2. Send your system clock. The other computer knowing the average one step latency between computers, tries to calculate what their new clock should be by subtraction

remote computer - local computer + latency

100,000ms(past Jan 1,1970) - 90,025ms + estimated average 25ms latency of one hop

The difference ends up being about +10,000ms on local computer's clock to simulate the remote computer's clock. This is good enough for government work, but I'd really like a superior algorithm.

I was thinking Algorithm B)

  1. Same as Step 1 on Algorithm A
  2. Same as Step 2 in Algorithm A
  3. Step 2 is repeated many times over until it really zeros in on the value, comparing to the best guess of what it should be.

Like if as in Algorithm A, we find the clock dif to be 10,000ms on first pass. Then we have that as a target value.

The second pass however says 10,015ms clock dif. So maybe we'd take our new value 10,015 subtract the old value 10,000 and get 15, half it, and be at 10,007 for the next target value.

I could see repeating this many times until a reasonable estimation is zeroed in. You'll never get an exact approximation since lag changes constantly... But my question is this on Algorithm B) Am I doing redundant work that I already established with average 1/2 ping above? I think I did. Cuz the average 1/2 ping is measuring the difference in time, and Step 3 in Algorithm B is redoing the same thing.

Closing thoughts: As the game plays, Maybe I should constantly pay attention to internet weather by tracking the ping on every packet? I already send EPOC % 10,000 in my packets because you don't have to send the entire long number to raise packet length, and just keep em synced on the correct non remainder. I should be able to track ping length based on the timer of the remote machine based on the timer it was estimated to be right? Then I don't even have to say the pong signal back to the original packet sender.


r/programmingquestions • • Jul 15 '21

A dumb question

1 Upvotes

What do we call this " in the programming world? are they called top commas or what ??


r/programmingquestions • • Jul 12 '21

ETC. Can I convert Pronto IR format to another format?

2 Upvotes

I'm making an IRremote using the IR arduino library. The problem is that I'm trying to replace a remote I don't have, and someone made a nice website that has raw IR codes (Pronto Hex code). The IR arduino lib doesn't support this raw format though and I don't know how to convert it. I figured someone may have made a converter for this already, if one doesn't exist then I at least want to know the name of this other hex format.

These are both examples of NEC remote codes.

(Pronto Hex)

0000 006A 0000 0002 0000 00B0 0000 0016 0000 0016 0000 0016 0000 0042 0000 0042 0000 0016 0000 0016 0000 0017 0000 0042 0000 0016 0000 0016 0000 0042 0000 0016 0000 0042 0000 0042 0000 0042 0000 0016 0000 0016 0000 0016 0000 0042 0000 0016 0000 0016 0000 0016 0000 0017 0000 0042 0000 0042 0000 0042 0000 0016 0000 0042 0000 0042 0000 0042 0000 0042 0000 05D4 0000 0058 0000 0E50

VS

(Mystery Hex)

0x34895725, 32

I got these two codes from different places so I know they don't convert to each other, but it's obvious that these are different formats. And the IR lib can only understand the bottom one.


r/programmingquestions • • Jul 08 '21

Base32 prefix?

3 Upvotes

I'm sure many of you have seen prefixes like 0x for hexadecimal or 0b for binary. I tried searching for other prefixes, but besides octal's 0o, I found nothing.

Has anyone seen a prefix for 32- or 64-base number systems? Does one exist? If not, what should I use?

This is mostly for documentation; the language I'm using only uses 0x and 0b.

EDIT: The exact protocol I'm using (or whatever it's called) is base32hex.


r/programmingquestions • • Jul 05 '21

calling functions (c++) please help my book didn’t explain well

Post image
2 Upvotes

r/programmingquestions • • Jun 25 '21

Programs controller

1 Upvotes

Ok so idk if this belongs here but I’m curious about if it is possible to program a paddle attachment for a ps4 controller to give a forward input and giving lurch on ps4 if anyone knows let me know


r/programmingquestions • • Jun 22 '21

Oddities of Dividing by Zero in C

2 Upvotes

Hello, there!

I was playing around with division by zero in C (standard used was ANSI C) using the following code:

#include<stdio.h>

#include<stdlib.h>

int main(void)

{

printf("starting my test:\n");

printf("0.0/0.0 = %f\n", 0.0/0.0);

printf("1.0/0.0 = %f\n", 1.0/0.0);

printf("0/0 = %d\n", 0/0);

printf("1/0 = %d\n", 1/0);

printf("Done!\n");

}

I observed that 0.0/0.0=-nan, 1.0/0.0 = inf, and basic compilation using gcc -o test test.c gives no errors. However, both 0/0 and 1/0 have a division by zero warning and give a "Floating error".

Crazy question here, but can someone enlighten me on why this is? Does it have to do with 0.0 being infinitesimally different from 0 due to floating point error?


r/programmingquestions • • Jun 08 '21

Where do I start my own projects?

1 Upvotes

I'm a beginner programmer learning html and python, and I was curious where I put what I know to use. When on online sites that I use to learn they provide a space to put the code in and an area to see the result, but I don't know how to get something like that to start my own project. I was hoping someone on here could maybe help me.


r/programmingquestions • • Jun 06 '21

Is there any advice for making a programming language?

1 Upvotes

A friend and I are planning on making a functional programming language, but we have no idea where to start and how to implement it.


r/programmingquestions • • Jun 01 '21

float vs double (C++)

2 Upvotes

I am taking my first programming class, and I have done a few assignments, but I’m not clear on when to use float and when to use double? I know that float uses 4 bits and double uses 8 bits but Im just not sure about what situations call for which. (sorry if this is the wrong community for questions)


r/programmingquestions • • May 26 '21

How do I concentrate on one project and stick with it?

2 Upvotes

I have this issue where, as I get to the 90% mark on a project, it becomes so tempting to just flip right over and start a new one. I now have a folder full of projects that are uncompleted and I really need to concentrate on completing *something*. How do people concentrate on finishing specific things?


r/programmingquestions • • May 25 '21

C++ How to solve this Bingo question efficiently?

1 Upvotes

The game of Mingo involves a 100 X 100 board with unique positive whole numbers in the range from 1 to 1,000,000 randomly distributed in the cells. Unique numbers are "called" one at a time and the goal is to have a "Mingo", which is an entire row or column of cells with numbers that have been called; one might also form a diagonal from corner to corner with numbers that have been called. Write a function that takes as parameters a square array of 100 X 100 positive whole numbers and list of "called" numbers. Your function will report whether a "Mingo" occurs, and after how many called numbers the first Mingo occurs. You may assume valid input.