/dpt/ - Daily Programming Thread

old thread: What are you working on, Sup Forums?

Other urls found in this thread:

stackoverflow.com/a/1572461
github.com/Skycker/AES/blob/master/aes128.py
libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Array.html
en.wikipedia.org/wiki/Bitwise_operation#XOR
twitter.com/NSFWRedditImage

First for D

Please help me with Java quickly

for(Walls walls: wall) {
scoreArray[i] = true;
}

I want to find the current number of the Walls array, and place that number into i.
So, if I'm on the 4th value of the Walls array, I want to set the 4th value of scoreArray to true.

I don't know how to change my foreach loop into a for loop, can someone write it for me?

I'm so stuck

CHANGE MAJORS NOW

kill yourself

really?

for(int i = 0; i < walls.length; ++i) {
scoreArray[i] = true;
}

I outgrew this general a long time ago, but I still come here to shitpost.

If your problem isn't literally fizzbuzz-tier, nobody replies to you.

(Me)
the answer is similar to this:
stackoverflow.com/a/1572461

How do I do that sexy code layout?
or something?

read the sticky

rcon = [[0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36],
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
]

what does this do

for(Walls walls : wall) {
if(cam.position.y - (cam.viewportHeight/2) > walls.getPosTopBlock().y + walls.getTopBlock().getHeight()) {
walls.reposition(walls.getPosLeftWall().y + (WALL_COUNT * WALL_SPACING));

scoreArray[i] = true;
}
if(bubble.getPosition().y > walls.getPosLeftWall().y && scoreArray[i] == true) {
// Increases the score
score++;
scoreString = Integer.toString(score);
scoreArray[i] = false;


}
if(walls.collides(bubble.getBounds())) {
gsm.set(new PlayState(gsm));
break;
}
}


If I could get the i in scoreArray[i] to be the same as the value of the array Walls, I'd be fine. But I don't know how

Defines a variable that's a list containing 4 lists of numbers.

