[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 / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y ] [Search | Home]
4Archive logo
/dpt/ - Daily Programming Thread
If images are not shown try to refresh the page. If you like this website, please disable any AdBlock software!

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

Thread replies: 330
Thread images: 33
File: 4aX1VW1 (1).png (819 KB, 1282x722) Image search: [iqdb] [SauceNao] [Google]
4aX1VW1 (1).png
819 KB, 1282x722
old thread: >>52339459

What are you working on, /g/?
>>
first for my feminine penis
>>
Anime is harmful.
>>
First for my wife's son
>>
Does /dpt/ support Traitor Snowden or Tr8r Trooper?
>>
I hope you have nightmares for posting this thread so damn early.
>>
>>52342289
how small is it? mine is 11cm when erect
>>
>>52342308
I can be reasonably certain that Snowden is white so I support him.
>>
>>52342308
star wars is shit
>>
>>52342272
i'm working on my makeup :3
>>
>>52342325
If Star Wars and anime had a child would it be the most awful thing on Earth?
>>
>>52342324
Why is /g/ so /pol/ lately?

I'm digging the change tho
>>
>>52342325
TRAITOR
[spins]
>>
>10 replies in
>not a single programming related post

good job "/dpt/"
>>
>>52342335
We're being raided by tumblr activists.
>>
>>52342330
pics?
>>
multi-threaded linked list stack implementations
>>
File: pascal in c.png (38 KB, 720x422) Image search: [iqdb] [SauceNao] [Google]
pascal in c.png
38 KB, 720x422
>>52342343
Here.

I put Pascal into C and its goddamn horrible.
>>
>>52342272
pthread_detach(52342272);
pthread_cancel(52342272);
>>
>>52342343
>feminine penis
>not programming related
>>
>>52342330
>>52342346
pls ;_; I so rarely get to discuss makeup with fellow programmers
>>
>>52342373
You've been posting this for a week and you still have no topic.
>>
>tfw racking my brain trying to average 2 ints in Brainfuck
I just can't think of a way to get to half an odd number since continuously subtracting 2 would eventually get me too far at -1, and BF only checks for 0
>>
>>52342512
>why are you doing this to yourself?
>>
>>52342512
public class Average {
private final static int TWO = 2;
public static int average(int x, int y) {
return (x + y) / TWO;
}
}
>>
File: small.webm (2 MB, 854x480) Image search: [iqdb] [SauceNao] [Google]
small.webm
2 MB, 854x480
>>52342333
surprisingly, no
>>
>>52342519
Mental challenge
>>52342564
This doesn't help at all
>>
>>52342564
>private final static

What if I want to do a different average (or even a different mean)?
What if TWO isn't 2?
>>
>>52342577
Why not do something productive?
>>
>>52342590
I've been productive all week
>>
>>52342595
Doing what?
>>
>>52342512
What's the deal with averaging numbers?
What's the catch, apart from doing it in brainfuck?
>>
>>52342601
mon-fri IT job and tinkering with pypy, cffi and sfml yesterday
>>
>>52342611
doing it in brainfuck is the hard part, there doesn't seem to be much on division
>>
>>52342611
If you average two numbers, say 5 and 7 it's pretty straight forward. Just (5+7)/2 = 6, yes? But what if you were dealing with numbers that might exceed the type bounds? You'd probably try 5/2+7/2 but that'd give you 5. You want to average two ints but be sure you'll never exceed the size bounds of the input type.
>>
I need to add logging and testing to my shit but I don't know what to log, what to test, who I'd be doing that for, or for what purpose, or why I'm even programming anything in the first place if no one will ever use, maintain, care, or even know about anything I ever do or say.
>>
>>52342643
just check for the overflow flag
>>
File: tAH4om6.webm (2 MB, 640x640) Image search: [iqdb] [SauceNao] [Google]
tAH4om6.webm
2 MB, 640x640
Ask your beloved programming literate anything.
>>
>>52342723
How do I divide an odd number in 2 in Brainfuck?
>>
>>52342732
does brainfuck have shift right
>>
>>52342732
with an accumulator loop.
>>
>>52342763
No, it has addition, subtraction, while not 0, increment pointer and decrement pointer

>>52342785
que?
>>
>>52342785
that sounds to hard fuck programing
>>
>>52342705
surely there's some logging and testing you can do if you "need" to do it
>>
>>52342809
could you do something like

while not 0 (x)
{
while not 0 (x-1)
{
x-=2
}
}
>>
>>52342834
the inner loop could also skip 0, if x-1 is odd
>>
>>52342834
NICE BRACES DORK
>>
>>52342512
// a / 2 = b
while (a--) {
if c == 0 {
c = 1
} else {
C = 0
B++
}
}

