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

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

Thread replies: 255
Thread images: 29
File: DPT.png (389 KB, 934x1000) Image search: [Google]
DPT.png
389 KB, 934x1000
Old thread: >>55480415

What are you working on /g/?
>>
File: 2chl10p.jpg (78 KB, 1046x678) Image search: [Google]
2chl10p.jpg
78 KB, 1046x678
>tfw a video game taught you more about concurrency and threading than any professor could
>>
>>55486761
>hi, my name is anon
>I'm a virgin that has never accomplished anything
>I have an irrational obsession with Japanese children's cartoons
>I spend all my time posting about Japanese children's cartoons on an online programming discussion community
>>
File: output.webm (137 KB, 128x128) Image search: [Google]
output.webm
137 KB, 128x128
I created this neural network that applies the visual effect to the black and white picture.

Video is the learning process: each frame is the result of model's work after a step of training.

I trained it on just one pair of input/output images.
>>
Any recommended json library for c++? I want write a bot that downloads json files and processes them.
>>
>>55486805
Yeah, node.js has some C++ bindings :^)
>>
>>55486805
javascript can do that a lot easier bud

http = require('http');
fs = require('fs');

port = 3000;
host = '127.0.0.1';

server = http.createServer( function(req, res) {

if (req.method == 'POST') {
console.log("Handling POST request...");
res.writeHead(200, {'Content-Type': 'text/html'});

var body = '';
req.on('data', function (data) {
body += data;
});
req.on('end', function () {
console.log("POST payload: " + body);
res.end( '' );
});
}

});

server.listen(port, host);
console.log('Listening at http://' + host + ':' + port);
>>
>>55486805
I'd suggest writing your own for practice. IRCC jsoncpp is easy to set up and use. Also it sounds like you want to make a simple networked program that does text manipulation, I'd suggest not using C++ at all ;) Unless you need the practice.
>>
>>55486805
There are probably dozens of C++ JSON libraries: JSON is easy as fuck to implement.
Just grab one off of the JSON website.
>>
currently getting destroyed by this:
https://codefights.com/challenge/WFRx6HvmG5KLABepG/comments/WADRsqgYMJAMnT7uk
>>
>>55486828
This.

As much as newfags like to hate on Node.js, learning it made me 1000x more productive. Few languages can compare to its simultaneous power and lack of bullshit.
>>
>>55486805
Maybe just use Golang instead of C++?
>>
File: Untitled-1.png (63 KB, 800x600) Image search: [Google]
Untitled-1.png
63 KB, 800x600
>>55486799
Here's some more pictures.

>>55486805
Qt is beautiful. It's probably too big for your small task, but using Qt with C++ is pure bliss.
>>
>>55486849
Any modern language is just as powerful and is without bullshit.
Python, for example, has much, much more functionality available for it also.
>>
>>55486828
I might as well try js. All I want to do do is a simple chan archiver that downloads threads, adds new posts to a db, marks deleted ones as deleted and updates message text of banned posts.
>>55486833
Getting practice would be nice, but I guess it would end up leaking memory all over the place after running constantly for a month.
>>
>>55486863
Except python sucks at functional programming, but javascript is scheme dressed up as an imperative language. Also node is asynchronous and nonblocking.
>>
>>55486852

Using a gui toolkit is always painful.
>>
>>55486878
What? Why would you think this?
>>
If I have a filename stored in a string and I am passing that variable to
fopen()
does the filename variable need quotation mark characters in its array?
>>
>>55486875
Python has just the same capacity for functional programming as js.
>>
>>55486890
Not really, python's lambdas are a lot less comfy than JS
>>
>>55486908
Comfiness is not a measure of functional programming capacity.
>>
>>55486890
Not even remotely. Functions are first class citizens in javascript. You can assign functions to variable just like you could with any other primitive data type. You can even instantiate functions as classes.

It's hard to appreciate the magnitude of the helpfulness of js's functional programming features without trying them yourself.
>>
>>55486882
No
>>
File: Capture.png (19 KB, 1366x715) Image search: [Google]
Capture.png
19 KB, 1366x715
writing a gui for a scraper I wrote for my school in python

that little bar in the middle is draggable and the panels all scale (staying centered)
and the whole thing can be resized smoothly while keeping the ratios the same
>>
>>55486918
Why are you telling this? Do you now know how it's the same in python or something?
>>
Learning to actually program in C++. Tried in the past but never took it serious. This time I'm actually making my own shit using the concepts I'm learning rather than going through the motions or copying code.
>>
>>55486919
What if there are spaces in the actual filesystem path to said file?
>>
>>55486917
I'd say comfiness is all that matters.
You can implement psuedo-OOP in C, or try to implement optional types in C++ but it's going to suck compared to languages that integrate them first-class
>>
>>55486933
No. You're not inside a shell or anything.
The kernel treats the filename EXACTLY as it is, byte for byte.
>>
>>55486936
Comfiness means nothing. It's just a word you say when you have no actual argument.

C is bad of OOP because you have to write a lot of boilerplate code, not because it's not "comfy".
>>
>>55486881

I've just never used a gui toolkit that was actually enjoyable.
>>
>>55486974
Try Qt.
>>
I've been putting off learning programming for 4 years now

and now after dabbling in some scripting languages, I finally feel motivated enough to dive in

