/dpt/ - Daily Programming Thread

Old thread: What are you working on Sup Forums?

Other urls found in this thread:

github
en.wikipedia.org/wiki/German_tank_problem
puu
twitter.com/SFWRedditGifs

What happened to the last thread?

Mods just nuked it?

Why?

Writing a rapidminer "clone" that actually uses fast libraries.

Yeah, I don't know why the got rid of the notepad one.
I'm pretty sure that one was valid.

It would be nice if the mods would make an appearance and explain. I didn't see anything out of the ordinary on that thread. No CP or anything.

So I'm trying to make a simple pattern generator in Ruby.
def carpetSquareGenerator()
blockArray = ["▓", "▒", "░", "█", "▞", "▚"]
carpetPattern = blockArray.sample(6).join
carpetSquare = 3.times do print(carpetPattern,"\n") end
return carpetSquare
end
print(carpetSquareGenerator)
This code outputs "3" after the pattern, like this:
▞█▚▒▓░
▞█▚▒▓░
▞█▚▒▓░
3
How can I prevent the "3" from being printed as well? Sorry for the noob question, I'm just starting out.

Probably because there were too many programming threads

The only other one is literally on page 9 and at bump-limit.

Reminder that if a new thread is created early but isn't deleted before the old one hits bump limit, it is now legitimate. If you create yet another new one after the bump limit, 9 times out of 10 it will be deleted in favour of the first new thread.

Attention, /dpt/:

The mods do not like C#.

There was entirely too much C# at the end of the last thread.

Please refrain from posting C#, or the threads will be deleted.

That is all.

It might be accidental then. Don't look too much into it, else people who hate this kind of threads will take it as a precedent

studying cs
which of these courses to choose this sememster
vb.net, php or security engineering
which will make me closer to becomin a Sup Forumsentooman

None of those. They all sound like absolute garbage, and aren't even CS.

what the hell? don't choose any of them and do something healthier

>arent even cs
define cs then

Ran out of pockets, had to rage somewhere.

notepad-tan was in the wrong place at the wrong time.

like what?
already chose c#, data structures and calc 2
need 2 more to take

No reason to learn VB if you're already go for C#.

No reason to learn VB at all, really.

The other two options are fine, I guess.

Jannie seems to not like my post.
I wonder what made him to be so buttblasted about the notepad-chan thread.

It's a shitty text editor

>he doesn't use mad vb macros skills to impress cute girls from accounting

VB.NET != VBA

Also,
>not using VSTO to modify your workbooks from a C# application

He probably made a mistake. Notepad chan is a nice and useful girl. How could anyone hate her.

Oh shi-

A drawfag should do anime girl representations for all programming IDEs and major text editors.

t. janny

Something probably easy but I can't figure it out.
Let's say I got a byte variable in Java.
I want to swap its 2 numbers places, so like 15 because 51, or 07 becomes 70. How can I do it without too much mess.

(n % 10 * 10) + (n / 10)
It only works if n < 100.

It is, since my byte value is always %100. Thanks

return carpetSquare

while i dont know ruby, that looks like you are returning 3 via that

You mean swapping the hex values? That's easy:
swapped = (a >>> 4) | ((a & 0xF)

>convert it to a string and reverse the string
That's the idiot's way of doing it.
If you ever bring a string operation into something not involving strings, you're doing it wrong.

I use LOB for macros because it respects my freedoms :^)

So could someone redpill me on this notepad-chan nonsense? I haven't been here since last night because I've been busy studying

Hot pockets didn't like the image of the last thread. That's it.

Swapping the places of two numbers does involve strings because the two numbers being swapped are from the string of the decimal representation of the number. The computer has no clue that it is decimal.

Oh please, if you're not using the built-in string operations then you're essentially just re-writing ParseInt or whatever the Java version is. And you're gaining absolutely nothing except a few bytes in memory.

If you're converting a number to a base that isn't a power of two you're creating a sub-class of the string. So why not just use the class that you already know works?

Learning functional JS.

What's the best 3 programming languages

1. C
2. Haskell
3. Bash

You two brainlets don't seem to know how modular arithmetic works.

C, BASIC, ECMAscript

>C

>Redox OS user calling anyone else a fedora tipper

>>C
>Le tips meme

*segfaults*

*are

c++/java/c# are all better

Come on, at least try. That's just insulting.

Can I generate a set of 10 numbers (12345-67890) based on another set of numbers?

These are codes for 2h wifi access. Can this be bypassed like a serial number?

I'm a bit of a noob to coding but i have this script, I was wondering how you would add it so instead of just visiting a profile i can get the script to send a defult msg?


github com/Hexalyse/Interpals-Autovisit/blob/master/InterpalsAutoVisit/interpals-autovisit.py

Java and C# are managed languages, they're not even remotely in the same class as C. C++ is a valid alternative to C, but only because it is almost a superset of C. Enterprise OOP C++ is still cancer.