Should translate to brain fuck. Only for positive numbers
>>
>>52342912
>if c == 0
Your only check is "while not 0", there is no "else" either
>>
File: dpt in a nutshell.jpg (236 KB, 1624x626) Image search: [iqdb] [SauceNao] [Google]
dpt in a nutshell.jpg
236 KB, 1624x626
>brainfuck
>complicated
>>
>>52342957
average 2 ints in BF then
>>
>>52342834
not using code formatting? that's a paddling
>>
>>52342965
,>,
>++++++[-<--------<-------->>]<<
[->+<]>>++<
[
>[->+>+<<]
>[-<<-
[>]>>>[<[>>>-<<<[-]]>>]<<]
>>>+
<<[-<<+>>]
<<<]
>[-]>>>>[-<<<<<+>>>>>]
<<<<++++++[-<++++++++>]<.
>>
>>52342957
I'd rather prolapse my anus than work in that language
>>
>>52343030
I can accomodate
>>
>>52343018
why can't anyone use code wraps for fuck sake
>>
File: 1445397997392.png (115 KB, 256x256) Image search: [iqdb] [SauceNao] [Google]
1445397997392.png
115 KB, 256x256
>>52343042
>code wraps
>wraps
>>
>>52343042
[,>,
>++++++[-<--------<-------->>]<<
[->+<]>>++<
[
>[->+>+<<]
>[-<<-
[>]>>>[<[>>>-<<<[-]]>>]<<]
>>>+
<<[-<<+>>]
<<<]
>[-]>>>>[-<<<<<+>>>>>]
<<<<++++++[-<++++++++>]<.
[/code]
You're right it looks so much better like this
>>
>>52343058
I could've sworn I had an opening tag.
Attempt #2:
[,>,
>++++++[-<--------<-------->>]<<
[->+<]>>++<
[
>[->+>+<<]
>[-<<-
[>]>>>[<[>>>-<<<[-]]>>]<<]
>>>+
<<[-<<+>>]
<<<]
>[-]>>>>[-<<<<<+>>>>>]
<<<<++++++[-<++++++++>]<.
>>
>>52343064
much better :)
>>
>>52342957
that looks even more unmaintainable than perl
>>
>>52343064
Looks like shit mate and it doesn't even work
,>,               #input 0 and 1 ; ptr 1
<[->+<]> #add 0 to 1; ptr 1
[->+>+<<]>- #dupe 1 to 2 and 3; 2 is 1 less 3; ptr 2
[-->-->+<< #subtract 2 from 2 and 3; add 1 to 4; ptr 2
[->>>+>+<<<<] #dupe 2 to 5 and 6; ptr 2
>>>[-<<<+>>>] #dupe 5 to 2; ptr 5
<<[->>+>+<<<] #dupe 3 to 5 and 6; ptr 3
>>[-<<+>>] #dupe 5 to 3; ptr 5
>-[[-]<<<<<]> #if 6 is 1 (one of 2 and 3 is 0 and the other is 1 so it's done) go
] to 7 (which is 0 or end); otherwise empty 6 and go back to 2; ptr 2
<<<. #go from 7 to 4 and print the halved amount
>>
>>52343128
Oh shit, just realized mine only works when the sum of 2 numbers is odd
>>
File: adadasads.png (33 KB, 679x576) Image search: [iqdb] [SauceNao] [Google]
adadasads.png
33 KB, 679x576
>windows api
kill me desu i have no idea what im doing anymore

is HWND a long or a long_ptr?
>>
>>52343139
i just copied the one i posted, so you're the only one writing faulty brainfuck code

>>52343155
a long ptr is just a regular pointer on modern systems
hwnd is just a handle
>>
>>52343018
This only handles 2 single digits
An "int" in Brainfuck is 0-255 tho
>>
>>52343189
extend the concept
>>
>>52343155
neither
it's HANDLE which is PVOID which is void *
>>
>>52343181
>i just copied the one i posted, so you're the only one writing faulty brainfuck code
The one you copied, the one you posted doesn't work
>>
>>52343199
I didn't write it :)
>>
>>52343202
didn't say you did pal, but I did ask if you could average 2 ints in BF
>>
>>52342564
what is overflow?
>>
>>52343212
No, if it can't be done in C it can't be done in brainfuck
>>
File: Sierpinski2.jpg (120 KB, 1365x726) Image search: [iqdb] [SauceNao] [Google]
Sierpinski2.jpg
120 KB, 1365x726
>>52343234
My meme dreams have come to an end

Have a Sierpinski lads
>>
>>52343257
10/10
>>
>>52342812
I'm told I need to. Are you telling me I don't need to? That's what I needed to be told!
>>
File: memelbrot.jpg (277 KB, 1041x441) Image search: [iqdb] [SauceNao] [Google]
memelbrot.jpg
277 KB, 1041x441
>>52343278
You ain't seen nothing yet. I tried this yesterday, but the comp restarted, goddamn windows, so I'm going to rerun it now
>>
>>52343309
does the code look like mandlebrot though
>>
File: gol.jpg (272 KB, 659x681) Image search: [iqdb] [SauceNao] [Google]
gol.jpg
272 KB, 659x681
>>52343376
nah, guess it's not as impressive, some of these other BF codes from years ago have been given some nice artwork, but Sierpinski being printed in the exact same format as its code is the only one of its kind I've seen so far
>>
>>52343398
Why are people called Linus so autistic?
>>
>>52343196

hmmmm...so it it generally safe to store a void* in a long_ptr, assuming the void* is a HWND?
>>
>people were making impressive brainfuck programs years ago
>we're still trying to figure out how to average 2 ints in it
>>
>>52343421
Averaging 2 ints is no simple task, it's too complicated even for C
>>
>>52343433
What do you mean by "even for C"? C complicates things, not simplifies things.
>>
>>52343438
>C is more complicated than brainfuck
>>
What are you doing with your morning, /dpt/?

I'm trying to manually parse a raw text dictionary into a usable json format using Sublime Text 2.

Currently line-breaking the document, 90,000 entries to replace. Sublime Text stopped responding about 5 minutes ago.
>>
>>52343451
Being a degenerate and watching anime.
>>
>>52343421
People were making big projects in C before.
You are just fucking retard and shit your pants when addition might overflow.
>>
>>52343128
I think I've got it lads

In the same way, I checked cell 6 was 1 and executed different code if it was, I could do the division as easy as
 [-->+<]

but check that if it's 1, I subtract 1. This way the next loop evaluates to 0, and I can get ready to print. Will do it after I shower
>>
File: sicpshy.png (481 KB, 811x599) Image search: [iqdb] [SauceNao] [Google]
sicpshy.png
481 KB, 811x599
>>52343448
actually, yes, more you go high level in abstraction and more it become complicated. you can learn brainfuck in 10 minutes, you need weeks to learn C.
>>
>>52343471
I was talking about brainfuck you cretentious melt
>>
>>52343476
>you need weeks to learn C
>weeks
>to learn C
>weeks
>C
>>
File: based jimmie.gif (456 KB, 300x169) Image search: [iqdb] [SauceNao] [Google]
based jimmie.gif
456 KB, 300x169
>>52343398
why are people called Ã…kesson so based?
>>
>>52343527
[spoiler]they aren't[/spoiler]
>>
>>52343547
>[spoiler]
>that post
return to /v/eddit
>>
Whenever I use an IDE I get confused by the interface and get a headache.
Eventually I have to go back to a text editor with code highlighting.

Is this normal?
>>
>>52343580
Fuck off newfag
>>
>>52343513
C is simple, but there is lot of libraries, for example sockets, or if you want programming system stuff, or kernel modules, you have to learn a lot.
>>
>>52343596
Wow you're so l33t dude :) We will definitely accept you :)
>>
>>52343622
thx d00d B^)
>>
Anyone here know how to use JSON.net?