What kind of shit did you program in your first year or two of learning?
What kind of shit programs do you write now?
when did you start contributing to other peoples projects n shit?
how often do you program shit from scratch that you actually utilize day to day at home?
>>
>>55486930
Guido specifically wants to keep functional programming out of python, even though everything in node is based around functional programming. It makes for js that's really simple, short, and fun to write.
>>
>>55486977

I have used Qt on linux projects.
>>
>>55486951
Python does FP bad because you can only have a single expression in a lambda, scoping is all fucked up for nested functions (well, JS has fucked up scoping rules until the ES6. jesus is lexical scoping really that difficult to get right? it's been around since scheme..), and Python doesn't and will never implement automatic tail calls.
>>
>>55486951
Confines is another way of saying boilerplate. You can't
var myFunction = function() {...}

or do any of the awesome stuff from lexical closures in python.
>>
Where is the programming board? What's going on?!!
>>
>>55487026
*comfiness

I fucking hate posting from mobile.
>>
Is there an extant file line counting function in C, or do I have to write my own?

I know it's a common tutorial topic, so searching line count C is really unproductive.
>>
File: programmer.gif (14 KB, 426x290) Image search: [Google]
programmer.gif
14 KB, 426x290
Been learning Python a series of months now. Enjoying it intensely. Programming is one of the most rewarding things.

Been writing scripts - flashcard tools, small file sorters, codewars challenges, stuff like book recommendation listers.

Some of it is now dry and easy.
Looking for some good project recommendations. Something accessible.
Recommend please

>>55486983
The best way to learn is just to program. Been picking this up fast. I use programming to accelerate my skills. The best thing I've made is an "impediment tracker" that helps me even-out irregularities.
>>
How feasible would it be to, instead of having a full-on compiler, have a programming language be described by a bunch of assembly language macros in the standard library that get all pasted together before you run your program? Like the way your code is compiled would be overrideable by the programmer because basic operations like addition and loops are just defined as inline assembly macros .

It would probably have to look kind of like lisp, though.
>>
>>55487006
>you can only have a single expression in a lambda,
That looks really horrible. I found more reasons to like Perl today. Perl's lambdas work just like javascript's.
>>
>>55487049
then don't. your contributions won't be missed
>>
>>55487106
Tensorflow. Maybe their MNIST tutorials.
>>
>>55487110
>being this butthurt that python is being supplanted by newer, better platforms
Lol, I love it.
>>
>>55487106
make me a software that hooks my operating system and intercepts mouse clicks
and then it only allows clicks through that are at least 20ms apart
because my gay ass mouse clicks twice almost every time I click once
>>
>>55487067
>Is there an extant file line counting function in C
No
>do I have to write my own?
Yes. However it's REALLY trivial.
int c, lines = 0;
while ((c = fgetc(some_file)) != EOF)
if (c == '\n')
++lines;
>>
>>55487129
He's not the person you're arguing with. I am. I do concede. Having just one operation per lambda is unacceptable. I'm new to python and am extremely impressed with what can be done with neural network libraries, which mostly seem to be developed on python. I never actually used lambdas in python - I usually use Perl and its lambdas are the same as in javascript, so I just assumed python can;t be worse.
>>
can someone give me an example of the use of lambdas?
to me they seem like anti-patterns in that they go against the concept of writing reusable code once and in only one place
>>
>>55487188
Something like this probably:

((call/cc call/cc) (call/cc call/cc))
>>
>>55487188
If you know you don't use this code anywhere else, why not write it in a place where it logically is supposed to be happening instead of somewhere far away? Why give it a name if it does not need one since it's only referred to once?
>>
>>55487204
why write it in the form of a function at all if the only place you use it is within another function?
why not just write the code in a scope in that function?
>>
>>55487216
Because it's not called at all during function execution - it's called later, as a callback for example. It belongs to function because it is directly related to what the function is doing and uses its local variables.
>>
>>55487157
ok. That's what I did.
I just didn't want to re-implement something that was already written.
>>
>>55487230
I personally don't use callbacks, but if I did I'd certainly want the callback to be its own function for ease of debugging and refactoring and for code clarity
is there any other use of lambdas besides that?
>>
>>55486779
try tis-100 for a real dose of autism.
Also, how far are you in spacechem?
I think I gave up half way through the last set of challenges.
>>
How do I, using Haskell Platform & Atom+HaskellIDE, install packages globally in a way that will automatically work with GHC & autocomplete
>>
>>55487271
You say for clarity but putting pieces of code that do related things away from each other hampers clarity. And whatever misconceptions you have about difficulty of debugging lambdas are false.
The other use I know of is binding data and code together. You can create a function that would output identifiers - first time you call it, it outputs 1; the second time - 2, etc - and if you create another instance of this function it would have its own counter.
>>
Holy shit I FUCKING HATE Dbus.

>Need my systemd service to send desktop notifications
>Set DISPLAY to :0 in unit file
>Set user to the user my X server is running under in unit file
>Still no notifications visible, because lol dbus.
Yet it works fucking fine in my shell.

Fucking HELL, this shit is pissing me off! how do I get my daemon to connect to the existing fucking dbus whateverthefuck under my user?
>>
>>55487310
Wouldn't that result in some really, really nasty side effects?
>>
I'm writing a program that needs to access some files in /dev/ (/dev/input/event* specifically). I'm currently using the setguid bit on my executable to allow my program to access them, but is there a better way I can be doing this?
Whenever I try to run my program with the setguid bit on through valgrind, it seems to show a whole bunch of leaks that my program isn't responsible for.
>>
>>55487348
Can't you just change permissions for files you're accessing?
>>
>>55487335
No, I just want to be able to install packages
>>
>>55487323
Actually I should clarifiy, the notifications ARE present, but because it's under a different dbus connection, it spins up a whole new dunst instance! (wtf dbus) and crashes BOTH instances.
Honestly I have no idea how dbus works or why it fucking exists, but I just want this shit to use the EXISTING fucking dunst instance when sending notifications.
Why do these ABSOLUTE FUCKTARDS HAVE TO MAKE EVERYTHING COMPLICATED AND BROKEN.
There is LITERALLY NO NEED FOR DBUS TO EXIST.
>>
>>55487369
You should be more careful what you wish for.
>>
>>55487360
Changing shit in /dev isn't really a good idea, as udev or whatever manages it all.
Also, if I ever want to distribute my program, it really isn't something I could expect other people to do, as changing those files in particular allows malicious programs to keylog you.
>>
/tech
>>
>>55487378
I just want to know how to fucking install packages so that I can actually fucking use them
>>
>>55487387
Well, if you do need root, then setguid is the way to do it. You can write another tiny program that would access your files, setguid just it and use IPC to communicate with your main program. You'll also limit the amount of code that runs as root, making your program less likely to be a security hole.
>>
How bad of an idea is this union
typedef union
{
uint32_t u32;
uint16_t u16[2];
uint8_t u8[4];
float f;
char hex[4];
char str[5];
} U32;


Im reading a binary file into a string. I want an 4 byte word from the string but its null terminated so its 5 bytes total. Hence char[5];
Also, is a string is just a null terminated char array. Why in the world cant I convert a string to a char array.
>>
>>55487428
You'll probably have to elaborate on what your inputs are, what you want to achieve, and what you mean by being unable to convert string to char array if you want someone to provide a good response to you.
>>
>>55487424
I'm only setguid'ing myself to the 'input' group, so the security implications aren't too massive.
I realise now I could just add myself to the input group, but it's still not really sure if it's a requirement I want my program to have.

>>55487428
>How bad of an idea is this union
It adds endian issues to your code.
>>
>>55486761
Stop using anime images
>>
>>55487482
yeah Ive already noticed the endian issue. I play to only use big endian so the uint8_t are probably going to be unused.
>>55487476
what elaboration about my inputs do you need. Its 4 bytes from a binary file in a string.
>>
>>55487508
Well, your 4 bytes from a binary can contain bytes that have value that are not printable characters which means you should not be printing them which meas your null terminator useless.

You can convert string to char array in C.
>>
>>55487533
I never said I was printing them nor that the null pointer was needed. Its just there. Do you know of a way to get a substring of length 4 without the null pointer. strings copy function seems promising but vs2015 is telling me its unsafe.
>>
File: Woot.png (15 KB, 407x1164) Image search: [Google]
Woot.png
15 KB, 407x1164
Trying out some console style output on my chip8 emulator in rust.. Only one question how the fuck does one clear the console screen in a way that is compatible on both windows and linux in rust?
>>
>>55487606
char x[]="abcdefgh";
char y[]="nmpqzxuw";
*((int *)y)=*((int *)x);
// y should be "abcdzxuw" now // if sizeof(int)=4 that is

//alternatively,
memcpy(y,x,4);
>>
>>55487609

I've got the sdl implementation working. I just think the ascii style output looks cooler. I'm thinking that a ncurses style library that has windows / linux support would be ideal.
>>
>>55487637
That violates the strict aliasing rule, idiot.
>>
>>55487716
>the way i do the same thing is better because arbitrary rules!
>>
>>55487609
>check if user is running linux or windows
>if linux then A
>if windows then B
is usually how you do it.
Either that, or you're using a library that does that for you.
I suggest running this check once on startup and keeping that as a global final var.
>>
>>55487609
#if _WIN32
windows clear
#else
linux clear
#endif


oh, right
rust doesn't have preprocessor
fucking el-oh-el
>>
>>55487741
The strict aliasing rule isn't some self imposed shit: your program contains undefined behaviour.
Maybe you should actually learn something about the language before you try to argue about it.
>>
Anyone care to point me in the right directions to learn various programming languages? I don't mean like all languages together, I mean like a good place to learn X language and such, languages you know. I want to start programming and making apps/software but I'm currently stuck in a rut, just have Eclipse open and nothing going on. Know the basic Javascript/Visual Basic/Android/etc.
>>
>>55487775

I could do that.. it'd be a pain in the ass though to accomplish so little. I mean I don't feel like writing a small c library + rust bindings for this trivial task. It looks like the answer will be using pancurses.
>>
>>55487637
unfortunately it has to be a string Im working with initially. Im returning the file as a string from a function.
Fortunately after turning off the compiler warning about string copy, it does exactly what I want I need.
Im still a little annoyed but the endian default and I need to make sure that there are no issues with signed and unsigned since I cant use an unsigned char.
>>
>>55487775
This is a very bad practice in C as any system is able to define _WIN32.

>>55487609
Files that compile only on one system and you define the same functions in them. This is what you should do in any language.
>>
>>55487839
>This is a very bad practice in C as any system is able to define _WIN32.
So? It's in the reserved namespace.
No platform is retarded/trolly enough to claim that it's a platform that it doesn't support.
>>
>>55487852
It's not about claiming something, it's that they have the right to do it, and only a retard would use something like that to check for a system.
>>
>>55487862
what do you suggest instead?
>>
>>55487862
>it's that they have the right to do it
Again, no platform that expects to be taken seriously will masquerade as another platform.
There are all sorts of nasty shit that a platform could do to you that they "have the right to do".
>only a retard would use something like that to check for a system
Do you have a better proposal?
>>
>>55487880
Did you not read my post above?
>>
>>55487883
>Again, no platform that expects to be taken seriously will masquerade as another platform.
Again, they do not claim to be another platform. They could as well consider anything that starts with _ and an uppercase as defined.

>There are all sorts of nasty shit that a platform could do to you that they "have the right to do".
And if you do not really need a feature that may cause this kind of thing, you should not use it, especially when better ways exist.


>Do you have a better proposal?
Did nobody read my post above?
>>
>>55487789
Both methods I listed always works as advertised in practice. Your theoretical knowledge is worthless in relation to the topic at hand.
>>
>>55487884
>Files that compile only on one system and you define the same functions in them. This is what you should do in any language.
that would result in code duplication. I would trust my compilers to properly define things thank you.
>>
>>55487909
>that would result in code duplication
No, not at all.
>>
>>55487904
>in practice
>My undefined behaviour "works"
You clearly don't know jack shit about what 'undefined behaviour' entails.
If you write programs which rely on undefined behaviour, you have failed as a programmer and should kill yourself.
>>
>>55487862
Only a retard would avoid using _Win32 for such a stupid reason
>>
>>55487937
Only a retard would use _Anything to check for a system.
Don't you care about the standard? I do.
>>
>>55487930
>If you write programs which rely on undefined behaviour, you have failed as a programmer and should kill yourself.
Such strong opinions....
You have failed to convince me, anon.
>>
I have problems understanding async js. I just want to write a method that downloads something using XMLHttpRequest and returns it. However that download is asynchronous. As soon as I send a download request, the rest of the code executes and function returns nothing.
I just want something like
var stuff = getStuff(stuffParam);
>>
File: fragzeichenmadchen.jpg (111 KB, 500x500) Image search: [Google]
fragzeichenmadchen.jpg
111 KB, 500x500
If I have a C function that returns a pointer to an array (not fixed-size) of structs, what should the function declaration and return type look like?

Something involving pointers, but I'm confused.
>>
>>55487992
>I just want something like
var stuff = getStuff(stuffParam);

Well, you can't. That's why it's caled asynchronous.

getStuff(stuffParam,function(stuff){
// do something with stuff here
});
>>
>>55487894
By your logic, we shouldn't rely on ANY identifier (besides standard C ones) in the implementer's namespace, ever.
In principle, you actually shouldn't, but if you have ANY platform dependant code, it's unavoidable.

>>55487950
Compilers have absolutely no obligations when it comes to undefined behaviour, and can optimise your code in strange, "incorrect" ways.
>>
>>55487993
>that returns a pointer to an array
Do you mean its first element?

>what should the function declaration and return type look like?
type *function(void)
>>
>>55487993
MyStruct *functionThatReturnsPointerToMyStructs();
>>
>>55488010
>By your logic, we shouldn't rely on ANY identifier (besides standard C ones) in the implementer's namespace, ever.
Nope, this is not my logic at all. After you know the implementation safely and are you sure that it is not going to affect other implementations then you are free to use whatever extension or UB/IDB you want.
>>
>>55488010
>Compilers have absolutely no obligations when it comes to undefined behaviour, and can optimise your code in strange, "incorrect" ways.
I already said this before - your theoretical knowledge here is useless - gigantic amounts of code do use patterns I mentioned and if a compiler produces code that doesn't do what the programmer wants for them, then no one would use that compiler.
>>
>>55488026
>UB
No. You're an idiot.
>>
>>55488037
Nope, I am not.
>>
>>55488018
I'm getting
 warning: address of stack memory associated with local variable


What should my return type look like?
>>
>>55488103
You're probably doing

Type *function(){
Type var;
// ...
return &var;
}


If that's the case, you shouldn't be doing that - space used by var is freed as soon as the function returns and it's very likely going to be overwritten by some other data as soon as you call another function.
>>
>>55488103
You are a fucking retard. You are trying to return a pointer to a local variable.
Learn C first.
>>
>>55488035
You're completely missing the point of a standard.
A standard is a contract between an implementation and a programmer, saying what one can expect from the other.
If your program contains undefined behaviour, the standard says the implementer has absolutely no obligations to do anything.

Even if GCC or whatever C compiler give the "correct" result right now, at any point in the future, for whatever reason, your code may suddenly break or act in strange ways. Optimisations are only getting more aggressive, and compiler writers will only take advantage of undefined behaviour more and more.

In the interests of quality and long lasting software, you program should not contain ANY undefined behaviour.
Even now, GCC will throw a warning for your example (-Wstrict-aliasing).
>>
>>55488135
Please reconsider.
>>
>>55488148
No
>>
>>55488139
None of this matters now because of how popular C became - it's not only defined by code written in it as well as the standard. There are no practical downsides to doing things I suggested.
>>
>>55488164
Did you even take in what I said at all?
Are you the kind of programmer who writes shitty hack code because it "just werks and could never possibly be a problem later"?
>>
Ported the chip8 over to the ncurses style library.. Wasn't impressed think I'll just stick to sdl.
>>
>>55488008
I don't get this approach at all. Recommend me some materials to read. Now I feel like I would end up with many nested funcions, like
getStuff(stuffParam,processStuff(anotherParam, anotherFunction(param, Function)…
>>
>>55488132
am I supposed to be using malloc instead?
If so, what should the malloc declaration of an array of structs look like (where the number of indices *is* known at this point)
>>
>>55488246
yes, because now you're returning address of something that is on stack and that stops existing when function exits
>>
>>55488202
I considered what you wrote very strongly but then dismissed it because it has very little to do with reality (for reasons I mentioned in my previous posts).
>>
>>55488246
I did
struct pcm *mytype = malloc(sizeof(struct pcm *) * known_count);

and the errors went away
It looks like I'm still able to reference it with array indices even though I didn't explicitly declare it as an array
I guess most array operations are just syntatic sugar for references of contiguous memory?
>>
>>55488279
or rather the struct type is pcm and the variable is *whatever.
>>
>>55488234
>Now I feel like I would end up with many nested funcions, like
Yep. That's how some javascript code looks. It's not pretty.
Here's a first result of typing 'javascript too many nested callbacks' into google:
http://callbackhell.com/

>>55488279
*(a+b) is equivalent to a[b] is equivalent to b[a] in C (if I recall that correctly).
>>
>>55488299
>*(a+b) is equivalent to a[b] is equivalent to b[a] in C (if I recall that correctly).
Correct.
>>
>>55488026
>After you know the implementation safely and are you sure that it is not going to affect other implementations then you are free to use whatever extension or UB/IDB you want.

Is this what it means to be a professional C programmer?
>>
>>55488234
I think ES7 (use a transpiler) has async/await similar to C# which would allow you to do
var stuff = await getStuff(stuffParam);

Otherwise you are stuck with callback or promises.
>>
>>55488037
What's your butthurt exactly?
>>
Is there a way I can have sort of GLSL libraries?
For example, say I have two similar shaders, one that does simple lighting + normal mapping, and one that does simple lighting + emission, I don't want to implement simple lighting twice in each shader.
Is there a way to have the simple lighting code in one GLSL file and sort of link them into the other two shaders?
>>
>>55488417
GLSL are just strings until you compile them, you can figure it out
>>
>>55488514
Seems a bit messy though.
Especially with the #version directive too.

Would using glAttachShader to link in common code work?
>>
>>55488556
Actually, implementing a simple preprocessor to replace #include directives might actually be a better idea.
>>
Retard here. Making my first android app that relies entirely on fetching data from an API using Retrofit, I'm wondering how I should structure my code.

I've looked at some other people's code and they seem to separate each API call into a Service interface, e.g. LoginService, ProductService, etc. But aside from making your code look neater I don't see the advantages of not putting all the API calls into a single SiteNameService and doing service.verify(credentials), service.fetch(productId), service.add(productId), etc. In my case the API I use requires you to provide credentials for each API call so it seems reasonable for me to create one central service and store credentials in it instead of tracking new services being created.

Can someone explain some advantages of why you want to separate them?
>>
>>55486779
Will that really help? What game.
>>
>>55489253
Did you even look at his picture?
>>
File: 1391909503819.jpg (23 KB, 337x372) Image search: [Google]
1391909503819.jpg
23 KB, 337x372
>>55489274
>I'm actually going blind.
>>
Never worked with random number generators before. What's the proper way to seed one if it doesn't need to be cryptographically secure but I do want to make sure the program uses a different seed each time and I don't want different users to follow the same seed sequence?
>>
>>55489315
use the time as a seed
>>
>>55489330
Won't user habits affect the way the program functions then? e.g. suppose someone runs the program every day at the same time.
>>
>>55489359
Current time together with the date.
>>
>>55489359
it's unlikely they'll be using exactly the same millisecond, and i meant the date too
>>
>>55489367
>>55489378
Doh. Thanks.
>>
>>55489399
also pre/append some hardware info so different people get different results even if they happen to boot up at the same nanosecond on the same day
>>
>>55489253
No, not really. Go read a book.
>>
>>55486799
Upload the caffemodel?
>>
What Mingw / C compiler to use in Windows?
>>
>>55489667
gcc?
>>
>>55489678
Yes, but there's mingw-w64, TDM-GCC, etc. I want to know which is the best.
>>
>>55489667
There is no "best" unless you know what you want

Just use the MSVC compiler instead
>>
>>55489693
I use TDM-GCC, and it just werks.
>>
>>55488299
>>55488314
It's been a while, but I feel like this is incorrect.

*(a+b) is just the raw address, while a[b] and b[a] take the type into account. So, if a=1000 and b=2000 and a is a pointer to an 4 byte int:
*(a+b) would be address 3000
a[b] would be address 9000

Is this correct, or an I way off point?
>>
File: Untitled-2.png (337 KB, 2560x1600) Image search: [Google]
Untitled-2.png
337 KB, 2560x1600
>>55489618
It's written in Tensorflow.
I guess I'll upload the code:

imageconv.py: http://pastebin.com/raw/VuJEitd0
train.py: http://pastebin.com/raw/i9G4idx7
apply.py: http://pastebin.com/raw/WEpYyxi8

You'll have to forgive my horribly looking mess, I've only known python for a week and a half.

Use train.py to train and apply.py a.png b.png to conver pictures. Training set goes into images/s/* and images/d/*.

Trains to look somewhat similar in 10 minutes, trains to look extremely similar in 2 hours.

My loss function is just abs(reference-output) which I feel is incorrect.
>>
>>55489359
time() is usually from the epoch, or something similar.
Unless their schedule lines up the period of the PRNG, it wouldn't be a problem.
>>
>>55489878
*(a + b), also takes the type into account, and scales it accordingly.

a[b], b[a] is just syntatic sugar, kind of.
>>
>>55489878
You're completely forgetting about pointer arithmetic.
>>
>>55489895
Oh, and sin() has been the best activation function for me - achieves best results in least iterations.
I tested identity, relu, leaky relu 0.1, exp(-x^2) and 1-cos(x).
>>
>>55489918
Ah, must have forgotten that.
>>
File: 1467533384486.png (242 KB, 396x407) Image search: [Google]
1467533384486.png
242 KB, 396x407
I wrote some godawful code to get the parameters from a query, like width:720 or height:1280 etc.

Here is the input and output:
Nichijou 01 width:720 height:1280 audio:"en, jp, ru"

['Nichijou', '01']
{'audio': 'en, jp, ru', 'height': '1280', 'width': '720'}


It works, but how can I make this less terrible
def parameterize(input, parameters):
i = 0
part = ''
parts = []
pdict = {}

while i < len(input):
if input[i] == ' ':
if len(part):
parts.append(part)
part = ''
i += 1
continue

if i == len(input) - 1:
part += input[i]
parts.append(part)
break

if input[i] == ':':
if part not in parameters:
part += input[i]
i += 1
continue

value = ''
i += 1
endquote = None

if input[i] == '"':
endquote = '"'
i += 1

while i < len(input):
if (input[i] == ' ' and not endquote) or input[i] == endquote:
break

value += input[i]

i += 1

pdict[part] = value

part = ''
i += 1

continue

part += input[i]
i += 1

return parts, pdict
>>
>>55490048
Write a proper parser.
>>
>>55490048
parser monad
>>
File: 1394844645270.jpg (11 KB, 251x242) Image search: [Google]
1394844645270.jpg
11 KB, 251x242
>>55489596
>Read a book about coomputas
>He doesn't just use computas to learn.
>>
File: 1463761900457.png (380 KB, 701x480) Image search: [Google]
1463761900457.png
380 KB, 701x480
Hey guys, I feel like an idiot. At my college, the programming class I took used bloodshed dev c++. I want to do the /g/ programming challenges but I don't know what programs I need to code. It says git on the /g/ challenges pic but Im not sure how to use it and their tutorial videos are super annoying and unhelpful. Is all I need a text editor like notepad ++ or something? How do I run a program that I wrote in the text editor?
>>
>>55490057
>>55490069
Any suggestions on where to start?
It seems like a lot of what I can see seems much more complicated than would be required for something like this, though I've never looked at properly parsing before.
>>
>>55490113
why not use the IDE you learned in college?
>>
>>55490113
you need a compiler

if you're on linux, gcc
if you're on windows, mingw
if you're on macos, this is /dpt/ not /wdg/
>>
>>55490113
>Is all I need a text editor like notepad ++ or something? How do I run a program that I wrote in the text editor?
Were you a no-show or just the course was that terrible?
>>
/g/ what's a good python module for inserting text data into a PDF form?
>>
>>55487006
>jesus is lexical scoping really that difficult to get right? it's been around since scheme..
Lexical scope in programming (with nested higher-order procedures) goes back to Algol 60. Scheme wasn't the first lexically scoped Lisp-like language (that was MDL).

If you mean "first-class procedures", other programming languages (which were actually implemented) already had them before Scheme.

http://www.cs.cmu.edu/afs/cs/user/jcr/ftp/gedanken.pdf
http://archive.computerhistory.org/resources/text/algol/algol_bulletin/A33/P33.HTM
>>
>>55490249
tk u histry lessen bro
>>
>>55490113
how to do you take a college programming class and not know how to compile a c++ program?
>>
>>55490113
What college?

>dev c++
I just got cancer
>>
>>55490048
https://regex101.com/r/mX8gK8/1
>>
File: 1447669589047.png (122 KB, 398x309) Image search: [Google]
1447669589047.png
122 KB, 398x309
>>55490274
>>55490216
All he ever showed us was bloodshed. Like I understand that I need something to compile and link the code but Idk if those are usually all the same program like bloodshed or what people in the real world actually use. I seriously think he should use something else
>>
>>55490309
stop talking about violence this thread is full of little kids reading
>>
>>55490309
I already answered you in >>55490214

You keep posting about a resolved issue. You keep posting anime pictures too, so you're obviously trying to bait a flamewar. I'm going to report you and hide your posts now. Bye shitcan!
>>
>>55490309
If you are using C just run gcc, it will run the linker and shit automatically.
Install an editor like kate, gedit, nano, emacs or anything really. What OS are you on?
What language are you using?
>>
>>55490309
http://www.wikihow.com/Learn-to-Program-in-C
>>
>>55490354
Wow, this is a shitty article.
>>
>>55490309
>if those are usually all the same program like bloodshed
No, not really. Even what you think you used is not just one program. Gosh the course was awful.

Just download a free version of visual studio, it'll be fine for a while for you.
>>
>>55490113
>>55490309
What degree?
>>
>>55490308
that wouldn't match anything other than pretty much exactly the given string
>>
>>55490386
You can make it as generic as you want. I've only seen one input.
>>
>>55490549
I thought about regex, but it would be too much of a pain.

Off the top of my head,
>Only parameters supplied to the function should match, not just any variation of x:y
>Parameters where the value is enclosed in quotations needs to have the endquote of the same type. That isn't in my current function, but I'll need to add it. (I can't think of an easy way to not have something like audio:"en, jp, ru' match)

There's probably a few more that I have missed.
>>
>>55490599
>I can't think of an easy way to not have something like audio:"en, jp, ru' match
("[^"]+"|'[^']+')
>>
File: lena01.png (100 KB, 1037x806) Image search: [Google]
lena01.png
100 KB, 1037x806
I'm still reading Lena's tutorial about reverse engineering.
His tutorial is pretty good, it's just that he often uses emoticon, and that triggers me.

I've disassembled a simple keygenme, now I want to rewrite the module back with high programming language.
Do you prefer A or B ?
A mimics how the calculation is processed in debugger
B crams everything to a single line

Version A
for (i=0; i < strlen(str); i++) {
a = str[i];
num = num + a * a;
num = num + a * (a / 2 + 3) - a;
num = num * 2;
}


Version B
for (i=0; i < strlen(str); i++) {
a = str[i];
num = ((num + a * a) + a * (a / 2 + 3) - a) * 2;
}
>>
>>55490686
Damn, I'm retarded. Thanks. Maybe I will try regex.
>>
>>55490698
+=
+=
*=
>>
Are there any bioinformaticians here ? I'm wondering whether i should switch from biology to bioinformatics since the job market seems to be bigger and it's way more of an interesting field since bioinformatics combine biology and infofomatics
>>
File: 1461985639901.gif (3 MB, 200x200) Image search: [Google]
1461985639901.gif
3 MB, 200x200
>interested in operating systems and network programming
>no jobs in these areas unless you have a PhD and 15 years of experience
>decide to learn javascript because that's where all the jobs are

>mfw "dynamic" typing
>mfw basically no standard library
>mfw browser incompatibilities
>mfw shit-tier "oop"

How do people even use this pile of poo?
>>
>>55490882
It's okay. Some bits of the language are really ugly but overall it works just like C/C++ with first class citizen functions, which is nice.
>>
>>55490882
Typescript makes it a little better, but still OOP.
>>
>>55490912
I mean, it's okay for projects I start from scratch and work on without any other developers, but if I got a job in writing javascript, I'd have to deal with reading other people's code.

I shudder at the thought of debugging a 10000 line behemoth written in a dynamically typed language.
>>
>>55490949
People have a capacity to produce horrible code in any language, no matter how hard it tries to stop them from doing it.
>>
File: Sad-Crying-Meme-Face-05.jpg (57 KB, 287x310) Image search: [Google]
Sad-Crying-Meme-Face-05.jpg
57 KB, 287x310
>>55490966
The truth hurts anon. It hurts very hard.
>>
Routinely system analysis check for servers in Python.
>>
Why doesn't dpt have a resource guide?
>>
>>55491318
Nobody would agree
>>
>>55486761
a stupid terminal based e-hentai downloader in nodejs
>>
I'm new to programming, I'm going through that Harvard CS50 MOOC which teaches C, and I'm really enjoying it. I feel like I'm really picking it up, though I'm aware that I'm totally a noob. Where should I go from here? I really like C, how do I take it to the next level?
>>
>>55491430
C++
>>
Is the Linux/Ubuntu subsystem on Windows 10 any good?
>>
If I create a program and then upload it to GitHub, can I then claim that I am the owner of an open source project?
>>
>>55486918
>>> def a():
... print("a")
...
>>> b = a
>>> b
<function a at 0x7f7f9e703cf8>
>>> b()
a


man, the captchas are all fucked up. looks like google changed something in their image recognition software... and it's tagging shit images wrongly or something
>>
File: 1466716035850.png (280 KB, 541x541) Image search: [Google]
1466716035850.png
280 KB, 541x541
is there a single reason to not host your own gitlab on digital ocean?
>>
>>55491605
DO caves to written letters and complaints and don't require a DMCA to do takedown actions.
>>
File: 1325229703684.png (121 KB, 500x500) Image search: [Google]
1325229703684.png
121 KB, 500x500
>>55491661
why would anyone take my private git down?
>>
>>55491605
because you might be straight
>>
>>55491661
What's the best hosting company then?
>>
>>55491735
It's incredibly easy to step on toes.
>>
This is valid C code.
CuCks will defend this.
int;
const typedef volatile void;
>>
>>55491812
Super useful.
>>
>>55491812
I like this very much.
>>
>>55491519
Well, it doesn't give linux programs direct access to GPU so to me that makes it no better than a VM I already am running.
>>
>>55491605
because you can host it for free directly on the official site????
>>
>>55492075
>????
>>
File: 1382875070045.gif (11 KB, 730x413) Image search: [Google]
1382875070045.gif
11 KB, 730x413
>>55492075
>>
>>55492075
Git's official site does not let you host your projects on it.
>>
fixing a bug in my text editor's embedded terminal
>>
>>55492264
Gitlab's official site does let you host your projects on it.
fag
>>
>>55489948
Have you tried logistic functions?
>>
Is it possible to access the static variable of a function outside of the function. I dont really want to have to parameter just to set the variable once.
Though I could just declare it as fun(int x=0) i suppose since I know x is never supposed to equal 0.
>>
>>55492462
no you fucking idiot use a global
>>
>>55492462
>Is it possible to access the static variable of a function outside of the function
Yes, get its address.
>>
>>55492462
What do you mean?
>>
>>55492494
Yeah I was thinking I could use function pointers, but not entirely sure how to go about it. If its possible though then I can look it up and find out how. thanks.
>>
>>55492542
>but not entirely sure how to go about it
int *getaddr(void) { static int i = 0; return &i; }
int add(int a, int b) { return (*getaddr() = a + b); }
>>
>>55492351
I didn't try it because it doesn't have f(x) ~= x when x ~= 0 and wiki said it's bad for training. Gonna have a go at it now. Logistic is something like this, right:

layer = 1 / (1 + tf.exp(-bias))
>>
>>55492987
I don't know, the wiki probably knows more than I do. Also yes, something like that.
>>
How do you add the same number to every non-zero value in a scipy sparse matrix?

Probably a really simple answer but I can't quite do it.
>>
>>55493080
If scypy has something like sign operation (sign(x)=1 if x>0, sign(x)=-1 f x<0, sign(0)=0), you can probably do this?

y=x+abs(sign(x))*a
>>
File: ss+(2016-07-09+at+09.18.29).jpg (94 KB, 796x714) Image search: [Google]
ss+(2016-07-09+at+09.18.29).jpg
94 KB, 796x714
>>55493059
Well, it didn't do very good compared to sin.
>>
Want to keep a session alive instead of having to log in every single time

I'm on android and using jsoup i login to a website to get data while logged in however i want to only have to log in once so every other time i just go to the link and get the data instead of logging in, going to the link and getting the data, is it possible?

How do i keep the session alive?
>>
File: 1468087536759.jpg (534 KB, 1515x2079) Image search: [Google]
1468087536759.jpg
534 KB, 1515x2079
>Upgrading from previous Eclipse IDE package to Neon (4.6) is NOT supported
well senpai. just fuck my shit up
>>
>>55493113
That seems redundant because the whole point of sparse matrices is that only non-zero values are stored. The sign function would never be 0.

I know you can add a value to a chosen element of the matrix like

Matrix[i,j] += 2


I just want to do that to every stored element. Seems like it should be possible because it's all there.
>>
>>55493243
Well, if you want to add a number to EVERY element and bot every non-zero element,try:

y = x + 5


x being your input matrice. Works for me in tensorflow and numpy.
>>
>>55493261
That doesn't work, you can't add scalars to scipy sparse matrices. Probably because it's ambiguous whether you want to add to EVERY element or just every stored element.
>>
>>55486761
I'm trying to decided if bringing open-back headphones into the office will annoy my coworkers

While also trying to figure out how to turn my latest spring issue into good OOP instead of just a mess of scripts.
>>
File: abc9531e9e.png (58 KB, 1251x474) Image search: [Google]
abc9531e9e.png
58 KB, 1251x474
>>55486761
I'm doing an app with WPF and the MVVM pattern, and found out that whenever I change to another view, the UserControl is created each time I do that. It kinda sucks because I need that UserControl/View to be instantiated once and stays there.
On the right is the UserControl, and in the left some code behind to know if the UserControl created instances of this view.
>>
Any interesting book about embedded systems?
>>
>>55493080
>>55493113
>>55493243
>>55493261
>>55493355
Found a way of doing it.

You can use scipy.sparse.csr_matrix.nonzero to pull out two arrays with the row and column indices of all the nonzero points. You can then just use that info to do what I said earlier but to every element I want.

i,j = Matrix.nonzero() # ij indices of nonzero elements
Matrix[i,j] +=5 # add 5 to every element covered by this index list
>>
>>55493637
Ah, I see. I misunderstood your question.
>>
>>55493536
qué mierda, XML me hace querer matarme
>>
>>55489596
gimmie some titles
>>
>>55493826
it just werks(tm)
>>
How can I compose functions in C?
>>
File: B A I T.png (26 KB, 603x222) Image search: [Google]
B A I T.png
26 KB, 603x222
>>55494047
You'll need 6ft of rope
>>
>>55494047
Lol? You can make a function that returns an object that holds a list of function pointers and calls them in order once given to a 'call_composed' function. But you would have to make the functions you are composing cooperate via a single argument (probably a struct or a stack pointer), so it makes things quite a bit harder.
>>
Hi.
I'm currently learning SFML with C++.
Is it possible to create a file containing all the resources needed by my program (images, sounds, ...) ?
>>
>>55494185
Yes, with tar
>>
>>55494208
How am I supposed to read the files contained in the tar from the program ?
>>
>>55494252
Use a library? Write your own decoder?
Thread replies: 255
Thread images: 29

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

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