/dpt/ - Daily Programming Thread

Old thread: What are you working on Sup Forums?

Other urls found in this thread:

en.wikipedia.org/wiki/The_Truman_Show
g.sicp.me/books/
en.wikipedia.org/wiki/Common_Lisp_Object_System
pastebin.com/LxhWXths
twitter.com/NSFWRedditVideo

First for D

How can i write a program to prove the earth is flat? and we're in a simulation?

>Write a program to prove the Earth is flat
Go outside, look off into the horizon and tell me, do you see Tokyo? What's that? You don't see Tokyo? But you can see the sun which is reportedly millions of miles away. There you go, the Earth is flat. Now write a real program.

Round, fuck, the Earth is round.

Seems like a bit of a Freudian slip to me

But user, every rational, thinking person knows the Earth is gay.

how do i make an app to clean the poo out of my vagina?

That doesn't prove anything.

I could be living in:
en.wikipedia.org/wiki/The_Truman_Show

A dome to give the illusion of a circular world

I was bored so I made something that processes images like the OP into this.

Pages are set to values within an array.

startPage = pageArray[0]

UIImage then displays start page no problemo.

As for making my next page button add to that, I have no idea.

My button action is as follows:
let newPage:Int = (startPage + 1)

self.ImageView.image = UIImage(named: pageArray[newPage])


This is of course utterly stupid as it will not continue to increase the value of newPage beyond 1, so I end up stuck with a two page book.

How do I into fixing this? I think one of the tutorials I did mentioned an increase value but that would still not help much. I need to return that value but I don't know how to use return very well.

Be gentle, I've been learning code for less than a week.

pls help.

Did you try reading the error message?

that is not how public works in c++
structs are public by default anyway

the struct already has those members.

Your problem lies on line 15, I'll let you figure it out

>C++
He's writing C though.

"public" is not a thing in C. Also, you need a semi-colon after the struct declaration.

Randomizes the locations of pixels in a bitmap? Or is it organizing them

wait, a C struct is a primitive type and not an object like java and C#?

C doesn't have "objects" (in the OOP sense).
A struct is a record type. It contains other types as members, and you can treat it as one unit, but that's about it. You can access any struct member.

>C
>Objects

this smells like bait

I'm a java C# programmer.

How do you reference an @user instance variable inside an entirely different controller, such as a friendships_controller? Is it even possible?

we can see that.

It sorts pieces of images by its 'redness'. Averaging the RGB values of an image piece, converting to HSL (hue,saturation,luma) then sorted by the euclidean distance from red. It also starts a full screen slideshow of these sorted image pieces.

how do I get this to not print the sentinel?

def main():
numbers = int(input("Enter a series of numbers with commas and terminate with '-99':"))
list = [numbers]
while numbers != -99:
numbers = int(input("Enter a series of numbers with commas and terminate with '-99':"))
list.append(numbers)
list = sorted(list)
print(list)

main()

input()

can I declare a struct outside the main function?

...

So I had a phone interview today, and the technical guy asked me to tell him what a "class" was. To be honest it was pretty difficult defining it, I think I ended up just saying that it "was a recipe which defines objects which are instanced from it".

I think I butchered it; how would you guys define a class?

>wait, a C struct is a primitive type and not an object like java and C#?
it's just plain old data. The struct keyword is used when both defining a struct and creating a struct variable. Some people typedef the struct definition so that you don't require "struct" when creating variables, but a lot of style guides are against it.

try it and see?

If I malloc a 32-bit integer, can I recast it into a char array with an size of 4?

Would it work?

code here


replace < with [ and > with ]

Why don't you try it?

Any students that work part-time as a dev during the school semester? What kind of job do you have, and how did you get it?

of course?

What if the simulation controls what you see?

Yes.
char *ptr = malloc(sizeof(uint32_t));
uint32_t n = 10;
char *ptr = (char *)&n;
union {
uint32_t u;
char c[4];
} n = { .u = 10 };
// Do something with c[0] etc.
Will all work, but will introduce endianess issues into your code.

Nevermind, managed it with this:

class Pge {
var Page:Int

init() {
self.Page = 0
}

func UpdatePage(pageToSet:Int){
self.Page = pageToSet
}

func IncreasePage() -> Int{
self.Page += 1

return self.Page
}
}


Is my code still the mess that I think it is, though?

wut

do that with ur code so we can read better

Opinions on D?

It's mostly about 'how' you responded, not so much 'what' you said
if you come right out and say
>Oh! It's like a recipe!
then it seems rehearsed

if you struggle for a bit and have a lot of umms and don't sound sure of yourself, that's also bad

if you think you struck a middle ground between those two, then you're good

so,

def main():
numbers = int(input("Enter a series of numbers with commas and terminate with '-99':"))
list = [numbers]
while numbers != -99:
numbers = int(input("Enter a series of numbers with commas and terminate with '-99':"))
list.append(numbers)
list = sorted(list)
print(list)

main()

input()

too small

I honestly don't understand the question
what do you mean by sentinel

I made a point that it's a collection of data and methods/functions so I think I may have gotten it right as far as he's concerned. They're just weeding people out who have never programmed before. Well that's what I hope.

-99 is the sentinel for that while loop, so when it's entered it terminates the loop and prints the list ordered by value