I'm trying to parse out a JObject so I can store it in a less shit format, but I have no idea how to access each individual token and only the first value in that token.

This is an example entry...
"DIPLOBLASTIC": "Characterizing the ovum when it has two primary germinallayers."

And I want to convert that to a data object like this...

    public class DictionaryObject
{
public string Word { get; set; }

public DictionaryObject() { }
}
>>
>>52343596
yes
in my experience, most good programmers seem to use emacs / vim or another editor
the only exception to this would probably be the games industry, where people mostly use tools made specifically for the engine
also sometimes people use an IDE for GUI toolkits, because the way some of them are set out makes it pointlessly retarded to position shit manually
>>
>>52343628
But I only want "DIPLOBLASTIC" without quotes.

I thought about just cutting the string at : and remove quotations but I was worried about horrendously inconsistent results.
>>
File: giphy.gif (2 MB, 300x169) Image search: [iqdb] [SauceNao] [Google]
giphy.gif
2 MB, 300x169
>>52343513
>>
>>52343596
no.
using an IDE should make it easier to work with the code, especially if you didn't write all of it.

Creating a new file -> create new file + add to git + add to cmakelist

Renaming a variable -> rename all the calls to it rather than search and replace

autocomplete is based on the available variables rather than the words you have written.

clicking on the function call can take you to the implementation

As I see it, an IDE is very useful if you accept that it can do a lot of stuff for you.

You can get a lot of functionality from a good text editor and sometimes this is enough.
>>
>>52343513
It depends what 'learn' means. You could probably pick up all of the basic shit in mere hours if you know another programming language, but like any language, it would takes weeks to months or even years to learn all of the intricacies of it.
>>
File: 1452413654022.png (654 KB, 580x582) Image search: [iqdb] [SauceNao] [Google]
1452413654022.png
654 KB, 580x582
What's the best way to get the current thread number in JS, /dpt/?

This is what I came up with:
document.getElementById("postPassword").parentNode.childNodes[3].value;


It works, but I don't like the look of it.
>>
So i'm trying to get the basics of structs/prototypes/involved calls in C, but when I run make I'm getting an error message that isn't very helpful:

error: argument #1 is incompatible with prototype:
prototype: pointer to struct fooBar {pointer to const char foo, unsigned int bar, unsigned int til}

argument: struct fooBar {pointer to const char foo, unsigned int bar, unsigned int til}

(and of course there are more details like the specific lines in my code with these.)
They look the same. Any general tips on how to write the parameters correctly and such?
>>
>>52343820
How does this girl not get fat after eating so much pizza and drinking so much coke?
>>
>>52343831
>prototype: pointer to struct fooBar
>argument: struct fooBar
>pointer to
>>
>>52343841
she can shapeshift
do you even watch it
>>
>>52343841
2D > 3D
>>
>>52343820

window.location.href.split('/')[5];
>>
>>52343841
onii san keeps her fit :^)
>>
>>52343850
think I know where to look now, thanks.
>>
File: dfg.png (4 KB, 276x65) Image search: [iqdb] [SauceNao] [Google]
dfg.png
4 KB, 276x65
>>52343865
>>
>>52343881
General tip for prototyping: Don't.
Obviously you have to if your function to going to be used in another file, but for everything that is local to the file, just reorder the functions so you don't need any prototypes.
When you do prototype, literally copy-paste your function definition and put a semi-colon on the end.
>>
in that case

