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.
>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.
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.
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 thisint[] 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 startingint[] 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 likeint[] 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 soint 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.
>>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.
>>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.
>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
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 callingecho -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
}
?
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.
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.
>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.
>it works
YES
YESS
Now I need to understand how I made it work.
>>51786211
>.c++
>C++
>>51786451
Explain
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
>>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>
>tfw you're going to be writing a switch statement that go's over a 1000 cases
>>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.
>>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
>>51787868BUTTHURT
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
>>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?
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 gottenpublic 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?
>>51789159else if (1550 < brtInc && brtInc < 2050)
>>51789159else if (brtInc > 1550 && brtInc < 2050)
>>51789188
>>51789187
Thanks guys.
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
>>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?
>>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
>>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
>>51789874
That still gives me a warning
And I was using the header as documented here: http://git.savannah.gnu.org/cgit/grub.git/tree/doc/multiboot2.h?h=multiboot2struct multiboot_header
{
/* Must be MULTIBOOT_MAGIC - see above. */
multiboot_uint32_t magic;
/* ISA */
multiboot_uint32_t architecture;
/* Total header length. */
multiboot_uint32_t header_length;
/* The above fields plus this one must equal 0 mod 2^32. */
multiboot_uint32_t checksum;
};
>>51785709
You might need to rebuild nCurses without ruby support. ./configure --without-ruby or some shit and then make install
How do I change this code so that when I first input for example [nig,gers] [20] and afterwards [niggers [20], then it won't go to the else line?def L_l():
lisamine = input('Fikseerige sade kujul [Identifikaator]Tyhik[Sademed] (C): ').split()
sona1 = list(lisamine[0])
sona2 = list(lisamine[1])
t2hnum=lisamine[0]
while sona1[0]!= '[':
lisamine = input('Fikseerige sade kujul [Identifikaator]Tyhik[20] (C): ').split()
sona1 = list(lisamine[0])
while sona1[len(sona1)-1]!=']':
lisamine = input('Fikseerige sade kujul [Identifikaator]Tyhik[20] (C): ').split()
sona1 = list(lisamine[0])
while sona2[0]!='[':
lisamine = input('Fikseerige sade kujul [Identifikaator]Tyhik[20] (C): ').split()
sona2 = list(lisamine[1])
while sona2[len(sona2)-1]!=']':
lisamine = input('Fikseerige sade kujul [Identifikaator]Tyhik[20] (C): ').split()
sona2 = list(lisamine[1])
while t2hnum[1:len(t2hnum)-1].isalnum() == False:
lisamine = input('Fikseerige sade kujul [Identifikaator] [20] (C): ').split()
t2hnum=lisamine[0]
else:
print(lisamine)
return
>>51789803
>Now I wish to display the string from foo.py
>>51790165
not actually displaying the function, just simplified the code to an example for the question...
>>51785689
>anonymous struct in C
Use C++, unless you're planning on making your own version of C++.
>>51788904
Woudn't that mean it should be mostly spics and asians then?
Given M, get the smallest n where n! contains at least M trailing zero.
Knowing that 1<M<1,000,000,000
Is there a mathematic formula or an algorithm for this shit ?
>>51790276
I think the point of the problem is to find it
you just have to find if n! / 10^M is a whole number
solved the tenth day.private let input = "1321131112"
private func lookAndSay(string: String) -> String {
var returnString = ""
var count = 0
for index in string.startIndex..<string.endIndex {
count++
if index.successor() == string.endIndex {
returnString += String(count)
returnString += String(string[index])
} else if string[index] != string[index.successor()] {
returnString += String(count)
returnString += String(string[index])
count = 0
}
}
return returnString
}
func solveTenthDay() -> Int {
var returnString = lookAndSay(input)
for _ in 0..<49 {
returnString = lookAndSay(returnString)
}
return returnString.characters.count
}
>>51790276
Just start generating factorials and check each one?
cout<<"hello, /g/"
>>51790276
Probably best off asking /sci/ if you want a non naive algorithm unlike >>51790325, if it exists.
I want to get into functional programming. Does it matter which language I start with or should I just pick one?
>>51790372
just start with C
>>51789558
Go to the practice arena. There are problems ranked from beginner, intermediate to expert.
>>51790372
Lisp if you want to learn it, Haskell if you want to actually use it.
https://www.jitbit.com/alexblog/249-now-thats-what-i-call-a-hacker/
>kumar-asshole.sh - scans the inbox for emails from "Kumar" (a DBA at our clients). Looks for keywords like "help", "trouble", "sorry" etc. If keywords are found - the script SSHes into the clients server and rolls back the staging database to the latest backup. Then sends a reply "no worries mate, be careful next time".
Does /g/ have their own automated scripts to make their lives easier?
What are some cool usernames I can use so I can see on my shell whenever it asks for my password?
>>51790160
ok, i solved it myself, but how do I make it so that the input is [Identifier][number], without a space. .split only works when there's a space between.def L_l():
lisamine = input('Fikseerige sade kujul [Identifikaator]Tyhik[Sademed] (C): ').split()
sona1 = list(lisamine[0])
sona2 = list(lisamine[1])
t2h=lisamine[0]
num=lisamine[1]
while (sona1[0]!= '[' or sona1[len(sona1)-1]!=']' or sona2[0]!='[' or sona2[len(sona2)-1]!=']' or \
t2h[1:len(t2h)-1].isalnum() == False or num[1:len(num)-1].isdigit() == False or IndexError == True ):
lisamine = input('Fikseerige sade kujul [Identifikaator]Tyhik[Sademed] (C): ').split()
sona1 = list(lisamine[0])
sona2 = list(lisamine[1])
t2h=lisamine[0]
num=lisamine[1]
else:
print(lisamine)
return
>>51790325
have you ever thought of large numbers ?
>>51790201
Oh, then it makes no difference if the code is not going to be reused outside of that particular project. If it may be I would say make it more general, i.e. if the function is to display a string, not just a single character, then put the loop in the display function in display.py. or perhaps have two functions: displayString, displayChar; where displayString has the loop and calls displayChar.
I want to make a simple cipher
M : 0
U : 1
R : 2
C : 3
I : 4
E : 5
L : 6
A : 7
G : 8
O : 9
The word to be encoded would be "TESTING". How do I make it so every time a word from "MURCIELAGO" appears in "TESTING" it's changed to the corresponding number? Is there any tutorial? I want to practice with ciphers and stuff.
>>51790392
I would say Haskell for both, Lisp isn't pure so you can be tempted to take "the imperative way out"
>>51790372
Haskell if you want to wank it all day while doing nothing.
Scheme if you want an embeddable lisp that can be very high-performance but is best used as a subsystem.
Ocaml if you want to do real stuff.
Church if you don't want to be deprecated.
Whats the best way to store text for a text adventure game? Writing it in C++, I don't want to hard code all the text in my main logic, I'd rather just read them from a txt file but I have no idea how to go about implementing this. I know how to read from a file but is there a way to read a specific line from the file without using a loop?
>>51790466
thank you
>>51790468
C++,
forgot to specify which language I was using.
>>51790478
Maybe I'm thinking of Scheme and not Lisp. From what I remember of Scheme, it had no synctactic sugar whatsoever, just straight up function definitions and lambdas.
You can use Haskell like that too but every Haskell book seems to go hard on the whole syntactic sugar thing, which will probably confuse beginners as to what's actually happening in their code.
>>51790407
>fuckingcoffee.sh
>this one waits exactly 17 seconds (!), then opens an SSH session to our coffee-machine (we had no frikin idea the coffee machine is on the network, runs linux and has SSHD up and running) and sends some weird gibberish to it. Looks binary. Turns out this thing starts brewing a mid-sized half-caf latte and waits another 24 (!) seconds before pouring it into a cup. The timing is exactly how long it takes to walk to the machine from the dudes desk.
My sides, I need to get a telnet able coffee maker now.
>>51790276
http://lmgtfy.com/?q=factorial+trailing+zero
>>51790468
You mean a character, like TESTING => T5ST4N8 ?
>>51790514
std::map
>>51790527
Syntactic sugar isn't an issue IMO, it's the fact that Lisps allow side effects and don't tend to have type systems at all
Functional programming isn't very useful without strong type guarantees and purity, IMO; even something like Haskell could be vastly improved in that department
>>51790527
Function definition is syntactic sugar for symbol definition bound to a lambda. let forms are syntactic sugar for lambdas.
new thread when ? :3
>>51790563
Something like that, but removing the letters and just keeping the numbers.
>>51790276
Trailing zeros... Trailing zeros are made by the number having multiples of 10. 10 made by multiplication of 2, 5, or any multiples of 10. Now mix in some intuition and make the formula yourself.
>>51790594
Hopefully after bump limit FFS
>>51790569
Most lisp implementations have type annotations available, all lisps that I'm aware of have type systems (and the great majority implement, at least, a full numeric tower). All compliant lisps have the CLOS which is an OO stack for CL. A lot of scheme implementations have type hinting available. Finally, you have clearly never tried to use a pure functional programming language in practice. Try venchurch and tell us how you like it. Protip: you won't. If you are ever going to go beyond fizzbuzz, mutability is required to do anything in a non-tarpitty way.
>>51790595
How would you decipher the example then?
>>51790631
I'm just doing what the guys at TopCode want me to do, don't ask.
>>51790630
>purity means no mutability
And that's where you're wrong
With linear types (which may be emulated somewhat with monads), purity admits side effects
The Haskell standard library is also full of partial functions, which is another drawback IMO
>>51790651
>Look ma, no brain!
>>51790597
So... to continue...
There will always be a glut of 2s compared to 5s, because multiples of twos are more common. So all we really need to do is find the number of multiples of 5.
10! = 1*2*3*4*5*6*7*8*9*10
guess how many trailing zeros? My guess is 2. Actual is 10! = 3628800. 2 trailing zeros. According to this the formula is floor(n/5)
But wait... 25 is 5*5, it has two fives in it to make two 10s...
Compensate. I'll leave that up to you.
>>51790506
Use XML and a C++ XML library
With XML you can do shit like<MyCharacter>
<quests>
<activeQuest>Find the princess</activeQuest>
<activeQuest>Kill the necromancer</activeQuest>
<completedQuest>Created character>/completedQuest>
</quests>
<attributes>
<intelligence>8</intelligence>
<strength>5</strength>
</attributes>
</MyCharacter>
then in C++, you could do something like
string currentQuest = XMLreader.read("MyCharacter").read("currentQuest")[0];
>>51790656
Am I wrong?
fuck me lads,i got accepted to an internship(did some test and passed) ,what do i do now?I suppose to meet them and discuss about schedule and stuff like that.But i never worked before,what do they expect of me?
>>51790577
Yeah, I think that's the most syntactic sugar that should be allowed in a functional language for beginners.
>>51785198
go shitpost on /o/
>>51790675
They expect you to fetch them their coffee and do the lowly gruntwork nobody else wants to do, like write getters and setters for over 1000 private variables.
There's a technique/pattern used by some libraries (I don't remember which) for asynchronous I/O that involves passing an object X to an async method and having that same object X returned by the library to the callback method in order to identify the original request/operation. Anyone knows if said technique has a name?
>>51790665
bro why not just use your own file and format and write your own parse lmao
Nah but that looks nice. I have to find myself a nice XML reader.
NEW THREAD!
>>51790693
>>51790680
Beginners or not, a language should have the least amount of syntactict sugar required to make it both simple yet concise. Scheme strikes the middle-ground perfectly. It is too bad that no other language has followed suite.
>>51790689
The internship is on tdd,agile and stuff like that.
I know basic stuff,i read some books and passed the test but i dont know whats next.
>>51790665
Just use sxml. No need for a complex, backtracking parser, much smaller filesizes and much easier to read.
>>51790691
Futures?
>>51790642
>I'm just doing what the guys at TopCode want me to do, don't ask.
hahahahahahaha, ask them to clarify the cypher, you don't wanna make something and then get it rejected because they fucked up. As and engineer always assume your clients don't know exactly what they want and ask lots of questions.
>>51790712
I disagree. from(1 n) (i.e generate a list of numbers from 1 to n) gets old pretty fast. Haskell's [1..n] is short and concise. But other shit like that $ sign thing and even (+) can detract hugely from code-readability.
>>51790725
>using xml ever
>>51790466
one more question, I am gonna be working with a large string from the clipboard, is there a memory efficient way to handle that
>>51790792
>being this retarded
>not knowing what sxml is
>>51790785
If you don't know what you're talking about, don't post.
>>51790816
It's garbage compile-to-xml language. How can you look at this and not throw up in your mouth a little?
>>51790812
write it to disk and split it into chunks
or just let the OS put it in the swap
>>51790861
>write it to disk
thank you, read it line by line then I suppose
>>51790443
bump
>>51790829
What do you mean? I know about Haskell and functional programming but not Lisp/Scheme.
>>51790852
>compile
So you are inbred as well as retarded. OK then.
>>51790812
Just keep it in memory unless you think you'll really need that memory back. In that case
>>51790861
>>51790663
I have a formula. Does /g/ do tex now?
sum k >= 1 while 5^k < n : floor(n/5^k)
Why is bare metal assembly so hard :(error:
push ax
mov eax, 0xb8000
mov ebx, error_string
mov ch, 0x4f
.begin_loop:
mov cl, [ebx]
mov word [eax], cx
add dword eax, 2
inc ebx
cmp byte [ebx], 0
jnz .begin_loop
jmp halt
error_string is a null-terminated C-string "Error". It instead prints Err<smiley face>
>>51790926
You want jz, not jnz, dumdumb.
>>51791007
That just prints Err<smiley> then a ton of blanks.
Then eventually triple faults.
>>51784960
WPF may be contrived, unintuitive and developer-hostile as hell, but it's still the only decent way to create GUIs in C#.
>>51784297
fuck Mesu-Nized was good
why can't anything be as good as this manga?
>>51784619
Personally I just Google until i find a working example, and then fuck around with it.
ListBox's are a mess in WPF.
>>51790926
Fuck, why won't this work:%define VGA_BUFFER_START 0xb8000
BITS 32
SECTION .boot_rodata
error_string:
db "ERROR"
SECTION .boot
EXTERN boot_stack
GLOBAL start
start:
mov esp, boot_stack
jmp error
error:
push ax
mov eax, VGA_BUFFER_START
mov ebx, error_string
mov ch, 0x4f ;White text on red back ground
.begin_loop:
mov cl, [ebx]
cmp cl, 0
jz halt
mov word [eax], cx
add eax, 2
inc ebx
jmp .begin_loop
halt:
hlt
jmp halt
No matter what I try, the last two characters of error_string get mangled into a smiley fucking face.
>>51791554
Of course. The moment I start raging, I solve it.
It seems that I'm smashing the error string when I push ax. What the fuck, I clearly set esp.
Did my intro to programming final today:
http://pastie.org/private/xqkqbnpwzwa6tnrhfzywa
Any retarded design decisions/non-pythonic constructs were mandated by the spec.
>>51784619
Are you binding the ListBox's ItemsSource to anything?
I don't see a binding for it in your XAML, but since you're setting x:Name, I guess you might be setting it in code-behind.
If so, then you probably shouldn't. It should work, but it's poor practice. Use bindings instead and just make whatever you're binding it to a public property on the view model.
>>51784297
Can I get a link to this manga? If it's real that is.
I image searched and found nothing.
>>51791610
Yes, but what did you set it to? You have it declared extern.
>tfw you have no ideas for projects that haven't been made already or are accomplishable within less than a few months
Hate myself right now.
>>51791859
The stack bottom
Instead of the stack top
FUCK stacks grow downward on x86 don't they.
So i wanted an offline documentation,
I want to download zeal
zealdocs org but is the download link broken? Is it just me? Any mirror?