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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 316
Thread images: 46

File: 1484999974726.gif (168KB, 640x400px) Image search: [Google]
1484999974726.gif
168KB, 640x400px
What are you working on, /g/?

Old thread: >>59235789
>>
File: 1488604517373.png (909KB, 1280x720px) Image search: [Google]
1488604517373.png
909KB, 1280x720px
First for Deadlang.
>>
Implementing useless features in my flash card game.
>>
File: 1474469537113.jpg (64KB, 1280x720px) Image search: [Google]
1474469537113.jpg
64KB, 1280x720px
Image segmenter. Takes scanned document of written words, splits it into individual characters.

>converts image to 2D vector
>splits into lines
>splits into characters
>both splitting algorithms ignore noise through a dynamic noise filter
>secondary noise check is done on split characters, removing characters smaller than (μ - 2σ)
>normalize characters to a square aspect ratio (by padding cols/rows)
>write individual images to disk

https://www.youtube.com/watch?v=-4SoT77acZM

Currently trying to optimize it so it's quicker. The bottleneck is file I/O, surprisingly. Input images are generally 120-150mb in size. 3/4ths of the time is just reading that fucken image. It takes 20x longer on Windows without altering the code, not sure why.
>>
File: vbox.png (85KB, 1429x1129px) Image search: [Google]
vbox.png
85KB, 1429x1129px
>>59240106
working on this. not really sure what's going on here.
>>
Rust is shit
>>
nothing but thanks for asking

