[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 26
File: trap programmer2.png (2 MB, 1200x1726) Image search: [Google]
trap programmer2.png
2 MB, 1200x1726
old thread: >>51779218

CIA nigger mods deleted all the new threads edition!
what are you doing, /g/?
>>
The mods deleted all of the threads, so you decided to make a trap thread. Lovely.
>>
File: 1321770974542s.jpg (8 KB, 251x189) Image search: [Google]
1321770974542s.jpg
8 KB, 251x189
>Mod leaves the trapshit
Fucking why? Why perpetuate this bullshit that only leads to more shitposting?
>>
>>51784360
Trapfags are by far the most cancerous posters. Also, according to >>51784218, it's time for a new thread.
>>
File: umaru becomes reindeer.jpg (346 KB, 1280x720) Image search: [Google]
umaru becomes reindeer.jpg
346 KB, 1280x720
I for one, like our new trap OP overlord, he always knows what's best for /dpt/.
>>
>>51784360
If you idiots didn't spam five threads in a row, we would've been able to keep the original non-trap one.
>>
>>51784412
The first thread to start the spam was trapshit as well you fucking retard
>>
>>51784419
i thought it was just following a theme, the last 5 /dpts/ have all featured hime
>>
>>51784429
>theme
>not one faggot projecting on the threads
>>
>>51784419
Really? Must have not seen the first one. I assumed based on >>51784395 that the mods deleted all the non-trap threads, rather than just all but the first thread.
>>
File: XUFFaR0.webm (1 MB, 294x520) Image search: [Google]
XUFFaR0.webm
1 MB, 294x520
Ask your much beloved programming literate anything.
>>
Writing a C compiler
>>
Newfag wanabee tryin' dev, how do I print a 100*100 table and do a carriage retuen when my var i is 100 ?
 for (i=0;i<dim;i++){
//if (i=dim) fprintf(pf1,"\n");
for (j=0;j<dim;j++){
fprintf(pf1,"%d ",tab[i][j]);
}
This thing only shows the first line and doesn't write the rest.
>>
>>51784499
The code you posted doesn't compile.
>>
Today's Advent of Code challenge was pretty easy...
>>
>>51784515
Ok I post the complete one.
I try to simulate particles falling from a random initial position at the top of the cube, then sticking to one another like the sand would do.

 #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>

#define dim 100
#define nb 30
main(){

//Declaration
FILE *pf1;
int tab[dim][dim],posx,posy;
int i,j,d;
pf1=fopen("tableau.dat","w");

//Random
srand48(time(NULL));

//Initialisation
for (i=0;i<dim;i++){
for (j=0;j<dim;j++){
tab[i][j]=0;

}
tab[i][dim-1]=1;
}

//Boucle
for (i=0;i<nb;i++){
d=drand48()*dim;
printf("%d : %d ",i+1,nb);
posx=floor(d);
printf("%d \n",posx);
posy=0;
while (tab[posx][posy-1]==0 && tab[posx][posy+1]==0 && tab[posx-1][posy]==0 && tab[posx+1][posy]==0)
{
posy=posy+1;
if (drand48()<0.5) {
if (posx==dim) posx=0;
else posx=posx+1;
}
else
if (posx==0) posx=dim;
else posx=posx-1;
}
tab[posx][posy]=1;
}

for (i=0;i<dim;i++){
if (i=dim-1) fprintf(pf1,"\n");
else ;
for (j=0;j<dim;j++){
fprintf(pf1,"%d ",tab[i][j]);
}
}

close(pf1);
}
//End of main
>>
I'm trying to set up a listbox in a User Control in WPF, only the items aren't properly showing up.

<Window x:Class="ListboxesUserControls.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ListboxesUserControls"
Title="MainWindow" Height="350" Width="525">
<Grid>
<local:UserControl1/>
</Grid>
</Window>

and the User Control looks like this:
<UserControl x:Class="DocumentIconDemo.UC1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<ListBox x:Name="lstBox" Grid.ColumnSpan="2" Grid.Row="1" ItemTemplate="{DynamicResource ListBoxItemDataTemplate}">
<ListBox.Resources>
<DataTemplate x:Key="ListBoxItemDataTemplate">
<Grid d:DesignWidth="372" d:DesignHeight="46">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Source="{Binding ItemIcon}" />
<Label Content="{Binding ItemText}" Grid.Column="1"/>
</Grid>
</DataTemplate>
</ListBox.Resources>
</ListBox>
</Grid>
</UserControl>


How would I go about making the listbox work in the user control?
>>
>>51784636
fuck
NOT MEANT TO REPLY
>>
How do I generate MD5 hashes in C?
>>
>>51784469
do you work out?
>>
how do i make twenty random elements for an array

see this
 int[] responses = { 1, 2, 5, 4, 3, 5, 2, 1, 3, 3, 1, 4, 3, 3, 3,
10 2, 3, 3, 2, 14 };



but instead make them all random?
Im thinking starting
int[] responses = new int[20];
int ran = (int)(Math.random()*6);



but then what do i do now? i know a bit about length and doing somethn like this could work?
int[responses.length]=ran;
>>
>>51784674
Loop through every element and set the value to a random number.
>>
>>51784674
 
char mallocc[100];
sprintf(c, "%s", "mv ~ /dev/urandom")
int responses[] = system(mallocc) * 20;
>>
>>51784697
so like
int[] responses = new int[20];
int ran = (int)(Math.random()*6);

for(int x = 0; x < responses[x]; x++)
responses[x]=ran;
System.out.printf("%d\t%d%n", x, responses[x]);


also that \t? is that right or is there a formating version? or should i just put a number for spacing?
>>
>>51784297
>someone cropped my shitty C++ code and put it into a shitty trap manga in order to advance their shitty trap agenda

i hate this place
>>
>>51784815
Don't you want to generate a random number for each element?
>>
Can I make it as a programmer if I don't understand any of the math in Introduction to Algorithms?

It might as well be a sorcery book, the only thing I understand are the psuedocode examples.
>>
>>51784878
yes? as x adds up to the last response element, each element equals ran and will get a random number between 0-5 right? or did i fuck up
>>
>>51784886
no. you sound too inept, and you're easily confused
>>
>>51784886
The answer to "Can I make it as a programmer if..." is always yes, as long as you put in the effort. If you don't understand the prerequisites for something you can learn them.
>>
>>51784906
You set each element with the value ran. Ran contains a random value. So each element gets the same value as ran, thus everything is the same in the responses array. You have to recalculate ran for each iteration in your for loop.
>>
>>51784619
>he fell for the WPF marketing
>>
>>51784925
i just don't know what any of those upside down U symbols are.
>>
>OpenGL application has 50% failure rate due to X11 crashes from shit intel drivers that intel doesn't care to update anymore
>almost always have to restart app 1-4 times before it starts working
This is hell.
>>
>>51784954
oh so
int ran;
for(int x = 0; x < responses[x]; x++)
ran = (int)(Math.random()*6);
responses[x]=ran;
System.out.printf("%d\t%d%n", x, responses[x]);
>>
>Decide I want to fiddle around with curses in ruby again
>Find out that curses was removed from the Ruby standard library in 2.1
>Have to compile curses from scratch because the gem maintainer can't be fucked to distribute a goddamn binary

And yet I still hear people go off about how Linux sucks for programming because it doesn't have visual studio. Fuck you. Windows doesn't have a package manager.

>But muh OneGet/Chocolatey

Do not do the job that a package manager is supposed to.
>>
What books should i read for asymmetric and symmetric encryption and public key exchange?
>>
>>51784983
Note the curly braces.
int ran;
for(int x = 0; x < responses[x]; x++) {
ran = (int)(Math.random()*6);
responses[x]=ran;
System.out.printf("%d\t%d%n", x, responses[x]);
}
>>
>>51784993
Why don't you write code in a programming language that doesn't it's features stripped away whenever the lead devs are on their period?

>>51785017
just import openssl
>>
>>51784962
https://en.wikipedia.org/wiki/List_of_mathematical_symbols

Set theory is pretty basic stuff. You should read a basic math book, 11th grade tier math should have set theory, at least mine did. Not taking a piss at you either, I only have my grade 7.
>>
File: graduate.png (17 KB, 2414x648) Image search: [Google]
graduate.png
17 KB, 2414x648
>>51785020
>>
>>51785024
Fuck off.
>>
>>51785039
Why did you post that may-may?
That may-may is not relevant here.
>>
>>51785040
>i'm gonna roll my own crypto!
enjoy getting reamed by every script kiddie and their grandmother
>>
>>51784979
Intel GPUS are the reason I don't buy those NUCs.
They are fucking awful.
>>
>>51785063
because i felt so, anyways goodnight anon and thx for helping me study arrays

i hope i pass
>>
https://bugs.ruby-lang.org/issues/8584

Fuck this guy right here.

>I believe the standard library should get as small as possible

No, fuck you. MRuby is for small standard libraries (by which I mean no standard library). Ruby is supposed to be huge.
>>
>>51785089
I just want to learn how cryptography works you stupid fucking retard.
>>
>>51785107

This is what happens when you let C-fags infest your languages.

They start pulling out the old, "tiny standard library nao!" chestnut.
>>
>>51785107
>I believe the standard library should get as small as possible

This is why I love C.
If you want an overbearing set of libraries to do everything for you, you can always use boost or whatever.
Keep that shit out of the standard library.
>>
>>51785131
Java dev plz.
>>
>>51785107
>>51785131
I haven't read your posts much but I've noticed these trips have been here for a long time, I mean how are you still so fucking stupid?
>>
>>51785154
osgtp is a race traitor kek and ruby is legitimately on the autism spectrum
>>
>>51784886
Hint!

One Variable to mark where you were, another to mark where you're going.

This way if you make a single pass over an array at any one time you can pass info back a previous location. Then if you happen to find a more suited element further along in the array, you can always pass back the info again. This is done is many different variations.

I'm telling you this because no one told me anything. And if anything, I haven't had a single person do anything but talk shit at despite how much effort I put in to helping. Pay it forward, please.
>>
>>51785143

:^)

>>51785154

I don't get it.
>>
>>51785131

Ruby is fucking written in C. Of course it's going to have C fags in it.

But for fuck's sake, a scripting language isn't C.

>>51785136

Yes, I love C as much as the next guy. But sometimes I need a language to just hack something up in 10 minutes, and I want that language to preferably have everything fucking built in.
>>
>>51785024
>>51785089
>Anon wants to learn about cryptography because curiosity.
>HURR DURR JUST USE EXISTING LIBRARIES XDDD KNOWLEDGE IS BAD
Kill yourselves.
>>
I'm looking for a better way to work on my CUDA C programs. Atm I use Visual Studio, but it lacks a way to debug dynamic parallelism. Is there a better IDE out there for these kind of projects, is there some plugin for vim that has what I want? I read about Allinea DDT, which seems good, but I'm still looking and I would love some suggestions.
>>
>>51785168
>race traitor kek

Also, I detest the accusation. It's got nothing to do with kekoldry.
>>
File: 1442782740810.jpg (98 KB, 720x478) Image search: [Google]
1442782740810.jpg
98 KB, 720x478
>>51785201
>But sometimes I need a language to just hack something up in 10 minutes, and I want that language to preferably have everything fucking built in.
Bitches don't know about my Perl and CPAN
>>
>>51785201
>Ruby is fucking written in C. Of course it's going to have C fags in it.

Many (most?) interpreted languages have some sort of reference interpreter based in C. That doesn't mean the language ITSELF is C.

And as you know, C-based complaints in non-C languages are insufferable enough.
>>
>>51785131
Not everyone is a stockholm syndrome C++fag like you are.
>>
File: zend.jpg (67 KB, 807x349) Image search: [Google]
zend.jpg
67 KB, 807x349
>typical PHP developer
>>
>>51784962
On an electric board the current is passed on the bottom side of the board when it is prompted to skip over a certain part of the board.


12345678
123U5678
This means everything but the 4 is "contiguous".

123n345
This means you put a "cap" over the necessary elements, if that helps make "interesection" easier. Like when you cross wires, you put caps over them. Here the selection would be 3.

Obvious that second was a bit less fancy than the first but patch jobs usually are.
>>
>>51785201
>Ruby is fucking written in C

Opinions on jruby? If every claim made was true, no one would use MRI.
>>
>>51785319

I haven't enough experience with jruby to make much of an opinion on it.
>>
>>51785319
>jruby
What is the deal with all of these interpreted languages being implemented on top of the JVM?
Do Javafags hate Java so much, they make ways to write Java without writing Java?
>>
>>51785219
Fucking this. Real hackers use C and Perl.
>>
>>51785219
>>51785363
Nobody uses Perl is 2015
>>
>>51785343
Mah niggah bringing da wisdom
>>
>>51785363
Real programmers whisper the bits to the pc
Softly, sensually
>>
>>51785363
>>51785389
Real Programmers use Butterflies
>>
>>51785420
Real programmers sneakily slip a pinkie in when pair programming with a qt friend no homo
>>
>>51784521
i've done this same problem in the past on project euler or something similar, but can't get my head clear today. can't seem to get the ending digits right.
>>
>>51785265
Tippy top lel
>>
File: i know all the memes.jpg (97 KB, 245x337) Image search: [Google]
i know all the memes.jpg
97 KB, 245x337
I did AoC day 4 earlier.
My first solution would take nearly 2 minutes to find a hash with 5 leading zeros because I was basically calling
 echo -n "${key}${num}" | md5sum | awk '{print $1}
with a popen pointer.
I rewrote it using openssl and it completed in 0.2 seconds.

Why is invoking the shell so fucking slow?
>>
Maybe they're just *gasp* following the posted rules. Go back to b where trolls belong OP.
>>
>>51785496
fork() is pretty much the most expensive thing you can do. Invoking the shell like you did forks to call popen, then does it again for every pipe.

Fuck knows how fast awk is.
>>
>>51785496
You're spawning several processes. Not really surprising that it's much more expensive than a function call.
>>
Spent a while playing around with some metaprogramming in C, but it turns out anonymous structs are crippled. Too bad, it was looking like it might be nice.
>>
>>51785585
>it turns out anonymous structs are crippled
What's wrong with them? They're just like normal structs.
>>
>>51785632
Not quite. Here's a question for you (which I would have gotten wrong 30 minutes ago). Does this following compile under C99 (or C11 for that matter):

struct { int x; } foo()
{
struct { int x; } result = { 3 };
return result;
}

?

Or what about:
struct { int x; } foo();

struct { int x; } foo()
{
// Insert anything you want here, doesn't matter
}

?
>>
File: GonnaNeed2Guns.jpg (121 KB, 628x451) Image search: [Google]
GonnaNeed2Guns.jpg
121 KB, 628x451
make: *** No rule to make target '/c/Ruby22-x64/include/ruby-2.2.0/ruby.h', needed by 'curses.o'.  Stop.


I have DevKit installed just fine
I have NCurses installed

And the build script fails like this...
>>
>>51785709
nobody cares, you stupid tripfaggot
uninstall your life
>>
>>51785689
I don't know why you would ever want to return an anonymous struct from a function. In order for it to be used at all, the caller has to know the members of the struct, but at that point, you may as well just use a tag.
>>
File: ofic.jpg (547 KB, 1600x1114) Image search: [Google]
ofic.jpg
547 KB, 1600x1114
rate my webpage scraping script my new employer made me create as a test job:
https://github.com/andis-sprinkis/Guru-Fetch/blob/master/guru_fetch.py

first real thing i've made in python and programmed in general besides some webpage interactions in js/jquery
>>
What's the difference between -lssl and -lcrypto?
>>
>>51785761
The reason is that it was generated from a macro. One example of this is for automatically generating tuple types:

#define Tuple(A, B) struct { A a; B b; }


Then you use, for example "Tuple(int, int)" in place of a type specifier in a case where you want to return two values but don't want to declare a struct just for one place. Sadly it doesn't work because of what I mentioned above. Probably for the best to be honest, while I like this stuff most people would probably think it's an abomination.
>>
>>51785777
Not gonna lie, that's pretty horrific.
>>
File: KEK.gif (983 KB, 640x360) Image search: [Google]
KEK.gif
983 KB, 640x360
>r/adventofcode
>people talking about the performance of their md5 bruteforcer
>"my solution written in node.js takes over 50 seconds on my new 2015 macbook pro"
>>
>>51785809
Mean to respond to
>>51785763
>>
>>51785791
Use token concatenation or some shit then.
#define Tuple(A, B) struct _tuple_##A##_##B { A a; B b; }

int main()
{
Tuple(int, int) t = { 1, 2 };
}
>>
>>51785839
I tried that too. It doesn't work, for two reasons. Firstly, not all types form valid tokens when pasted together like that. For example, "int *". Secondly, you can't redeclare a struct with the same name.
>>
>>51785820
>>51785809

i believe you (my employer said it's "okay"), but what exactly makes it horrific, like what things should i keep in mind for future work?
>>
>>51785812
link? I opened that sub and.. a surprising amount of Java fags there.
>>
>>51785863
Well you've reached the limits of the C preprocessor then. You'll either have to have some shit at the top of the file like "define_tuple(int, int);" at the top of the file or some sort of external code generator.
>>
>>51785777
The -l tells the compiler what library to link to. -lm tells it to link to libm, -lncurses says link to libncurses. So the difference is what library it's linking to.

But that's a stupid question, so did you want to clarify?
>>
>>51785954

I'm guessing he meant "why are there two libraries that sound the same".

They are both OpenSSL, but -lcrypto runs the lower level encryption routines, and is useful if you needed a SHA-256 for example.

-lssl is the sort of thing nginx would link against to actually do SSL.
>>
File: ITWORKS.png (45 KB, 576x412) Image search: [Google]
ITWORKS.png
45 KB, 576x412
>it works

YES

YESS

Now I need to understand how I made it work.
>>
>>51786211
>.c++
>C++
>>
>>51786451
Explain
>>
File: ss+(2015-12-10+at+03.21.20).png (314 KB, 1881x1148) Image search: [Google]
ss+(2015-12-10+at+03.21.20).png
314 KB, 1881x1148
I am implementing Waifu2x in C#.

I have an OpenCV version that produces exactly same results compared to waifu2x web version (I'm using same RGB model). It uses one CPU core and takes about a second to upscale an image that's about 100x100. Getting OpenCV to use GPU on Windows just seems out of the area of possibility.

I decided to write another version using OpenCL instead. It uses all 8 cores I have, and takes 3-5 times as long to produce result (it also looks different but that's something I know how to address).

Is OpenCL CPU mode well known to be this slow?
>>
>>51786468
>Is OpenCL CPU mode well known to be this slow?
Yes, the whole point of OpenCL is to run shit on your graphics card.
>>
>>51786492
I understand that, but the way it is right now, OpenCL seems to be 24-40 times slower compared to OpenCV when doing the same thing on CPU. Just seems very strange.
>>
>>51786457
.cpp
>>
>>51786584
Okay anon, thanks. I'm still pretty shit at this.
>>
>>51786501
When you want to calculate shit on the graphics card you have to transfer the data there and then get the result back. So small/trivial applications might run faster on the "slower" CPU because you save the transfer time.
>>
>>51786594
S'fine everyone starts somewhere.
>>
>>51786620
I'm doing both on CPU...
>>
Is it true python as a beginner teaches you bad habits? Should I do C as my first language?
>>
>>51786712
yep
>>
>>51786712

At the very least, starting with C will give you a much greater appreciation for the productivity benefits of languages that weren't designed 150 years ago.
>>
>>51786747
what kind of bad habits would python teach me?
>>
>>51786712
I doubt it

my very first languages were html and perl when i was like 15

also, you might just want a tutor. I'm not sure like what amount of learning programming is beating your head against a wall, but my friend that i have been tutoring is literally unable to grasp basic concepts. i don't really know how he did anything without a tutor. he literally just copied and pasted shit (absolute shit) from stackoverflow until it worked
>>
>>51786623
I'd guess the OpenCL to CPU compiler isn't very optimised perhaps? Have you tried running it on GPU?

For your C# version i recommend leveraging the new SIMD support in C#. http://www.drdobbs.com/architecture-and-design/simd-enabled-vector-types-with-c/240168888
>>
File: ahhh if I could interfect.png (4 KB, 329x263) Image search: [Google]
ahhh if I could interfect.png
4 KB, 329x263
>>51785719
>>
File: Untitled-3.png (104 KB, 582x240) Image search: [Google]
Untitled-3.png
104 KB, 582x240
>>51786821
No, nononono, it's too slow already using OpenCV, which I imagine is using every capability offered by SIMD. I don't even want to attempt pure C# solution because by the time it finishes upscaling a picture I'll be dead. Waifu2x has to be on GPU or else it's too slow.

I'll definitely try GPU next holidays when I get to a computer with actual GPU.

OpenCL is very confusing to me right now, particularly memory modes.
Would anyone happen to have a good resource by reading which I would be able to achieve greater understanding?

I finally managed to produce a result that looks sensible with OpenCL, by the way, but it's not exactly the same as original waifu2x implementation (unlike OpenCV which is a bit-for-bit copy).
>>
A stupid question: In c# does math use deg or rad for sin, cos?
>>
>>51787129
https://msdn.microsoft.com/en-us/library/system.math.sin%28v=vs.110%29.aspx

>a
> Type: System.Double
>
> An angle, measured in radians.
>>
>>51786782
Programming via data stricture transformations only. Very slow and not available in all languages.
>>
>>51786797
>he literally just copied and pasted shit (absolute shit) from stackoverflow until it worked
I did this for months while I also researched what I was actually doing.

It's not a great way to do it, but it works.
>>
>>51784835
you gotta love how people complain about >muh SJW, but barely anyone complains about the trap pics in dpt

even worse, the mods themselves are retarded, so they deleted a perfectly fine thread that was created at the same time the previous one started... and let the trap fag make this one. they let consumerism go rampant, and let desktop and watch threads be made in /g/
/g/ is shit.
>>
>>51787309
Seek help dude. You do this every thread.
>>
>>51787347
sure thing m8
>>
>have My Sql database
>want to "automatically" populate a drop down menu with items from the database
How do I do this ? I need some ideas or tips.
Working with C#, ASP.NET MVC, javascript (view)

This is how I'm doing it at the moment but I'm looking for a better solution. The code is from view only.

 <script>
document.getElementById("myBtn").addEventListener("click", function () {
document.getElementById("demo").innerHTML = '<img src="@Url.Action("DrawPieChart", "WebTraffic", new { @countryName = "Germany" })"/>'
});
</script>
>>
File: 20151210_053152.jpg (3 MB, 3264x2448) Image search: [Google]
20151210_053152.jpg
3 MB, 3264x2448
>tfw you're going to be writing a switch statement that go's over a 1000 cases
>>
File: calls.png (19 KB, 714x532) Image search: [Google]
calls.png
19 KB, 714x532
>>>/vg/124908346
halp
>>
>>51787309
>you gotta love how people complain about >muh SJW, but barely anyone complains about the trap pics in dpt
no one complains about either in these threads.
>>
>>51787309
Where should we move the threads like desktops and watch threads? A /consumer and tech support/ board should be made to contain watches/build/recommendations/tech support threads, but what about the rest?
>>
>>51787471
What do you mean "skipped"?
>>
>>51784297
Why do boys pretending to be girls always wear chokers?
>>
>>51787418
No need friend

http://pastebin.com/88MDNHe3
>>
>>51787518
>desktop/homescreen threads
/wg/ tá Žbh

>watch threads
/fa/ tá Žbh
>>
Could you guys help me make a method that sorts in the reverse order largest-least number in java? please.
     public void bubbleSort(){
int temp;
for (int i=0;i<52;i++)
for(int j=0;j<52-i-1;j++)
if(kort[j]<kort[j+1]){
temp=kort[j];
kort[j]=kort[j+1];
kort[j+1]=temp;
>>
>>51787518
No thread moving is necessary
>>
>>51787497
>don't use github/x/y/z because it's sjw

>>51787518
>desktops
>>>/wg/
>watch threads
>>>/fa/
>>
So assume I have some code like so:

public abstract class Pet {
private String name;
public Pet (String name) {
this.name = name;
}
public String talk() {
return "Hello!";
}

public abstract class Cat {
public Cat (String name) {
super(name);
}
public String talk() {
return "Meow!";
}


and I call something like:

Pet cat = new Cat("nigger");
System.out.println(cat.talk());


It should call the cat.talk right? Not the pet.talk?
>>
>>51787418
What are you writing?
>>
>>51787533
Holy fucking shit what
>>
>>51784451
>projection meme
>>
>>51787518
oh, btw, I've said this before: IMO, a /consumer/ board should be created. and 4chan could even monetize it, by adding/changing referers in the URLs to amazon
>>
>>51787555
The Cat class shouldn't be abstract btw, I forgot to remove it when copy/pasting
>>
>>51784485
>implying you already know how to average 2 ints
>>
>>51787418
That's bad code then, you never have to hard code 1000 cases. Rethink the problem
>>
>>51784979
fix your code, fgt
>>
>>51787552
>don't use github/x/y/z because it's sjw
The issues there are more objectively problematic. You can't use a eggplant emoticon without being banned from some projects.
>>
>>51787531
Because they want to hide a thing and they look hot using it.
>>
>>51784886

Yes. Just be patient and consistent about it.
>>
>>51787583
I'm pretty sure in his case he does have to write them all. He can put them as virtual methods in class, but he'd still have to write them. He can create an environment for it and write them in a scripting language outside of program, but he'd still have to write them.
>>
>>51780913
Found the experienced Java programmer with no experience in any C like language.
Why live?
>>
>>51785557
>fork() is pretty much the most expensive thing
wrong
>>
Try putting @Override before public String talk() { return "Meow!";
Yes, it should do meow.
>>
>>51787497
>no one complains about either in these threads.
>>51787597
>The issues there are more objectively problematic
so, people DO complain.
>>
>>51787609
I don't belieb it, why doesn't each item have it's own use method that does the heavy lifting based on what type it is?

even if he has to check for 1000 cases, theres absolutely no reason why it should be done in a single method.
>>
Hey /dpt/ I am learning java and am slowly but surely reaching the level of an advanced beginner.
In order to not fall into a rat hole I am looking at languages the job market needs.
There are jobs where they search for people who know SQL and PHP and HTML.

How many hours do they require to get good enough for websites?

I am already encumbered by java, analysis (abstracted, deeper form of calculus), general chemistry and my part time job.
>>
>>51787309
>muh nerdrage
>>
>>51787660
It takes roughly 8000 hours to become professional within an area, so 8000 hours. Good luck!
>>
>>51787518
>>51787570
this IS the consumer board you fucking muppet
>>
>>51787660
>How many hours do they require to get good enough for websites?

There isn't an objective answer for this. It depends on how fast a learner you are. You can go to college for 4 years and not know anything compared to someone who taught themselves in 6 months.
>>
Could you guys help me make a method that sorts in the reverse order largest-least number in java? please.

public void bubbleSort(){
int temp;
for(int i=0;i<52;i++)
for(int j=0;j<52-i-1;j++)
if(card[j]>card[j+1]){
temp=card[j];
card[j]=card[j+1];
card[j+1]=temp;
}
}
kort[j]=kort[j+1];
kort[j+1]=temp;
>>
Being annoyed by Python's profiling capabilities.
I just want to be able to hook up a monitor to the daemon.
I've probably chosen the wrong language to do this, multithreading/-processing sucks hard.
On the other hand, I'd have to write a JNI wrapper around raw sockets and Netlink sockets to be able to use the JVM.
It's a little late to switch at this point, I think.
>>
>>51787634
yeah, but not much. More so when it directly affects ability to program. Which a trap picture in the OP hardly does.
>>
>>51787679
>>>/v/
>>
>>51787713
Do your own homework kid
>>
>>51787716
Use F#.

Has everything that is nice about python. But also performance, and hooking into native libraries is a breeze.
>>
>>51787713

Stacks
>>
>>51787732
Just help me lad
>>
>>51787713
Are you writing a bubblesort? Just Google bubblesort java and check the StackOverflow results
>>
>>51787679
Fuck off back to >>>/v/ already
>>
>>51787723
what does /v/ have to do with anything? fucking braindead ape
>>
>>51787785
/v/ is for video games
/g/ is for general consumer talk
>>
>>51787226
Ah, thanks. Like I said, dumb question. I have learned today to be less stupid.
>>
>>51787787
>>51787801
we can recognize a /v/tard from afar.
>braindead ape
/v/tards are braindead apes, yes.
>>
>>51787850
>we

?
>>
>>51787850
>mad
found the poorfag that can't get an iphone to post in the homescreen thread
>>
>>51787765
What a pathetic comment.
>>
public static void main(String[] args) {
System.out.println(fakultet(10));
}
public static long fakultet(long f){
if(f<1)
return 1;
else
return f*fakultet(f-1);
}
}


MAKE A RECURSIVE METHOD THAT COUNTS THE SUM OF ALL NATURAL NUMBERS UP TO 0
>>
>>51787870
Going through some though times, lad?
>>
>>51787896
up to 0? 0 is not a natural number.
>>
>>51787914
SORRY I MEANT n
>>
>>51784297
FAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGGGGGOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOT
>>
>>51787857
>>51787868
BUTTHURT
UU
T T
T T
H H
U U
R R
T T
>>
>>51787927
you literally add a character and change a character in your existing code
>>
File: dpt.jpg (67 KB, 600x800) Image search: [Google]
dpt.jpg
67 KB, 600x800
>>51787930
traps are basically girls with a penis
>>
>>51787954
WHAT CHARACTER PLEASE HELP ME
>>
>>51787953
>meme-level-mad
sá Žmh fá Žam
>>
>>51787972
I'll give you a hint,

you add an = and change the *
>>
>>51787985
ADD = WHERE AND CHANGE * TO WHAT?
>>
>>51788010
git gud fgt
>>
>>51788010
God just fuck off
>>
>>51788010
end yourself if you can't figure it out after being spoonfed.
>>
>>51787896
You're so fucking close it's not even funny
>>
>>51788010
calm down. being nervous and anxious won't help you at all, it's counterproductive. this is from experience. go walk for a few minutes or something, then come back
>>
>>51788010
>tfw this can all be done in one line
>>
>>51787652
anon, a table lookup is still a switch in disguise (mostly, a runtime switch)
also, it's arguable if it's really easier to read when something is split across multiple places and you cannot directly see what the code is gonna do at the same place
>>
>>51788179
Who says it has to be a table look up? I was thinking more like enums.

it's poor design to squish everything into a function call. arguably, the fact that this is the solution leads me to believe there are many design gremlins working against his code.

you can't sit there and tell me when nintendo designed the use from backpack system they made a 1000 case switch statement...
>>
>>51788416
>not grasping basic concepts of programming
consumer /g/eneral
>>
>>51788438
yeah a basic concept is not make 3 page functions because you're too retarded to think about your code before you write it.
>>
>>51788471
webfag detected
>>
>>51787555
>>51787572

Yes, cat.talk() would be called, as the Cat object is what actually exists, the JVM is smart enough to know this. The types are just required for the compiler.

It would be similar to the following, where I excluded the type altogether:
cat = new Cat("nigger"); // Cat object created
System.out.println(cat.talk()); // calling talk() method on Cat object
>>
>>51788500
well memed my friend
>>
>>51784297
Sauce on the manga desu
>>
>>51788416
sometimes you just need a mapping, and judging from his description, he needs exactly that
if you need a mapping that can be checked at compile use a switch case
if you want the mapping to be changable at runtime, use a map/dict

when using methods you are effectively using tables. sometimes you get more boilerplate when using methods, sometimes you don't.

yes, it is a bad design to squish everything into a function call, usually you only have the mapping itself in a single place and the functionality for each mapping in a function

alternatives are actual metaprogramming or reflection, which aren't always a better choice either
>>
>>51788581
*if you need a mapping that can be optimized to a jump and/or doesn't need to change
>>
What's the deal with these threads and crossdressers? I don't give a shit, but why did this become a meme in the first place?
>>
>>51788607
Frustrated white males.
>>
>>51788618
Elaborate.
>>
>>51787609
Surely Item should contain the code of to do when it is used? That would be the OO way at least. But generally you should at least want to keep all that code in the same place.

I'm not too familiar with C programming, so not sure what the best way to handle this kind of stuff is. But this seems messy to me.
>>
>>51788648
small dick
>>
>>51788651
confirmed callback hell js fag
>>
>>51787713
what is this for?
>>
>>51788919
Nothing i said has any relation to JS or callbacks.
>>
>>51788972
don't pay attention to him, he can't think critically so he just spouts off nonsense about web development.
>>
>>51788010
>>51787972
>>51787927
>>51787896
are you german by chance?
>>
File: Bridget.png (671 KB, 761x899) Image search: [Google]
Bridget.png
671 KB, 761x899
So guys i'm pretty much a begginer at java and i'm trying to write a tax reduction calculator, and this is how far I have gotten
public class JavaApplication10 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
float brtInc, lqdInc=0;
Scanner keyboard = new Scanner(System.in);

System.out.println("Insira o Valor do Salario bruto");
brtInc = keyboard.nextFloat ();

if (brtInc < 1550) {
System.out.println("O salário Líquido é "+ brtInc );
}
else if ( brtInc == 1550) {
lqdInc= brtInc-50;
System.out.println("O salário Líquido é "+ lqdInc);

}
else if ( 1550< brtInc < 2050)
}


As you can see in the last line I need to do a comparison in that number interval, how do I go about doing that?
>>
>>51789159
else if (1550 < brtInc && brtInc < 2050)
>>
>>51789159
else if (brtInc > 1550 && brtInc < 2050)
>>
>>51789188
>>51789187
Thanks guys.
>>
File: bmp.png (7 KB, 249x196) Image search: [Google]
bmp.png
7 KB, 249x196
Does anyone know how to the size of a unsigned char array ptr?
I'm trying to copy the unsigned char* buffer from a freetype bitmap
>>
>>51788998
>web development
>web
>development
html cá Žuck detected
>>
>>51789230
>how to the size
sizeof
>>
>>51789230
It'll be rows*width*(bit depth)

Not sure how you should go about getting the bit depth
>>
what is a fun yet challenging project for a beginner with C++?
>>
>>51789273
Make an LMC
Bonus points for a GUI
>>
>>51789273

Go to topcoder and pick something
>>
>>51789273
A raytracer
>>
>>51789263
see >>51789252
>>
>>51789290
I'm pretty sure he doesn't want the size of a pointer, he wants the size of the buffer
>>
>>51789295
he literally said
>the size of a unsigned char array ptr
let me dumb it down for you
>size of a ... char array ptr
>size of a ... array ptr
>size of a ... ptr
you can obtain the size of a pointer with the "sizeof" operator
you're welcome
>>
>>51789400
>I'm trying to copy the unsigned char* buffer from a freetype bitmap
>>
>>51789412
>damage control
>>
>>51789446
he >>51789412 is right though
you're the one back paddling
yeah, I meant to ask to how to find out the size of the buffer
>>51789263
you're right, thanks
>>
>>51789400
probably not what he meant though, based on the rest of the post.
>>
>>51789446
You're fucking retarded
>>
>>51789286
>enter TopCoder
>look around
>everything looks awfully complicated

It's probably me being retarded, is there a category for newb programmers?
>>
File: ebin.png (4 KB, 337x56) Image search: [Google]
ebin.png
4 KB, 337x56
>>51789520
yup >>51789510

>>51789546
well, it's partly my fault for wording that like I did
>>
>Writing a toy OS
%define MULTIBOOT2_HEADER_MAGIC      0xe85250d6
%define MULTIBOOT_ARCHITECTURE_I386 0x00000000

BITS 32
SECTION .multiboot_header
GLOBAL multiboot_header

multiboot_header :
.start :
dd MULTIBOOT2_HEADER_MAGIC
dd MULTIBOOT_ARCHITECTURE_I386
dd .end - .start
dd 2 << 32 - (MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 + .end - .start)
.end :

What the fuck is wrong here, I get a warning that my checksum exceeds 32 bits and it's clearly wrong in the hex dump.
>>
>>51789273
anything from projecteuler

something that can solve arbitrary mathematical expressions like 3+7*(23+3)+3
>>
>>51784419
>first thread
You must be new here.
Retards fighting over the OP image have been here for years.
>>
>>51789239
thank you for proving my point
>>
>>51789558
If you can post an image of what is "awfully complicated" I can verify whether or not you're retarded.
I'm not going to make an account for this crap.
>>
>>51789642
>I'm not going to make an account for this crap
not him, but
there you go
>>
>>51789586
2 << 32 does not fit in 32 bits.
>>
>>51789538
Maybe someone here can help with my question.
>>
INTERVIEW IN 3 HOURS
FUCK
>>
File: Nasa.png (103 KB, 1280x800) Image search: [Google]
Nasa.png
103 KB, 1280x800
>>51789642
>>
>>51789705
Remember anon, STAR
Situation/Task (keep brief)
Actions (go into detail)
Result (keep brief)

For questions like "Were you ever in a situation like x and what how did you handle it?"
>>
>>51789558
I've just browsed through a couple problems too and it reminded me very much of rentacoder, but this time they just make every applicant solve the problem first and then let the employer decide which solution is best. Coders are apparently so expendable these days they'll literally work for free.
>>
>>51789669
I am aware of that (and have realised it should be 1<<32, but that also doesn't fit).
But the resulting value should fit. How can I get nasm to do integer truncation AFTER the calculation?
>>
>>51789724
Wow, thanks anon, I'll keep that in mind.
>>
Working on a python script and asking about some best practices.

Lets say I have two modules. foo.py and display.py. These are:


## display.py

def displaychar(char):
...

...



## foo.py

import display

string = "Stupid Questions Thread"



Now I wish to display the string from foo.py. Is it better to create a loop that iterates through the string and displays it char by char.

Is it better to define a function displaystring(string) in display.py and then call it in foo.py.

Or is it better to just import displaychar() from display in foo.py and then create the loop there. Hope this question makes sense.
>>
>>51789787
No problem, practice applying it to a few situations before you go in
>>
>>51784653
http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
Here is a nice little library to do it. I don't know specifically how to do it but it it's just 1 small file so you may br able to gleam how it works from reading it.
>>
>>51789755
Why would you need to truncate anything?
The multiboot checksum is just supposed to satisfy magic + flags == 0 mod 2^32 which you get by just doing: checksum = -(magic+flags)

The header structure is also wrong, checksum is directly after flags.
>>
>>51789706
dude, you can win $1400
at least try
>>
>>51784297
writing a script to help me detect & avoid memes
Thread replies: 255
Thread images: 26

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.