[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: 323
Thread images: 40

File: mccarthy.jpg (410KB, 1600x1012px) Image search: [Google]
mccarthy.jpg
410KB, 1600x1012px
What are you working on, /g/?

Old thread: >>60635941
>>
think I'll write datadog tracing bindings for Haskell
>>
second for Java
>>
>>60641745

gross
>>
>>60641745
Fourth for Java. Teaching myself Spring so I can port a small webapp I wrote from Python.
>>
I don't understand why people say that Lua does not have many features. It may not on the surface have a lot of features, you don't need any because each feature so powerful.
>>
>>60641703
Tetris clone
>>
File: lua_waifu.jpg (113KB, 573x892px) Image search: [Google]
lua_waifu.jpg
113KB, 573x892px
Threadly reminder that Lua is super duper cute; and she's a blast to write in! Say something nice about her, /dpt/!
>>
>finally finished university
now what?
>>
>>60641907
give me ur uni projects to use as my own
>>
File: 1445722183259.jpg (68KB, 700x700px) Image search: [Google]
1445722183259.jpg
68KB, 700x700px
>tfw you fell for the programming job meme
>>
How do I read data from a file?
>>
>>60641949
open file
copy and paste everthing in a string
>>
>>60641962
>open a file
>begin copypasting it
>another process kicks in
>overwrites the file
>end up with a string full of shit
>>
>tfw can't into awk
>>
>>60641949

use the open, read,write system calls
>>
>>60641980
i was memeing
>>
File: Best-Jobs-in-America.jpg (204KB, 1243x881px) Image search: [Google]
Best-Jobs-in-America.jpg
204KB, 1243x881px
>>60641907
never had a job senpai?

>>60641947
>tfw you fell for one of the best jobs in the world
>tfw all your friends from highschool already have a bouquet of work related health issues
>tfw you are handsome, fit, healthy, calm and intelligent
>>
>>60641995
>use open() syscall
>use read() to read a piece of data, whether it's a byte or whatever else
>another process overwrites the next piece of data
>end up with garbage anyways
>>
>>60642008
not one worth mentioning
also britbong

>>60641937
last stuff i worked on was a simple neural net in python, a 5 a side football sim in prolog, and some horrid little network enabled android app.
>>
>>60642008
>one of the best jobs
lol
also
>college professor that high
is that true? I actually wanna be a professor
>>
File: logo-small.png (5KB, 190x88px) Image search: [Google]
logo-small.png
5KB, 190x88px
A formally proven implementation of FizzBuzz, r8: https://github.com/batonius/idris-fizzbuzz/blob/master/FizzBuzz.idr

At the moment I've proven that for each non-zero positive n the function produces a strictly ordered sequence n..1, with each element having a string component according to the FizzBuzz rules, and I've kinda run out of properties to prove.
The most interesting thing is I don't have to write the values themselves, once I've proven the properties, Idris is able to deduce the actual value for me.
>>
>>60641703
i am trying to do my homework, but can't muster the motivation to do so.
it is in java and the exercise says, that I need to read a textfile, read the numbers in the file and put them into an array.
but here I am yawning and feeling sleepy and not willing at all.....
>>
>>60642117

that's fucking easy m8, if it takes you more than 10 minutes you're hopeless
>>
>>60642117
>reading files in java
>buffer(print buffer(read buffer( teleports behind you buffer( factory buffer ( lets add something else here ( writer (buffer( ayylmao (the virtual machines bows to them ())))))
>>
>>60642125
>that's fucking easy
Not him but I've posted a much simpler/more generic problem and nobody ITT answered it correctly yet (at least 2 anons tried).
>>
>>60642141
TeleportToNullPointerException at thread main()
>>
>>60642125
I am a fucking newbie to programming.
It is easy as fuck i bet.
But i just want to lay o my bed and sleep away my existence.
>>60642141
tanks i guess
>>
>>60642158
I'll come back later on.
I need to pull myself to the neurologist for medication.
cya.
>>
>>60642087
prove that fizzbuzz of a prime n where n > 5 is (show n)
>>
>>60642082
Of course it's comfy, the hard part is to get a position in a good place. One of my pals spent a couple of years in one of the African countries, teaching negroes math or physics iirc. That was pretty horrible according to him, he still managed to get a couple of students to good eu unis after all and he is proud of it
>>
>>60642158
https://www.youtube.com/watch?v=t894eGoymio
>>
>>60641855
Fuck Lua.

Had to write in Lua for child scripts in V-REP. Worst fucking language, ever.
>>
>>60642082
Is that including or not including tenure?

Because Adjunct profs don't get anywhere near that stability or salary. also, most profs get between 40-60k, not 70k. the fuck is the data from?
>>
>>60642176
It's actually not that hard. Once you have some good formalization of "is prime" property you can deduce Not (n % 3 = 0) and Not (n % 5 = 0) from it and then use the Nat case constructor directly.
>>
>>60641947
>>60642004
>meme
>>>/v/
>>
>>60642178
teaching is the only job I can see myself doing for a longer period of time, but I fucked up by not getting into a good university
>>
File: 1491313681798.png (313KB, 700x995px) Image search: [Google]
1491313681798.png
313KB, 700x995px
>>60642087
>r8
Cute / 10
>The most interesting thing is I don't have to write the values themselves, once I've proven the properties, Idris is able to deduce the actual value for me.
That's a property of any constructive system.
>>
>>60641703
Lisp is best language. Working on a Common Lisp project that uses Node.js / web browsers as a compilation target, with Parenscript. Here's an example macro I wrote to chain ES6 Promises without resorting to .then() syntax:

(defmacro chain-promise (&rest lambdas)
(let ((form (car lambdas)))
(loop for lambda in (cdr lambdas) do
(setf form `((@ ,form then) ,lambda)))
form))
>>
Webdevelopment in Idris
>>
>>60642403
>web ''''development''''
>>
>>60642403
USE ATS YOU FOOL
>>
>>60642087
>Only works for natural numbers
Please generalise this to work on any Euclidean domain.
>>
>>60642403
>Web""development""
Use >>>/g/wdg/
>>
>Machine code for C library is linked into program code whereas the code for windows function if loaded outside of your program in DLLs.
Does this imply c library are bloated?
>>
>>60641855
Something nice? github.com/luvit/luv such beauty. Got the async networked program I wanted working in NO TIME! Lua make me do what you want, I am your sex slave.
>>
>>60642448
No the operating systems ABI model is bloated.
C does define how libraries/programs are packaged, loaded or executed.
>>
>>60642470
Meant to say that C does NOT define
>>
>>60642436
FizzBuzz itself is defined for N+ only tho. Besides, I rely on the length of the vector being Nat as well.
>>
>>60642554
I don't see why I can't work on any ring with "division with remainder".
>>
>>60642559
Well, for starters I need a strict ordering for sorting/uniqueness and a successor function for induction.
>>
>>60642484
I heard System V is abi for linux
What is the abi spec for windows?Why didn't linux adapt it? Is it patented by MS?
>>
Explain move semantics to me like I am a retard
>>
>>60642470
>But... But it was developed by open sores community it is supposed to be efficient than windos.
>>
>>60642714
>like
No need to lie, anon.
>>
>>60642681
>I heard System V is abi for linux
It's used by most 64-bit unixes, including the BSDs and macOS.
>What is the abi spec for windows?
They have multiple, for some stupid reason.
>Why didn't linux adapt it?
Why didn't Windows adapt the System V ABI? They're the odd ones out here.
The most surface level reason is sizeof(long). 8 bytes on System V, 4 bytes on le winmeme.
There is a lot of software that makes the assumption that a long is the size of a pointer. So they would probably subtly break a lot of software if they had it 8 bytes. I think micromeme chose 4 bytes because their shitty APIs made a lot of assumptions about long being 4 bytes specifically, but I'm not certain about that.
>>
>>60642681
Windows has it's own spec, it's just "the Windows ABI". System V was a Unix OS, linux, being a unix-like, uses the Unix ABI. And Linux isn't just going to change the ABI, that's a net-zero effort, there is more than just the ABI keeping linux and Windows applications separate.
>>
>>60642730
>meme
>>>/v/
>>
>>60642765
>you
>>>/trash/
>>
>>60642792
>>>>/trash/
>>>/b/
>>
>>60642730
What is the name of windows abi?
>>
>>60642730
>le
>>>/v/
>>
>>60642714

Foo owns a heap pointer to a big array. It's expensive to copy this array.

struct Foo
{
size_t my_stuff_size;
char* my_stuff;
}

Under normal circumstances, if you want to create a copy of Foo, you also must make a deep copy of that array which the new Foo owns.
Foo(const Foo& otherFoo)
{
my_stuff_size = otherFoo.my_stuff_size;
my_stuff = new char[my_stuff_size];
memcpy(my_stuff, otherFoo.my_stuff, my_stuff_size);
}

If you know that the other Foo isn't going to be used, that means you're free to steal its resources using a move constructor.
Foo(Foo&& otherFoo)
{
my_stuff_size = otherFoo.my_stuff_size;
my_stuff = otherFoo.my_stuff;

otherFoo.my_stuff_size = 0;
otherFoo.my_stuff = nullptr;
}


The move ctor will be automatically be invoked on an unnamed temporary (rvalue) Foo, or you may explicitly write std::move as well.
>>
>>60642751
Thanks for the information. I couldn't find this on google search.
>>
>>60642723
You got me

>>60642836
Much appreciated faam
>>
==19712== HEAP SUMMARY:
==19712== in use at exit: 804,918 bytes in 2,609 blocks
==19712== total heap usage: 61,560 allocs, 58,951 frees, 354,023,997 bytes allocated
==19712==
==19712== LEAK SUMMARY:
==19712== definitely lost: 88 bytes in 1 blocks
==19712== indirectly lost: 776 bytes in 1 blocks
==19712== possibly lost: 42,615 bytes in 1,283 blocks
==19712== still reachable: 761,439 bytes in 1,324 blocks
==19712== suppressed: 0 bytes in 0 blocks
==19712== Rerun with --leak-check=full to see details of leaked memory

Languages with GC are scrary.
>>
>>60643120

what am I looking at here?
>>
>>60643223
Valgrinds output on simple GUI program compiled with chapel, I might forgot to quit the sdl so that's why it leaked...

But here's one for hello world
==19971== HEAP SUMMARY:
==19971== in use at exit: 0 bytes in 0 blocks
==19971== total heap usage: 2,258 allocs, 2,258 frees, 765,278 bytes allocated
==19971==
==19971== All heap blocks were freed -- no leaks are possible
==19971==
==19971== For counts of detected and suppressed errors, rerun with: -v
==19971== Use --track-origins=yes to see where uninitialised values come from
==19971== ERROR SUMMARY: 21 errors from 21 contexts (suppressed: 0 from 0)

Still spooky.
>>
>>60643266
compared to hello world in C.
==19994== HEAP SUMMARY:
==19994== in use at exit: 0 bytes in 0 blocks
==19994== total heap usage: 1 allocs, 1 frees, 1,024 bytes allocated
==19994==
==19994== All heap blocks were freed -- no leaks are possible
==19994==
==19994== For counts of detected and suppressed errors, rerun with: -v
==19994== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

So clean.
>>
>>60643266
What did you use? OpenGL(glfw,glew or sdl) or some shitty opens sores library for gui?
>>
>>60643370
it just started the window and closed it, didn't draw anything.
>>
>>60642387
explain this expression by expression
>>
books for beginner compsci math?
>>
>>60643598
https://courses.csail.mit.edu/6.042/spring17/mcs.pdf
>>
>>60641703
lisp is the least weird programming language
>>
any arduino people in here? i'm doing the project where you make pressing the button turn a blinking red light or, while not having it depressed has the green light on. i changed it to be where you press it once to change the state, but it can't register button presses half the time when the red lights are blinking because of the delay function. how do i do this?
>>
>>60643822
don't write a shitty delay function
>>
>>60643885
i didn't write a delay function. i asked for arduino people..
>>
I've read K&R and made some things with C what book should follow next to get even better in C?
>>
>>60643939
The Practice of Programming by Brian Kernighan and Rob PIke. Even though it is a general programming book, it focuses on C a lot.
>>
>>60643910
can I see the code? I don't know how to arduino but I did something similar last year in uni.
>>
>>60643629
thanks !!
>>
>>60643954
it's on my laptop but it's

state = 0; // 0 is green, 1 is flashing red

void loop(){
push = digitalRead(button);
if (push == HIGH){
state = !state;
}
if state {
digitalWrite(red, HIGH);
delay(250);
digitalWrite(red, Low);
delay(250);
}
else{
digitalWrite(green, HIGH);
delay(250); // to give you a chance to let go of the button before it reads again
}

>>
>>60644038
lower the delaytime?
>>
>>60644093
i was more wondering if they have threading
>>
>>60644131
yeah I was actually thinking about too. I was just starting to write something similar but with threading. I'm pretty sure you don't need threads for this. we did something like this on a 8051 and instead of the delay function we just let it count from 255^2 to 0.
>>
>>60644167
sounds like a pretty good idea actually, might try it out. only thing i don't like about it is that the duration of the blinks would be based on the processing speed of the hardware though
>>
Can somebody tell me where this is going wrong?

#include <cmath>
typedef long double num;

num snd (num x)
{
return exp(-0.5*x*x)/sqrt(2*M_PI);
}


Supposed to be a standard normal distribution calculator, should be trivial to make but it keeps throwing up wrong answers.
>>
any android devs here? what is the difference between layout and activity?
>>
>>60641980
>open file gets changed
now this is a meme

captcha: UMUM barcelona
>>
>>60644395
exp might not be defined for long double. Have you tried regular doubles?
>>
File: 1489008954468.jpg (138KB, 1247x810px) Image search: [Google]
1489008954468.jpg
138KB, 1247x810px
>tfw someone forks your project on github
Do you know this feel lads?
>>
>>60644395
My guess would be M_PY, not only because Ï„ is the way to go, but also because I can't confirm it's even in the C++ standard, so maybe your C++ implementation is fucking with you on that. Afaik exp and sqrt are overloaded for long double in C++.
>>
>>60644335
yeah i think we used a timer later in the semester, but I forgot how long the delay had to be.
>>
>>60644421
layout defines the UI elements, eg where buttons are, that doesn't contain any code. The activity can be seen as the entry point of the application code.
>>
>>60644498
he probably missclicked
>>
>>60644488
It is, and trying regular doubles would prove what exactly?

http://en.cppreference.com/w/cpp/numeric/math/exp
>>
>>60644533
Nothing, i was too lazy to check if it was actually overloaded for long doubles.
>>
File: 1489173082128.jpg (33KB, 400x400px) Image search: [Google]
1489173082128.jpg
33KB, 400x400px
>>60644518
Delet
>>
>The 64 bit version of windows operating system supports up to 16 terabytes of random access memory whereas 32-bit versions can only support up to 4 gigabytes.
Does this mean we are about to see impossible things in coming decade?
>>
>>60644571

64bit has been the standard since forever man
>>
>>60644498
>github
well deserved
>>
>>60644571
did you have lag for the last 15 years or what is this post supposed to be
>>
>>60644571
I think most processors' address space is only like 48 bits
>>
>>60644581
So why are we limited to 32 gb ram meme?
>>
>>60644612
Because right now having more is a waste of money?
>>
>>60644600
whats stopping us from harnessing 16 tb of ram?
>>
>>60644631
if you have a use case you actually do
ask some internet service providers of different sorts
they all do
you won't ever need it as end user
>>
>>60644612
I once saw a server with 128GiB, but in general I think the motherboard sockets are the limiting factor.
>>
>>60644631
>>60644640
afaik for example spotify and similar services, they don't stream music from their HDDs to you, it's all stored in the memory
but their servers also don't run on >>60644571 >>>>>fucking windows
so their memory limiations may be entirely different
>>
>>60644631
>The total CPU plus coprocessor memory was 1,375 TiB (approximately 1.34 PiB)
We have. Its in china
https://en.wikipedia.org/wiki/Tianhe-2
>>
>>60643939
Head first C
>>
>>60642817
win32 I think
>>
>>60644131
>>60644167

okay so I think I made it with threading. I'm not sure if this is a "good" way of doing it though. please tell if it isn't.
[CODE]
#include <thread>
#include <memory>
#include <iostream>


int state = 0;
std::unique_ptr<std::thread> t_run;
std::unique_ptr<std::thread> t_input;


void red(){
std::cout<<"red\n";
}
void green(){
std::cout<<"green\n";
}
void input(){
std::cin>>state;
}
void run(){
while(true && state != 2){
if (state == 0)
red();
else
green();
}
}

int main(){
t_run = std::unique_ptr<std::thread>(new std::thread(run));
t_input = std::unique_ptr<std::thread>(new std::thread(input));
t_input->join();
while (state != 2){
t_input.reset();
t_input = std::unique_ptr<std::thread>(new std::thread(input));
t_input->join();
}
t_run->join();
return 0;
}
[/CODE]
>>
>>60644812
lmao fuck me, sorry
#include <thread>
#include <memory>
#include <iostream>


int state = 0;
std::unique_ptr<std::thread> t_run;
std::unique_ptr<std::thread> t_input;


void red(){
std::cout<<"red\n";
}
void green(){
std::cout<<"green\n";
}
void input(){
std::cin>>state;
}
void run(){
while(true && state != 2){
if (state == 0)
red();
else
green();
}
}

int main(){
t_run = std::unique_ptr<std::thread>(new std::thread(run));
t_input = std::unique_ptr<std::thread>(new std::thread(input));
t_input->join();
while (state != 2){
t_input.reset();
t_input = std::unique_ptr<std::thread>(new std::thread(input));
t_input->join();
}
t_run->join();
return 0;
}
>>
>>60644751
Thats api.
Its called "windows abi" imo
No google results though
>>
lazy fuck here spoonfeed me
I need a c/c++ library with all the fucking different sorting algorithms for random purposes and comparison, computation tests etc
I don't want to waste any time on writing them myself
where do I even start looking for something like this?
I'm new
>>
>>60644395
nvm, turns out I'm just retarded
>>
>>60644865
I know it's the API, but I think I heard somewhere they also called their ABI that.
>>
Is there a less retarded way to switch between functions/graph types?
for (var i = len * -PI; i < len * PI; i += 0.1) {
var x1 = scale * (i);
switch (graphOneInput.value()) {
case 'sine':
var y1 = scale * ( amp * sin( i * freq + step));
break;

case 'cosine':
var y1 = scale * ( amp * cos( i * freq + step));
break;

case 'tangent':
var y1 = scale * ( amp * tan( i * freq + step));
break;

case 'secant':
var y1 = scale * ( amp * sec( i * freq + step));
break;

case 'cosecant':
var y1 = scale * ( amp * csc( i * freq + step));
break;

case 'cotangent':
var y1 = scale * ( amp * cot( i * freq + step));
break;

default:
var y1 = scale * ( amp * sin( i * freq + step));
}
>>
>>60644865
>>60644917
Yeah you are right, they don't call the ABI win32, Wikipedia also just calls it Windows ABI.
>>
It used to be a few users working on pet game projects. So how did those go? and is there any place anymore on the mobile platforms for the indie game dev?
>>
>>60644395
M_PI definitely not standard C++, see note at the bottom:
https://www.gnu.org/software/libc/manual/html_node/Mathematical-Constants.html

so it aims to be accurate enough for a double, not a long double. You can use M_PIl on GNU systems, which will have more digits.
>>
>>60644834
You don't have to store std::thread in std::unique_ptr, std::thread is already RAII/move aware type. You still have to either join or detach it before destroying it tho.
>>
>>60644834
My openGL program has one "render function" that renders a triangle on screen.
I have a GLSL file from where my program reads the glsl program(uses FILE* of C).
I want to a thread locking system where user shall be able to edit the file write and my "render function" should follow up with updated glsl code.
Should I switch my code from C to C++ to use std::thread or I learn pthreads?
Never did threading

Is threading almost exclusively require for making video games?
>>
>>60644923
[/code]var trigonometric_function = sin;[/code]
I'm not a C# mofo but I bet you it does what you and I think it does. Then maybe use a hash table that maps the name to the trigonometric function you want.
>>
>>60644883
#include<algorithm>

Is not this enough?
>>
>>60644949
I m from time where I used to browse XPDA or xda forums about symbian game dev.
Haven't learned anything yet.
>>
>>60644923
I would define a function which takes another function as an argument and then just pass your 'sine' 'cosine' etc.. functions as arguments
>>
>>60644960
I was confusing the SND function with the cumulative function, code was doing exactly what it should. Thanks anyway.
>>
>>60644971
is it a bad practice?
>>60644989
idk man, it's the first time I used threads. I think std::thread is a safe way of using pthreads, so I guess you're fine with using pthreads. I might be bullshiting though.
>>
>>60645054
I can't say it's a "practice" because so far you're the only one who've come up with such nonsense to my knowledge, it's like putting all your ints and string in unique_ptrs for no reason.
>>
>>60645005
wow fuck me I guess
I use all kinds of shitty libraries and yet I never saw this basic bitch
neat desu thanks
>>
>>60641786
>web*pp
Use >>>/g/wdg/
>>
>>60645018
There used to be some /g/uys who had promising things, I especially recall two, one of whom was working on a shoot em up, something akin to what Touhou Project has, the other was some abstract concept stuff. This is well over one or two years ago, there wasn't many who asked students level stuff back then, so it is quite old by Internet standards.
>>
How long would it take for on average person to learn enough coding to land a job if you spend two hours every day?
>>
>>60645123
oh right, now I understand. thanks for the feedback.
>>
>>60645186
depends on your progress you dingus
>>
>>60645030
Thanks anon! shortened my code by a bit, but not sure if it's any faster, not that that was a primary concern anyway.
>>
>>60645186
>will do koding for monnies
shittons o' years wouldn't suffice girl. Just switch fields right now and go into something that suits your inferior brain. Even if you are actually a boy (female), if you haven't learned algorithmic thinking when you were young, you're never going to be actually productive. Maybe you could land button-mashing jobs, idk, but you won't become a programmer.
>>
>>60645242
How does that solve the massive switch issue tho?
>>
File: dlang_chan.jpg (139KB, 470x545px) Image search: [Google]
dlang_chan.jpg
139KB, 470x545px
Threadly reminder that dlang-chan is not dead; she's going to have her GC tumor removed (eventually); she's super duper cute; and she's a blast to write in! Say something nice about her, /dpt/!

>Features
https://dlang.org/comparison.html
>Standard library
https://dlang.org/phobos/index.html
>GC
https://dlang.org/spec/garbage.html
https://dlang.org/blog/2017/03/20/dont-fear-the-reaper/
https://dlang.org/blog/2017/04/28/automem-hands-free-raii-for-d/
>Books
https://wiki.dlang.org/Books

>>60641855
Her and C are great friends!
>>
I'm a man (female), how do I get other programmers to take me seriously?
>>
>>60645383

code good and shut up
>>
>>60645383
You forget the other set of parentheses
>man (female (male))
To answer your question, Lisp of course!
>>
>>60645383
Be brilliant, just like male men have to do to be considered in the field. Shine, the rest is automatic.
>>
>>60645403
>>man (female (male))
That doesn't even make sense
>>
>>60644167
tried this out and it didn't work, i think the compiler might be breaking it but even if i'm just being stupid i can't be fucked to do it this way
>>60644834
arduino's language is a dialect of C and i don't think they allow the thread library :/ thats what i read at least
>>
>>60645281
Changed all the input types to the actual function name, e.g. sine . => sin cosine => cos etc...
Then use
window['sin'](args) // for example

to call the function. Could use `eval`, but would rather stay away from that.
>>
>>60645419
a trans man that wants to be a man
makes perfect sense
>>
>>60645427
hmm that's too bad. good luck
>>
>>60645447
ok makes sense. Didn't know you could do that tho.
>>
>>60645419
Neither does lisp.
>>
Just found a fun game /g/. Take any non-trivial C/C++ project you've written then build it with clang using -Weverything. Post the most useful warning you get here.
warning: function 'syntaxError' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
>>
>>60645186
2 hours is shit.
I have been working for 6+ hours for 3 months and I don't have any production code yet.
>>
>>60645476
Should've done that from the beginning.
>>
>>60645516
Shut up faggot. Learn Lisp.
>>
>>60645516
The following NEW packages will be installed:
clang clang-3.8 libclang-common-3.8-dev libclang1-3.8 libffi-dev libllvm3.8
libobjc-6-dev libobjc4 libtinfo-dev llvm-3.8 llvm-3.8-dev llvm-3.8-runtime
0 upgraded, 12 newly installed, 0 to remove and 0 not upgraded.
Need to get 57.8 MB of archives.
After this operation, 293 MB of additional disk space will be used.


nah
>>
>>60644923
Is this what /g/ programming is nowadays? Are u retarded? Whats wrong with you? How can u be this dumb to write such code? Nigger you are wasting more cycles than the sun has energy. How in ur dumb mind did u figure out it was good to make switch on string input which is then used and maps 1:1 to vtable of next action ?

This has to be a troll post or some Kode bait, judging by your colors and font you are sucking dicks as a braindamaged fag or baiting. Which one is it?
>>
>>60645123
>>60645191
so I use reading about std::unique_ptr recently and thought why would I ever need that.Then I thought
What problem can I get into if I don't use std::unique_ptr?
float *somemathconst = new float()
float *anotherptr = somemathconst;

There is a risk to delete anyone of them because programmer thought he is done with that object.
By using std::unique_ptr I don't have to worry about using delete.
>>
dsdfdf
>>
>>60645630

congratulations anon, you're finally learning about RAII
>>
>>60644923
Functional programming

lookup graphOneInput [
("sine", sin),
("cosine", cos),
("tangent", tan)
]
>>
>>60645588
I knew that way was retarded, thats why I asked, now i have an answer and a non-retarded method.
And my colours are comfy.›
>>
>>60645630
>By using std::unique_ptr I don't have to worry about using delete.
that's the point of smart ptrs
>>
File: 1495999951162.gif (912KB, 240x176px) Image search: [Google]
1495999951162.gif
912KB, 240x176px
>>60645588
You seem upset.
>>
>>60645586
Build 4.0.0 from source anon. You'll thank me later.
>>
>>60645186
>time is a good measure of experience
Do you just want to look good for a role, or actually be good at it?

Work at it until you are confident you know enough to be reasonably informed. There is no meaningful time estimate, it's going to be different for everyone: http://www.gse.harvard.edu/news/ed/15/08/beyond-average
>>
>>60641703
>What are you working on, /g/?
a program to get the cpu usage for a given time period on linux

>>60644498
what's your github?
>>
>>60645186
Do a project nigga, see how long it'll take.
>>
Does anyone in here know how to choose what an arduino will consider HIGH and what it will consider LOW?

I've been building a very simple system. What it does is besides the point, given it is working perfectly, but I bought a switch to have it turn it on and off. However, it doesn't work as expected.

It ONLY works when the switch is connected to pin 4 for input. That can't be the configuration used, though, because the pin 4 is used for writing on an SD, which my program uses. When on any other pin, it turns on when the switch is turned on, but when I turn the switch off it keeps reading HIGH. So I imagine the fourth pin reads differently for some reason, and I want other pins to behave the same way.


I'm using an arduino uno with an ethernet/sd card shield btw, not sure if that makes any difference (while testing with only the arduino uno, it behaved the same way, with only the digital pin number 4 being able to read correctly).
>>
>>60645186
https://techcrunch.com/2012/05/10/dev-boot-camp-is-a-ruby-success/
>>
>>60646067
Show us your setup, cant help you without the details.

In short, no, you can't change the I/O HIGH/LOW thresholds in software, but you probably just need a pullup/pulldown resistor.
>>
>>60646207
Unfortunately, I don't have it rn because I left it at the workshop (we were using it anyways, just wiring it directly to gnd or vcc to simulate a switch), but the switch is just some average 2 pin, 2 states one.

How do I calculate how much resistance I'd need for a pull up/down resistance?

And since i can't provide a pic, I'll just try to describe it. It is quite simple desu, one of the pins of the switch is connected to the 5V output of the arduino, and the other one is connected at a digital pin, simple as that. There isn't anything else connected to that part of the circuir
>>
>>60646310
So when the button is pressed, the circuit is complete and 5V goes to the digital input.
Think about what happens when the switch isn't pressed. Why do you think it would shoot down to ground of it's own accord?

Give this a read: https://www.arduino.cc/en/Tutorial/DigitalPins

You can use the internal pullups, but you'll have to invert the logic i.e. unpressed reads HIGH (20k pullup), pressed reads low (short to ground).
>>
>>60646452
Huh, thanks m8.

I'm going to the workshop rn, hopefully it will work
>>
>>60645667
ok show me the code you have now.
>>
>>60646639
Actually read through the thread.
>>60645447
>>
>>60641703
I'm reading through the source of tesseract.gg a Cube 2 FPS variant to learn how do they solve several problems. Right now trying to make sense of the Cubescript parser. Compilers have never been my strong suit.
>>
>>60641855
It's shit, functions don't even have arity.
>>
What kind of project should I make to prove I know how to code so I can get a job?

>tfw not an ideas guy
>>
>>60647487
what kind of software interests you?
>>
>>60641703
>What are you working on, /g/?
My XDCC auto downloader, got IRC message parsing + DCC parsing, next up, doing the actual download
>>
>>60647502
I'm not sure. Do you mean what do I use regularly or what do I want to work on?
>>
>>60646840
DIY language
>>
>>60647620
I did that years back.
The DCC protocol isn't well standardized.
In the I didn't use much because most anime subbers stopped sharing package list on the xdcc bots.
>>
OK this is very tough question.
Anyone with correct answer gets a girl friend next month.
You can use __cdecl__ too.
int __attribute__((__stdcall__))main(){
return 2+3;
}

The above code compiles in GNU/LINUX 64 machine with below options
gcc -m32 prog.c


Compiling the same without -m32 option give warning that __stdcall__ is ignored.

>Now here is where it get scary.
>Go to mingw environment in windows
compile using below option
gcc -m32 prog.c
gcc -m64 prog.c
gcc prog.c

None of these would give warning.

Did you notice? This is very suspicious behaviour. I guess NSA/CIA have zero day for gcc too.
>>
>>60641703
just casual load balancer with classification, which will proxy your connection to the right server by properties of request
>>
File: 1464478482554.gif (1MB, 430x360px) Image search: [Google]
1464478482554.gif
1MB, 430x360px
>>60641703
I need advice again /dpt/

I'm the anon who's been learning how to program since January (I wrote two "popular" lua mods, went to reading books and grinding endless C# terminal executables for practice, played around with unity and scripting, just made a JS bot for fun).

I think I want to get into freelance coding. I have a career in construction already which covers money and health benefits but when things get slow I would like to switch freelancing for some pocket money and coding experience that I can put on a resume.

Can anyone explain HOW to get the knowledge required to do it? I'm aware of the sites like upwork and I am comfortable with C# (and not opposed to learning C/C++). What is the next step I should take? Right now I'm hobby learning dev and I want to make the jump to => amateur freelance dev.

Thanks /dpt/
>>
>>60647701
>The DCC protocol isn't well standardized.
From what I've seen so far, bots tend to use the
DCC SEND <filename> <ip> <port> <file size>
format, where the IP is in network byte order, granted I've only tested with HS bots so far.
>>
>>60647487
a program that involve a database and a graphic interface will be a good demo.

>>60647711
stdcall is windows only, that's why there a warning on linux.
>>
>>60647711
stdcall is for 32-bit Windows only : https://en.wikipedia.org/wiki/X86_calling_conventions#List_of_x86_calling_conventions
>>
>>60647825
The commands are standardized well but the actual file transfering is not.
I think you are supposed to tell the host how much you have downloaded after each block.
But how much is one block is not defined. Emacs irc package responds to sender every 1024 bytes. There's actually comment in the source that says that every implementation seems to ignore it.

You can get it to work by just reading the amount of bytes you were told the package size is but there's really no info on how to properly inform that you downloaded it succesfully.
I just ignored it.
>>
>>60647740
Read Soft skills software developer's manual.
>If your current job is supporting you, don't take risk leaving it.
>Work on your project independent of your day job.
>Farm time. Basically cut facebook, whatsapp, girlfriend, friends anything you see which is not your project/freelancing
>You will not get satisfactory money out of freelancing. C# and windows jobs are mostly outsourced to pajeets.
Decide what you want to achieve in one year.
Since you mentioned resume I guess you want to be wage cuck. Just have working project in your resume which you can showcase to interviewer. That will be enough.
>>
>>60647894
>>60647844
A C convention totally owned my microsoft?
How is this possible?
Is not C specs open standard?
>>
>>60647982
the c standard doesn't say anything about calling convention.
>>
>>60647982
C standard doesn't define calling conventions, they're too low-level.
>>
>>60647982
*most prominently used by microsoft, owned by no one because it's just a calling convention
out of the scope of the C language specification.
>>
>>60647844
>>60647894
They said though that they get a "stdcall ignored" warning only when compiling as a 64-bit Linux executable, not when compiling as a 32-bit Linux executable. IIRC, Windows doesn't use separate calling conventions in 64-bit mode, it just uses a single 64-bit calling convention, whereas cdecl, stdcall, pascal etc are all for 16/32-bit Windows code. But that should imply that stdcall would be ignored when targeting ANY version of Linux? Maybe it comes down to a difference in GCC versions between the Linux and MinGW versions?

>>60647982
The calling conventions aren't part of the C standard. They're extensions, just like the old far and near pointers.
>>
Lol why is windows so bad?
>program C in linux
>just works

>program C in windows
>have take care of the stack yourself
>>
>>60648078
>want to program with an obsolete programming language on a modern operating system.

move with the times, kid
>>
>>60648128
>msdos with shit stacked one
>modern operating system
>>
>>60648078
Is not called bad.
Its called programmer's freedom.
Also, I read somewhere that stdcall generate better object code than cdcel which is default for C in 32 bit machine.
>>
File: help.png (57KB, 879x298px) Image search: [Google]
help.png
57KB, 879x298px
the power of qml font rendering
>>
>>60648146
msdos has been replaced by NT a long time ago.
>>
>>60648147
>I read somewhere that stdcall generate better object code
such a strong and precise blow, you should take up boxing senpai.
>>
>>60648078
>>have take care of the stack yourself
What do you mean? The stack is managed by the compiler. C code is generally compatible between Windows and Linux unless it depends on libraries (like unistd.h) that aren't generally present on Windows.
>>
>>60648178
or <windows.h>, respectively
>>
>>60648175
Which means NT is almost as ancient as DOS.
>>
>>60648078

>have to take care of the stack yourself
Where'd you hear that nonsense?

>>60648147

Why are you using a 32-bit OS in 2017?
>>
>>60648198
You know Unix came from the 70s GNU was started in 84 and Linux kernel was started in 91 rite?
>>
>>60648198
NT is younger than Linux, *BSD and macOs tho.
>>
>>60641703
jewoogle calendar api
>>
>>60648217
>Why are you using a 32-bit OS in 2017?
Because there's really no point in using a 64-bit OS if you have less than 4 GB of RAM.
>>
>>60648198
no.

DOS 1981
NTOS 1993
Linux 1991 (but based on old unix)

NTOS got a huge revamp in 2003 with windows x64

David Cutler is a better kernel designer than Linus. When he started NT, he already knew that using the char type for communications was obsolete. NT is much better designed for concurrency; Do you know that linux still doesn't have syscalls for pausing/waking a thread? libraries like pthread must rely on hacks based on posix signals.

NTOS also has one of the most well written source codes with a lot of inline documentation (comments)
>>
File: 1451687329537.jpg (38KB, 400x400px) Image search: [Google]
1451687329537.jpg
38KB, 400x400px
>programming in C on windows
>don't have valgrind and instead using dr. memory
>it doesn't yet have full support for 64-bit programs compiled in a msys environment
>have to compile everything as 32-bit for testing and hope that the 64-bit release doesn't have any hard-to-trace memory problems introduced
I don't want to go back to VC++. It doesn't even support all of C99!
>>
>>60648373
More registers mean faster function calls since arguments aren't put on the stack
>>
>>60648386
>NTOS also has one of the most well written source codes with a lot of inline documentation (comments)
How exactly would you know?
>>
File: 1482524569421.png (460KB, 716x702px) Image search: [Google]
1482524569421.png
460KB, 716x702px
>>60647960
Useful stuff, thanks anon.

> cut facebook, whatsapp, girlfriend, friends
I don't have any of these things

> you mentioned resume I guess you want to be wage cuck
I'm already a wage slave in construction. In 5 years I don't want to be breaking my body and racing for my job against Juan who lives 5 people to one closet, I would rather sit on my ass all day and race against Pajiit while bettering my skills at my hobby (computing).

My logic is the more resume padding I have then the easier it would be to land a job doing what I want in the future (game development, software dev, remote coding, etc).

> If your current job is supporting you, don't take risk leaving it
I don't plan to, I would like to grab the construction jobs near home but stay home freelancing when they're 40+ min away and code for money instead.

> Read Soft skills software developer's manual
I will do this cause I've been reading though a few books already and I need some direction to go in
>>
>>60648411
>>60648386
you better answer my question.
>>60647711

how is mingw environment able to compile
without warning. but gcc in linux complains.
>skipped my day job to find this and no clue
>>
>>60648411
Why not use cygwin, WSL, or a *nix VM?
>>
>>60648458
What are the respective GCC versions?
>>
Sup /dpt/. I have a function that I use to approximate integrals:

num Simpsons (num L, num U)
{
num output = 0;

const unsigned P = 1000;
num interval = (U-L)/P;

num F[P+1];

for (unsigned counter = 0; counter <= P; counter++)
F[counter] = func(counter*interval+L); // func() used here

output += F[0]+F[P];

for (unsigned counter = 1; counter < P; counter++)
output += ((counter % 2) == 0 ? 2 : 4)*F[counter];

output *= interval/3;

return output;
}


When I wrote it there was only one function I had to integrate, but now I have to integrate a whole bunch of different functions. Instead of duplicating the same code over and over, is it possible to make it work with any generic function? Something like this:

num Simpsons (num L, num U, function func())
{
// Same code as before, except this time func() is whatever function was inputted
}

Thanks in advance.
>>
>>60648455
In the same boat mate.
Just keep going and measure your progress.
>>
>>60648468
>cygwin
Bloated.
>WSL
I don't want to upgrade my botnet experience with 10.
>*nix VM
I doesn't run too well because my PC is shit. Plus, I start ricing my VMs instead of actually using them as a development environment. Last one's my fault though.

I'm hoping for dr. memory to have another release pushed with full 64-bit support for MSYS2 applications, but the last release is almost a year old.
>>
>>60648505

this is C, right? Look into function pointers.
>>
>>60648471
Latest. 4.9 on GNU and installed mingw yesterday on a new windows 10 installation so it has to be new.
>>
>>60648544
>Latest. 4.9 on GNU
>4.9
>latest
Also GCC is a known shitware
>>
File: ndev.png (429KB, 600x1066px) Image search: [Google]
ndev.png
429KB, 600x1066px
>>60648421
>How exactly would you know?

The source code of the kernel from Windows Server 2003

http://gate.upm.ro/os/LABs/Windows_OS_Internals_Curriculum_Resource_Kit-ACADEMIC/WindowsResearchKernel-WRK/

code is in /WRK-v1.2/base/ntos/

from the readme
Organization of the WRK sources

The file License.txt contains the license covering use of the WRK.

The public\ directory contains a number of include files shared among system
components. base\ntos\ contains the NTOS sources.

The primary NTOS source components included in the WRK are organized as follows:

cache\ - cache manager
config\ - registry implementation
dbgk\ - user-mode debugger support
ex\ - executive functions (kernel heap, synchronization, time)
fsrtl\ - file system run-time support
io\ - I/O manager
ke\ - scheduler, CPU management, low-level synchronization
lpc\ - local procedure call implementation
mm\ - virtual memory manager
ob\ - kernel object manager
ps\ - process/thread support
se\ - security functions
wmi\ - Windows Management Instrumentation

inc\ - NTOS-only include files
rtl\ - kernel run-time support
init\ - kernel startup


github mirror https://github.com/zhengyangl/WRK
>>
>>60648589
>font rendering in kernel space
>>
File: 1446742814508.png (290KB, 590x609px) Image search: [Google]
1446742814508.png
290KB, 590x609px
>>60648529
Good luck to you as well anon, may we meet in a later /dpt/ and share our progress
>>
>(quit)
>Bye.

^_^ so cute
>>
>>60648543
It's working, cheers anon.
>>
Do I need Java to make a GUI for Android, or can I do everything in C?
>>
>>60648544
>4.9
What the fuck, anon?
>>
>>60648675
You need launch the application with java.
You can do everything else in C though.
>>
>>60648675
java
>>
>>60648629
what are you talking about?
>>
Nobody answered my question. Feel like quitting.
>>60647711
>>
>>60644452
>>60644612
>meme
>>>/v/
>>
>>60648708
Clisp?

Haven't done lisp before, it's a nice touch.
>>
>>60644498
Why is she smiling like that?
>>
>>60648373

x86-64 is a better instruction set than IA-32, even if you only have 512 MiB of RAM.
>>
Any python wizards around? I may be failing terribly at reading the docs ( https://docs.python.org/3/library/json.html ) but to me this seems correct, yet doesn't work:

import json

class DummyEncoder(json.JSONEncoder):
def default(self, obj):
raise(ValueError)

print(json.dumps([2], cls=DummyEncoder))


I expect it to raise a valueError, it returns [2] instead, any ideas /g/?
>>
>>60649052
>python wizards
Fuck off "code artisan"
>>
File: are-you-a-wizard_fb_237198.jpg (18KB, 300x290px) Image search: [Google]
are-you-a-wizard_fb_237198.jpg
18KB, 300x290px
>>60649101
>>
>>60648675
Even java isn't enough, hope you like XML.
And by "like" I mean "can bear it long enough that you don't kill yourself".
>>
File: 1494086582529.gif (974KB, 500x281px) Image search: [Google]
1494086582529.gif
974KB, 500x281px
>>60641703
Trying to create an anime-like language
>>
how do I get __attribute__((noinline)) work in gcc, every example I look at has it in a different position relative to the function, and none of them seem to do anything
>>
File: file.png (183KB, 1818x921px) Image search: [Google]
file.png
183KB, 1818x921px
Still working on that Tray Launcher, working out some functionality right now then gonna integrate it into the library
>>
>>60649825
just use -std=c99 and use the inline keyword
or if you want to be autistic, replace the word inline with nothing using some preprocessor directives
>>
>>60641703
Seriously, I need to control my caffeine addiction.
At least I am normal again.

So, if I read a textfile with only numbers in them, are they always depicted as Strings or chars?
No matter what?
Do I have to convert these into numbers, aka int, double, long, floats etc.?
>>
Around what semester can I expect CS classes to actually start becoming challenging?
>>
>>60649911
Never do the challenging stuff on your own time.
>>
>>60649911
Depends on what you lack.
When I started to really program in Java I was actually stuck in the later challenges.
Something similar could happen to you, so actually understand your classes if you can spare the time.
If you have time after taking too many classes that is.....
>>
>>60649908
There's no such thing as coffee addiction.
Maturity is not adopting an addictive vice and complaining about it to relate to others.

>>60649911
It literally never gets any better, you have to self-teach everything fun yourself.
Take this opportunity to ask yourself if continuing your college program is a good idea.
>>
>>60642046
Is it really that bad?
>>
>>60642008
>calm
Except we're all autistic as fuck.
>>
>>60649958
tell that to my headache fucking up my head.
It is my biggest vice.
I can say no to alcohol, limit myself.
I can say no to tobacco, never touched it.
I never had so much of a love hate relationship with any other drug than coffee.
>>
>>60648373
he fell for the meme
>>
>>60649964
literally the first two weeks on a shitty door to door sales job, which i recieved £30 for because they dont hire anyone proper who cant immediately start making sales. only reason i even bothered with it is because my mother insisted i bring in some form of money in the couple of months between leaving the shitty apprentaceship thing i was on and starting college.
>>
>>60649958
>Take this opportunity to ask yourself if continuing your college program is a good idea.
Well for one I'm already a few years in. No point in just dropping out and getting nothing for it.

I always thought that well I probably could teach myself all this without the classes, I still need to say I have a degree if I want to get seriously considered for not shit jobs.
>>
>>60649993
You sound like you don't even enjoy coffee anymore from the melodramatics you're spewing.
Just stop cold turkey and stop being a faggot.
>>
File: hills and valleys.png (21KB, 1316x358px) Image search: [Google]
hills and valleys.png
21KB, 1316x358px
I'm trying to detect hills and valleys in a discrete-time wave. For example, pic related.

The valleys are jagged and have their own relative maxima and minima. What are some common algorithms and techniques to find these?
>>
>>60650045
That's what I am gonna do.
Finish my homework, drink coffee until finished, drop remaining coffee down the toilet.
Never touch it again while getting the melodrama of my life.
>>
I've been fucking around with writing a parser and I've been looking at a yacc example of ANSI C, but I don't understand this part involving declarations.
declaration
: declaration_specifiers ';'
| declaration_specifiers init_declarator_list ';'
| static_assert_declaration
;

init_declarator
: declarator '=' initializer
| declarator
;

initializer
: '{' initializer_list '}'
| '{' initializer_list ',' '}'
| assignment_expression
;

assignment_expression
: conditional_expression
| unary_expression assignment_operator assignment_expression
;

assignment_operator
: '='
| MUL_ASSIGN
| DIV_ASSIGN
| MOD_ASSIGN
| ADD_ASSIGN
| SUB_ASSIGN
| LEFT_ASSIGN
| RIGHT_ASSIGN
| AND_ASSIGN
| XOR_ASSIGN
| OR_ASSIGN
;

Why does initializer have '=' if an assignment_expression requires an assignment_operator? How would this work for constructions like
int foo = 1;
?
>>
File: DArjKKPXYAAnLGc.jpg (53KB, 650x629px) Image search: [Google]
DArjKKPXYAAnLGc.jpg
53KB, 650x629px
>>60647825
>>60647927
Oh christ, I think I might have fucked up """"""""""slightly""""""""""
>>
How?!
>>
>>60650202
http://lmgtfy.com/?q=cache+miss
>>
>>60650202

When you hit one memory address, many adjacent addresses are loaded into cache as one cache line.
If you use one of those cached addresses, it's much faster. If you zigzag across memory, you waste the cache.
>>
>>60650202
Cache locality.
By reading a 2D array in row-major order, you're importing the whole row into the cache and code doesn't need to wait on the main RAM for every array access.
By accessing it in column-major order, it's forced to wait on main ram for EVERY iteration of that loop.

This is also a freiendly reminder that flat C arrays > multi-dimensional dynamic C arrays any day of the week simply because all those layers of indirection DESTROY cache locality.
It's the same reason why linked lists are utter shit.
>>
>>60650110
That's so
int b;
int a = b = 0;

is valid.
The "normal" parse would go though conditional_expression, if there was no second equals.
>>
File: 2017-05-29-190558_612x514_scrot.png (56KB, 612x514px) Image search: [Google]
2017-05-29-190558_612x514_scrot.png
56KB, 612x514px
brainlet here
does anyone have a solution to HtDP's exercises 1.3.3 and 1.3.4?
http://www.ccs.neu.edu/home/matthias/HtDP2e/part_one.html

string manipulation has always fucked with my head, regardless of the language. It's what fucked me up learning C too. I feel like if I could just see a solution it'd click.
>>
>>60650271
Shit, I didn't even consider that, thanks.
>>
File: me.png (1012KB, 720x960px) Image search: [Google]
me.png
1012KB, 720x960px
>>60649825
>>60649877
my problem was that I was compiling the wrong file, the one without __attribute((noinline)) in it.
The program runs slower with -O3 slower anyways though, I just found.

I guess I should just do any inline functions manually or with a keyword instead of relying on the compiler if I'm trying to optimize anyways.
>>
>>60650221
>>60650250
>>60650255
Damn. I'm taking a computer hw & organization class right now, and my professor made no mention of this. I'm glad I am going through cs:app.
>>
>>60650255
>because all those layers of indirection DESTROY cache locality
You can write true dynamic multidimensional arrays which won't destroy cache locality though.
int w = 10, h = 20;
int (*arr)[h] = malloc(sizeof *arr * w);
>>
>>60650443

I'm pretty sure he's talking about vector and similar. Of course you can use the old C style array if you want to.
>>
I just wrote some x86 assembly to convert unicode chars into numbers. Just for fun.

hex_to_bin PROC
mov eax, [esp+4]
mov ecx, eax
test ecx, 64
jz no_letters
mov edx, 63
add eax, 9
jmp cull
no_letters:
mov edx, 15
cull:
and eax, edx
ret
hex_to_bin ENDp
>>
>>60650501
wtf i just ran this and my computer crashed
>>
>>60650362
>computer hw
He may have called it pre-fetching, that's what our prof. did during our Computer Architecture class, he briefly mentioned it when talking about how the CPU fetches memory,
and our Operating Systems prof. when more into detail about how memory layout actually matters and why, when looping over arrays.
>>
I've seen this referred to as undefined behavior.
Does that mean the result of a shift < 0 is machine dependent?
>>
>>60650597
>is machine dependent?
Implementation dependent, i.e. different compilers may handle it in different ways.
>>
>>60650516
>my computer crashed
Impossible. The MMU would prevent that.
>>
That's my code for now
public class Abgabe{


static void printArray (int[] a) {
// nicely print all elements of an array in a single line
Out.print("{");
for (int i = 0; i < a.length; i++) {
if (i > 0) Out.print(", ");
Out.print(a[i]);
}
Out.println("}");
}

public static void main(String[] args){
//Open the textfile, print all numbers and count the needed indices while doing so
In.open("TestSeq01.txt");
int indices = 0;
while(In.available()==1){
Out.println(In.readInt());
indices++;
}
Out.println(indices); //the length of the array to be made.
//the array
int[] sequence = new int[indices];
//try to put the numbers into the array once to test out if it works. it doesn't, so this part needs to be fixed ASAP
printArray(sequence);
sequence[0] = In.readInt();
sequence[1] = In.readInt();
printArray(sequence);
}
}
>>
File: DArjKKPXYAAnLGc.jpg (50KB, 650x629px) Image search: [Google]
DArjKKPXYAAnLGc.jpg
50KB, 650x629px
>>60650181
And here's what it should look like
>>
>>60650181
Actually do you think you could get a way to recreate this? It looks kinda cool.
>>
>>60650740
Why the fuck is she mocking me
>>
File: 1495456955367.jpg (172KB, 869x1231px) Image search: [Google]
1495456955367.jpg
172KB, 869x1231px
>>60650770
>Actually do you think you could get a way to recreate this?
Yes, the current way my irc client handles DCC transfers, though it fucks up different images in different ways.
>>
Æ’
>>
R
>>
>>60650255
>same reason why linked lists are utter shit.
They have a different usage. If you used flat arrays for every situation where linked lists are useful that would be pretty retarded.
>>
trying to run a windows forms application in c# but it says it cant run cause it has no main
what the fuck
it worked when i did it in class and i dont remember creating a main
>>
File: 1495238745404.jpg (71KB, 736x682px) Image search: [Google]
1495238745404.jpg
71KB, 736x682px
>>60650181
>>60650740
This is what programming after half a bottle of whiskey looks like
>>
File: fuck you.jpg (104KB, 700x393px) Image search: [Google]
fuck you.jpg
104KB, 700x393px
>>60650796
>REC
Fuck you
>>
>>60650880
this guy here
i think its cause i started the project with a console app then added a windows forms one on the project so the program.cs wasnt created
should I start over or is there any other way?
>>
>>60651013
>windows
>mixing console and window applications
Yes, you should start over
>>
>>60647620
>>60650181
>>60650796
>>60650916
I wrote an IRC bot which used DCC several years ago, and this worked for the bots on Rizon #news.
It's not the highest quality code, but is there anything you're doing which is much different to this?
static void send_ack(int sfd, int pos)
{
uint32_t net = htonl(pos & 0xFFFFFFFF);
send(sfd, (char*)&net, 4, 0);
}

static void *dcc_do(void *data)
{
struct dcc_ent *dp = data;
int sfd, n;
char dcc_buf[4096];
bool need_ack = false;

sfd = socket_connect(dp->ip, dp->port);

/* Main DCC loop */
while (1) {
n = recv(sfd, dcc_buf, sizeof(dcc_buf), 0);

if (n < 1) {
if (n < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
if (need_ack) {
send_ack(sfd, dp->position);
need_ack = false;
}

continue;
}
} else {
WARNING("Unexpected DCC failure for %s: %s; Closing connection\n",
dp->q->title, strerror(errno));
break;
}
}

if (write(dp->fd, dcc_buf, n) < 0) {
WARNING("Unable to write DCC to file for %s: %s; Closing connection\n",
dp->q->title, strerror(errno));
if (need_ack)
send_ack(sfd, dp->position);
break;
}

dp->position += n;
need_ack = true;

if (dp->position >= dp->filesize) {
send_ack(sfd, dp->position);
LOG("Sucessfully downloaded %s\n", dp->q->title);
config_add_episode(dp->q->series, dp->q->title);
break;
}
}

/* Cleanup */
close(sfd);
close(dp->fd);
free(dp->ip);
free(dp->port);
free(dp);

/* Thread is closed here */
sem_post(&dcc_download);
return 0;
}
>>
File: 1454792760215.jpg (43KB, 816x756px) Image search: [Google]
1454792760215.jpg
43KB, 816x756px
>>60651048
Thatnks anon, I will look at it tomorrow
>>
File: 763255.jpg (66KB, 1280x720px) Image search: [Google]
763255.jpg
66KB, 1280x720px
>>60641703

saved some pcap files after sniffing my work apps traffic, most of it is unencrypted and doesn't require authentication just requires driver_id replies are usually in the form of json string, I can retrieve messages, booking history including cell numbers address info from clients. I can send GPS info so to make co-workers appear elsewhere, I can send messages to dispatch which appears to come from co-worker, log co-workers out, log them in. I'm working on a python script to create bots which will use random proxies and have some fun. I'm also pretty sure the server is vulnerable to sql injection.

Python for silly stuff and Java when i want to get serious
>>
File: problem.png (27KB, 842x409px) Image search: [Google]
problem.png
27KB, 842x409px
Fucken, I got this
public class Abgabe{


static void printArray (int[] a) {
// nicely print all elements of an array in a single line
Out.print("{");
for (int i = 0; i < a.length; i++) {
if (i > 0) Out.print(", ");
Out.print(a[i]);
}
Out.println("}");
}

public static void main(String[] args){
//Open the textfile, print all numbers and count the needed indices while doing so
In.open("TestSeq03.txt");
int indices = 0;
while(In.available()==1){
Out.println(In.readInt());
indices++;
}
Out.println("The amount of indices for the array: "+indices); //the length of the array to be made.
//the array
int[] sequence = new int[indices];
/*try to put the numbers into the array once to test out if it works. it doesn't
printArray(sequence);*/
In.close();
In.open("TestSeq03.txt");
indices=0;
for(int i=0; i<=sequence.length-1;i++){
sequence[i]= In.readInt();
}
printArray(sequence);
}
}
>>
>>60650056
What is a derivative.
>>
>>60650056
Use an optimisation algorithm like simulated annealing or differential evolution
>>
I feel dead inside, I want to do some programming, but I don't know what to do. Maybe I'm burned out? Fu.....
>>
>>60644989
>Is threading almost exclusively require for making video games?

unless you're making a turn based strategy or chess, yes threading is pretty much required. Input, Physics, and Sound should run on seperate threads. Depending on how your system is set up rendering can go with the 'game loop' and the way rendering works most graphical libraries/APIs have it execute on its own thread.
>>
>>60651398
Answer this question
>>60647711
>>
File: 1495143364676.png (55KB, 217x190px) Image search: [Google]
1495143364676.png
55KB, 217x190px
>>60650916
>>
Okay, so I am trying to make methods out of my programming so far and I have become stuck in my mind.
Let's say, I have a method for opening my textfile, then return me a count of lines, then give the variable over to a new method that takes the number oflines to make me my array. would it look like this?
static int indices(int lines){
int count = 0;
/*code for counting the lines*/
return count;
}
static int[] makeAndFillArray(int index){
int [] list = new int[index];
/*code to create the array and fill it with the numbers in the textfile*/
return list;
}
>>
>>60650916
All anime girls start to look like Neptune?
>>
File: maxresdefault.jpg (85KB, 1280x720px) Image search: [Google]
maxresdefault.jpg
85KB, 1280x720px
>>60651571
>>
>>60651566
    static int indices(String txt ){
In.open(txt);
int count = 0;
while(In.available()==1){
Out.println(In.readInt());
count++;
}
In.close();
return count;
}

static int[] MakeArray(int indexC){
indexC= indices(txt);
return null;
}
>>
>>60650597
Undefined means dependent on implementation and not expected to be documented.
>>
>>60651617
>Undefined means dependent on implementation and not expected to be documented
No, that is completely wrong. That is closer to what "unspecified behaviour" means.
Undefined behaviour means that there is no correct answer and the implementation is under no obligations to anything; it means your code is invalid. It's undefined in the same sense that division by zero in mathematics is undefined. Any and all results you get are meaningless.
>>
NEW THREAD!!!

>>60651640
>>60651640
>>
>>60651617
That would be implemented defined, undefined means even the implementation doesn't need to deal with it.
>>
just found out about match in racket
(define (fizzbuzz max)
(define (fb n)
(match (list (modulo n 3) (modulo n 5))
[(list 0 0) "fizzbuzz"]
[(list 0 _) "fizz"]
[(list _ 0) "buzz"]
[_ n]))
(map println (map fb (map add1 (range max))))
(void))
>>
>>60651660
>list
>match on (list
Can't it match on cons? Like (0 . 0)
>>
>>60651660
sure, just swap it over to cons
>>
>>60651713
Isn't racket a scheme and doesn't it have (car . cdr) syntax?
>>
>>60651734
Yeah I could write the match like this instead
(match `(,(modulo n 3) . ,(modulo n 5))
[`(0 . 0) "fizzbuzz"]
[`(0 . ,_) "fizz"]
[`(,_ . 0) "buzz"]
[_ n])

cons pairs show up like
(0 . 0)
when quoted so I quasiquote and use , to tell it to actually evaluate the modulo and the _
>>
>>60651783
Why can't you just do something like

match (cons (modulo ....
[(0 . 0) ...
>>
>>60651860
The list/pair needs to be quoted. That's how the language knows not to actually evaluate that s-expression. list/cons/quote/quasiquote would all produce a quoted expression there or '/` would mark the expression as quoted.
>>
>>60649993
I found when I gave up caffeine that I had a headache for about a week. After that I slept really well.

Just bear through it, and switch to decaf if you like the taste of coffee.
Thread posts: 323
Thread images: 40


[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.