i appreciate it
>>
File: unrelated.png (332KB, 2560x1440px) Image search: [Google]
unrelated.png
332KB, 2560x1440px
What's the minimum "good" size for a TLB?
pic semi-unrelated
>>
>>59240106
ba(){
matf(!wx);
if(r=0!=n)

pop ax=al // inline
pop bx=dx
pop cl=al
ax=al;dummy
nan.nocwa

wtf is this supposed to resemble?
>>
How meme is it to program in Mathematica?
>>
>>59240367
very

just dont do it man
>>
>>59240367

Wolfram Language is incredibly terse and difficult to understand.
>>
>>59240367
Lisp.
>>
File: file.png (121KB, 1366x768px) Image search: [Google]
file.png
121KB, 1366x768px
>>59240377
Help
>>
>>59240500
what the fuck
>>
File: 1481251105704.gif (494KB, 646x466px) Image search: [Google]
1481251105704.gif
494KB, 646x466px
>>59240500
what the fuck is this shit?
>>
>>59240500
Uhh....
>>
>>59240332
It looks like some curly brace language using inline x86-16 assembly. It's pretty bad code because the ba() function doesn't specify its arguments or return type, uses poorly named variables and functions, and includes assembly code without a proper inline assembly syntax.

Also, having an equivalence statement in a pop assembly instruction makes no sense. Maybe they mean pop the first, then mov the result into the second?
>>
File: ixnfjse3.jpg (29KB, 500x318px) Image search: [Google]
ixnfjse3.jpg
29KB, 500x318px
>>59240500
Never again I thought I would see that tongue being spoken
>>
File: niggap[ass.png (30KB, 1758x779px) Image search: [Google]
niggap[ass.png
30KB, 1758x779px
Some good C# intermediate books?
>>
>>59240649
https://github.com/vhf/free-programming-books/blob/master/free-programming-books.md

work hard
>>
>>59240520
>>59240532
>>59240555
>>59240583
xD
>>
what are some nice programs to practice learning C# on? I'm not new to programming, but I just need some ideas of things to practice the syntax with to retain it.
>>
>>59240657
Is everyone here a fucking code monkey? That's plan imperative style implementation of a basic root-finding numerical scheme with decorated symbols. Nothing surprising.
>>
>>59240652

uh.. t-thanks
>>
>>59240687
the syntax is absolutely disgusting
>>
>>59240683
Anything that involves CRUD.
>>
File: thanksthumbsup.jpg (37KB, 210x263px) Image search: [Google]
thanksthumbsup.jpg
37KB, 210x263px
>>59240683
http://www.yoda.arachsys.com/csharp/teasers.html

try this out
>>
how much memory should ncurses use?
I wrote a basic thing to test it out and it uses ~4mb of ram and doesn't nicely clean up after itself according to valgrind, but it doesn't seem to increase or go through more than the one set of allocations
>>
File: 1438520287799.gif (754KB, 473x400px) Image search: [Google]
1438520287799.gif
754KB, 473x400px
OOP is the way God meant for us to program. Accept it.
>>
Is the urge to kill yourself everyday a feature or a bug of a webdev career?
>>
>>59240864
it's a bug that can be fixed
hang in there =)
>>
>>59240864
Wrong thread
>>>/g/wdg

But feel free to kill yourself
>>
File: vbox.png (40KB, 1012x696px) Image search: [Google]
vbox.png
40KB, 1012x696px
>>59240247
Looks like it no longer crashes when I stop doing console i/o at interrupt time (how surprising)
Still I'm not getting any tx irqs, otherwise it would've returned my input without std::flush.

io::rs232_config cfg { };
cfg.set_com_port(io::com1);
//cfg.flow_control = io::rs232_config::rts_cts;
io::rs232_stream s { cfg };
s << "hello world!\r\n" << std::flush;
std::string input;
while (s.good())
{
s >> input;
s << "you said: " << input << "\r\n"; // << std::flush;
std::cout << "you said: " << input << std::endl;
}
>>
>>59240786
>~4mb
I'm a proponent of programs being mindful of memory usage, but that is nothing to get worked up over.
>doesn't nicely clean up after itself according to valgrind
Are they actual leaks or just "still reachable" stuff?
>>
>>59240958
>>59240786
Actually, I just looked it up, and the manpage for _nc_free_and_exit has a justification for why ncurses doesn't free all of its memory.
>>
>>59240791
okay
>>
>>59240929
rude
>>
Non-trolls, what's the current state-of-the-art/approach for doing .NET(ish) under Linux (ie. no Win vm / dual-boot). Is it ".NET Core"? Still good ole Mono? MS Visual Xamarin 2017? What's the ticket. Haven't done .NET in years but wanna sharpen up the old skillset, get up to current-year speed and play with F# too
>>
File: cat on CRT 4.jpg (2MB, 2448x3264px) Image search: [Google]
cat on CRT 4.jpg
2MB, 2448x3264px
what should i read if i want a detailed breakdown of how to impliment goal based agents? norvigs AI a Modern Introduction is pretty light on details on this as far as i can see
>>
Okay, so I have hte page source for a particular webpage, and as part of the page's source, I have botht he HTML and some other stuff (including some JSON).

How would I be able to retrieve the JSON?
>>
>>59240106
Should I drop out of uni? (CE)
I feel I don't get anything out of it. But then again, every workplace wants a fucking bachelor's degree. Shit's fucked.
>>
Better to have a degree than no degree at all.
>>
>>59241436
Feels like it slows me down though. 3 years is a long time to feel like you do nothing.
>>
File: Catwithsuperbrightyelloweyes.jpg (68KB, 800x554px) Image search: [Google]
Catwithsuperbrightyelloweyes.jpg
68KB, 800x554px
>>59241488
I think you should stick with it just a little bit longer, perhaps another semester or year just to see how things go- maybe your mind will change, maybe it won't. Just see how it goes, I trust that you'll make the best decision for yourself when the time comes.
>>
Improved my AmericanByte patch for GNU coreutils
I abandoned precise units (like 5 inchbyte + 372 byte) and instead opted for rounded ones, similar to -h.

$ src/ls --imperial -l /usr/lib/thunderbird/
total 1.1 milebyte
-rw-r--r-- 1 root root 526 byte Feb 15 00:46 application.ini
-rw-r--r-- 1 root root 6.0 yardbyte Feb 6 16:48 blocklist.xml
lrwxrwxrwx 1 root root 30 byte Feb 15 00:46 chrome -> ../../share/thunderbird/chrome
-rw-r--r-- 1 root root 4.0 inchbyte Feb 6 16:50 crashreporter.ini
lrwxrwxrwx 1 root root 32 byte Feb 15 00:46 defaults -> ../../share/thunderbird/defaults
-rw-r--r-- 1 root root 66 byte Feb 15 00:46 dependentlibs.list
lrwxrwxrwx 1 root root 20 byte Feb 15 00:46 dictionaries -> ../../share/hunspell
drwxr-xr-x 2 root root 4.1 inchbyte Feb 19 15:39 extensions
lrwxrwxrwx 1 root root 27 byte Feb 15 00:46 isp -> ../../share/thunderbird/isp
-rw-r--r-- 1 root root 5.2 yardbyte Feb 15 00:46 libldap60.so
-rw-r--r-- 1 root root 10.3 inchbyte Feb 15 00:46 libldif60.so
-rw-r--r-- 1 root root 1.5 yardbyte Feb 15 00:46 liblgpllibs.so
-rw-r--r-- 1 root root 1.9 footbyte Feb 15 00:46 libprldap60.so
-rw-r--r-- 1 root root 1.1 milebyte Feb 15 00:46 libxul.so
lrwxrwxrwx 1 root root 31 byte Feb 15 00:46 omni.ja -> ../../share/thunderbird/omni.ja
-rw-r--r-- 1 root root 48 byte Feb 15 00:46 platform.ini
-rwxr-xr-x 1 root root 7.3 yardbyte Feb 15 00:46 plugin-container
-rw-r--r-- 1 root root 2.0 footbyte Feb 15 00:46 removed-files
-rwxr-xr-x 1 root root 8.9 inchbyte Feb 6 16:50 run-mozilla.sh
-rwxr-xr-x 1 root root 3.5 yardbyte Feb 15 00:46 thunderbird
-rwxr-xr-x 1 root root 3.5 yardbyte Feb 15 00:46 thunderbird-bin
>>
>>59241488
I goofed off for 3 years easily, coded/learned my own stuff, just made sure I pass enough modules/exams to just-about-make it to graduation (12 years ago tho).. depending on your uni/country it can be done and seems "preferable" to dropping out and flipping burgers (not really 100% sure about that yet tho)
>>
File: vbox.png (13KB, 756x193px) Image search: [Google]
vbox.png
13KB, 756x193px
>progress
>>
>>59241567
Next two semesters do look more interesting, but I'll see what happens during the summer. If I manage to find a job, I might honestly just take it.
>>
Writing a lisp macro to generate a simulation e.g.
(define 1d-motion
(generate-sys
(cfg a)
(d/dt v) = a
(d/dt x) = v))
(define 1d-sim
(make-sim 1d-motion
#:dt 0.1
'((a . -9.8)
(v-init . +8)
(x-init . 0))))

(require plot)
(plot (points (in-sim 1d-sim '(time x)
#:time 4)
#:x-label "Time"
#:y-label "Position")
>>
>>59240106
Hacking some perl scripts go get me the nearest bus for my commute. I plan to make it into some sort of service so my frontend friend can make a nice android app for me.
>>
File: ENFP Telescope looking thru.png (113KB, 576x403px) Image search: [Google]
ENFP Telescope looking thru.png
113KB, 576x403px
>>59241866
Will it be on github/open source?
>>
>>59241183
Every relevant tool uses Mono, for example when you want to natively develop using Unreal Engine 4 on Linux that's the dependency it requires. So I guess it's still the safest to use.
>>
>>59242034
Do you mean Unity 5?
>>
>typical illustration from a Haskell introduction article
Oh god. Will this language ever become mainstream?
>>
>>59242095
Programmers are not artists
>>
>>59242106
But some would argue that programming is an art.
>>
>>59242114
Only certain languages qualify as art.
C, Lisp, and Piet come to mind.
>>
>>59242095
What introduction article?
>>
>>59241885
No.
>>
#include <stdbool.h>
>>
>>59242048
No, Unreal Engine.
https://wiki.unrealengine.com/Building_On_Linux#Distro_Specific_Instructions
>>
>>59242162
#ifndef __STDBOOL_H
#define __STDBOOL_H

/* Don't define bool, true, and false in C++, except as a GNU extension. */
#ifndef __cplusplus
#define bool _Bool
#define true 1
#define false 0
#elif defined(__GNUC__) && !defined(__STRICT_ANSI__)
/* Define _Bool, bool, false, true as a GNU extension. */
#define _Bool bool
#define bool bool
#define false false
#define true true
#endif

#define __bool_true_false_are_defined 1

#endif /* __STDBOOL_H */
>>
a2cb:   8b 45 b8    mov    eax,DWORD PTR [ebp-0x48]
a2ce: 8b 40 04 mov eax,DWORD PTR [eax+0x4]
a2d1: 8b 45 bc mov eax,DWORD PTR [ebp-0x44]
a2d4: 8b 40 18 mov eax,DWORD PTR [eax+0x18]
a2d7: 89 45 c0 mov DWORD PTR [ebp-0x40],eax
a2da: 8b 45 bc mov eax,DWORD PTR [ebp-0x44]
a2dd: 8b 70 1c mov esi,DWORD PTR [eax+0x1c]
a2e0: 8b 40 20 mov eax,DWORD PTR [eax+0x20]
a2e3: 8b 45 bc mov eax,DWORD PTR [ebp-0x44]
a2e6: 8b 40 24 mov eax,DWORD PTR [eax+0x24]
a2e9: 8b 45 bc mov eax,DWORD PTR [ebp-0x44]
a2ec: 8b 40 08 mov eax,DWORD PTR [eax+0x8]
a2ef: 89 c3 mov ebx,eax
a2f1: 8b 45 bc mov eax,DWORD PTR [ebp-0x44]
a2f4: 8b 50 0c mov edx,DWORD PTR [eax+0xc]
a2f7: 8b 40 10 mov eax,DWORD PTR [eax+0x10]
a2fa: 89 45 a0 mov DWORD PTR [ebp-0x60],eax
a2fd: 8b 45 bc mov eax,DWORD PTR [ebp-0x44]
a300: 8b 40 14 mov eax,DWORD PTR [eax+0x14]
a303: 89 45 9c mov DWORD PTR [ebp-0x64],eax

why does gcc emit so much bullshit code?
>>
>>59242162
#include <stdnoreturn.h>
#include <stdalign.h>
>>
>>59242129
Yet another "These are called monads, look at them!" newbie crap. Didn't save the link.
>>
>>59242182
https://lkml.org/lkml/2014/7/24/584
>>
>>59242182
GCC is known to have some weird bugs in its back-end. Can you compare with different optimization levels?
>>
>>59242200
>We're talking "sloth that was dropped on the head as a baby" retardation levels here
I really like reading Torvalds going off at shit. If I saw this out of context, I would have assumed someone from here wrote it.
>>
>>59242192
99% of monad tutorials are garbage and the other 1% are crap

follow the wikibook
>>
File: cryingcat.jpg (21KB, 300x300px) Image search: [Google]
cryingcat.jpg
21KB, 300x300px
>>59242144
y
>>
File: 1407832912935.jpg (12KB, 251x242px) Image search: [Google]
1407832912935.jpg
12KB, 251x242px
>>59242200
God bless Torvalds
>>
File: 1474229641700.jpg (12KB, 258x245px) Image search: [Google]
1474229641700.jpg
12KB, 258x245px
>>59242200
My fucking side, one more reason to use a linux distro
Linus is God
>>
>>59242200
is it possible to compile the Linux kernel with Clang yet?
>>
>>59242320
Don't think so, from what I know the main project has been dead since 2014.
>>
>>59242201
seems a little better at -O1, but it's still generating a lot of nonsense.
13ac9:   c6 45 e5 00                     mov    BYTE PTR [ebp-0x1b],0x0
13acd: 8a 45 e5 mov al,BYTE PTR [ebp-0x1b]
13ad0: 83 c8 80 or eax,0xffffff80
13ad3: 88 45 e5 mov BYTE PTR [ebp-0x1b],al
13ad6: 8b 45 08 mov eax,DWORD PTR [ebp+0x8]
13ad9: 8b 40 68 mov eax,DWORD PTR [eax+0x68]
13adc: 83 e0 03 and eax,0x3
13adf: 83 e0 03 and eax,0x3
13ae2: 88 c2 mov dl,al
13ae4: 8a 45 e5 mov al,BYTE PTR [ebp-0x1b]
13ae7: 83 e0 fc and eax,0xfffffffc
13aea: 09 d0 or eax,edx
13aec: 88 45 e5 mov BYTE PTR [ebp-0x1b],al
13aef: 8b 45 08 mov eax,DWORD PTR [ebp+0x8]
13af2: 8b 40 70 mov eax,DWORD PTR [eax+0x70]
13af5: 83 e0 07 and eax,0x7
13af8: 83 e0 07 and eax,0x7
13afb: 8d 14 c5 00 00 00 00 lea edx,[eax*8+0x0]
13b02: 8a 45 e5 mov al,BYTE PTR [ebp-0x1b]
13b05: 83 e0 c7 and eax,0xffffffc7
13b08: 09 d0 or eax,edx
13b0a: 88 45 e5 mov BYTE PTR [ebp-0x1b],al
13b0d: 8b 45 08 mov eax,DWORD PTR [ebp+0x8]
13b10: 8b 40 6c mov eax,DWORD PTR [eax+0x6c]
13b13: 83 e0 01 and eax,0x1
13b16: 83 e0 01 and eax,0x1
>>
>>59242347
This looks much saner but I don't know what the context is.
>>
>>59242320
Yes it can. Check out http://llvm.linuxfoundation.org/index.php/Main_Page.
>>
Is python the easiest language to understand?
>>
>>59242378
No, Lisp is.
>>
>>59242378
No, Haskell.
>>
>>59242371
It's from the same function but I'm not sure if it's the exact same section. The double AND here struck me as odd. Also note how it keeps loading and reloading [ebp-0x1b] which just stays zero the whole time.
>>
>>59242182
>>59242347
Post code. I'm curious as to what would cause this to be output.
>>
What music are you listening to right now anon?
>>
>>59242418
I don't know man. Try building with clang or compcert and seeing if your code is too obfuscated for compilation or it's just gcc being retarded.
>The double AND here struck me as odd
Doesn't get much worse than
a2e3:   8b 45 bc    mov    eax,DWORD PTR [ebp-0x44]
a2e6: 8b 40 24 mov eax,DWORD PTR [eax+0x24]
a2e9: 8b 45 bc mov eax,DWORD PTR [ebp-0x44]
>>
File: rs232_ctor.png (41KB, 764x904px) Image search: [Google]
rs232_ctor.png
41KB, 764x904px
>>59242436
it's in here somewhere.
>>
>>59242446
https://www.youtube.com/watch?v=ypGEkDIsO_Q
>>
>>59242446
https://www.youtube.com/watch?v=Q0q1gCsZykg

xtal, great ambient music- I highly recommend checking out Aphex Twin's album on YT.
>>
>>59242475
Garbage in, garbage out.
>>
>>59242446
https://www.youtube.com/watch?v=8MC0G-Lbuuk
>>
>>59242446
https://www.youtube.com/watch?v=36211-ul46k
>>
>>59242446
https://www.youtube.com/watch?v=eUO9SNCBL6U
>>
>>59242502
where do you see garbage?
>>
I know this isn't a t help thread but could someone help me identify an error i've been having with a make file? Every time i try to compile it says it doesn't know where a .h file is even though i defined it in incs. I can provide a drop box link.
>>
File: 1483447574449.png (67KB, 869x725px) Image search: [Google]
1483447574449.png
67KB, 869x725px
>>59242627
>>
>>59242446
http://dl.allkore.com/track/the-effect-of-askaryan
>>
>>59242618
Don't worry, it's a baby sees actual code for the first time episode
>>
>>59242182
>>59242347
You should take a look at the output of the Rust compiler some time. I tried posting the code it generated for Hello World here once, but it was too big to fit in the post. GCC on the other hand generated only 10 lines of assembly, even with optimization off.

>>59242451
That's just utterly ridiculous. The compiler can detect that variables in source code are unused, so it SHOULD be smart enough to realize how stupid it is to load the same register two instructions in a row. The ONLY way that would make sense if it's using those bytes to store data that coincidentally happen to form a valid instruction, but that should only be seen in the output from a disassembler - compilers should put data in as a data directive, not as an instruction.
>>
>>59242643
Funny thing: once I've started to put effort into my questions I rarely need to ask these questions anymore. Rubber duck debugging FTW!
>>
>>59242627
What's the name of the header?
>>
>>59242618
The code is stupid and ugly.
I don't really know anything about RS-232, but just by how this function is designed, I can infer that your program is probably poorly desgined.
>>
How do I read user input integer in Go? I swear this should be simpler than it should
>>
>>59242698
onscripter.h-
>>
>>59240106
Writing a program that does modular polynomial algebra for me, because I'm trying to learn cryptography and right now I'm stuck on chapter 1 of a babby's first crypto book.

>tfw you realise you're not as smart as you thought
>>
>>59242732
http://stackoverflow.com/questions/3751429/reading-an-integer-from-standard-input-in-golang
This was literally the second result on google
>>
>>59242743
drop box https://www.dropbox.com/s/hf0n4ncwqgl3nhn/on.rar?dl=0
>>
>>59242775
>stackoverflow
lmfao
>>
>>59242781
let's download a file from a /g/tard's dropbox
>>
>>59240958
>>59241010
>that is nothing to get worked up over
I'm not autistic about it either, but that's pretty severe for a <150loc tictactoe when people used to shittalk emacs as eight megabytes and constantly swapping, and I can't tell whether it'll inflate if I build something larger or stay around the same
I just wanted a better idea of what it ought to consume than checking ncmpcpp or whatever other ncurses things I use would give me, and no one seems to have asked a similar question (about usage in general, not freeing on exit, I saw something similar about that after some more searching) elsewhere
>>
>>59242781
Jesus christ, don't share code over ""cloud"" services or anything like that.
Anything git related is much better, and if you're just sharing a throwaway/single file, pastebin (or something similar) is better.
I had a group project in University where we had retards trying to share shit over Google drive and refused to learn/use git for some reason, despite the fact they taught it to us. It was horrible.
>>
>>59242789
Sorry, it the compiled libraries for onscripter along with the makefile.
>>
>>59242662
>the output of the Rust compiler some time
I don't know what goes wrong with rustc, LLVM usually produces sensible results even if they aren't as aggressively optimized as gcc.
>>
>>59242716
constructive criticism please. honestly I'm open to improvement. how would you do it?
>>
>>59241381
sed,grep
>>
>>59242838
For starters, your code is C++. I'm not expert in C++, so I don't know all of the semantics and I might be wrong about some things.
- Your weird "initialiser list" thing is just filled with "p.io_port". I don't know if io_port is a pointer, but from this context, it seems like it is. I imagine it being like this would cause the compiler to have to copy these fields individually. You're already keeping 'p', so I don't know why you need to copy all of its fields out, when you could just go through 'p'. If this is a pain, maybe you need to revise your design of 'rs232_config' to make it easier to use (e.g. use a union to give names to fields in an array).
- Your code seems to have way too many fucking types (OOP disease). Maybe I'm just misinterpreting your type names correctly, but 'irq_enable' sounds like a flag, so maybe an integer or a boolean. Yet you're calling irq_enable.write(uart_irq_enable_reg). What the hell is this shit? Why aren't you just using integers like a sensible person would? This applies to more than just that; irq_enable was just the first.
- I just hate the way all of these types are being initialised as well. I would suggest a designated initialiser, but that's a C-only feature. I don't know how sepplesfags justify its absence.
- You're using an exception. Exceptions are garbage.
>>
How did writing so many long-winded and delicate tutorials on the concept (M, return, >>=) with a couple of laws become such a meme anyway?
>>
>>59243028
>Exceptions are garbage
get a load of this faggot
>>
>>59243065
>M, return, >>=
It's like missionaries explaining the holy trinity
>>
Can you guys please help. im trying to rewrite a loop using a temp. place holder
#include <stdio.h>

sort(int *p, int m)

{
int i, t;
for (i = 0; i < m / 2; i++)
{
t = p[i];
p[i] = t;
}
}

main(){

int i, n;

int *p, num[20];

printf("input n:");

scanf_s("%d", &n);

printf("please input these numbers:\n");

for (i = 0; i < n; i++)

scanf_s("%d", &num[i]);

p = &num[0];

sort(p, n);

printf("Now, the sequence is:\n");

for (i = 0; i < n; i++)

printf("%d ", num[i]);

getchar();

getchar();

}

>>
why use
List list = new ArrayList();
over
ArrayList list = new ArrayList();
????

generally what is the benefit of using the interface name?
>>
File: 1481460001803.jpg (72KB, 960x656px) Image search: [Google]
1481460001803.jpg
72KB, 960x656px
>>59243115
>leddit formating when coding
>4 spaces tab
>not int main()
fucking disgusting
>>
>>59242823
IIRC rust puts overflow checks every single time you add integers, so that obsviously doesnt help1
>>
>>59243135
Forces you to only write code using that interface so you can swap it out for a different implementation later.

>>59243149
Yeah, it was stuff like that and a panic handling subroutine, I believe. There's certainly arguments against that kind of thing but being autistic about assembly size is a bit off the mark.
>>
>>59241250 anyone?
>>
anyone here know Verilog?

If I'm making a module that will be fully combinational (using an "always @( * )" style block, why the FUCK do I have to still declare outputs as "output reg" even though it's definitely not a register?
>>
>>59243115
>t = p[i];
>p[i] = t;

These two lines are doing absolutely nothing
>>
>>59243028
>Your weird "initialiser list" thing is just filled with "p.io_port". I don't know if io_port is a pointer
It's an integer, or actually an IO port number (http://wiki.osdev.org/Port_IO). The rs-232 uart's registers are accessed through a base port + offset, that's what the initializer list sets up.

>Your code seems to have way too many fucking types (OOP disease).
These are the contents of the uart registers. Each register being 8-bits wide, I could've hardcoded all this as hex values. Would that really improve the code though?

>Maybe I'm just misinterpreting your type names correctly, but 'irq_enable' sounds like a flag
>Yet you're calling irq_enable.write(uart_irq_enable_reg)
Register, again, which actually contains only flags. The write() and read() functions on these contain a single asm instruction (OUT and IN). I suppose my variable naming could improve though.

>I just hate the way all of these types are being initialised as well. I would suggest a designated initialiser, but that's a C-only feature.
agree. The next best option would've been writing constructors for each register type but that adds way too much code bloat. They would've been used only once during initialization, anyway.

>You're using an exception. Exceptions are garbage.
disagree.
>>
>>59243073
This is a RS232 library right? So this code probably works on a microcontroller or an embedded processor of some description. What happens if one of those exceptions escapes, what the fuck are you going to do? What does the code escape to?

Exceptions are already a terrible flow control mechanic. Using them on an embedded system is completely fucked and if you worked at a shop that did that exclusively you'd probably get fired, or at least reprimanded.
>>
>>59243213
My verilog is rusty, but I'll give it a go:
You can only "assign" (like programming) with reg types.
If you were to have it without reg, you would have to use a continuous assignment.
assign x = y ^ z;
>>
>>59241381
here brah
$ curl -s 'https://lakeshorerecords.bandcamp.com/album/night-stalker' | sed '/^\s*trackinfo/!d;s/^.*.file.:..\([^\"]*\)\"..\([^\"]*\)\".*$/https:\2/'
>>
>>59243264
Wait, I thought "assign" is only possible with wire types and you can't have a wire variable on the left-hand side inside an always block

For this reason, my output would have to be defined as an "output reg" even if I want to use an always block to compute a combinational value
>>
>>59243139
the only part i wrote was within the Sort brackets
>>59243242
now that i see it you're right. but what can i do to make the t bring out the values in reverse
>>
>>59240500
Dear diaria, today i added math symbols to my backlog, love the game.
>>
>>59243292
Well then leave your uni immediately because this code is fucked
>>
>>59243304
its not a uni its a Com. college
>>
>>59243274
Not him but I'm always amazed by what you can do with sed, I should learn how it work someday
>>
>>59243287
>I thought "assign" is only possible with wire types
Right.
>you can't have a wire variable on the left-hand side inside an always block
Yes, you cannot assign to a wire variable. The "assign" keyword would appear outside of an always block.
Unfortunately, the assign keyword would only be useful for somewhat simple statements.
>my output would have to be defined as an "output reg" even if I want to use an always block to compute a combinational value
Yes, I know. It probably isn't something to get too worked up about. I'm sure the optimiser will deal with it.
>>
>>59243253
>What happens if one of those exceptions escapes, what the fuck are you going to do?
It won't escape, that's what try/catch blocks are for. What's the alternative? Passing error codes all the way down the call chain? What happens if you forget to check the return value in one of your funtions somewhere?
>>
>>59243321
https://www.edwardrosten.com/code/sed/sedoku.sed
>>
>>59243252
>These are the contents of the uart registers.
>Register, again, which actually contains only flags
How are these implemented? Are you using bitfields?
>>
>>59243331
I see, thanks

I was worried about that the output would become a register that would take an extra cycle to update, because I'm trying to build an ALU that should output a result within a clock cycle
>>
>>59243321
sed and awk are fucking magic.
I've written all sorts of useful shell scripts with them.
>>
>>59241381
with the json parsing library of your favorite scripting language. or regex.
>>
>>59243399
theonly thing i dislike with awk is that you can have arrays like
a = ("blabla", "adas", "adadas")

or in a similar fashion, you have to do
a[0] = "blabla";
a[1] = ....
>>
File: roll.png (378KB, 1450x1080px) Image search: [Google]
roll.png
378KB, 1450x1080px
>>
>>59243472
Delete this. We don't need a bunch of useless rolling posts in here.
>>
File: rs232_fields.png (35KB, 392x1082px) Image search: [Google]
rs232_fields.png
35KB, 392x1082px
>>59243377
yes
>>
File: BenderEmbarassment.gif (282KB, 500x370px) Image search: [Google]
BenderEmbarassment.gif
282KB, 500x370px
I'm learning how to use Selenium

If I have a button located at (x,y) in a webpage, how would I go about pressing that button in a script? Would I have to use another library to go to that site and then use selenium to press it?

What would the general syntax of that be?
>>
if you aren't using python for scraping you are literally a luddite
>>
>>59243476
na
>>
>>59243505
t. brainlet
>>
why the fuck would u use regex and some ancient language when you can just use a modern library.
>>
>>59243472
Why exactly is "Sound synthesis" in the hard category?

Does it have to do with timing requirements?
>>
>>59243532
>modern library
What the hell are you going on about? The awk+sed thing we were talking about?
What meme shit are you proposing is better than those?
>>
>>59243554
the json module in python, ruby, php, etc, etc
>>
>>59243476
rolling
>>
>>59243590
If you need proper JSON parsing in a shell, just use jq.
You don't need to reach into the shitheap to get that.
>>
what's a good way to practice z80 asm

i have SDCC installed, and that comes with an assembler for that
>>
https://discord.gg/vQNxa7z
new discord pls join
>>
>tfw struggle with most of the random math problems in programming books

How did you guys solve them when you are not good at math?
>>
>>59243960
Why the fuck do you people keep posting this stupid shit?
Get your proprietary trash out of here.
>>
>>59243986
We can't we don't have Java's garbage collector in this thread

OOUUUUU
>>
>>59243960
Why not IRC?
>>
#include <sys/resource.h>

// bunch of code

setpriority(PRIO_PROCESS, 0, 0); // >Function 'setpriority' could not be resolved

// bunch of code

setpriority(PRIO_PROCESS, 0, 0); // no problem


what the actual shit?
>>
>>59244029
A compiler will only omit that warning once.
>>
>>59244029
Does the second // bunch of code include a function declaration?
>>
>>59244039
>omit
emit*
>>
>>59244039
if i comment out the first one it's all fine.

>>59244052
it includes <TargetConditionals.h>, <android/native_activity.h> and <egl/eglplatform.h>. it doesn't include anything which declares setpriority
>>
junior software developer:
java - intermediate - advanced
C - intermediate

I need a new language. I've experimented with C++, Rust, and Ruby, but none of them really hooked me. Is Go worthwhile? D? Should I dive into functional programming? Finally learn Python?
>>
>>59244075
><TargetConditionals.h>
nvm, not this one (#ifdef __APPLE__)
>>
>>59244088
Node.js
>>
>>59244075
and if i move the includes to the top it's still the same as in >>59244029
>>
>>59244096
I'm trying to stay the fuck away from web development, but thanks.
>>
>>59244088
>D
Do it. Go try the tour on their site
>>
>>59243484
some other fag here. the only way i can see gcc generating those pointless reads is if you've declared something as volatile, so it has to preserve the order and number of reads. didn't see anything volatile so far though.
>>
>>59244088
you can learn python in couple days
maybe pickup Fortran if you're into number crunching

it all depends on why you need to learn additional language ie to learn new ways of doing things, have access to ecosystem, etc

i know C/python/node now and am looking to pickup java to get into android programming and c++ to be able to hack on couple opensource projects i'm interested in
>>
>>59244029
ok i fixed my paths and symbols to point to the include folder so now it works properly
>>
>>59244088
teach us how to become advanced java programmers
>>
If you want to do something substantial with D you will need the garbage collector. Stop kidding yourselves.
>>
>>59244282
>http://stackoverflow.com/search?q=oop+design+patterns
>copy
>paste
>>
>>59244284
okay
>>
>>59244116
Everything is moving to web development. Even desktop applications are being built with web languages.
>>
>>59244394
nice meme
>>
File: 1458249001878.jpg (21KB, 500x374px) Image search: [Google]
1458249001878.jpg
21KB, 500x374px
>have a niche hobby
>every hobbyist ever struggles on a part of the job
>even professionals do it by hand, sort of, it's a time consuming as fuck task
>my autistic mind sorted it one daydreaming evening
>design a solution with the app's JSAPI and some web app quickly
>after some time, it finally JustWerks™ and I do in 1 hour what takes at least a dozen man-hours to do
>it's inelegant as fuck and needs the initial job to be made with the software framework in mind but with some tweaking it could become the new reference in terms of automation of said task, I'm 90% sure
Solution 1 : le free software install gentoo release it for free
Solution 2 : try to sell it
Solution 3 : subcontract because I can do it way faster and cheaper than anyone ATM
Solution 4 : keep competitive advantage

wat do ?
>>
File: stalker.jpg (18KB, 350x251px) Image search: [Google]
stalker.jpg
18KB, 350x251px
>>59244428
If you're good at something don't do it for free, Anon.
>>
>>59244428
Lets hear your idea
>>
>>59244314
Many thanks sir
>>
File: 1455583175374.jpg (43KB, 319x310px) Image search: [Google]
1455583175374.jpg
43KB, 319x310px
I want to be a good programmer with a job one day.
>>
Pajeet here

Ask me anything
>>
>>59244527
>Lets hear your idea
Well I'm thinking of keeping the competitive advantage for the moment
>>
>>59244557
the basic general idea not niche specifics so we can tell you if it's a good idea or not
>>
File: hot_cocoa.jpg (489KB, 1600x900px) Image search: [Google]
hot_cocoa.jpg
489KB, 1600x900px
Is it at all practical to program an online application and the server for it without using any libraries?
Also, what should I program the client and the server in?
>>
Are you guys ever waiting around for stuff to compile ? With with the launch of Ryzen everyone is talking about upgrading to reduce compile times but its not something I experience. I know it takes a long time for some stuff like firefox and linux but I don't mess around with that. I have modified some rather large windows programs built in visual studio that take a bit to initially build but after that my subsequent new builds go very fast.
>>
>>59244584
You'll learn quite a bit. You decide if it's a wise use of your time.
>>
File: fatcryingcat.jpg (39KB, 540x416px) Image search: [Google]
fatcryingcat.jpg
39KB, 540x416px
>>59244553
1. Why do so many of you like comp sci

2. Why are you working for US companies for only pennies/few US dollars and stealing programming jobs that should belong to American programmers??? Pajeets need to start their own startups and get jobs in their own fucking country instead of stealing programming jobs from american citizens this shit ISN'T FAIR!

3. Favorite language?

>>59244549
There's so many sources and ways to learn, you can do it Anon. You just need to work hard, study hard, and don't get cucked or something.
>>
>>59244613
>and don't get cucked or something.
Loved this part.
>>
>>59244613
>Why do so many of you like comp sci
A computer will not judge you

>Why are you working for US companies for only pennies/few US dollars and stealing programming jobs that should belong to American programmers??? Pajeets need to start their own startups and get jobs in their own fucking country instead of stealing programming jobs from american citizens this shit ISN'T FAIR!
It's a free market bro

>Favorite language?
F#
>>
>>59244590
it's only 1-2 secs for me even on a shitty old core 2 duo. if your project grows big you can put things in static/shared libraries and don't use templates. but i'm looking to upgrade this year and i might go for 7700k for better performance in general applications. not sure if i need lower clocked 8c/16t or if it will even help compared to 7700k which can easily overclock to 5 GHz.
>>
>>59244613
Lets think of it logically you are trapped in bad living conditions and one of the few ways out to a better life is to learn about computers and work with them. Would you rather be broke and starve in your own country or easily learn a field of computers?

I prefer to program in C++ but I also like Java
>>
>3rd year CIS, can't into algorithm design
>can only hack together shit using other people's libraries
>haven't written anything larger than ~300 LOC myself
Am I doomed?
>>
>>59244644
Introduction to Algorithms by T Cormen
>>
File: Cryingthing.jpg (43KB, 500x281px) Image search: [Google]
Cryingthing.jpg
43KB, 500x281px
>>59244630
>>59244643


fuck you're right :'(
>>
>>59244673
Why so upset bro?
>>
>>59244584

>without using any libraries?
I mean, if you're not counting the standard library as a library... maybe. Depends upon what language you're using.
>>
>>59244695
The standard library is for wimps.
>>
>>59244695
Do you enjoy programming in Rust?
>>
>>59244695
Javascript for the client of course, then PHP, Javascript, or Java for the server.
Can a server run on Javascript?
>>
>>59244644
>>haven't written anything larger than ~300 LOC myself

yeah thats pretty bad mate. Unless you have super super condense coding style or a weird way of counting lines of code. Wrote stuff longer than that for CS 102.
>>
>>59244718
>not doing everything in Lisp
Disgusting.
>>
>>59244681
Just thinking about the future is kind of frightening, idk if i'll ever get a programming job or some shit like that cause more experienced people will work for lower pay (Pajeets). Microsoft is also working on an AI called Project Deep or something like that which can program on its on, if it gets advanced enough it could replace a fuck ton of jobs

And then there's Pajeeta in my Comp Sci class who I've kind of grown a bit affectionate for but she thinks i'm a fucking creep or some shit, so that's making me sad and angry aswell

I don't really have a justifiable reason to be upset, except for worrying about jobs but that's the least of my concerns right now.
>>
>>59244553

Is it true that the Dalit are the master race of Indians?

>>59244715

I don't have enough experience with it to form any strong opinions

>>59244718

>Can a server run on Javascript?
Yes, it's called Node.js.
>>
/dpt/ needs more diversity
>>
>>59244778
if we're all anonymous (with the exception of namefags) then there's diversity because none of us know who eachother are

I could be a nigger
but i'm not

you never know, so therefore it's diversity.
>>
File: 1476243078955.jpg (237KB, 858x1200px) Image search: [Google]
1476243078955.jpg
237KB, 858x1200px
>>59244613
This is the most complex thing I've done pls no bully.
import Tkinter
window = Tkinter.Tk()
num = 0
def farentocels(finput):
finput = int(ent.get())
cresult = (finput - 32) * 5 / 9
result.configure(text = str(finput) + " degrees Farenheit is " + str(cresult) + " degrees Celsius.")

def celstofaren(cinput):
cinput = int(ent.get())
fresult = cinput * 9 / 5 + 32
result.configure(text =str(cinput) + " degrees Celsius is " + str(fresult) + " degrees Farenheit.")

window.geometry("400x400")
window.title("Temperature Converter")
ent = Tkinter.Entry(window)
lbl = Tkinter.Label(window, text="Type a temperature you want to see converted to the alternate scale")
ftcbtn = Tkinter.Button(window, text = "Convert to Celsius", command = lambda: farentocels(num))
ctfbtn = Tkinter.Button(window, text = "Convert to Farenheit", command = lambda: celstofaren(num))
result = Tkinter.Label(window, text = "")
lbl.pack()
ent.pack()
ftcbtn.pack()
ctfbtn.pack()
result.pack()
window.mainloop()

Next I want to learn how to use network functionality.
>>
>>59244789
>with the exception of namefags
Talk for yourself fgt.
>>
>>59244804
yes

>>59244793
follow your dreams
>>
>>59244733
I am 2 years out of Uni and still NEET. I really don't know what to do. I can either go for a masters degree (with money i dont have), totally change out of programming into a different career field, some how get hired in Texas or CA where there is actual entry level jobs (I live on east coast) and some how have a place to live, or an hero.
>>
>>59244819
go into web development
>>
>>59244834
there is nothing in web dev either. I can maybe go IT but its not programming related its all help desk and managing cisco hardware/software shit and I know fuck all about that shit.
>>
>>59244819
https://www.youtube.com/watch?v=eY52Zsg-KVI&t=4510s
>>
>>59244849
doing help desk is a great gateway into IT for programming web dev and other IT stuff. Also cisco router stuff managing is very easy I am a retard and did a course on it and understood how to configure the routers by following the commands
>>
>>59244849
If you have nothing else to do then keep moving forward. Try to get a job in the area if you can? D.C might have opportunities.

Hope you figure it all out soon
>>
File: 1479519499806.jpg (284KB, 1268x1485px) Image search: [Google]
1479519499806.jpg
284KB, 1268x1485px
>>59244814
What type of things should I learn if I want to to get a job?
How experienced should I be before requesting internship?
>>
>>59244880
do not worry about experience applying for an internship. for the love oh god dont end up like me and graduate without one its the worst decision. Basically the companies are incentivized through various laws and relationships to hire interns but the catch is you have to be an current student, once you graduate you are useless for them. They just want a warm body, be that warm body.
>>
>>59244880
>What type of things should I learn if I want to get a job?

You need to be more specific. If you want a web dev job, learn web development- etc etc. Search engines are your greatest friend (Except google cause it's a filthy fucking botnet) in a question like this, just look up how to get a job in your field and maybe take some free online courses to help you out

>>59244892
this
>>
>>59244912
There is literally nothing wrong with Google
>>
How can I get out of this do while loop if I press cancel? it just keeps on asking for input aggressively
[script]
do {
Numpreguntas = parseInt(window.prompt("Choose a numbre between 1 and 100",""));
} while (isNaN(Numpreguntas) || Numpreguntas > 100 || Numpreguntas < 1 )[/script]
>>
>>59244923
chuckled irl
>>
File: 1484814892034.jpg (59KB, 1000x1200px) Image search: [Google]
1484814892034.jpg
59KB, 1000x1200px
>>59244912
sorry, meant to type software engineer.
>>
>>59244923
Consider the fact that Google is also an advertising company, your search history is stored (IP too) used to target you for advertisements.

>Nothing wrong
ok have fun with your botnet
>>
>>59244936
Look, I failed at this too, just kill me already.
>>
>>59244936
Make the cancel button set a boolean variable to false. Then in your while loop check for that boolean to be true, if it isn't it will stop lloping.
>>
File: thanks mr shark.png (675KB, 740x836px) Image search: [Google]
thanks mr shark.png
675KB, 740x836px
reminder that everything will be okay
don't forget your semicolons :)

thanks mr shark
>>
>>59243472
Okay fuck it. What will it be?
>>
>>59244428
Do what they did with Doom.
>>
Just cooked up a quick script to download a video game album!
>>
>>59244584
sssmcgrath Does this for an upcoming moba (the generic meaning of the term is used here). But it seems he does it because he hasn't found anything that really fits his requirements, which are quite high.

I'm sure it'd be better if you found an API you enjoy if you aren't that constrained.

But if you're going that route he's got most of his code detailed in videoform.
>>
>>59240106
I've seen it suggested that
call/cc
can be used to "rewind" execution, but I haven't seen that take place in any example code. Is it just vague language, or is it possible? I only know about using it to break from code.

Let's say I have vector v:
#(a b c)

And I have a function whose body is doing:
(vector-set! v 0 'x)
(vector-set! v 1 'x)


Is there actually a way to use call/cc to "rewind" to a previous state of the vector, when it was still
#(a b c)

Or am I stuck copying the entire vector to a temporary value and restoring from that?
>>
>>59244936
Add a boolean, start it out with true. Detect a button press, set the boolean to false when you do. For your condition do
while(newBoolean&&(theConditionYouAlreadyHave)) 

That way the boolean 'overrides' the condition. And since the button sets the boolean the button exits the loop.
>>
>>59243543
Yes.
Practical sound software needs to be multi threaded, fast, remain in sync, and generally not use things like mutexes.
>>
>>59245278
This is what I was looking for, thank you.
>>
>>59245295
It's good to understand that
>>59245047
Said the exact same thing and you should work on understanding people a bit more if possible. It will help you a lot.
>>
>>59245331
Oh, didn't notice the guy above you said the same thing.

>>59245047
Thank you too.
>>
>>59240714
Because it was developed by mathematicians.
Have you fucking seen multivariable calculus or logical proof notation? It's a mess.
>>
>>59245331
>you should work on understanding people
Yeah lol, should have provided an example aswell.
>>59245348
np
>>
Playing bitcoin blackjack instead of working
I went all in and doubled my money tho so I guess I was productive
>>
File: openstep.png (45KB, 1538x67px) Image search: [Google]
openstep.png
45KB, 1538x67px
I think I'm doing it wrong.
>>
I want to compare two very similar but slightly different images and quantify their differences. Are there existing algorithms that do this?
>>
C apologists are NSA shills plain and simple. Rust makes it harder to produce vulnerable programs as it actually implements safety precautions like Bounds checking, dangling pointer prevention, data race prevention, lifetimes etc. This is against the interest of the NSA and so they are shilling C so that people continue to produce exploit prone, unsafe and vulnerable programs.

Ignore the NSA/C shills, Programming in C should be banned and outlawed.
Say no to security exploits, say no to the NSA. Your data and your privacy is worth preserving.
>>
>>59245452
Define how complicated of differences do you want to detect. Would you want to be able if the images was shift to the right a few pixels. Or are you looking just to take a look at the differences in the pixels.

If you are just looking at the pixels you'll probably want to convert the colors from RGB to HSV before doing anything with calculating distance.
>>
>>59245472
Oh, it's this guy again.

Don't worry anon, someday Rust will hit 1.0 and then people will write actual programs in it instead of just imagining them and talking about syntax at conferences.
>>
>>59245498
Nice try, NSA drone. Rust is now at 1.15.1, latest stable release was 20 days ago.

>This hurts the NSA shill
>>
>>59245472
Rustc currently produces horrendously bloated binaries. And this isn't anything to do with static linking or the standard library - even the assembly generated for simple user-defined functions is ridiculous.
>>
>>59245542
>Rust is now at 1.15.1
And it still can't allocate registers properly.
>>
>>59240106
Nothing :)
>>
>>59245546
Binary size is not Rust's goal, the goal is preventing possible security exploits in your program. Like data races
>>
>>59245561
>babyduck syndrome kicking in
>>
>>59245571
Sacrificing everything for safety is the reason nobody takes Rust seriously. You can't just check everything all the time and trust the JIT to save you when you suddenly need performance. Soon it will be accepted wisdom to drop down to C. Where is your safety now?
>>
 
while True:
x = input("> ")
if x != playerdeck[0,1,2,3,4,5,6].lower():
print("No")


i'm trying to get it to print "No" if the user inputs anything other than an object in the list but i keep getting this error:

Traceback (most recent call last):
File "C:\Python34\gofish.py", line 39, in <module>
if x != playerdeck[0,1,2,3,4,5,6].lower():
TypeError: list indices must be integers, not tuple


could anyone help?
>>
>>59245579
What's that supposed to mean?

>>59245571
How does having 144 bytes of local stack in a Hello World program facilitate safety?
>>
>>59245603
>you can't close all doors so you keep all of them open
>>
>>59245606
>hello world
Write a bug and exception free hello world program right now (In C)

>protip:
you can't
>>
>>59245474
I can assume the images are in the same relative position and the differences will be in the pixels.

For example, in the letters in the pic, differences could include corrupted edges or missing anti-aliasing on curves.
>>
File: 500px-A-small_glyphs.svg.png (23KB, 500x474px) Image search: [Google]
500px-A-small_glyphs.svg.png
23KB, 500x474px
>>59245634
forgot pic
>>
>>59245606
>>59245546
Why is binary size important in 2017?
>>
>>59245634
They can't even average two integers and you expect them to produce an exception proof program in C

lol
>>
Learning Python writing a Sudoku solver. Any ideas for a more graceful way of checking the 3x3 squares than just storing a list for each one? It'll work but it looks dumb and I'm blanking on anything clever
>>
>>59245658
#include <stdio.h>
#include <conio.h>
int main (void)
{
clrscr();
int a = 12;
int b = 4;
return (a+b)/2;
}
>>
>>59245664
I wrote one in qbasic once. don't recall how I did it but I'll see if I can find it
>>
File: 1487974409142.jpg (79KB, 640x640px) Image search: [Google]
1487974409142.jpg
79KB, 640x640px
>>59245682
As expected from a C tard
>>
>>59245682
kek

0/10
>>
>>59245625
#include <stdio.h>
#include <stdlib.h>

FILE *logfile = NULL;

void error(char err_string[]);

int main(void) {
logfile = fopen("errors.log", "w");
const char string[] = "Hello, World!";
if(logfile == NULL) {
error("Cannot open logfile!\n");
}
if(puts(string) < 0) {
error("Something went wrong with puts!\n");
}
return(EXIT_SUCCESS);
}

void error(char err_string[]) {
fputs(err_string, stderr);
if(logfile == NULL) {
fputs("Also, something wrong with logfile!", stderr);
} else {
fputs(err_string, logfile);
}
exit(EXIT_FAILURE);
}
>>
will pushing/popping a segment register on 32-bit x86 advance the stack pointer by 2 or 4 bytes?
>>
>>59245761
True C experience™.
>>
>>59245768
Depends on the D flag in the stack segment descriptor
2 if not set, 4 if set
t. currently reading Intel Dev Manual
>>
>>59245768
http://www.felixcloutier.com/x86/PUSH.html says that the value is zero-extended, so I assume that it's 4 bytes.
>>
>>59245807
>>59245796
thanks. so my initial assumption was right and that's not causing my bug... hnngn.
>>
redpill me on bcrypt

does it really automatically salt your hashes?

is it the best password hashing algorithm in 2017?
>>
I'm new to programming. What's wrong with my Python code?

Code:

a = 10
print('a is', a)

b = a
print('b is equal to a')
print('b is', b)

c = a * b
print('c is a times b')
print('c is', c, '\n')

a = 20
print('a is now', a)
print('b is', b)
print('c is', c, '\n')



Result:

a is 10
b is equal to a
b is 10
c is a times b
c is 100

a is now 20
b is 10
c is 100
>>
>>59245906
What did you expect?
>>
>>59245906
There's nothing wrong with the code, it runs exactly as it's written. However, your expectations about what the code does is wrong.

Each variable is a "box" that's completely separate from all other variables. A variable's value will not be updated unless you EXPLICITLY tell python to update the value.
>>
>>59245906
are you trying to make c equal 200?
c = a * b is doing c = 100. it's not retroactive.
>>
>>59245906
your code says a should be 20 but it never says b should be 20

when you originally set b=a it sets b to the value of a at that point in time, it doesn't permanently bind them

similarly c is 100 and not 200 because you never told the value of c to change, you just set it to a*b when a was 10
>>
>>59245921
>>59245944
a is now 20
b is 20
c is 400


>>59245944
So if I need to change variable 'a' in the middle of the code, I have to reassign 'b' and 'c' as well?
>>
>>59245957
just c since b is not dependent on a
>>
>>59245957
>>59245906

Use pointers
>>
>>59245605
some help pls. i'm new to programming.
>>
>>59245957
What you're expecting is called reactive programming. Most programming languages don't work like that - variables simply hold the immediate result of the computation.
>>
>>59245605
if x not in playerdeck[0:7]
>>
>import math package
>use function from said package
>get two errors
>first one is "unused package"
>second is "undefined function"
>mfw
I am THIS CLOSE
>>
>>59240106
Im working on a solver for the 8puzzle slider, i know the functions to use but im pretty new to python

im making a couple different patterns to search with dfs, bfs, A*, IDA

I know i need 3 classes: puzzle, movesequence, and solver

looking all over the internet i only seem to find A* (which is the most effective way i do believe)
>>
>>59245981
>>59245991
Thanks for the info. I guess I'll read up on those things before I continue.
>>
>>59246007
thank you.
>>
>Rust doesn't have 1 (one) crypto library that isn't utter shit
wew lad
>>
>>59246080
Remember:
- The "not equals" operator only compares the value of the left-hand side with the value of the right-hand side
- The "in" or "not in" phrase checks if the left-hand value is inside the right-hand collection
- You use the "[x:y]" notation to get a subarray or substring
>>
>>59246084
i feel like that's the case with a lot of libraries.
the postgresql lib is a pain in the ass to work with, while the alternative lib diesel doesn't support postgresql enums.
i love the irony in that to use a library that uses "feels like rust" as a selling point, i have to get rid of type safe enums.
>>
>>59246135
Well Rust itself is a pain in the ass.
Probably one of the main reasons the development for most of the libraries is stalled or just generally slow.
>>
I'm having issues getting a program ported to GNU/Linux. It's this:

Issue is this:
#define CLO_CALL(method)            (u_int)((callback_empty*)(method))

gcc complains about initializer element is not constant, but I don't know what the fuck it's talking about because I don't know enough about C to work with it.

Stackoverflow had some case-specific answers, but I wasn't able to relate it in a way I could understand t.

total project is on github at ddlsmurf/SoV
>>
>>59246396
What are the invocations of the macro that are causing errors?
>>
>>59246471
If I understand your question:

The makefile uses these arguments.
CC = gcc
CFLAGS = -g -Wall
LIBS = -lpcap

The callback_empty is defined in the main file:
typedef    void callback_empty();
>>
>>59245452
Look into pdiff
>>
>>59246538
No, I mean give me an example of where this macro is being invoked that is producing an error. Just defining that macro won't cause an error, one of the uses will be causing the error.
>>
>>59240143

import std.stdio;

void main()
{
size_t count;
bool[8191] flags;

writeln("10 iterations");

// using iter as a throwaway variable
foreach (iter; 1 .. 11)
{
count = 0;
flags[] = 1;

foreach (index, flag; flags)
{
if (flag)
{
size_t prime = index + index + 3;
size_t k = index + prime;

while (k < flags.length)
{
flags[k] = 0;
k += prime;
}

count += 1;
}
}
}

writefln("%d primes", count);
}
>>
>>59246554
OK I see.

Here GCC say:
src/SoV.c:98:33: note: in expansion of macro ‘CLO_CALL’
{"?", NULL, CLO_TYPE_TERMINAL, CLO_CALL(print_use)},

And there are others of similar syntax.

print_use is here:

void    print_use()
{
print_version();
printf(
"A description");
print_options(sov_arguments);
}


sov_arguments is

commandline_option_t sov_arguments[] = {

and commandline_option_t is

extern commandline_option_t sov_arguments[];
>>
>>59241250
Fear SDK?
>>
>>59246623
The program is doing some non-standards-compliant stuff which happens to work with the compiler they use. The error message is pointing out a legitimate error. The macro does a cast from a pointer type to an integer type. In an integer constant expression you can only do casts from arithmetic types to integer types, and pointers are not an arithmetic type.

The easiest fix is probably to use void* instead of u_int in commandline_options_s.offset. But this will require changes in other places too.
>>
>>59246769
Thanks for that insight. I work to understand better.

Cheers.
>>
>>59246623
>>59246769
>>59246868
If you need it to be an integer, use uintptr_t.
>>
>>59246872
In general, yes. But it won't work in this situation - uintptr_t is still an arithmetic type, so you can't cast a pointer to it in a constant expression. e.g.: the following (rightly) causes a compile error:

#include <stdint.h>

int *foo;
uintptr_t bar = (uintptr_t)foo;
>>
>>59246904
>int *
>uintptr_t
pajeet
>>
>>59246904
That wouldn't work with a void * either.

>>59246922
That's the correct way, idiot.
>>
>>59246922
You realise I was posting an example of an error, right? But the only reason this doesn't work is because it's a constant expression. Otherwise casting a pointer to a uintptr_t is perfectly fine, in fact it's what uintptr_t is for...
>>
New thread:

>>59246942
>>59246942
>>59246942
>>
>>59246936
pajeet^2
go learn some C types basic
>>
>>59246952
What the fuck are you on about?
>>
>>59246936
Oh yeah, true. I guess he needs to use the actual function pointer type instead of the hacky shit he is doing.

>>59246952
Low effort.
Thread posts: 316
Thread images: 46


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.