put this instead the first line
for(int i = 0; i < wall.length; ++i) {
Walls walls = wall[i];

but what are these numbers?
what would they be used for

or i'm not sure what you mean by
>get the i in scoreArray[i] to be the same as the value of the array Walls

it's don knuth's hacking sequence of opcodes

No one is a psychic medium here and won't be able to tell you without any context whatsoever, it's almost as if I posted a few random numbers like 5 1231 593252 252035 and asked you what are they used for. The only hint here is the variable name, which could be server authentication sequence? Although it wouldn't make much sense because the first list is simply multiples of 2 in hexadecimal notation.

Thank you user
You know what I'm trying to do, but I'm not sure the syntax is 100%

see pic related

github.com/Skycker/AES/blob/master/aes128.py

ah, it's not a plain array, it's an Array object.

you can see in the documentation here:

libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Array.html

that you need to do wall.get(i) instead of wall[i]

thank you so much
i actually love you
i've been crying for almost 90 minutes now

Gee, I wonder...

bro i literally still have no clue explain it
so they're using these magic 0xGYPSY numbers for what

looks like it's using rcon to precompute some scheduling. Kinda like how some CRC32 implementations use a table.

en.wikipedia.org/wiki/Bitwise_operation#XOR

but bros i literally still have no clue explain it
it looks like they're using these magic 0xGYPSY numbers for what

How about you just fuck off.

FOR FUCKING
HASHING
BECAUSE
ITS
A
CRYPTO
LIBRARY

can you kindly just fuck off back to /wdg?

bros i am still shaking.
it looks like they're using these magic 0xGYPSY numbers for something shady

Anons how can i insert data into mysql from file.
I have file hls, infile is:
1456893207286.webm
1456893239983.webm
1456893429952.webm
1456911883636.webm
1456912417621.webm
1456913173330.webm
1456919432270.webm

i tried
LOAD DATA LOCAL INFILE '/path/to/file/hls' INTO TABLE mytable

table has id and name
id primary key and autoincrement
name varchar and unique

Ignore this, I'm retarded.

Not working tried that too.
It inserts only one row

Need some help measuring time time it takes to do something in a c++ program.


int start_s = clock();

//code to time

int stop_s = clock();
cout

ldr destination, source
str source, destination

Why would they do this?

...

see how its done in this example
#include
#include
#include
#include
#include
#include
#include

int count_wrds(std::string s)
{
int numberOfWords = 0;

if (isalpha(s[0])) {
numberOfWords++;
}

for (size_t i = 1; i < s.length(); i++) {
if ((isalpha(s[i])) && (!isalpha(s[i - 1]))) {
numberOfWords++;
}
}

return numberOfWords;
}

void typing_speed()
{
std::cout

>not steady_clock
kys

xD

You have to tell mysql where to insert the data, what you're doing will make it try to insert it into the ID column.

LOAD DATA LOCAL INFILE '/path/to/file/hls' INTO TABLE mytable
lines terminated by '\n'
(name);

same as

then I don't know, just tested and it worked just fine.

This is supposed to print something but it prints nothing.

#include

class Test
{
char *member;

public:
Test()
{
std::cout

Test *b = new Test();

this is part of error from workbench
>pic

Yes, it's trying to insert the webm names into the ID column, did you copy the whole code snippet from , all 3 lines ?

yes

Shouldn't I get an error if I'm not declaring my shit correctly?

Also my destructor is never called now.

No, because what you're doing is, as far as I know, the preferred way of doing things, that is, not using 'new', not really that familiar with C++ though.

And you don't need
member = new char[1024];
just do
char member[1024];
// instead of
char *member;

I deleted id and everything is inserted.
My question is could i add id now and make it generate id by it self?

Not quite sure what you mean, this is how I did it, starting with a clean table.

CREATE TABLE `test`.`webm` (
id int auto_increment primary key,
name varchar(256)
);


LOAD DATA LOCAL INFILE '/path/to/file/hls' INTO TABLE test.webm
lines terminated by '\n'
(name);

Oh I get it the destructor is only called for objects on the heap duh.

You have fallen victim to the *most vexing parse*.
Basically the compiler interprets the Test a(); as a function declaration.
To prevent this, remove the parenthesis. Test a;

Thanks, I found what I need with chrono, but in my compiler I wasn't in c++11 for some reason and am having some trouble switching to it,

I run the command:
g++ -std=c++11 main.cpp -o main
but then if I a.out it does run the file with the new changes. And if i try to compile normally again with
g++ main.cpp
I get errors because my compiler still isn't in c++11

Do checks have a place in C++ or is everything exceptions?
In C I used to make an error function and wrap it in a macro, would that be considered bad C++?

Eh... the problem is?

You can't compile pre c++11 code without specifying the standard you're compiling against.

I deleted table and created the same way as you and it worked.
Cant get what was problem

fuck guys, I'm having trouble implementing a zipper for my data structure
data Filesystem a = Item a [Filesystem a]


any ideas?

>making games in Java
kys

hello rêddit

The char * there was to demonstrate how to use constructors/destructors to manage stuff like that.

No, it gets called for both heap and stack objects, in case of the stack objects it happens when they go out of the scope, in case of heap objects it happens when you call the delete operator.

ncurses is comfy

How did you do that?

is there ncurses for windows

like an actually recent and good one i mean

Skipped physics classes in primary school? It's a basic position bounce & text display at the coord.

Physics?
I never had that in school.

ok we get that but we're talking about the non-linear printing of text in 2d space

...

Skipped terminal printing classes in primary school?

How do I get a job

What? It's you who does not understand even though he included the keyword you're supposed to look for in his post.

so make a new file,and then set the compiler to c++11? makes sense

>terminal printing
He was using ncurses, which is different from that.
It uses termcap to get commands to draw things at arbitrary locations on the terminal. It isn't just printing out a whole bunch of lines over and over to simulate a frame.

what have you coded?

Sup Forums bingo

no u.

That's the ncurses part, senpai.

C and Non x86 cpu

float root = 0.0f;

float sqsr = x*x + y*y + z*z;

__asm__("sqrtss %1, %%xmm0;"
"movss %%xmm0, %0;"
:"=r"(root)
:"r"(sqsr)
:"%xmm0");

return root;

Can anyone help me why this isn't working? the error i get is

C:\Users\User\AppData\Local\Temp\cc5A0cab.s|199|Error: operand type mismatch for `sqrtss'|

> when you get a star

Even after making whole new files im still not in c++11, how do you make sure you change your compiler settings?

guys, I have no idea what the PatterGuards haskell pragmas does
any help?

static public String rot13(String message){
String res = "";
for(char a:message.toLowerCase().toCharArray()){
res += (a>='a' && a

-XNoPatternGuards
disable pattern guards

ignoring the fact that problem seems already resolved,

for(Walls walls: wall) {
should be for(Wall wall: walls)
singular for a variable or field, plural for a collection

scoreArray[i] = true;
can be done with scoreArray[walls.indexOf(wall)] = true;

Is she a boy?

If i compile something with this line of code:

g++ -std=c++0x main.cpp && .a.out

What would my Makefile have to look like to compile this? My Makefile currently looks like this:
CXX = g++
SRCS = main.cpp
HEADERS =
OBJS = main.o
output: ${OBJS} ${HEADERS}
${CXX} ${OBJS} -o outut
${OBJS}: ${SRCS}
${CXX} -c $(@:.o=.cpp)
clean: rm -f *.o output


semen

changed my mind on if statements

providing you're using MultiWayIf

Anyone here familiar with the eyeshot framework by devdept?

A ... star?

Man, we real ded

I'm in the process of learning some Haskell

This one was a bit easy imo.. Like do you really consider yourself a programmer if you don't get bingo here?

Yeah it's considered bad C++ but exceptions are bad and tons of other things are 'bad C++' that are generally good. So don't worry about it unless you're being scrutinized by retards with power.

also known as a shithub (you)

Ganbatte!

I'm afraid to leave one programming job for another. Looking for comforting advice and stories. The one Id move to is literally doubling my pay, but I will miss a few of my coworkers. But Im working for so little money...

>His programming language can't multiply a string.

print(100 * "YOUR PROGRAMMING LANGUAGE IS SHIT ")

The * operator is clearly not mathematical multiplication in that case.

What purpose would this serve?
You're multiplying a char pointer by 100,

GHC/Haskell has Data.Semigroup with
stimes :: Integral b => b -> a -> a
mtimesDefault :: (Monoid a, Integral b) => b -> a -> a

Multiplication by a natural number is well defined for monoids (for non-zero it's well defined for semigroups)

It's not about semiring multiplication (i.e. a closed distributive operation), it's about repeated addition

Monoids only have one operation and it's usually denoted by multiplication. Never will you see a * a = 2a in a monoid.