document.getElementsByClassName('thread')[0].id.substring(1, document.getElementsByClassName('thread')[0].id.length)
>>
>>52343914
>>52343896
>>
>>52343599
It's not like the same wouldn't apply if you tried doing the same stuff in Brainfuck (except you'd have to handle all that encapsulation interaction yourself, not just learn about a library that does it for you).
>>
I wish there was Java with explixit type-safe pointers and explicit heap allocation
>>
>>52343910
got it.
>>
File: 1451596612755.jpg (36 KB, 447x447) Image search: [iqdb] [SauceNao] [Google]
1451596612755.jpg
36 KB, 447x447
>>52343914
That's worse than:
document.getElementById("postPassword").parentNode.childNodes[3].value;
>>
>>52343934
I never sad brainfuck is easy, but i said C cant be learn in week
>>
>>52343979

it's not, it only looks worse because theres a bit of string manipulation

if you want to do it your way, then just do

document.getElementsByName('resto')[0].value

just jquery if you want neatness
>>
I'm still trying to average 2 ints in brainfuck, this shit is not easy
>>
So in Android you have activiities which are the GUI
screens. My problem is the following.

I'm making a todo list, however I don't know how to consistently keep track of objects. I have this "look at list" activity and the only solution to keeping a consistent list I have is to create a static list somwhere in another class.
>>
>>52343914
Why not just

document.getElementsByClassName("thread")[0].id.substring(1);
>>
Going to go through Learn C The Hard Way because K&R is boring as fuck.
>>
>>52344056
Learn C The Hard Way is fucking horrible.
It's literally just "copy this code: the "book"".
>K&R is boring as fuck
What? Did you expect an action-thriller or something?
It's a programming textbook, and one of the more interesting ones at that.
>>
Can someone help me with some D?
string[] foo() {
string[] output;
output[0] = "";
return output;
}

gives me a range violation (which it probably shouldn't, because this is dynamic array syntax as per the documentatioon), but
string[] foo() {
string[123] output;
output[0] = "";
return output;
}

gives me 'escaping reference to local output'
how the fuck do arrays even work in D?
bonus:
ideally I want
string[] foo(string str) {
string[bar(str)] output;
output[0] = "";
return output;
}

int bar(string str) {
return someNumber;
}

but that gives me 'variable str cannot be read at compile time'
at first I thought it was worried that bar() might be negative, but it doesn't work with uint either

I love D, but I keep getting these weird errors that don't seem to make any sense. I don't want to have to go back to C++
>>
>>52344028
I assume your problem is passing the objects from one activity to another. You can pass them to other activities by making them implement Parcelable and add them to the activity intent. A less elegant options is to store them in a singleton.
>>
>>52344075
>It's literally just "copy this code: the "book"".

So every programming book ever?
>>
>>52343473
>>52343128
>>52343064
>>52343018
>>52343195

Average 2 actual ints (0-255) in Brainfuck without overflow, truncate. Input as two numbers separated by whitespace.

http://paste.debian.net/363613/

Example:
./bf average-ints.bf
100
200


150
>>
>>52344028
sqlite
>>
>>52344109
you crazy son?
>>
>>52344109
I refuse to believe you haven't written something to translate from a more readable language into brainfuck
>>
>>52344106
a good programming book isn't just about copying code
>>
File: 1452384802667.jpg (185 KB, 488x484) Image search: [iqdb] [SauceNao] [Google]
1452384802667.jpg
185 KB, 488x484
>>52344007
I think I've finally settled on this, anon:

document.querySelector(".postNum a:last-child").textContent
>>
For some reason my mind isn't letting me logically figure this out.

            for(int i = 1; i <= length; i++)
{
string value = UppercaseFirst(keys[rand.Next(1, keys.Count)]);
sb.Append(value);
}


I want to check if "value" has a space or a hyphen in it, and if it does get another value, and continue to get another value until there isn't a space or hyphen in it.
>>
>>52344200
Use monads
>>
>>52344212
If I'm asking a question as dumb as this, do you really think I even know what a monad is, let alone how I would do it in code?
>>
File: 1403270759586.png (19 KB, 226x161) Image search: [iqdb] [SauceNao] [Google]
1403270759586.png
19 KB, 226x161
>>52344140
>>52344127
bfcomp macro language

Too many lines to post.
http://paste.debian.net/363624/

Haven't used it before. Neat macro language.
>>
>>52344200
It's called tokenization. I'm not actually sure which language you're using is, but pretty much everything has a way of tokenizing strings.
>>
Hey friends, need your help.
I am trying to consume Rotten Tomatoes' API on Android, using Retrofit+Gson, but I am getting an exception
(java.lang.NumberFormatException: Invalid double: "") thrown by Gson,
I am suspicious the Json the APi is giving me is wrongly formatted, since I tried another API with the same code I have and it worked. Can someone give it a try and see if my suspicion is correct?
Here's the entry point I am trying to use:
http://api.rottentomatoes.com/api/public/v1.0/lists/movies/box_office.json?apikey=snvygxnkhe8aa7jw8c3ktx5v
>>
>>52344246
Yeah I know how I'd actually go about checking whether or not it has a value I don't want.

What I can't work out is how I'd loop it until that condition isn't met.

My brain can't seem to grasp the logic properly, I'm just not sure how to make it work.
>>
>>52344288
Isn't "" a null value?

Ignore null values would fix that surely.
>>
>>52344293
..a while loop?
>>
File: memelbrot.jpg (558 KB, 1038x744) Image search: [iqdb] [SauceNao] [Google]
memelbrot.jpg
558 KB, 1038x744
Can't display the whole thing, but here's the brainfuck mandelbrot
>>
>>52344318
>an empty string is the same as a null string
>>
>>52343841

Because she's a Mary Sue. Literally, the show is just "look at me, I can have 10/10 looks and grades when I'm out of the house, and be a total bratty slob at home with almost zero consequences to my actions!" Hence, why the show only got one season (or a half season, really, if you're the type to consider a season to be 26 episodes).

>>52343910

This, and also make any function that's local to a file only as static. Except for main, because that has to have external linking.

>>52343771

>add to cmakelist
Disgusting.
>>
>>52344329
Yeah that's what I was thinking, but I'm not sure how I'd write it. Maybe I'm just overthinking it. I shall just try to write it first and see how it goes.
>>
>>52344369
26 episodes is a lot of episodes m8
>>
>>52344318
Could be an option, indeed, but I think that the API is trying to give me an String where a Double is expected. My models are okay since I used the Json response of that request to create the models using jsonschema2pojo.
>>
>>52344404
Work out exactly what value it gives you and convert it from that to whatever you need it to be.

Or modify your models, sometimes the tools fuck up.
>>
>>52344369
Cmake is widely used and works on multiple systems.
A unix makefile is fine for small projects but either the file is long and unmaintainable or you build everything all the time.
>>
>>52344016
I fucking did it lads, works whether the sum is even or odd
,>,<[->+<]>[-[->+<[<]]>[>]<<]>.
>>
>>52344455
Maintain a Makefile is easy as fuck. You just have to be organized.
>>
>>52344468
try it with 0 and 0
>>
File: 1413660451168.png (45 KB, 800x800) Image search: [iqdb] [SauceNao] [Google]
1413660451168.png
45 KB, 800x800
Is something wrong with global variables?
in short (under 300 lines) scripts should I actively try to avoid them, even if its more work and I feel less readable?
>>
>>52344487
It works
>>
>>52344489

Only autistic people have a problem with globals
>>
>>52344489
Unless a variable needs to be global, don't make it global.

Yeah you might not like it as much, but you'll be grateful later on when you don't have an absolute clusterfuck on your hands.
>>
>>52344489
fuck me, python I am talking abut
>>
>>52344494
255 and 255
>>
>>52344520
It works
>>
>>52344489
>Is something wrong with global variables?
>in short (under 300 lines) scripts should I actively try to avoid them, even if its more work
Yes, absolutely.

>and I feel less readable?
It may be less readable *for you* because you already understand the code. I can assure you it makes the code easier to understand to anyone not already intimately familiar with what it does. Which includes you in three months.
>>
>>52344489
If it's throwaway code, who fucking cares?
For anything else though, they need to be used with extreme caution. Global state can seriously fuck with the extendibility of your program and can make it very difficult to reason about.
>>
>>52344530
255 and 0
>>
>>52344489
functions also are global variables so we should also forbid them and program everything in the same block (a la basic)
>>
>>52344438
Will give it a shot and see what happens.
If nothing works i guess I will have to find another API.
>>
>>52344559
Returns 127 whichever order you input it
>>
>>52344565
>Function are variables
In languages that aren't memes, they are not.
>>
>>52344576
but anon
the average of 255 and 0 is 127.5
>>
>>52344598
In math, yes. In integer arithmetic, no
>>
>>52344608
The (arithmetic) average of two integers is not an integer

ergo the average is not a part of integer arithmetic
>>
>>52344628
You are talking about arithmetic with integers, I'm talking about integer arithmetic. An integer division yields an integer. A round function that takes a float returns a float even if it's already an integer.
>>
>>52344574
Glancing at the thing I can't see why you'd even need to generate a model.

But I use an API that simplifies my JSON stuff massively, I can just create a data object with relevant properties, define a collection of that data object and just slam the entire thing into that collection in one hit.

And even if it hasn't got a property name I can just use a "JObject" and navigate via keys/values.

I'd recommend looking for a similar API instead of writing it all, seems like it's more hassle than it's worth to me.
>>
>>52344641
integer arithmetic takes integers and returns integers
But the average of two integers is not an integer
ergo the average of two integers is not integer arithmetic
>>
>>52344669
And the division of 2 numbers is not always an integer
Yet integer division still yields an integer
>>
>>52344679
Integer division is not division
>>
>>52344652
By API you meant Framework?
I didn't write the API, I am just trying to consume something on my Android app. The idea is to have a screen showing the latests movies, one for the movie's details and some movie searching, nothing too complex.
>>
>>52344694
Then integer average is not average
>>
>>52344708
There's no such thing as integer average
>>
>>52344704
Sorry, yeah. I meant framework.

Get a JSON framework that does all the heavy lifting and then just create a container for each individual object and slam all your data into that.

Makes life much easier that way, you can just run the JSON call again to refresh the data and you have it all stored locally to do with as you please.

I imagine the way you're currently doing it relies heavily on the code being absolutely airtight, where as with the JSON.NET framework I literally just deserialise whatever the hell JSON I like however I like.
>>
>>52344748
There's no such thing as integer division then
>>
A rss 2.0 reader with Xerces as XML parser, Qt as UI and a binding for the Appindicator in elementary.
>>
>>52344501
Retard
>>
>>52344774
Yes, yes, you're starting to understand now
>>
>>52344822
Yes, I've understood you don't actually program, because you would have denied what I've said, considering integer division is prevalent in most languages.
>>
>>52344837
>prevalent in most languages
>good, correct or appropriate
pick one
>>
>>52344849
I pick all chum
>>
Any Scandinavian fags out here? Is Valkyrja Norwegian for Valkyrie?
>>
>>52344849
To add, you still didn't combat the claim that integer division was a thing. Even if it wasn't in your language of choice, denying its existence meant you're just being retarded, or you're making claims with no prior research
>>
In python does pickling two objects with the same structure and data result in the same text? That is, is there any information about the pointers, creation time, last modification etc. stored?
>>
>>52344772
Retrofit and Gson is what I use to do the heavy lifting to me. Gson converts automatically the JsonObject to my POJO and Retrofit "converts" the API endpoints into an interface. It works like a charm most of times, but since there's something wrong with this API it's giving my this headache. Guess I will just simply search for another API and forget about this shit.
Anyway, thanks a lot for the help fellow anon.
>>
>>52344885
>square circles exist because language x has a feature called square circle

cult programming
>>
I'm thinking of getting into machine learning for my course work at uni (computer science department)t. Specifically, I thought about learning to work with TensorFlow.
The problem is, I can't think of any cool projects to actually do with said library. Any ideas?
>>
>>52344912
If that language has that feature, then that feature exists. Whether it's a widely used term is up to its influence in programming. Integer arithmetic is a useful concept as float operations are more expensive.
>>
>>52344669
>But the average of two integers is not an integer

(1 + 1) / 2 = 1
>>
>>52344946
You're supposed to choose libraries to use based on the project, not the other way around
>>
File: 648.jpg (64 KB, 1280x720) Image search: [iqdb] [SauceNao] [Google]
648.jpg
64 KB, 1280x720
>>52344891
id(object) gives the unique id of the object (in cpython, it's actually the address of the object).
>>
>>52342308
that trooper in the pic is not even the traitor trooper
that trooper in the pic tried to kill the traitor trooper
>>
>>52344953
Doesn't contradict what I said
>>
>>52344975
>not knowing who Tr8-or is
>being a literal traitor
*spins*
>>
>>52344976
>>52344953
Not sure if samefagging to avoid arguing with my point. Either way, my post is above it
>>
>>52344958
Well, I don't have one, so I just picked something that sounded challenging and potentially interesting, really.
Dunno. I just heard one of the advisors currently works with TensorFlow, and said learning to work with it would be a great course work and a great opportunity to learn, so I kinda went along with it. I don't really have much knowledge about machine learning, but I'm reading a book about it currently.
In any case, the problem is, I still don't really have any perspective on what cool things you can actually do with machine learning. I just picked it because I had to pick something, or I would never start doing anything, and now I'm kinda confused on what are the actual capabilities of machine learning.
>>
>>52344990
If you wanted your senpai to notice you you could've just asked

>>52344947
They mislabel it
>>
>>52345008
Are you sure you aren't here to shill TensorFlow?
Are millilitres being added to your account?
>>
>>52345013
>They mislabel it
No you are just out of the loop with common programming terms
>>
>>52345032
>common
>good

Democracy doesn't apply
>>
>>52344967
that;s the opposite of what I want to achieve because I'm building a lookup table and that will give me two different keys for the two instances of an object even if they have the same value.
>>
>>52342272
Anime?
>>
>>52345027
Nah, I'm being honest here.
It's just a new dank hot library, and I kinda thought of it coming out as an opportunity. "Hey, why not figure out machine learning, might be fun".
Well, OK, it was actually the advisor who offered me an option, and I kinda went along with it.
>>
Hey guys, I kind of learned C++ on my own for like 2 years, without following any book, so I kind of know some stuff.
What parts of C++ do you consider essential to know?
>>
>>52345113
Definitely addition and subtraction
>>
>>52345152
Subtraction is redundant
>>
>>52345113
Fucked up casting system, OOP crap, c++11 lambda.
>>
>>52345174
>implying addition isn't merely the subtraction of negative numbers
>implying positive numbers exist whatsoever
>shilling addition
don't even have a reaction image that can describe the disgust I feel reading your post
>>
>>52345289
>Implying subtraction isn't merely multiplication by a higher order vector
>Implying subtraction exists at all
>Shilling subtraction
>>
>>52344115
>>52344028

Thanks fellas.
>>
>>52345340
Homogenous numbers, obviously
>>
what exactly is wrong with object relational models? I've read a fair bit of anti ORM stuff saying it's an antipattern but it seems to me that if you use it properly it would work out as good as using a DAO.
>>
>>52345039
Avoiding the point
>>
What is best development environement for Rust?
>>
Not sure if this is correct place to post but:

So I have an exam tomorrow and I'm planning to bring a usb with me.

We get exam accounts (active directory) for the login and exam.

I have a queqtion, is it possible to block usb inserts via active directory GP's?

I think you can but is it possible to specify the media in the usb? Like allow a mouse but deny usb stick in usb port?
>>
>>52345469
Suicide hotline
>>
Can /programming fags/ into cowsay?


________________
/ Thank you for \
| using an anime |
\ pic :3 /
----------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
>>
File: gytr.png (35 KB, 463x195) Image search: [iqdb] [SauceNao] [Google]
gytr.png
35 KB, 463x195
Can't think of a way to make this any better if I'm honest.

Any suggestions senpai?
>>
>>52345725
move on
>>
>>52345485
Here's a suggestion: Study for your exams
>>
File: shock.jpg (141 KB, 550x412) Image search: [iqdb] [SauceNao] [Google]
shock.jpg
141 KB, 550x412
>mfw when macro pattern matching with ellipsis in scheme

holy fuckkkk /g/
at last I truly see
>>
>>52345721
a=" ________________"
b="/ Thank you for \"
c="| using an anime |"
d="\ pic :3 /"
e=" ----------------"
f=" \ ^__^"
g=" \ (oo)\_______"
h=" (__)\ )\/\"
i=" ||----w |"
j=" || ||"
print();
print()
print()
print(a);print(b);print(c);print(d);print(e);print(f);print(g);print(h);print(i);
print(j)
>>
>>52345751
explain
>>
>>52345725
Why would you download JPGs but not PNGs? tbqf it makes more sense to have 'videos' and 'images' as options fellow chap.
>>
>>52345766
Like I just figured it out myself so it's probably only the tip of the iceberg

but you can match the pattern of arguments like:
(macro (x y z) ...)

where the macro takes an indefinite amount of three argument lists, and the first element of each of those lists can be operated upon as x, the second as y, and the third as z.

so if your macro said:
(+ x ...)


and you ran
(macro (1 2 3) (100 200 300) (1000 2000 3000))


it'd return only the sum of the x's, AKA 1101

sorry for the trivial example, but it came in super handy for a more convoluted program I was grappling with
>>
>>52345762
>not compiling to pdf
\documentclass{article}
\usepackage{luacode}
\begin{document}
\begin{luacode*}
a=" ________________"
b="/ Thank you for \\"
c="| using an anime |"
d="\\ pic :3 /"
e=" ----------------"
f=" \\ ^__^"
g=" \\ (oo)\\_______"
h=" (__)\\ )\\/\\"
i=" ||----w |"
j=" || ||"
--texio.write_nl(nl);
--texio.write_nl(nl)
--texio.write_nl(nl)
texio.write_nl(a);texio.write_nl(b);texio.write_nl(c);texio.write_nl(d);texio.write_nl(e);texio.write_nl(f);texio.write_nl(g);texio.write_nl(h);texio.write_nl(i);
texio.write_nl(j)
\end{luacode*}
Hello, /g/!
\end{document}
>>
File: 1451659793903.png (14 KB, 258x264) Image search: [iqdb] [SauceNao] [Google]
1451659793903.png
14 KB, 258x264
>parametric polymorphism
>>
>$ rm .vimrc.old *
Fuck nearly had a heart attack.
>>
File: 1452403462016.png (79 KB, 307x400) Image search: [iqdb] [SauceNao] [Google]
1452403462016.png
79 KB, 307x400
>>52345788
If I was only looking for files with a transparent background, like this one, there's no point in downloading .jpg files.

If there was only 'videos' and 'images' options I wouldn't be able to omit .jpg files.
>>
File: 1443880568682.jpg (6 KB, 250x224) Image search: [iqdb] [SauceNao] [Google]
1443880568682.jpg
6 KB, 250x224
How to stop threads started via thread.start_new_thread in Python?
>>
>>52345874
biggest oop meme
>>
>>52345929
>python
>interpreted language
>threading
what u doing man
>>
Would it be possible to create a sizeable game in a purely functional programming language? Mainly asking because I'd like to try functional programming and I like developing video games
>>
>>52345901
Makes sense.
>>
>trying to find a better job without a CS degree
why is it so hard lads?
>>
>>52345960
Yeah. John Carmack had plans to do exactly that. I think id Tech 6 actually is purely functional.
>>
>>52346005
What degree do you have?
>>
>>52346018
Anthropology
>>
>>52346018
None, last thing I got was a distinction award for a btec hnd (hons) in ComSci major in Software Development
>>
>>52346011
Any quick ideas for what might be useful tools and tips for that? just before I google for generic answers
>>
>>52345874
Shit performance, shit maintainability.
>>
Where does this "you need to know advanced math to understand SICP" meme come from?

It's high school math at most.
>>
>>52346095
then most of "good" programmers are retards. carmack said it was hard.
>>
>>52346095
From people that failed high school math
>>
How to statically link a program on Linux so that it can be redistributed on both 32-bit and 64-bit platforms? Or do I just link dynamically, copy over the .so files I used and use LD_PRELOAD and distributed it this way?
>>
I've never tried Haskell, I've only seen the wiki but it looks beautiful
>>
>>52345863
Hygienic macros a shit. A SHIT.
>>
>>52346150
Really nice to read
Not so fun to write
I start something, inevitably get bogged down in irrelevant type madness, then just do it in lisp
>>
>>52346150
It is. It's like painting a picture. You have to REALLY work at it to get it to be anything other than shit, but when you're done and show it to somebody else they'll think it's beautiful.
>>
>>52346105
SICP is hard but it doesn't require good understanding of math but good problem solving skills.
>>
>>52346190
>not so fun to write
>so i turn to lisp

MEME MACHINE
>>
>>52345725
What about a cookie to remember which images you've already downloaded so you don't download the same images twice?
>>
Rate:
int* pureFun(int* x)
{
(*x)++;
return x;
}
>>
>>52345744
Here's a suggestion: go back to reddit
>>
>>52346201
Lisp is incredibly fun to write in. It's far less likely to give you shit than Haskell or C.

Now reading Lisp...
>>
File: illuminater.webm (3 MB, 213x229) Image search: [iqdb] [SauceNao] [Google]
illuminater.webm
3 MB, 213x229
>>
>>52346223
Here's a suggestion:
>>
>>52346224
((((((((((((((((((((((((nice meme, anon)))))))))))))))))))))))
>>
>>52346221
Is this function pure though?
>>
>>52346251
Ah, I get it now
You're a mental midget with nothing but inane comments to contribute to this thread
Feel free to return to your Python program
>>
Can you average two bools in C, /dpt/?
>>
>>52346279
(true + false) / 2
>>
File: 1452403565183.jpg (338 KB, 1369x1183) Image search: [iqdb] [SauceNao] [Google]
1452403565183.jpg
338 KB, 1369x1183
>>52346268
>inane
>he's a Stallman fanboy
>>
>>52345949
It has standard threading libraries, nigga
>>
What's the difference between 'open'- and 'import'- a project in most ide's?
>>
>>52346279
I can get the integer average of 2 ints in Brainfuck
,>,<[->+<]>[-[->+<[<]]>[>]<<]>.
>>
#!/usr/bin/env python

import math

def gcd (a, b):
a = abs (a)
b = abs (b)
while b > 0:
c = b
b = a % b
a = c
return a

def round (x):
if x > 0.:
return int (x + .5)
else:
return int (x - .5)

def main (count):
a = 1
while count > 0:
for b in range (1, a):
if gcd (a, b) == 1:
c2 = a * a + b * b
c = round (math.sqrt (c2))
if c * c == c2:
print (b, a, c)
count -= 1
a += 1

main (25)
>>
>>52346279
>C
>bools
hahaha
>>
>>52346342
>not knowing stdbool.h
just end yourself
>>
>>52346342
_Bool has been in the standard since C99. stdbool.h refines it a bit more.
>>
>>52346364
>_
fuck that
>>
>>52346351
>having to include a header just to use a boolean primitve
Nice language m8.
>>
>>52346351
>m-muh macros
>>52346364
>C has bools!
>_Bool

Jesus christ why don't C stop being so damn autistic and add a fucking boolean type
>>
>>52346379
You don't need bools in C.
>>
>>52346377
Then use stdbool, which defines 'bool' to be equivelant to '_Bool'
>>
>>52346379
Booleans aren't primitives in any language.
>>52346384
C does have a boolean type. It's called "_Bool".
>>
>>52346326
Bump
>>
making a VPN kill switch...rolling my own because the ones that available either don't work or just complicated to use and/or tied to a certain VPN provider. This will be windoze... yes WINDOWS :)
>>
>>52346391
Do I need to #include <stdint.h> so I can use int and not _Int?
>>
File: 1452413066290.png (139 KB, 400x398) Image search: [iqdb] [SauceNao] [Google]
1452413066290.png
139 KB, 400x398
What's the point of booleans when you can just use 1 and 0 to represent true and false?

Seems like unnecessary bloat if I'm honest.
>>
>>52346403
>>52346390
>mfw while(OMX_ErrorUndefined) actually works
Ayyy it keeps getting better.
>>
>>52346427
No, because int is a primitive type. Boolean is not.
>>
#define TRUE 1
#define FALSE 0

if (shit != FALSE) {
/* meme magic */
} else {
/* some stuff */
}
>>
>>52346428
>what are sum types
>>
>>52346420
>implies VPN's garantee anon-mode
>>
>>52346428
Pythonfags literally don't know how to use integers.
>>
>>52346434
While don't use bools in C.
>>
>>52346428
What's the point of having other primitives than
long  double
. It holds everything.
>>
>>52346379
>>52346384
>moving the goalposts this hard
>>
Why does C have anything other than ints and floats? It's literally retarded
>>
>>52346428
because you can define "true" to mean whatever you want, not just 1

for example a list can be true if it has elements, a string can be true if it's not empty, an int can be true if it's not 0. Being able to define this gives you clearer concise code
>>
>>52346478
Why do you have anything but fucking legs, torso and head? You would literally stop shitposting.
>>
>>52346470
Nothing uses bools in C because they don't exist. stdbool.h is a nasty hack to implement boolean like primitives.
>>
>>52346475
Jesus fucking Christ I know this is an anomalous enemy college boarding school but you could at least check the fucking post times
>>
>>52346449
That's pretty much what stdbool does. Here's the file without comments:
#ifndef _STDBOOL_H
#define _STDBOOL_H
#ifndef __cplusplus
#define bool _Bool
#define true 1
#define false 0
#else
#define _Bool bool
#if __cplusplus < 201103L
#define bool bool
#define false false
#define true true
#endif
#endif
#define __bool_true_false_are_defined 1
#endif
>>
>>52346478
err it doesn't, all the primitive types are numerical afaik

this makes perfect sense and is exactly what a language with the use case that C has should do
>>
>>52346500
>#ifndef _STDBOOL_H
>#define _STDBOOL_H
The mark of the unskilled coders.
>>
>>52346488
>>52346502
So why aren't chars called _char?
>>
>>52346506
Do you have a better way?
>>
>>52346514
Import properly
>>
>>52346514
Don't put that and include your header only once.
>>
>>52346498
What does that change
>>
>>52346513
why isn't your mother chaste?
>>
>>52346536
Indicates that they probably aren't the same person?
>>
>>52346513
char is just syntactic sugar for int.
#include <stdio.h>
main()
{
char c = 102;
c++;
printf("%c",c);
}

This program prints "g" to stdout.
>>
>>52346555
Reread my original post and explain how that changes what I said retard
>>
>>52346563
No it prints char 103 to stdout. It's your terminal that display char 103 as 'g'.
>>
>>52346563
So why isn't bool syntactic sugar for int?
Why do I need to include stdbool?
>>
>>52346578
To be more correct, it calls my kernel's first syscall with '103' as argument 1 and '1' as argument 2. My kernel then executes this by sending charcode 103 to the program's designated stdout, which in this case is my terminal.
>>
>>52346599
>>52346599
>>52346599
NEW
>>
>>52346453

some protection is better than no protection..
>>
>>52346581
>So why isn't bool syntactic sugar for int?
It is.
Well to be more specific, they're reverse-syntactic sugar, as they actually have less functionality than ints.
>Why do I need to include stdbool?
You don't. It's for usability's sake if you're a pythonfag and can't wrap your brain around how memory stores variables.
>>
>>52346574
Because the same person didn't say both things and so can't have moved the goalposts from one post to the other?
>>
>>52346632
How are bool and char any different?
>>
>>52346677
sizeof(char) is always one. sizeof(int) is implementation dependent - on my machine it's four.
>>
>>52346604
No. The C norms say that printf prints to stdout. We do not care about your specific implementation of C.
>>
>>52342931
while (a) {
a--;
while (c) {
c = 0;
b++;
}
c++;
}

Should this work?
>>
File: le lol over lisp.png (162 KB, 571x307) Image search: [iqdb] [SauceNao] [Google]
le lol over lisp.png
162 KB, 571x307
>>52346323
>he's a python babby
>he thinks he has anything to say about programming
>>
>>52346482
This works just fine
int trigger = 0;
if(sizeof(array) > 0) trigger = 1;
if(trigger) {
do something;
}
Thread replies: 330
Thread images: 33
Thread DB ID: 390192



[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 / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y] [Search | Home]

[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 / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y] [Search | 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.
This is a 4chan archive - all of the shown content originated from that site. This means that 4Archive shows their content, archived. If you need information for a Poster - contact them.
If a post contains personal/copyrighted/illegal content, then use the post's [Report] link! If a post is not removed within 24h contact me at [email protected] with the post's information.