like a seed to a PRNG?

Just add a print with the message you want it to say

Yes you can. It's task either for simple neural net ("artificial intelligence") prediction or you can reverse engineer the algorithm that generates the numbers. Either way, the more samples you have the more reliable the solution will be.

en.wikipedia.org/wiki/German_tank_problem

do i not need to give some form of coding relating to actually selecting "message" someone?

>tfw review stackoverflow posts
>tfw crush pajeet dreams every flippin day

Sorry, your question was worded confusingly.
>Go to profile in your browser
>Open up your browser's web tools
>Open up the Network tab
>Filter URLs for the site you currently are on
>Send message and look for the request with the message in it

It's your goal to try and take that request and generalize it and send it for when you want to send the message.

>all this maths

This is a programming thread faggot.

>C++ is a valid alternative to C
No it's not. C++ has many things wrong with it, making it an utterly inappropriate alternative to C.

Computer science and programming is a subset of mathematics.

What's wrong with the C-like subset of C++? Just because a language lets you be a retard, doesn't mean the language is bad.

>The "my subset of C++" argument
Languages should be evaluated in their entirety.

C++ is too large to evaluate

What's wrong with the entirety of C++?

>programming is a subset of mathematics
lol

Apologise for that, but thank you for the response. I got this stage now, i am assuming it is the initial one or the first two i want to pay attention to. What do i have to do with this information now?

puu sh/uxncC/1555dee232.png


I assume something to do with this?

puu sh/uxniN/1ae43d3f23.png

By that logic, C is bad because you can do stuff like return 1 / 0.

Undefined behaviour.

It's undefined by the C language. That case is very well defined by the implementation.

Can you point me to a webapp exemple or some source code so I can analyse and compile based upon that?

Very interesting...

You clearly don't understand the implications of undefined behaviour.

Oh yeah, the compiler might delete your stupid ass "undefined" statement because they love improving their little benchmarks.

Right click on the first one and click copy as curl. Now you can use this in your terminal to test it out. After you are able to replicate sending messages via curl, start removing arguments to curl you think are unnecessary. Some sites might check your headers when you try to post but a lot don't. After everything is stripped down you can convert your commands into the actual requests you need to do in your python script.

A compiler is under no obligations to do anything if your program has undefined behaviour, and is well within its "rights" to optimise based on the assumption that it never happens.
It's one of the reasons that C is inherently faster than most other languages.

F O R T R A N
O
R
T
R
A
N

Either way it's retarded, but the compiler still lets you do it.

>A compiler is under no obligations to do anything if your program has undefined behaviour,

Actually if there's undefined behavior, the entire program is undefined. So the compiler should just generate an empty executable and save us the trouble.

>It's one of the reasons that C is inherently faster than most other languages.

It's the reason compilers output absolute bullshit code sometimes. How in the fuck can you justify bugs that only happen at high optimization levels?

gcc used to have a feature that allowed you to throw c++ exceptions from trapping instructions like n/0.

okay thanks i copy and pasted everything you've said for me to do tomorrow as it is getting late here. I've apprciated your insight, i will probably come back tomorrow. Peace out

If you know what PRNG they use and if they use a cryptographically insecure algorithm (in which they want speed) you can possibly predict the next output of the generator.
It's also possible that the numbers are created from an algorithm and aren't random. In that case you'll need to reverse engineer it. Another user suggested to use machine learning. While that may work, you would need a lot more training data then what you showed in your picture.

>the compiler
There is no "the" compiler.

Find a C compiler that will reject that code.

>c++ exceptions

You prefer C exceptions?

...

All my C compilers throw warnings. You're not one of those subhumans who just ignore warnings are you?

>-Werror

So? A compiler with a different set of command line options counts as a "different" compiler in its own right.
To get an actual standards compliant GCC, you need to pass it several command line arguments.

>C exceptions
aka "instant crash with no warning or opportunity to fix your shit"

binlist = [bin(x)[2:].zfill(8) for x in range(0,256)]

[print(i,j) for i,j in enumerate(binlist)]

Is there a text editor that's similar to notepad++ for linux\? I'm not a fan of notepadqq.

VIM or GNU Emacs

When someone ships software in C/C++/Java do they compile the executable file with optimization flags?

Typically, yes.

No, it takes too much time to build and they include all debug flags so the user can see what happens when an assert goes wrong.

Yes, that's the Unix way. Error handling is code-word for bloat.

python 2.7+ compatible
print [(i,j) for i,j in enumerate([bin(x)[2:].zfill(8) for x in range(0,256)])]

Java doesn't optimize at compile time because it compiles to byte code and optimization depends on the native implementations (so optimization is done at run-time).

As for C/C++, usually people optimize to some extent for their release builds but there are some trade-offs especially for very large programs.