[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: 34
File: pair_programming.png (198 KB, 640x480) Image search: [Google]
pair_programming.png
198 KB, 640x480
Daily Programming Thread

What are you working on, anonymous ?

# New & Revised /dpt/ Code of Conduct #
We want to ensure that the /dpt/ community, while large and diverse, remains
welcoming and respectful to all participants. To that end, we have a few
ground rules that we ask people to adhere to.

- *Be friendly and patient.*

- *Be welcoming.* We strive to be a community that welcomes and supports
people of all backgrounds and identities. This includes, but is not limited
to members of any race, ethnicity, culture, national origin, colour,
immigration status, social and economic class, educational level, sex,
sexual orientation, gender identity and expression, age, size, family
status, political belief, religion, and mental and physical ability.

- *Be respectful.* Not all of us will agree all the time, but disagreement
is no excuse for poor behavior and poor manners. We might all experience
some frustration now and then, but we cannot allow that frustration to turn
into a personal attack. It’s important to remember that a community where
people feel uncomfortable or threatened is not a productive one. Members of
the /dpt/ community should be respectful when dealing with other members as
well as with people outside the /dpt/ community.

- *When we disagree, try to understand why.* Disagreements, both social and
technical, happen all the time and /dpt/ is no exception. It is important
that we resolve disagreements and differing views constructively. Remember
that we’re different. The strength of /dpt/ comes from its varied community,
people from a wide range of backgrounds. Different people have different
perspectives on issues. Being unable to understand why someone holds a
viewpoint doesn’t mean that they’re wrong. Don’t forget that it is human to
err and blaming each other doesn’t get us anywhere. Instead, focus on
helping to resolve issues and learning from mistakes.
>>
>>54440731
fuck off faggots
>>
>>54440742
>>>/b/
>>>/trash/
>>
is the construct (condition)?this:else from c or c++?
>>
>>54440731
fucking idiot, i know you're being sarcastic, but you're causing real SJW fags to come here who don't realize that you're joking
>>
>>54440766
https://en.wikipedia.org/wiki/%3F:
>>
>>54440782
thanks
>>
>>54440731
>Being unable to understand why someone holds a viewpoint doesn’t mean that they’re wrong.
if they're wrong, it means they're wrong. being a delusional arrogant smug faggot doesn't help your case.
>>
Report and do not post in this thread.
>>
I hope the OP is an ironing
>>
>>54440731
first for we should nuke pajeets from programming jobs.
>>
Why do people hate javascript so much?
>>
>>54440880
only C and Java is taught in indian computer schools
>>
>>54440845
>>54440897
you have to be at least 18 years old to use this site
>>
>>54440880
because python is superior in every way
>>
>>54440880
it's fucking shit, even python is better
>>
File: 1462607937061.jpg (497 KB, 960x1280) Image search: [Google]
1462607937061.jpg
497 KB, 960x1280
does she like programming in C?
>>
>>54440922
it's a trap
>>
>>54440930
not possible
>>
>>54440909
you have to be white to post in this thread
>>
>>54440930
even better, post more
>>
>>54440937
Kalindra chan is a trap you new fag gay boi.
>>
>>54440944
xD
>>
File: proj.webm (2 MB, 1280x720) Image search: [Google]
proj.webm
2 MB, 1280x720
/dpt/-chan, daisuki~

Ask your much beloved programming literate anything.

>>54440421
;; space counter in r10
;; upper counter in r11
;; lower counter in r12

XOR r10, r10
XOR r11, r11
XOR r12, r12
MOV rdx, strAddress
.loop:
MOVZX eax, byte [rdx]
INC rdx
TEST rax, rax
JZ .nullChar
CMP rax, 32
JNE .upperAndLower
INC r10
JMP .loop
.upperAndLower:
AND rax, 32
SETNZ r13
SETZ r14
ADD r12, r13
ADD r11, r14
JMP .loop
.nullChar:
...


>>54440321
looks like lazy copy/pastes

>>54440766
C has them since the beginning but conditional expressions existed way before.

>>54440880
At the beginning, javascript was a glue language for web designers, its semantics and syntax were crappy but decent enough for quickly scripting a web browser. Since then, it has been imposed everywhere and it's now being used for everything. WebAssembly could free us from javascript.
>>
>>54441012
>programming literate
doesnt seem like it
>>
>>54441012
quit posting anime on /gee/ u faglord
>>
>>54441086
why?
>>
unironically
>>
>>54441012
>programming literate

>looks like lazy copy/pastes

ha nice one
>>
anyone know anything about optimizing GLSL code? especially for mobile devices which don't have good run-time compilers

if you're using s=sign(x), should you use abs(x) or is it better to do x*s

since the implementation might not have good abs i'm guessing x*s is better?
>>
>>54441012
>looks like lazy copy/pastes
it's obviously for scope and readability
>>
>>54440731
Just doing some things left over from the previous week with work. (Pays well so im not bothered).
A little bit of coding in cellnode (a company invested language) to tie up environmental variable integration with the recent updates of the operating systems of our micro controllers at our plant. (Spill overflow). I work at a hydro electric powerstation in New Zealand.
>>
>https://software.intel.com/en-us/articles/api-without-secrets-introduction-to-vulkan-preface
>TL;DR
i want to make a mobile game that targets the latest high-end devices with new features like geometry shaders and transform feedback. should i use modern opengl or should i go full vulkan?
>>
>>54441343
I don't really know about the performance characteristics of floating point operations in GPUs, buts abs() should be a REALLY cheap function.
It can be implemented by clearing a single bit.
>>
>>54441568
yeah good point i didn't think of that, it should be really cheap just like sign
>>
>>54441412
You should use opengl ES because vulkan is not for people making games vulkan is for people making graphics APIs.
>>
>>54441634
yeah vulkan looks really complex i just saw an intel ad on stackoverflow which made me curious about it
>>
>>54440731
Trying to learn Isabelle/HOL and ISAR and proof methods
>>
File: pepe wondering (rare).jpg (71 KB, 599x600) Image search: [Google]
pepe wondering (rare).jpg
71 KB, 599x600
I'm thinking about creating a program similar to a standard php cms but without the dynamic bullshit. What I have in mind is a static page, that upon creating a post, gets read by the program appends the necessary html and that's it. I haven't started to implement it yet physically but I kinda have the system in place in my head. What so you think?
>>
>>54440731
How do I write a function in python that returns the different ways I can calculate the number N using sums of differenet increasing sequence of numbers?
FOr example calling function(5) would return number 3, because I can write 5 as 1+4, 2+3 or 5
>>
Where to start if I want to get into python?
I did some code modification in blender engine but the actual knowledge with the language is 0.
I know the general programming logics and stuff.
>>
Would anybody here be able to write me a script in python or point me in the right direction, I want it to be keyed rot but with two keys one for if the word is odd and one for if it's even
>>
Along with Python, should C be learnt as that was what Python was made in? Also is codeblocks acceptable to use as a beginner?
>>
>>54443017
By that logic, you should also learn assembly.
>>
>>54443042
would be nice
>>
File: booty.png (294 KB, 528x400) Image search: [Google]
booty.png
294 KB, 528x400
>>54443042
>not learning assembly as first language
>>
>>54443017
If you want to go the hard route learn C. After C pretty much every language you will be able to pick up quickly.
If you want to go the easy route, learn Python first. But be warned going from Python to other languages isn't as simple as it would be if you took the time to learn C first.
>>
>>54442827
how long is the sequence? Does it increase at a constant rate?
>>
How do I into concurrent programming in C++?

What are some good books?

What are some exercise problems (preferably coding up a concurrent solution to a problem) I could do?
>>
>>54443088
>tfw want to learn assembly so i can reverse engineer/decompile programs to create patches/exploits, but theres too many other things i want to do

one day..
>>
https://www.youtube.com/watch?v=VipvF26XRNY
27:00

FUCK YEAH

even on flat screens, with a wide fov i think the standard rectilinear projection looks fucking disgusting, so it's great that this issue is starting to get recognized and we're even getting hardware support for alternate projections
>>
>>54443280
>>>/v/
>>
>>54443280
>>>/v/
>>
>>54443288
>>54443289
>CLIonly linuxbabbies
kys
>>
I want to return a struct of the form
let a = A::new();

X {
the_a: a,
other_stuff: a.do_it()
}

But whether I wrap the A, the A and the X, or just the X in an RC or in a Box, or even if I add a lifetime (trying to coerce the A to live as long as the X, not the other way around), I always get an error of the form
...but borrowed value is only valid for the block suffix following statement 0


How do I fix this?
>>
Yesterday I posted my idea of writing a download manager. After giving it some thought, I want to create a web based remote file manager instead. That's much more flexible for my purposes.
So now my idea is to basically write a glorified file manager found in Chromium and Firefox. I looked at ownCloud, but that's overkill for my purposes. The extra features I want to implement are:
- Removing files
- Uploading files
- Download files by url
Eventually I want to add:
- Moving files
- Compress/extract files
All as a website without the need to use JavaScript (+1 in the freedom dimension) written in Go licensed under the AGPLv3.
Does /dpt/ know of any other useful features?
>>
>>54443017
no. and even that, python has been implemented in python (pypy), java (jython), c# (iron python), javascript (skulpt, pyjs), c++ (pyston, nuitka, pyjion), ruby (typhon), ...
>>
File: 1393712027399.png (43 KB, 512x323) Image search: [Google]
1393712027399.png
43 KB, 512x323
>>54440731
I'm very inexperienced at programming but I was following the programming challenges thing and made an ascii clock.
http://pastebin.com/X7KnSphx

I couldn't get the time function to work properly (it was only displaying 01:3:8 as, for some odd reason, it consistently gave time back as 1 hour, 4199813 minutes and 2686868 seconds even though I practically copy-pasted the code from a working example) so the clock is plagiarised from http://www.cplusplus.com/reference/ctime/localtime/

Also, I added that, every time the clock skips a second, the thread sleeps for less time so it keeps time better the longer it runs.
This is so that, as long as it takes less than a second to print the ascii, the clock keeps ticking at one second per second regardless of how slow your computer is.
On the other hand, it means that it eats up more CPU the less the thread sleeps: without sleeping, it was using 25% on my CPU.

If you're not happy with the thread sleeping for varying amounts of time and want to keep it consistent, change
int waittime = 1000;
to how many milliseconds you want and double-slash out the
if(timeinfo->tm_sec > sec+1) waittime-=10;
line.

The ascii numbers I made myself some three years ago whilst trying to make a panic countdown.

Go bully all you like: I need to learn how to be not shit.

># New & Revised /dpt/ Code of Conduct #
>Code of Conduct
Jesus Christ! How horrible!
>>
>>54443280
Fuck off
>>>/v/
>>
>>54443505
Looks pretty ok to me me senpai.
Try to get rid of the sleep function though. Use a high precision timer instead. This will also help you get rid of the windows dependency.
http://www.cplusplus.com/reference/chrono/
>>
How do I write scripts?
I want to make a script where you can input a custom created playlist from youtube and it would go through the playlist and download convert all videos from the playlist to mp3 and download it to your computer using this website
http://www.youtube-mp3.org/
Where do I start?
>>
>>54443613
https://rg3.github.io/youtube-dl/
>>
>>54443549
kill yourself retard
>>
>>54443154
It desn't matter how long the sequence is, it can only contain the number N, so "function(7)" would return 5 because you can write 7 as 1+2+4, 3+4, 5+2, 6+1 and 7
>>
>>54443632
>>>/v/
>>
>>54443626
sweet
>>
>>54443505
Use the c++ headers instead of c headers. Ctime instead of time, etc.

Learn to use const.

For the love of god use an auto formatter, your style is all over the place and many of the new lines seem arbitrary.

Use std::array instead of c style arrays. Std::array knows its own size so you don't need to use pass around the size c style or use magic numbers.
>>
>>54443723
Factor some of those magic numbers out into constants, like that 7 in main.

Comment the purpose of your functions at least.

Look into using enhanced for loops.
>>
>>54443577
I'll look into using Chrono but it won't entirely get rid of the dependency: there's still the system("cls") in there.
I've had a look for better ways to clear the console but they've gone beyond my understanding.

>>54443723
>c++ headers instead of c headers
Will do. I only used it because I couldn't figure out why my code wasn't working but the example was.
The example was using C headers so I left them alone.

>Learn to use const
That'll be like "final" in Java?
I don't see why it's necessary but okay.

>use an auto formatter
I'll look for one.

>enhanced for loops
>std::array
I'll have to familiarise myself with those, then.

>Comment the purpose of your functions at least
I will next time: I was concerned it'd be the mark of an autist to comment on something as amateurish as this.
>>
>>54440731
why do you fags keep making the same stupid fucking op? you want people to leave? fine i'll fucking leave.
>>
>>54444522
bb xoxo
>>
>>54440731

why does my phantomjs code work when I just let it crash the terminal when it finishes, but when I add phantom.exit() at the end it doesn't crash the terminal but the code doesn't work, even before it executes it?
>>
File: 1458516291219.png (560 KB, 1150x614) Image search: [Google]
1458516291219.png
560 KB, 1150x614
Where to start if I want to get into python? Any recommended tutorials or tutorial lists?
>>
>>54444687
https://www.youtube.com/watch?v=N4mEzFDjqtA
>>
>>54444702
>less than an hour
wow man thats fast
>>
File: ayasesmile.jpg (136 KB, 1280x720) Image search: [Google]
ayasesmile.jpg
136 KB, 1280x720
>>54440731
When did you last pair program, /dpt/?
>>
>>54444830
never
the entire concept seems weird, like having 2 people work on the same art piece at the same time.
>>
>>54444830
>tfw no qt to pair program with ;_;
>>
>>54443633
Oh I misunderstood the question. I thought you were given a sequence of increasing numbers and had to find sets that sum to your number of choice.

So if it can be any increasing set, it's probably reducible to some nested factorial type thing.

I thought about it for a while and have a manual algorithm down. Now it's just about automating it. Is this what CS homework looks like?

My search pattern:
1  2  3  4  5  6  7  8  9  10 11 12
###################################

12

1 11
1 2 9
1 2 3 6
1 2 4 5
1 3 8
1 4 7
1 5 6

2 10
2 3 7
2 4 6

3 9
3 4 5

4 8

5 7


>I'm not a robot
>>
File: bleeeuuuuuugh.gif (2 MB, 640x360) Image search: [Google]
bleeeuuuuuugh.gif
2 MB, 640x360
>>54444890
Have you ever worked on any software development project involving a team before? That's what it is.

But what people claim the "advantage" of pair programming is is that two different minds who understand the same code apply their reasoning processes to it at the same time. When they arrive at different conclusions, they discover this quickly and discuss it.

>>54444913
;_;
>>
>>54444935
That's not what team programming is. It's literally 2 programmers using the same computer.
>>
File: 1457304153115.jpg (172 KB, 502x659) Image search: [Google]
1457304153115.jpg
172 KB, 502x659
>>54443324
Wouldn't it be logical for the X object to own the A andd not just borrow it? Also that's Rust right?
>>
>>54444962
I didn't say programming on a team was pair programming. I said "2 people working on the same art piece at the same time" could easily be a description of programming on a team.
>>
>>54444935
>When they arrive at different conclusions, they discover this quickly and discuss it.

As if any /g/ autist could accomplish this without turning into a REEE-ing puddle of tears.
>>
When my prof asks "Do a binary search on an empty array"

Does he mean:

array = null (and properly handle any exception errors)

or

array = {0} (array only has one zero in it

or

array = {0,0,...,0} (evey nmbr in array is 0 regardless of array size)

Damn this shit is ambiguous
>>
>>54444986
Do you consider programming a craft?
>>
>>54444926
>Is this what CS homework looks like?
Unless he goes to a good school, no.
I've seen a solution for this problem with predefined lengths of sums (n = 12, k = 3, answers = <2, 3, 7>, <1, 11, 0>, etc.) and the inclusion of 0. That can be modified so zeros are removed and all the solutions for all sequences of length k from 1 to n (for number n) can be put into a set and then summed once complete.
>>
>>54445004
Instantiated array with no elements.
>>
>>54445004
>"Do a binary search on an empty array"
For any of those interpretations how and why would you do a binary search through it?
>>
>>54445004
array = []
>>
>>54445007
Depends on how you define "craft". I define it as something where the optimal answer is so far beyond the capability of a human that we apply various subjective rules on a regular basis in order to judge and approximate it. From that perspective, yes.
>>
>>54445015
>and then summed
Well just the cardinality of the set.
>>
>>54445004
>null
That's no array
>{0}
That one's not empty
>{}
This is empty. Maybe Java requires
new int[0]
.

You made me curious... Hey /g/, is int[0] a valid type in C/C++? Not asking for anon, just for me
>>
>>54445004
if length = 0 return
>>
>>54445049
http://www.gotw.ca/gotw/042.htm
>The answer is Yes. Zero-length arrays are perfectly okay, kosher, and fat-free etc...
>>
File: 1460787768492.jpg (12 KB, 230x219) Image search: [Google]
1460787768492.jpg
12 KB, 230x219
>>54445085
Sweet! Thank you anon, see pic related
>>
>>54444830
>>54444935
I do this quite a lot with my friend. We often cooperate with teamviewer; I think it's fun and adds a lot of motivation to the development of the project.
>>
>>54445040
So does that mean anything involving math is a craft?
>>
I recently started to learn C, coming from Java background, and I'm trying to implement a bare-bones printf function, handling %s, %c, %d and %f. This is what I have so far.
#define NUL '\0'
(...)

void printf_(const char *string, ...)
{
va_list var_arg;
va_start(var_arg, string);
while (*string != NUL)
{
if (*string == '%' && *++string != NUL)
{
switch (*string)
{
case 's' :
print_str(va_arg(var_arg, char*));
break;
case 'c' :
putchar(va_arg(var_arg, char));
break;
case 'd' :
print_int(va_arg(var_arg, int));
break;
default:
break;
}
string++;
}
else
{
putchar(*string++);
}
}
va_end(var_arg);
}

static void print_str(const char *string)
{
while (*string != NUL)
{
putchar(*string);
string++;
}
}

static void print_int(int i)
{
if (i < 0)
{
putchar('-');
print_unsigned_int(i * -1);
}
else
{
print_unsigned_int(i);
}
}

static void print_unsigned_int(unsigned int i)
{
unsigned int q = i / 10;
if (q != 0)
{
print_int(q);
}
putchar('0' + i % 10);
}

Is my code any good? Any tips on how to implement printing floating point values?
>>
>>54445133
>#define NUL '\0'
>>
>>54445015
Any easy programming solution that has an awful runtime is.
1. k = 1
2. if all combinations have been tested goto 8
3. get a k length combination with replacement of numbers 0 through n
4. if the sum of the combination is n continue, else goto 2
5. filter out zeros from combination
6. add filtered combination to set
7. goto 2
8. increase k
9. if k <= n goto 2
10. otherwise, cardinality of the set is the answer

I can see a dynamic programming solution and a not super obvious closed form.
>>
>>54445015
so is there no solution without predefined lengths?
>>
Hey guys,
I'm trying to Write Conway's Game of Life (https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life) in C++. The output gets fucked up and I can't figure out why. Any ideas? I'll include the code in another reply because 2k limit.
>>
>>54445142
what's wrong with it? I spent a lot of time tracking a bug caused by a typo in '\0', so I'm #defining it since then
>>
>>54445191
>Error: Too many lines
http://pastebin.com/TULaNVbw
>>
>>54445174
Yes, the solution without predefined lengths is the sum of the solutions with predefined lengths of lengths k = 1 to n, with repeat removed. The closed form solution will be a pain to determine, but shit is easy to compute. Just might take a long time.
>>
what is a callback function in javascript
>>
>>54440731
Build crud website
>>
>>54445174
Try working out the solution to the first three or four numbers and put that into OEIS.I bet you'll find it.
>>
File: 1426887475717.jpg (84 KB, 664x1002) Image search: [Google]
1426887475717.jpg
84 KB, 664x1002
>>54445133
>#define NUL '\0'
Why ?

>print_unsigned_int(i * -1);
why not -i ?
may fail if i = INT_MIN and -INT_MIN = INT_MIN

>>54445133
>while (*string != NUL)
do { putchar(*string) } while(*(++string) != '\0');
>>
>>54442827
Do the numbers in the sum have to be different?
>>
>>54445116
Under this definition, sure.
>>
Posted in another thread, but it closed before i could get an answer.

Guys, some weird shit is going on with my code

There's a data structure for a graph which has the char pointer pointers. They never interact with each other in any way, and still, if the second array has less than three terms, the second and third values will be equal to the values in the respective positions of the first array.

I've never seen anything even close to being like this. This is all dynamically allocated, which makes it even more weird. How could some variables automatically associate themselves to some pointer? And i'm sure they don't share the values but the pointers point to the same space. I know this because freeing one of those will count as a free for both

really weird shit, guys. Any idea what the fuck is going on? Is my pc haunted or something? Could it be because of realloc?

Code is:

for(i=0;fgetc(fp)!='\n'; i++){
fseek (fp, -1, SEEK_CUR);
grafo->vertices = (char **) realloc (grafo->vertices,(i+1)*sizeof(char*));
grafo->vertices[i]= (char *) malloc (TAM*sizeof(char));

fscanf(fp,"%s", grafo->vertices[i]);

a=strlen(grafo->vertices[i]);
if (a!=0){
if (grafo->vertices[i][a-1]==',') grafo->vertices[i][a-1]='\0';
}
else i--;
}


for(j=0;fgetc(fp)!='\n'; j++){
printf ("%d \n",j);
fseek (fp, -1, SEEK_CUR);
grafo->vertices_origem = (char **) realloc (grafo->vertices_origem,(j+1)*sizeof(char*));
grafo->vertices_origem[j]= (char *) malloc (TAM*sizeof(char));

fscanf(fp,"%s", grafo->vertices_origem[j]);

a=strlen(grafo->vertices_origem[j]);
printf ("%s \n", grafo->vertices_origem[j]);
if (a!=0){
if (grafo->vertices_origem[j][a-1]==',') grafo->vertices_origem[j][a-1]='\0';
}
else j--;
}
>>
>>54445533
grafo is defined by

typedef struct Aresta{
char ori[TAM], dest[TAM];
int peso;
}Aresta;


typedef struct Grafo{
char **vertices, **vertices_origem;
struct Aresta *arestas;
}Grafo;


Also, what the program does is, it reads from a file the names, which are separated by a comma then a space. The program saves the names on their respective parts, and then remove the comma
>>
>>54444205
>That'll be like "final" in Java?
>I don't see why it's necessary but okay.

It's not really. Most people consider it a "good habit", but then I generally believe that not trying to modify variables you shouldn't be touching, or reducing their scope is a much better one.

Use final for things that really shouldn't change, not even at initialisation, but not every single variable you haven't yet decided to mutate.
>>
>>54445174
my pattern here has no predefined length
>>54444926

I might program it later but the algorithm basically goes:

1. sequence = N
2. take highest number in sequence A
3. if number can be split using "outsides" of unselected numbers, replace A with those numbers

2'. Take new highest number A'
3'. If A' can be split using "outsides" of unselected numbers, replace A' with those numbers

2''. Take new highest number A''
3''. If A'' can be split using "outsides" of unselected numbers, replace A'' with those numbers

.
.
.
else
4''. if shifting the two numbers "inward" produces the same sum, do that. If that cannot be done move to the last nested level and shift those inward. Repeat 2'' and 3''

4'. if shifting the two numbers "inward" produces the same sum, do that. If that cannot be done move to the last nested level and shift those inward. repeat 2' and 3'.

4. if shifting the two numbers "inward" produces the same sum, do that. If that cannot be done move to the last nested level and shift those inward, repeat 2 and 3

5. if function is at the least nested level and still cannot move in, it has listed all increasing combinations which sum to N.


I'm not sure how to turn this into code off the top of my head.
>>
>>54442969
Python is easy as shit, as in you can learn it by watching a couple videos. Don't expect to make anything big with it though, since it's slow as shit. People are gunna say it's a shit language but it's not. It is great for what it is meant to do. Autonomize small shit, back-end web dev(That's the easiest programming job you are gunna get) and more shit like that.
>>
>>54445533
>Is my pc haunted or something?
No. Until you become a better programmer, don't blame any of this on your runtime environment.

The first thing you should do is fix your indentation. (specifically, near the "if (a!=0)") I think these conditionals are doing something other than what you expect.

And when you need help, try to give smaller snippets of code in the future.
>>
>>54440731
Stop this programming fag meme.
OP must be indian.
>>
>>54445252
>#define NUL '\0'
>Why ?
why not? is it considered a bad practice?

>print_unsigned_int(i * -1);
>why not -i ?
yeah, that was stupid
>>
What do I use if I want to script web pages?

For example, I want to download all images on a given site. How can I make and run a script on the page?

Do I have to make an entire browser extension
>>
>>54445600
Why are they? They do exacly what i want(which is to remove the comma from the string).

And sorry about that huge text, but that's pretty much what interacts with those variables. They're never called again in the program(yet)

Also, i was joking abou the haunted thing. I don't literally think there's a ghost on my machine fucking up where my poiters point to
>>
>>54445694
there is absolutely no reason
regardless, 0 == NULL == '\0'
>>
>>54445719
The indentation is wrong. Look at
if (a!=0){
if (grafo->vertices[i][a-1]==',') grafo->vertices[i][a-1]='\0';
}
else i--;
}
If I were to supply curly braces and correct indentation, this is how the compiler interprets the conditional (both the first and second time):
if (a!=0) {
if (grafo->vertices[i][a-1]==',') {
grafo->vertices[i][a-1]='\0';
}
else {
i--;
}
}
>>
File: line.png (132 KB, 942x739) Image search: [Google]
line.png
132 KB, 942x739
>>54445777
Oh, sorry, I was looking at it wrong. I think the conditional works the way you think it does, but the indentation is wrong.

if (a!=0){
if (grafo->vertices[i][a-1]==',') grafo->vertices[i][a-1]='\0';
}
else i--;


That's really bizarre. You should unindent your close braces. I've never seen anyone who writes code that way.
>>
Modeling framework which uses SystemC simulation kernel. It will be used for verification purposes (SV-DPI) and performance analysis.
>>
>>54445818
That's mostly from me messing with my code trying to fix the bug. The final code will be way more organized than this
>>
>>54445716
https://chrome.google.com/webstore/detail/linkclump/lfpjkncokllnfokkgpkobnkbkmelfefj
>>
>>54445818
>pic
Is there a plugin for some editor that enters braces and semicolons in this fashion for you?
>>
>>54445716
you can do it in JS, perhaps using Greasemonkey, to do it in browser
It'll be really easy to do it in Python as well, if you want to do it in the term or something
>>
>>54445888
Not that I know of, but it would be easy enough to be worth making. The first time I saw that image I lost it.
>>
Hi, guys, Im working in an Android app with a webservice using ASP.

WHen I run the webservice on the localhost is working fine. But on the Android app gives me an Unexpected response code 400.

I check everywhere and there is not any solution. I dont know where the problem is, in the Client or the server.

How can I know where the problem is? Is there any way to call localhost (10.0.2.2) on AVD browser to test it?
>>
>>54445858
That was just a simple example. I want to do things much more complex than that.

>>54445907
Yeah I want to do it in the browser using JS, but I can't figure out how to make the browser run my JS according to some criteria. For example, I want to write some code that can work with site X, and have the browser automatically enable and run it whenever I visit the site.

Does this Greasemonkey do that? Can I use the full Chromium extension API?
>>
>>54445947
where is your server hosted
disable your windows firewall and try again
>>
File: Screenshot_117.jpg (33 KB, 422x312) Image search: [Google]
Screenshot_117.jpg
33 KB, 422x312
Is this like an index out of bounds error for an array?
I'm also confused by the fact that Program/File/Line where the error appears, isn't my cpp file (my only file in my project).
>>
>>54446020
Greasemonkey can do that; I don't know about chromium but I'm sure it's worth looking into
>>
>>54446034
>Is this like an index out of bounds error for an array?
yes
>I'm also confused by the fact that Program/File/Line where the error appears, isn't my cpp file (my only file in my project).
the assert is in the vector file
>>
>>54446034
What a shitty error, no backtrace?
It's somewhere where you're using the vector
>>
>>54446034
Not an array, that comes from the vector [] operator, but either way it's the same problem.
>>
File: jdcbqi;bcq.png (390 KB, 640x1136) Image search: [Google]
jdcbqi;bcq.png
390 KB, 640x1136
Still working on my iOS and android app. First app 100% by myself. Should be complete next month. Just integrated google maps in it.

Nativescript + angular 2
>>
>>54446147
What is it?
>>
>>54446065
>>54446076
Cool, thanks everyone. The program works with 5 indexes, but I tried adding more to the vector and got this error. This is going to be poop to debug.

>>54446084
>Not an array
Sorry, I wasn't being clear. I meant to draw parallels to vectors and arrays. I'm still new to C/C++ stuff.
>>
>>54446147
>DESIGNATED shitting app

Do the needful, pajeet.
>>
>>54442459
Not a bad idea, but don't write it in PHP.
>>
Sup
>>
File: al.gif (1 MB, 275x218) Image search: [Google]
al.gif
1 MB, 275x218
Hey /g/, I've started learning Java from the beginning and while I'm new to programming, I've had moderate contact with obsolete Pascal and C++ in Visual Basic IDE back in classes.

My question is about carriage return \r. From what I understand it basically overwrites the string in the same line before the \r and puts the rest of the string from the same line in its place. Is that correct?

If so, how is that of any help in anything? If I wanted to do that, I'd just erase the part of string before the \r. I don't get it. It seems useless, am I missing something?
>>
File: oi oi oi.jpg (42 KB, 802x561) Image search: [Google]
oi oi oi.jpg
42 KB, 802x561
>>54446034
>>54446230

So, greater than 9 indices and VS throws an error.
....but when I run it on the Linux servers at my school it runs fine.
Assignments are graded on Linux machines, so I guess it works, but I mean really? Does it really work?
>>
>>54443227
To be honest you can basically do that without learning assembly, just google any mnemonic you don't understand. Assembly is very simple to read even if you don't really know it. The reason it's so difficult to write assembly programs is not because it's complicated, but actually because it's too simple to be expressive.

Also, here's another hint for reverse engineering a program in assembly: look for the strings. They should be all together in a table at the end of the executable. Find the address of a string that looks related to the code you're looking for, and then find where that address gets referenced. It helps you figure out where things are even if the executable has been stripped.
>>
I've been writing bash scripts for the majority of my life as I'm a sort of low level IT guy and usually all I really need to do is move some files, maybe check some other site small tasks etc.

What language should I learn that's actually a programming language?

I really don't want to do a compiled language because I always have issues with compatibility.

I really don't want to learn python because every time I install a python script from someone else I always spend a month and a half on dependencies, plugins, and the 9000 different versions of python that every developer writes in.

I just want a portable language so I can download my scripts and run on most machine with as little setup as possible, and bash was great for this but with some of my latest projects the limits of the scripting have really started to show.
>>
>>54446537
Honestly, Python really is the correct answer here.

There are 2 incompatible versions of Python, the 2.x series and the 3.x series, and they can be installed side by side. Python's standard libraries are huge and more comprehensive than most other languages. So if you need outside dependencies to do a task in Python, you'd probably need them to do that same task in a different language.

For your purposes (basic system automation stuff,) you won't need to go outside the Python standard libraries anyway.

Alternatives:
* You could try some of the .NET languages with MONO, but the UNIX integration isn't going to be as good, and MONO is kind of overkill to deploy for a few simple scripts.
* Perl used to be the traditional choice for those who wand something a little better than shell scripting, but ts syntax is kind of opaque and that makes it harder to learn initially.
* TCL has the same everything-is-a-string weak typing that BASH has, which might be more familiar to you and make it easier for you to learn. But that also brings in a lot of the same annoyances as BASH.
>>
>>54446537
>>54446632
Oh, and I forgot to mention Lua. Lua is, in my opinion, actually a better and more elegant language design than Python. But you miss out on those great standard libraries, and the Lua devs tend to evolve the language more quickly and break compatibility. I haven't used Lua in years, and that kind of makes me sad.
>>
>>54446537
Consider stack + haskell + turtle
https://hackage.haskell.org/package/turtle-1.0.0/docs/Turtle-Tutorial.html
>>
>>54440731
>sex...gender identity

Aren't these the same thing? Like, if you're male, your identity is a male.
>>
>>54446632
I'll be honest I really hate that that may be the correct answer because I really despise working with python.

TCL probably wouldn't work because one of the problems I had with bash was variables not working properly.

Perl is a maybe, but the syntax looks like a mess.

Lua I have no idea about.

>>54446715
Haskell can be run as both an interpreted and compiled language right?

Interesting.
>>
>>54444830
I program really slow and shitty. I also need to google alot, and stare at my ide for awhile and brainstorm.

It would be embarassing desu
>>
>>54446742
you're triggering me
>>
>>54446825
maybe you should program more for practice so you aren't shit
>>
>>54446771
>https://hackage.haskell.org/package/turtle-1.0.0/docs/Turtle-Tutorial.html
sorry, I linked you the old one https://hackage.haskell.org/package/turtle-1.2.7/docs/Turtle-Tutorial.html
this one also shows usage with stack

>both an interpreted and compiled language
No, in this use case it's just gonna be compiled on demand
>>
>>54446847
Huh, interesting.

This actually might be what I wanted.
>>
>>54446435
It moves the cursor back to the beginning of the line, but doesn't delete anything. It does allow you to write over what was there before, which could be handy if you want to (for example) show an animated ASCII progress bar in the bottom line.
>>
>>54445191
>>54445212
You can't read from and write to the array at the same time, the changes you make will mess up the calculations for the neighbouring cells. Make a copy of the array, read from one, write to the other.
>>
>>54446742
i'm a 5 ft tall female dragon because i say so, SHITLORD
>>
>>54446480
Share the source code and I will tell you why.
>>
File: 1462512692258.jpg (454 KB, 2352x1563) Image search: [Google]
1462512692258.jpg
454 KB, 2352x1563
Is dynamic typing a social construct?
>>
>>54442459
why php? do you hate yourself?
>>
>>54441012
webassembly _could_ be the solution. However, it will be a really ugly transition: web developers used to writing shit code will have a really hard time with it, mostly for the conceptual jump from spamming jQuery to actually paying attention to algorithms. There will almost certainly be a few major security breaches caused by shitty programmers. With that being said, it has the potential to solidify C++'s rightful place as the world's most important programming language.
>>
>>54443626
>>54443679
(pro-tip: it doesn't only download youtube videos. Try it out for soundcloud, vimeo, etc)
>>
any good books for learning Swift?
>>
>>54446147
>integrated google maps
>iOS
jesus christ
>>
>>54445854
The only time your code can be incorrectly formatted is while you are busy editing it. It's not something you fix at the end.
>>
>>54447233
I can't fit it in a post....
http://lpaste.net/162680
>>
>>54447301
Static typing is a social construct. All memory is born dynamic.
>>
http://www.strawpoll.me/10162584
>>
>>54447661
There is only ONE objective good answer to this

if you think otherwise, go check yourself
>>
>>54447693
This.
And its no2.
>>
>>54447704
this
>>
>>54447414
what
>>
>>54447721
BLOAT
>>
>>54447704
>>54447709
What have you got against T&, anon?
>>
>>54447752
There's nothing wrong with that if you like to get raped by a dozen aids riddled niggers.
>>
>>54447747
most apps are bloat on top of bloat

>Nativescript + angular 2
>>
It's
specifier Type& name
.

Stroustrup says so, anything else might as well be purged of earth.
>>
>>54447787
Just because most apps are bloat, doesn't mean yours should be too.
>>
>>54447531
The problem is here:
    // Finish off the first subarray, if necessary.
while (first1 <= last1)
{
// At this point, b[first....index-1] is in order.
b[index] = a[first1];
first1++;
index++;
}


Both index and first1 reach 11, but since the indexes start from 0, it should only check from 0 through 10.

Although at this moment I cannot spot the problem right off the bat, might be some simple typo.
>>
>>54447661
Do they mean different things or is it all the same in the case of references? Because I thought in C, const T *thing; and T const *thing were two different things if the first is even legal
>>
>>54447838
Hmmm, interesting. That part is lifted straight from the book, too.
>>
>>54447824
i'm not him

but using google maps on iOS for an app that uses maps doesn't seem weird to me
>>
>>54447839
>const T *thing; and T const *thing were two different things
No,
const T *thing
and
T* const thing
are two different things. In the second case pointer can't be assigned to, in the first you can't assign to thing[index] but can change the pointer.
>>
>>54447661
I know you faggots love to argue, but it doesn't matter, as long as you are consistent.
>>
>>54447925
Yeah, and if you combine the two into
const int* const ptr;
you can't do either.
>>
Howdy fellas.
>>
>>54447956
What about const int const * const ptr
>>
>>54440731
Is it really comfy having someone hugging you from behind like that?
>>
>>54448000
Only if they have a penis.
>>
>>54447992
Then you get a nifty warning!
>>
>>54447992
same as const int* const ptr
>>
>>54447661
I am really surprised how many people have good coding style here. What the hell.
>>
>>54447882
Upon further investigation, the problem is your slicing/partitioning.

You end up with these start/mid/end values:
0 - 0 - 1
2 - 2 - 3
4 - 4 - 5
6 - 6 - 7
8 - 8 - 9
0 - 1 - 3
4 - 5 - 7
8 - 9 - 10
0 - 3 - 7
8 - 11 - 10


Obviously the 11 shouldn't be there in the last iteration (and rightly so without the last iteration you get non-crashing working solution).
>>
>>54448000
i don't really like getting touched around my waist but maybe if she leaned against my back and hugged around my upper body on top of my arms
>>
>>54448000
yeah

>>54448113
>on top of my arms
>>
File: Screenshot_48.jpg (162 KB, 1920x1080) Image search: [Google]
Screenshot_48.jpg
162 KB, 1920x1080
>>54448088
Thanks.
>>
>>54448185
Also, for what it's worth, it will crash on Linux too, it does not because GCC does not have runtime bound checking by default but you can see it crash if you compile with the _GLIBCXX_DEBUG flag like so:
g++ -D_GLIBCXX_DEBUG -omerge merge.cpp
>>
>>54448165
fuck you it's not that easy to explain

like her arm doesn't go between my arm and my torso, but in the other configuration
>>
>>54448208
i understood what you meant, it just seems restricting
over the shoulders is okay tho
>>
>>54448231
yeah like over the shoulders or one arm over the shoulder and one around the arm or something like that
>>
>>54448280
ah ok i see, thats ok yeah
>>
File: 1461191114189.jpg (86 KB, 454x633) Image search: [Google]
1461191114189.jpg
86 KB, 454x633
/g/ I made a very small Qt program that downloads and compiles some shit to avoid doing it every time I format, I used the windeploy tool and despite being a tiny program the final folder is full of dependencies and shit.

Is there a way of compiling all the shit into a single exe? I don't mean as in static linking, I want to use move a single exe instead of the entire folder full of manifests and irrelevant shit.
>>
>>54448312
who is this semen demon?
>>
File: emily helen barry1.jpg (187 KB, 640x640) Image search: [Google]
emily helen barry1.jpg
187 KB, 640x640
>>54448312
holy hell and her friend is cute af but the tits just override everything
>>
>>54448312
You can merge resources in your executable by using: http://doc.qt.io/qt-5/resources.html.
>>
File: 2016-05-08-132721_612x820_scrot.png (486 KB, 612x820) Image search: [Google]
2016-05-08-132721_612x820_scrot.png
486 KB, 612x820
>>54447356
Thank you for not replying with a troll.

>>54448028
Really ? according to the syntax rules defined in the standard, it's legal.
>>
>>54448425


this is very helpful, but this doesn't reduce DLL and external config files such as the manifest and the multiple folders the deploy tool adds

isn't there a way of making an executable around the final folder to move just that one single exe?
>>
>>54448312
>>54448504
iirc you'll need a specific license to do that
>>
>>54448504
Like just moving the executable and leave everything in place? You might be able to change that in the qmake file, but I'm not sure though.
>>
>>54448504
why not wrap it in an msi then use msi /quiet in your deploy?

(assuming windows, ofcourse)
>>
I have this function to copy the contents of an array to another array
/* copy: copy 'from' into 'to'; assume to is big enough */
void copy(char to[], char from[])
{
int i;

i = 0;
while ((to[i] = from[i]) != '\0')
++i;
}


If the original array has a
 '\0' 
as its last element it doesn't get copied to the other array, right? Or does it?
>>
>>54446537
>I really don't want to learn python because every time I install a python script from someone else I always spend a month and a half on dependencies, plugins, and the 9000 different versions of python that every developer writes in.
>I just want a portable language so I can download my scripts and run on most machine with as little setup as possible, and bash was great for this but with some of my latest projects the limits of the scripting have really started to show.
Java. it has great IO libraries, strict backwards compatibility and requires very little setup
>>
>>54447301
>Is dynamic typing a social construct?
dunno, but it's useless shit
>>
>>54448607
it does
>>
>>54448608
>Java
>Scripts
>>
>>54448461
>Python's name is derived from the television series Monty Python's Flying Circus,[96] and it is common to use Monty Python references in example code.[97] For example, the metasyntactic variables often used in Python literature are spam and eggs, instead of the traditional foo and bar.[97][98] Also, the official Python documentation often contains various obscure Monty Python references.
cringe
>>
>>54443324
A bit late, but wouldn't this work?

let a = A::new();
let tmp = a.do_it();
X {
the_a: a,
other_stuff: tmp
}
>>
>>54448630
Technically, they are.
>>
>>54446537
java

https://docs.oracle.com/javase/tutorial/

FUCK python, don't listen to those shitkids

>>54448630
>What language should I learn that's actually a programming language?
>>
>>54448630
A new tripfag has been spotted in the wild!
>>
>>54448677
>t wouldn't this work?

He's been here for a few weeks.
>>
>>54448698
>tfw your clipboard isn't empty
>>
>>54448645
Do you know what a script is?
>>
>>54448630
I was using it as basically a scripting language for complex file operations and it turned out great for that
>>
>>54448698
Oh, I've been on holiday for three weeks. That might explain why I've never seen the tripfag.
>>
>>54448709
what definition are you using because java bytecode is usually interpreted so java programs can be considered to be scripts in some sense
>>
>You'll never have a qt (22/7.0f) computer science bf/gf because most gays are vapid and hate hard fields/most women are brainless

why live
>>
What language can teach me the most about network security?
>>
>>54448504

http://upx.sourceforge.net/

what you want to do is called executable compression, check this one out, pretty popular
>>
>>54448758
Java, especially servlets.
>>
>>54448755
Except you have to wait for the JVM to start up. Most other scripting languages start up quickly. Why not just use ruby or something?
>>
>>54446537
>I really don't want to learn python because every time I install a python script from someone else I always spend a month and a half on dependencies, plugins, and the 9000 different versions of python that every developer writes in.
you are a fucking retard. Python is not to blame here.

>>54446715
>haskell
>installed uses 1GB of files
>scripting lang
top kek
>>
>>54448755
A script is a programming code file that can be executed directly without needing to be compiled to a binary first manually. Java bytecode is certainly not always interpreted. And if it was that would make bytecode a scripting language, not Java. And bytecode is not a programming language as such, it's not meant to be written by humans.
>>
>>54448798
>you have to wait for the JVM to start up
i swear a lot of you linux neckbeards are running fucking ancient machines
>>
>>54448746
>I've been on holiday for three weeks.

Where to?

>>54448706

I tend to highlight things as I'm reading, and then I forget to click off before replying.
>>
>>54448829
fair enough
>>
>>54448836
>Where to?
Taiwan.
>>
>>54447802
I was going to go with
specifier Type &name
, but then I remembered I'm in C++ land so everything must be inverted to remain consistently inconsistent.

That said, if you are going to be stubborn enough to force yourself to use C++ and NOT use
specifier Type& name
then you deserve every bad thing that ever happens to you.
>>
File: Screenshot_76.jpg (20 KB, 527x176) Image search: [Google]
Screenshot_76.jpg
20 KB, 527x176
>>54448207
Damn. Totally thought I was getting out of this just because "Visual Studio is stupid" or something.
>>
>>54448709
do you know what a script is?

you can script systems with pretty much any language, as long as it supports standards streams (assuming reasonable OS that uses a concept of standard streams, whether its backed by a fd or a pipe or a socket)

all a script (and scripting language) is is the automation of tasks instead of doing it 1-by-1 manually.

sh (csh,ksh,ash, etc) are technically a scripting language (well, closer to a domain-specific scripting language) because you can do foo | bar > baz.

which is run foo, pipe stdout to stdin of bar after you run it then redirect that stdout to the fd baz

you can do the exact same in java

if you think that scripting language == an interpreted language then you're an idiot.
interpreted languages are used for scripting because of the execution process is generally simpler: take a text file and execute it procedural. the reason people don't like to use languages with compilers is that the compiler generally is slow and developer iteration takes too long.

pinning the jvm (keeping it warmed up and running, then uploading new code to it) would reduce the start up / execute delay time. even then there's different JSRs that provide scripting (and soon, official repl support) along with running interpreted languages on the JVM.

if your concern is about running it as a shell script, its basic work to make java (8) act as a shebang: literally
#!/usr/bin/jjs -fv
# code goes here


guess what jjs stands for
>>
>>54448851

Oh, I figured you'd be going back to Norwich so you could have another go at your nan.

I'm sorry, that was rude.

Did you enjoy the shemale prostitutes in Chinese Taipei?
>>
>>54448875
>guess what jjs stands for
java javascript?
>>
>>54448758
PHP, to learn all about the ways you can fuck up
https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet

Also check out https://github.com/OWASP/DevGuide
>>
Is it unsafe to do
char array[10];

array[10] = 'x';


I know trying to access an array range that wasn't initialized gives you nonsensical output, or crashes your program at worst; but how about writing to that range? Is it just as dangerous? Is it even possible? I'm using C if it matters any.
>>
>>54448882
It's great walking around town and not being robbed at every corner of the street by niggers or mudslimes.
Though I bet your prison colony is just as safe with all the guns you have :^)
>>
>>54448908
yes, running es6 on the jvm (technically its java bytecode so the people here would disagree that its scripting for odd reasons)

if you wanted to use java (the language) as similar to a shebang you could just cat the jar into the java -jar

or have a my-program.sh that calls java -jar foo and use nailgun or the like
>>
>>54448965
could give you some stack smashing something something
>>
File: Screenshot_4.png (52 KB, 685x833) Image search: [Google]
Screenshot_4.png
52 KB, 685x833
>>54448798
>you have to wait for the JVM to start up. Most other scripting languages start up quickly.
scriptfags are fucking delusional
https://benchmarksgame.alioth.debian.org/u64q/python.html
>>
>>54448983
>US
>prison colony

Well, I can't be mad at you. They don't teach you how to read in Norwich after all.

>robbed at every corner of the street by niggers or mudslimes.

Once Trump is president, they'll all be gone. It'll be a utopia.

>safe with all the guns you have :^)

It really is. :)
>>
>>54449004
reminds me of when someone was brute-forcing a math puzzle in like 9 hours with python and i did it in like 2 minutes in java
>>
>>54448993
So one should avoid doing it at all costs then, correct?
Thread replies: 255
Thread images: 34

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.