I want it to disregard the sentinel value from the list so it doesn't show up in the print

what are you trying to do?
get input and sort it?

yes, and not have -99 show up in the print

I was visiting stackoverflow today...

What a cancerous comunity, holy fucking shit.

im not a python fag
but you're complicating things
if the input is a string
then string.split(',')

it isn't a string, that is a prompt for an integer

I assumed the input would be converted to a string, nvm, like im not a python fag
also, the prompt is confusing
it implies I should input, like this: 99,2,1,22,-99
but in fact, I have to press enter everytime, and no commas
change the prompt

anyways, your problem is that something not -99 gets inputted, then stored, the while checks that is not -99, then one actually puts -99, and gets stored, and then it will stop
your best bet is to remove it before sorting
so something like
list = sorted(list[:-1])

*like I said, im not a python fag

Does the size of the vertex buffer automatically increase if I use glBufferSubData to append it with a larger array than I previously bound to it?

So say I:
glBindBuffer(GL_ARRAY_BUFFER,VBO[1]);
glBufferData(GL_ARRAY_BUFFER,sizeof(aBox), aBox, GL_DYNAMIC_DRAW);

But then I:
int offset=96;
glBufferSubData(GL_ARRAY_BUFFER,offset,sizeof(anotherBox),anotherBox);

Will the buffer become 192 bytes or is this bad practice? Is the second 96 bytes just tacked onto the end or is the buffer the correct size?

What's the best language/platform to invest my time on?

I was thinking Python. JVM is too heavy, .NET is too Microsoft, etc

It worked, thanks

Best startup lang? Also is there any interest in creating a better Sup Forums site

C, Ruby.

Implement FizzBuzz in digital logic circuits then you can move on to a higher-level language like machine code and then you'll have enough of a base to move on to assembly.

yeah, you did fine

what language is this?

/dpt/ my job is making me run Javascript on JVM for their company AI. it's an abysmally shitty combination that makes the whole job a lot harder without any benefit.

Is there any way for me to get around this so I can use the basic goddamn JS methods? I can't install anything else on their server

fuck them right in the pussy

I'm not into 30+ year old Ukrainian immigrants who are dudes. I don't even think they have pussies.

do you have any helpful advice?

Type punning with unions is technically undefined but works in practice.

what's a company AI

The AI the company markets to clients. She's supposed to be like siri but personalized for your own company's office work and customers

that said, she's much dumber and slower than your average employee and actually makes things worse

>technically undefined
Not in C11.

But is she hot

She looks like the creepy 3d model that was made to replace Jennifer Lawrence as Pam in a live-action Archer movie after she tripped over her dress at an awards show and broke her goddamn neck

g.sicp.me/books/

Why isn't this in the sticky?

How the fuck do I use Qt Designer to actually do anything useful? I already know C++ and I figured I'd learn Qt, but it doesn't seem like Qt Designer can actually do anything but move buttons around. I just wanted to make a simple program to test if I can; enter numbers in a couple boxes, do some math to the numbers based on the results of some evaluations, then output a number somewhere else.

Hey Sup Forums what languages aside from C doesn't have the cancer that is OOP?

Lisp.

Haskell

What the hell are you smoking? Common lisp and its many derivatives have one of the most powerful and flexible OOP implementations that exist: CLOS

en.wikipedia.org/wiki/Common_Lisp_Object_System

Scheme.

Common Lisp has objects, IIRC.

90% of the people who shill Lisp here have never used it

c++ """"""""""""""""programmers"""""""""""""""" everyone

Fuck off Java shill. You don't get to comment on first world languages.

So in other words, only meme languages that barely anyone here on Sup Forums actually use... At least I got an answer desu.

Most languages worth using support objects to some extent. If you're looking for a language still in use with no objects... maybe Perl 5?

>helpful advice
>/dpt/
which are you looking for?

Yes, but CLOS is so optional in CL that you could likewise say that C is OOP since there are libraries that do that.

Also, CLOS is different enough from traditional OOP that it doesn't really count as such.

CL is very much not a meme language, though.

Go

Matlab

SQL

What's the best book for learning C#?

The See Pound Sign Programming Language

C# Step by Step.

Thanks anons, I'll give them a read.

Anyone? Does no one here know how to use Qt?

You misunderstand -- this thread is for pissing matches and counting angels on pinheads.

If you need help actually producing something of value, you should look elsewhere. I recommend Freenode.

honestly I've intentionally avoided qt
when I'm making a windows desktop application I use windows API directly
the one time I needed a cross platform GUI, it only needed to be very simple and I made it from scratch with sfml
sorry bro

I'm working on a game.
I had a question and forgot it.
I gotta write this stuff down or something.
Anyway, here's a function I wrote a while back that I wasn't able to get to work with my other code like I wanted, since I was already showing someone. pastebin.com/LxhWXths

Why is it that when I call getElementsByClassName("name") I get double the number of posts in the thread?

Also why is it that when I try to go through the list and filter out all the posts that are named "anonymous" only some posts get removed?

It's been years since I've touched Qt, and the last time I used it, I didn't use Qt Designer -- I just did all of the GUI shit in code.

I can handle writing libraries and such in just code, but once I start designing a GUI, I lose 100% of my programming ability and need a GUI to do anything. I don't know why.