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

/dpt/ - Daily Programming Thread

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

Thread replies: 326
Thread images: 43

File: fp.png (243KB, 810x763px) Image search: [iqdb] [SauceNao] [Google]
fp.png
243KB, 810x763px
Previous thread at >>51543878

What are you working on, /g/entoomen?
>>
File: muh monads part 2.png (16KB, 597x285px) Image search: [iqdb] [SauceNao] [Google]
muh monads part 2.png
16KB, 597x285px
>>
>>51547562
What the fuck kind of bastardized language is this? Why is there code in those strings? Is there some kind of runtime compile system or something compiling that in the background?
>>
>>51547622

template Monad(string Bind, string Unit, string Extra)
{
class M(T)
{
public:
this()(T X) { mixin(Unit); }
mixin(Extra);
}

static auto bind(alias S = x => x, T)(auto ref M!T X) { mixin(Bind); }
}
>>
>>51547562
Second, also what is that exactly?

F#?
>>
>>51547562
language?
>>
>>51547562
>>51547665

FIRST FOR D
>>
File: Captura.png (19KB, 709x463px) Image search: [iqdb] [SauceNao] [Google]
Captura.png
19KB, 709x463px
>>
>>51547700
is there any problem with this piece of code?
>>
>>51547680
>>51547694
>Xamarin Studio External Console
>>
File: b-but muh haskell.png (7KB, 709x159px) Image search: [iqdb] [SauceNao] [Google]
b-but muh haskell.png
7KB, 709x159px
>>51547734
Xamarin is the best IDE supporting D imho
>>
has realtalkintech been confirmed for /g/? or is there a possibility that hes for real
>>
>>51547734
>Xamarin Studio External Console
That's not a language m8
>>
>>51547747
Visual D.
>>
>>51547747
Neat. Did not know Xamarin supported D..
>>
What database should I use for Node.js? I'm thinking MongoDB..
>>
>>51547797
It's not built in, but it's easy to install

Main thing you need is DMD (official compiler & library implementation)
>>
/dpt/ - D Programming Thread
>>
mixin is the feature every language needs
>>
I want to make a multiplayer game as a project with my friend. What networking library should we use?
>>
I know I suck cocks at programming and all but:
        for (String s:someArrayListOfStrings) {
if (s.charAt(s.length()-1) != '/') {
s = s.concat("/");
}
}


Reassigning the elements to one with / concatted in the foreach loop doesn't seem to actually do anything to the objects contained in the ArrayList. What am I doing wrong? Is s not a reference to the object stored in the arrayList?

java btw
>>
File: error.png (262KB, 1440x900px) Image search: [iqdb] [SauceNao] [Google]
error.png
262KB, 1440x900px
posting error code.
>>
Guys, what are your toughs on Multi-threading Programming?
>>
>>51547869
Second this
>>
File: rss.jpg (84KB, 1577x407px) Image search: [iqdb] [SauceNao] [Google]
rss.jpg
84KB, 1577x407px
I'm trying to write a bash script that will daily, check to see if there's a new podcast episode posted on a certain website caching server. If it's newer than the one I have downloaded, then wget it, to my directory.

pic related: it's a piece of what i'm writing
>>
>>51547490
kill yourself
>>
>>51548027
Why are you including print statements? Presumably you plan on running your script in the background as a cronjob, no?
>>
>>51547913
Not sure about java, but re-assigning the loop variable in a for each loops doesn't work in C#.
>>
>>51547971
Its modern message passing concurrency not taught in CS curriculum because everyone expects that people are going to fall back on semaphores. Most programmers dont understand multi-threading and have stupid ideas like you can break up a program into 6 threads and it will run 6 times as fast. The truth is most programs depend on previous instructions so that programs are forced to run linearly.
>>
>>51547913
s is a copy of the element in the array list. You should do a for loop over the indices in the array list so that your last line reads something like

 someArrayList[i] = someArrayList[i].concat("/"); 
>>
>>51548135
It should work fine depending on what you're doing. Don't add or remove elements for example but just modifying what they point to shouldn't be problematic. That wasn't the problem. foreach loops are fucky and bascially, on an arrayList, perform a get operation on the arrayList and assigns it to s.

I then modified s, which doesn't change what the arrayList refers to.

Since I'm converting it to a regular array anyway I converted it a step earlier and did the typical for (int i = 0; blah blah) iteration over it instead.

I might just never use foreach loops again. I always have problems with them and all they do is save writing thingyArray[i] over and over.
>>
>>51547913
In Java you're only editing on a copy of the pointer. If you want to operate in-place you need to either do a manual loop (for int n = 0; n < array.length.........) or write a very verbose iterator.

THE MAIN REASON IS THAT STRINGS IN JAVA ARE NOT MUTABLE. THERE IS NO WAY AROUND THIS.
>>
>>51548174
I just realized that the syntax is wrong (my Java is rusty), but the basic idea is right.
>>
>>51548197
Yeah I know strings are immutable I just didn't know s was a copy of the arrayList's pointer instead of being the pointer itself.
>>
>>51548218
Yep as a rule of thumb, if you're ever reassigning a variable that you declared in a function (not a field in an object, just a variable such as "x = 2" or "s = s.concat(...)"), you are ONLY MODIFYING THAT VARIABLES VALUE. You are not modifying any property of any object anywhere or any member of any list or anything, and you aren't modifying any variables other than the variable in the assignment.

It's a little bit trickier when you're assigning a field
class Foo {
private x;
void thing () {
x = 3;
}
}

But a good way to think about this is that it's actually just "this.x = 3", and that "x = 3" is just a shorthand for doing the "this" thing.
>>
Please don't tell me D fags are the same guys who cry about how convoluted and complex C++ is
>>
>>51548265
>that it's actually just "this.x = 3", and that "x = 3" is just a shorthand for doing the "this" thing.
QA people would probably reject this code because it makes it less clear on scope. If what you mean to modify is the class member then just use this keyword even when there's no other variable to get confused about.
>>
>>51548113

The printf's are there just for testing and IF I want to convert it to a scrip that I can run manually.
>>
>>51548316
>use this keyword even when there's no other variable to get confused about
I suppose that's a good convention to follow but I don't personally follow it in languages like Java, C# or C++.
>>
>>51548292
why do you think D was named D?
>>
any book recommendation on express and angular?
>>
>>51548437
mixin doesn't always return

for instance

mixin("struct S { int x; int y; }");
>>
>how you want your macro system family?
>I can do the preprocessor, template, or exposed AST
>just compile my strings up
>>
>>51548158
I was one of those people, until we had a class about that, we separate 1 program in 2 and 3 threads, the "speed" barely increase.
>>
>>51548158
>>51548537
What kind of bare bones applications are you writing that are actually that I/O bound?
>>
File: 1446146233623.jpg (409KB, 4288x2848px) Image search: [iqdb] [SauceNao] [Google]
1446146233623.jpg
409KB, 4288x2848px
>>51547913
Java has no one-liner to accomplish that. Not even in the latest version, which is 8.
The object-oriented solution to your problem is as follows:

import java.util.Arrays;
import java.util.List;

public class Main {
public static void main(String[] args) {
List<String> derp = Arrays.asList("amd","intel","nvidia","samsung");
Mapper.map(derp, new Mapper<String>() {
public String handle(Integer index, String element) {
return element.toUpperCase();
}
});
System.out.println(derp);
}
}


and the helper class

import java.util.List;

public abstract class Mapper<T> {
public abstract T handle(Integer index, T element);

public static <U> void map(List<U> array, Mapper<U> m) {
for(Integer n = 0; n < array.size(); n++) {
array.set(n, m.handle(n, array.get(n)));
}
}
}


To summarize: you have to create a helper class for both iterating over all list elements as well as providing an interface for your string operation (s.concat or whatever). Then you must instantiate a new Mapper object and provide a handle() method that does whatever you want with each element. I added the index Integer for shits and giggles, but it is unused. The <T> and <U> stuff is to ensure that you can re-use the Mapper class for every kind of list (strings, integers, floats, even your own custom classes). This is actually a very common design pattern in all of Java and can be seen in other classes like Calendar, Comparator, Sets, and Bytestreams. It's not like there's no other way to solve this - it's that Java (and OOP) was INTENTIONALLY designed this way.

Welcome to Java. Enjoy your bloat.
>>
Any fellow Indians here?
>>
>>51548197
what about scala strings?
>>
>>51548714
I have never used Scala so I can't comment on that matter.
>>
>>51547724
not only one
>>
>>51548714
http://lmgtfy.com/?q=are+scala+strings+immutable
>>
File: indians.png (18KB, 786x212px) Image search: [iqdb] [SauceNao] [Google]
indians.png
18KB, 786x212px
>>51548677
the stereotype is just a minority
right?
right?
>>
>how do we prevent string literals from being modified? this will let us share identical literals
>why not add "const" like C or C++?
>good idea, that will also allow other objects to be made immutable if the programmer wishes
>NAH GUYS LET'S JUST MAKE THE STRING CLASS IMMUTABLE EVEN IF IT'S NOT A LITERAL
>excellent idea Johnson
>>
>>51548820
The irony here is that mutable strings are the #1 top googled C segmentation fault error message.
>>
>>51548906
Blame C for not forcing string literals to be const
>>
>>51548820
>how do we prevent integers from overflowing? this will let us share safe integers
>why not add "unsigned" like C or C++?
>good idea, that will also allow other numbers to be made unsigned if the programmer wishes
>NAH GUYS LET'S JUST MAKE THE INTEGER CLASS SIGNED AND REMOVE ANY AND ALL UNSIGNED TYPES
>excellent idea Johnson
>>
>>51548921
but muh backwards compatibility
>>
>>51548959
god dammit, Johnson!
>>
>>51548600
>What kind of bare bones applications are you writing that are actually that I/O bound?
I never said anything about I/O, I/O is not the issue preventing programs from being parallel. What is preventing parallel programming is that most programs you use from day to day are doing a simple task that cannot be broken up into smaller tasks. An easy example is a text editor, it just sits there and waits for you to push a key and then it does something. There is no parallel programming that can speed that up.
>>
>>51549248
>An easy example is a text editor, it just sits there and waits for you to push a key and then it does something.
Is that not I/O bound? Maybe not in the typical sense where you're waiting on the disk, but still...
>>
>>51549295
ok, well even if you eliminate programs that dont wait for keystrokes, most programs I can think of are made to do a simple task and only one task at a time. Even the graphical interface for those programs cant be made parallel because the interface is waiting for the single threaded program to tell it what to do.
>>
Can I get some help on this? Trying to parse a string of numbers that can be formatted in the form x,y,z or x, y, z, however, when the spaces are added, it ignores everything after x.
while(stream >> n) //reading input
41 {
42 numbers.push_back(n);
43
44 if(stream.peek() == ',' || stream.peek() == ' ')
45 {
46 stream.ignore();
47 }
48 }

Sorry about line numbers, yanked directly from vim.
>>
>>51549489
What type is 'n'?
>>
>>51549522
int
>>
>>51549522
and numbers is a vector of ints
>>
>>51549489
In the case of
x, y, z
, you have two junk characters between the numbers you wish to read (',' and ' '). So what you may want to do is change that inner if-statement to a while-statement to keep dropping junk.
However, when I run your code with g++, I get all the numbers as expected, so not totally sure.
>>
Would anyone recommend this book? It got good reviews on Amazon
>>
>>51550169
Yeah I loved it. Great read and a nice reference piece too.

I also really enjoyed the Stanford Coursera course on algorithms
https://class.coursera.org/algo-004/lecture
>>
>>51550210
Sweet, I just ordered it.
>tfw $10 off and free two-day shipping thanks to based Prime
>>
>>51550169
Yes, it is a really good book to use as reference.
>>
>http://www.extremetech.com/computing/182428-ironic-iframes-adblock-plus-is-probably-the-reason-firefox-and-chrome-are-such-memory-hogs
holy shit this is cancerous. a lot of website have really cancerous ads but shouldn't there be a better way to block ads? my gjewgle chrome slowed down to beyond retardation (despite having 700 MB RAM available according to the task manager) and i tried disabling adblock and it seems to have helped a bit although it won't recover fully until i've restarted my browser/computer or at least refreshed each tab
>>
>>51551010
these last months, the media has been pushing against ad blockers and encryption... journalists don't know shit about technology, so you have to wonder if these are concerted attack from certain companies and political groups, or something.
>>
>>51547918
>libGDX

garbage
>>
I'm working on a softbody dynamics simulation in C++ and opengl. The rendering is good enough. Working on physics unit test by unit test
>>
>>51549489
Try changing the 'if' to a while
>>
>>51551010
Protip: It's not true.
You really think people who make money from adverts are going to be like "Yeah adblock is great"
>>
>>51551084
>>51551229
adblock has been using like 260+ MB RAM for me though. and maybe it adds even more on each tab?
>>
>>51551262
and google chrome runs fine for like a day or two and then it gets worse and worse until it's barely usable.
>>
>>51551270
wow ads are extremely cancerous. switched forcus to a tab, went up 5,5 MB. refreshed with adblock disabled, memory usage went up 49 MB...
>>
File: 1352344718582.png (13KB, 180x195px) Image search: [iqdb] [SauceNao] [Google]
1352344718582.png
13KB, 180x195px
Hello /g/

I'm a beginner at coding (java) and I'm trying to make a class extend JPanel and then add a JButton to the panel. how can i do this? if I just type
JButton retry = new JButton ("retry");
add( retry);
I get an error message I cant solve.

Also how do you post code in the picture area like above posters?

Thanks
- T. Newfag
>>
>>51551640

>I get an error message I cant solve
Why do you think it is okay to ask us for help, telling us you have an error message, and not tell us what that error message is? Do you think we are some sort of group of magical hackers who can see what is on your screen at any given time? What do you think this is, some kind of mosaic.wav song?
>>
so uh if i understand this correctly
directx uses row-major matrices for operations (World * View * Projection) and column-major for storage
HLSL uses column-major for operations(?), meaning i have to transpose the final matrix in directx before sending it to the GPU right?
im surprised shit like this havn't been standardized after all these years
>>
>>51551749
I figured you might know how to do it correctly and I would just figure it out from there, instead of burdening you with solving all of my problems.

I'll be more specific next time so I don't confuse you, tripfag. I fixed it anyway, you can disregard the request,

I also read the sticky so you don't have to answer the second request either.
>>
>>51551801
np vulkan coming soon
>>
>>51551804

>I'll be more specific next time so I don't confuse you, tripfag
It's generally a wise idea to provide a decent amount of information when requesting for help, especially since it is likely to lead to...

>I fixed it anyway, you can disregard the request
solving your own problem before posting, or very soon after posting.
>>
>>51551868
Yeah...I just said that.
>>
>Trying to be comfy coder at work
>End up being DBA for 75% of my day
>DBAing a database designed by code monkeys.
Fuck.
What's /dpt/'s opinion on SQL anyway? Does it count as programming or not?
>>
>>51551931
Adding to why the db is made by monkeys:
>MS SQL Server
>GUID primary keys everywhere
>Clustering on primary keys everywhere, everything is newid() not newsequentialid()
>No database level foreign keys anywhere, all done manually
>Using separate databases instead of schemas
>Holy random text collation rollercoaster batman
>nvarchar(max) everywhere, even when nchar(4) would be acceptable
>Every application and developer uses a god-access account, even on production (at least it's not sa).
>>
File: 20150913180421.jpg (46KB, 960x538px) Image search: [iqdb] [SauceNao] [Google]
20150913180421.jpg
46KB, 960x538px
>WHY WON'T YOU PROGRAM IN COMMON LISP AND MAKE BETTER LIBRARIES FOR IT ONIIICHAN
>>
File: Untitled-1.png (140KB, 1190x2354px) Image search: [iqdb] [SauceNao] [Google]
Untitled-1.png
140KB, 1190x2354px
>>51551931
>What's /dpt/'s opinion on SQL anyway? Does it count as programming or not?
Considering you can write sudoku solver in SQL, it definitely has the potential.

Most often though, it's more of a data query language than programming language.

Doesn't meant you shouldn't post your SQL stuff here, of course.

Picture related. Postgres query explanation for one of bigger queries I wrote yesterday.
>>
>>51552037
ahhhh my eyeesssss
>>
>>51552051
There's no better way. Or at least the way I understand it.
>>
>>51549436
You should be running i/o in a separate thread.
>>
>>51551931

Terrible understanding of SQL is one of the major reasons so many apps don't scale.

>Sysadmin
>Developer demands faster serve
>Code looks absurd, so I profile it
>950+ SQL queries on the fucking landing page
>Discuss concerns
>Developer has solution
>"We'll buy SSDs"
>>
>>51551801
pls respond
>>
>>51552031

Most of the time, when I want to use a Lisp, I use a variant of Scheme called TinyScheme. It's main usage is embedded programming. Of course, since I've discovered just how hackable mruby is, I have not been playing with TinyScheme as much.

With regards to Common Lisp, I've tried learning it a few times, but it just feels kind of awkward compared to Scheme, and when I look at the grand scheme of things, it doesn't fit a use case that the languages I already know cannot fit easily, nor does it have many libraries that would make it stand out and have a niche.

But why aren't YOU writing libraries for Common Lisp?
>>
>>51552119
I/O is handled by the OS not the programming language, programming language I/O functions are just wrappers to syscalls
>>
File: C.png (136KB, 2000x2126px) Image search: [iqdb] [SauceNao] [Google]
C.png
136KB, 2000x2126px
>>
>>51552549

What he is suggesting is that if some section of code is making syscalls related to I/O, it should be done in a separate thread. It would be very shitty for the user to press on a button and have it not respond because that thread is currently in the middle of some heavy computation. It would also suck for the computation to have to be stalled until the user does some input.
>>
>>51552735
thats overkill to spawn a thread just to wait for a file to open, its better to just use callbacks
>>
>>51552798
You don't have to spawn it, you can already have it running.
>>
>>51552798

Honestly, it depends upon the I/O used. The practice of spawning new threads for I/O is typically done with things such as, say, a UI or network traffic. Interestingly enough, on Android, if you try to do network stuff in the UI thread, the OS will bitch at you and crash your application.
>>
>>51552798
you ever try to click on a window while I file open dialog is open?
DING
DING
DING
DING
I even changed it to a relaxing wave crashing on beach sound, and now the mere sight of beaches and waves makes me ANGRY.
It's like a less irritating form of your printer, which grinds gears against eachother every startup for some reason.
>>
>>51552870
I/O in Android is a joke, you cant directly access system I/O, just make broadcasts and listeners
>>
>>51552279
jesus christ tell me this was made up in a fake scenario to explain retardation
>>
File: 1343389455826.jpg (102KB, 620x916px) Image search: [iqdb] [SauceNao] [Google]
1343389455826.jpg
102KB, 620x916px
C++ time.
say, guyise, i have a vector of virtual bases(of gui elements, for example) and those bases are actually concrete elements that can have various methods that allow you to interact with them. how would you provide these methods to the end-user who get an element as a base pointer from the object that stores the vector?

now, i can imagine two ways- manually casting pointer class or providing virtual bases for absolutely every setter that throw an error, therefore throwing whenever there's no overload. and both feel shitty.
>>
>>51552913

Not only is it completely not made up, it's also only half the story.

When the SSDs didn't do shit, I presented a paper to management showing them I'd traced the issues, and the fact that even Google bot hitting the site ran this triple nested query bullshit to generate a table.

Management took it to the developer and came back with the solution: I would install Redis, which is great for caching.

So I installed Redis. And they made absolutely no changes to the codebase refused to believe they actually had to do something to make Redis useful.

They subsequently posted on reddit, wherein /r/webdev advised "your sysadmins musn't know what they are doing. If they did, you would purchase a cloudflare business plan". So they did.
>>
>>51553021
Fuck I'm so sorry dude, maybe in another life you wont have to work with Pajeet and Rajesh.
>>
>>51553021
The state of the industry, ladies and gentoomen. Milking as much money as possible on bullshit.
>>
>>51553042
Actually their names are Pooja. Both of them.
>>
>>51553050
OOL EHT NI OOP
>>
>>51553049
I don't think thats something normies can avoid however I think the problem is that these paid (and probably qualified) developers that should understand the basic concept of dataflow and where a bottleneck occurs.
>>
post links to new thread
>>
File: ayyyyy.webm (2MB, 450x515px) Image search: [iqdb] [SauceNao] [Google]
ayyyyy.webm
2MB, 450x515px
I spent ten hours trying to fix a problem only to give up when my solution didn't work.
When I reverted to the old method, I then found that one of the trivial changes in some other section of code I had made to facilitate the new method must have fixed it, because now it works golden.
Before, the hallways in maps above 120 units in size looked like a swarm of dead insects in a spider web.
Looks better now, layouts actually make sense.

This means, of course, that I am literally finished with the map generation for now, and can start working on the computer exploration module.
>>
File: ZuqqFk1.webm (713KB, 404x404px) Image search: [iqdb] [SauceNao] [Google]
ZuqqFk1.webm
713KB, 404x404px
Ask your beloved programming literate anything.
>>
>>51553163
nice cat
>>
>>51553163
how long will humanity last
>>
>>51547490
>What are you working on, /g/entoomen?
It's not pretty, but it works
https://gist.github.com/anonymous/a2c464bfdecde5e0da28
I ported interjection.pl to python for https://github.com/infinity-next/
>>
>>51553213
Mate that code was painful to read.
>>
>>51553163
Are you aware of the urban myth (that has some mild scientific backing) that feeding your cats spinach will result in them getting kidney stones and piss crystals, potentially killing them via infection?
>>
>>51553170
>>51553188
>>51553254
not programming
>>
>>51553007
Need more information. How is user interacting with those objects? Who is user anyway? Programmer who is using you library? A normal person who is using the program you wrote?

Former is the right way here, but since you feel bad about it, maybe you're doing something incorrectly.
>>
>>51553142
use local git repo anon. it makes catching bugs that you have introduced through mistype or other silly errors super-easy.
>>
>company wants multi language support
>language variables
>language variables everywhere
>>
>>51553142
Oh, there you are.

Trying to do something similar to what you're doing.

But I'm thinking of also using perlin noise to generate connections between caves.
>>
i thought it's ask me anything
>>
File: 1448620490373.jpg (20KB, 1024x231px) Image search: [iqdb] [SauceNao] [Google]
1448620490373.jpg
20KB, 1024x231px
I need to make a site authentication so you can't use a page on a site without being logged in. What is the best way to do this? I'm currently trying to make a token, but it doesn't seem to be that easy.
>>
>>51553419
neato.
If I have one suggestion, try playing around with making expansions and contractions of your cells take place in separate frames.
Actually, no contractions: just apply an expansion rule, but to the floor instead.
I found that it ends up working way better than doing them both in the same step, like traditional automata.
then just play around with adjusting each of these one at a time and seeing how they play off of eachother.
>>
>>51553462
The way I did it was by having a data structure that stores a person's username, ip address and user agent. If you're in the structure, you're logged on.
>>
>>51553494
Could you explain this a little more? Like what programming language did you use? Is there a link online which could help me understand this?
>>
>>51550169
I read parts of it related to sorting, it was well written that's about it.
>>
File: Untitled-2.png (10KB, 1188x396px) Image search: [iqdb] [SauceNao] [Google]
Untitled-2.png
10KB, 1188x396px
>>51553467
Ah, yes, I am doing that.

Working on each layer separately and then just overlaying them.

Although after working on those layers for a while, I think the best solution for me would be to let user define the whole algorithm using some visual flowchart-like thing. Nodes would be operations, like generate noise, expand/contract, merge, etc and connections would be half-done maps passed around between nodes. Seems like a massive effort, but I believe it will be worth it in the end.
>>
>>51553551
we'll both be drafted or nuked before either of us finish.
>>
>>51553555
Please don't say that.
>>
>>51553502
I use C#.

I have a data structure, a dictionary of two strings to be exact.
Answering a captcha correctly adds you to a dictionary with the key as the concatenation of userip and user agent
The value in the dictionary is the username, but without "logging" in the username is anonymous

After you login, that is if the hash of the hash of your password is equal to the double hashed password (yeah I know) as stored in the database, it replaces anonymous with the actual username.

Whenever a user connects I check to see if their ip and user agent is in the database, if so I get their username and check their privileges, if they're anonymous or have insufficient privileges I return a 403. Otherwise, if they're not even in the database I return a 401. Lastly, if everything checks out I 200 and return the resources they requested.

Using my own hashing algorithm, so I can hash the same way on my website as in my database. I'm using a massive salt, so I doubt anyone would spend the time creating a rainbow table.

I might post code next if you're still not getting it, but be warned I'm that guy who wrote his own framework, so unless you want to use a library called "FAP"...
>>
>>51553577
Ow, I was actually looking for something more web-based
>>
>>51553342
i would ideally want to
struct Test
{
virtual Test* get_derived() = 0;
};

struct Test1 : Test
{
virtual Test1* get_derived() {return this;}
void Lol() {}
};

Test* test = new Test1;
test->get_derived()->Lol();


however covariant return doesn't work that way. and i wouldn't wanna add serialization just so that programmer doesn't have to manually cast objects whenever he wants to modify them.
>>
>>51553577
What if two people using same browser inside same mobile network connect to your site? Will the second one be logged in as first?
>>
>>51553634
If programmer wants the Lol function, he knows he's working with Test1 class. So in this case, his variable definitely should have type Test1 *, not Test *.

Also get_derived function is kind of nonsensical. It would return this always. You don't need it.

So the way I see it, code would look something like this:

QList<Test *> items;
(...)
Test1 *item=(Test *) items[999];
item->Lol();


Doesn't look that bad to me.
The only problem is how to ensure that the item you're working with is actually Test1 and not something else. In Qt and Borland, you have built-in reflection, so that's easily solved. Outside of it, I believe you'll have to come with at least some form of reflection. And the fact that Qt and Borland people did invent their own form of reflection, means that there's really no way around this.
>>
>>51553603
You absolutely cannot create a login system without a backend, that would be insanity, you could defeat the system just by reading the js code. Look, my captcha verification code is 12 lines of code is it worth turning on my computer for?

These kind of things are actually so simple I don't think anyone has bothered to write a guide for it. Compare hashes and add to a session data structure, quick dirty and easy.

>>51553639
Within the same mobile network they have different ips, so its all good.

Behind a private network they have the same ip and so if they're using the exact same make of browser, including the same os, there'll be caching issues first and second there'll be session issues. The second guy will be basically stuck on the login view and get a lot of 403 errors.

For EXTRA SECURITY I implemented a sort of token system, the second guy will basically have an incorrect session number. In hindsight this isn't as useful or as secure as I thought it would be (because the token sequence is the same each time), but it's already done so whatever.

If I could be really fucked I'd add the day of the year to the hashing sequence, so the hash is different every day you login (but still predictable on both ends). I can't be fucked and if you're worrying about more than just a kid running wire shark you have issues.
>>
>>51553007
How about:
struct Parent
{
template <typename T>
T *as()
{
return dynamic_cast<T>(this);
}
};

struct Child: public Parent
{
};

Base *ptr = new Child{};
ptr->as<Child>()->something();
>>
>SICP or the art of computer programming

better one?
>>
File: 1422905827890.jpg (50KB, 1280x720px) Image search: [iqdb] [SauceNao] [Google]
1422905827890.jpg
50KB, 1280x720px
>>51553692
but we have virtual function table in c++, so when i call get_derived() this little shit knows exactly which get_derived() i want. therefore it knows to what type i wanna cast this. why do i need to specify ONCE AGAIN that i want the derived class, when it could just give me derived through virtual function table and simultaneously rid us of dynamic_cast<>?
>>
reddit is easy to use, you don't even need an email to set a login in 2sec
>>
File: ebinfug.png (51KB, 1646x822px) Image search: [iqdb] [SauceNao] [Google]
ebinfug.png
51KB, 1646x822px
So, I literally started my programming learning few days ago. I went straight to C++.

I made a program, that converts temperatures.

It converts the selected type of temperature to the unselected ones.

First it asks you to choose the type, then it asks the question again to confirm, after the comfirmation it jumps to the conversion, you enter the value, it does the conversion, after that it asks you, if you want to redo the conversion, jump to the beginning or exit the program. Pic related, that's what's happening. Ite does the same for all the temperature types.

I noticed few things:
>It became pretty long for such a simple program
>I used goto. I heard that you should never use it
>You need to actually enter the numbers and press enter, instead of reading the keyboard input straight
>And so on....

So:

Tips, tricks, corrections, simplifications? Also I'd like to know where to go from here, or how to extend this project to be more advanced.

I suck balls at this, and I'm a total newfag to programming in every aspect, since C++ is the first language for me.
>>
>>51553887
What the fuck are you naming your variables? And people said I picked bad variable names...
>>
>>51553887
Is that a screenshot of your code?

Please, for your own sanity, have sensible variable names. If you ever come back to this code after a while away from it, you'll thank me for telling you this.

There's nothing wrong with using goto, but usually there are better ways to structure your code.

You can use something like Readline to read things as they're being typed.

You can also omit the {} around if blocks that only contain one statement.
>>
>>51553887
is this bait?

-variable names are shit
-you can << after endl. endl literally means <<"\n"<<std::flush
-do not use goto
-read up on switch statement
-read up on classes
>>
>>51553887
>I went straight to C++.

Good choice, my man.

You've made a bunch of fuckups, like
while (jalkikysmys = 1)
.

And just make variables in English instead of Mongolian or whatever that is, it'll be easier for everyone.
>>
>>51553938
Well, that's true. They are in finnish for some god forsake reason. I'll just use english from here on.
>>
>>51553952
also use can post your code with code /code tags
>>
Hey guys. I'm working on a python script which loads a SGM file. There is a long text inside which I need to pass to a bash script and retrieve the results. The bash script is on remote server to which I have an access via ssh.

How do I execute the remote script, pass the data and retrieve results from within a python script?
>>
>>51553770
>but we have virtual function table in c++, so when i call get_derived() this little shit knows exactly which get_derived() i want
That much is true.

>therefore it knows to what type i wanna cast this.
But this is false.
Virtual functions have fixed return type.
The whole virtual stuff is resolved at runtime. When you are looking at code that calls a virtual function, you do not necessary know which one will be called - it is decided at runtime. But everything related to types only lives at compile time. So you can't benefit from virtual functions this way.

Looking closely at your code:
virtual Test1* get_derived() {return this;}


Should be:
virtual Test* get_derived() {return this;}


When you do
Test* test = new Test1;
test->get_derived()


Compiler expects return type of that to be Test *, because you're working with an object of type Test *, and get_derived is defined to return Test * for it.
>>
>>51553887
A good way to use your program more readable is to group code into logically independent parts using functions.
>>
>>51553887
First thing you should do is work on removing repetition. You have almost completely identical heaps of code. There is never a situation where this is a correct and proper solution to a problem, to just copy paste heaps of code.
>>
>>51553997
actually it compiles. look up "covariant return types". it just returnes base when called from base.


so is this the best we can do for storing different types in a vector and downcasting to perform modifications, without bringing serialization in:

struct GUIStorageObject
{
virtual GUIStorageObject* Clone() = 0;
virtual GUIStorageObject* Get() = 0;

virtual ~GUIStorageObject() = default;
};

template<class T>
struct GUIStorage : GUIStorageObject
{
void setValue(T value) { m_value = value; }
T value() const { return m_value; }

GUIStorage<T>* Get() { return new GUIStorage<T>; }
GUIStorageObject* Clone() { return new GUIStorage<T>; }

private:
T m_value;
};


this shit trips my autism so hard.
>>
File: 1431065947020.jpg (315KB, 960x1280px) Image search: [iqdb] [SauceNao] [Google]
1431065947020.jpg
315KB, 960x1280px
>>51553969
Alright, I'll just that in the future.

>>51553926
So, here's what I've picked up:
>Variable names are shit. I should use english instead of my native language
>Goto should not be used. I'll stay away from it.
>I'll need to read up on switch statements and classes
>Use "\n" and std::flush instead
>Use readline to read things as they're being typed

What else?
>>
>>51554046
>Alright, I'll just that in the future.
Alright, I'll just use that in the future.*
>>
>>51554030
Oh, I do know it compiles. took me so long to respond because I was playing around with it.

What I mean is, for your situation, having different return types makes no difference in practice, since you're referring to object using pointer to base type.

>code
what
>>
>>51554029
I kinda knew that, but my knowledge of a better way of doing things was lacking, so I just did that to make my program run. Even I knew, that I should avoid doing that in the future.
>>
>>51553938
indeed finnish is mongolian language
fins are just chinese
>>
File: 1362865407497.jpg (127KB, 895x595px) Image search: [iqdb] [SauceNao] [Google]
1362865407497.jpg
127KB, 895x595px
>>51554046
well basically now you just have to read up on how to actually structure your code or code on your own and frequently consult /g/. i see a few ways how your code is shit and should be restructured, mostly through wrapping parts of it in basic classes. also read up on "stl containers" and what they do for you. this is a good site for that http://en.cppreference.com/w/
for now start up with std::vector and std::unordered_map

then there are templates, function pointers etc.

also familiarise yourself with this https://en.wikibooks.org/wiki/C%2B%2B_Programming/Code/Design_Patterns later.
>>
>>51554080
No, during the development it's completely okay to copy paste as big as you want. But it is absolutely necessary to remove code duplication after you get it to work and make sure code does what you wanted. It makes it much much easier to read and maintain the program.
>>
>>51554046
>Use "\n" and std::flush instead
no, you can use endl, there's no reason to not use endl unless you expicitly want to not flush stream, it's just that you can write
endl<<"someshit", instead of writing cout<< two times.
>>
File: 1448439321350.png (154KB, 253x395px) Image search: [iqdb] [SauceNao] [Google]
1448439321350.png
154KB, 253x395px
Any suggestions guise?

>>51554031
>>
>>51554070
code is what i use for my situation when i want to pack different types into single container and later access them
>>
>>51554116
Never thought about that. Thanks for the advice.
>>
>>51554070
>>51554030
Right. Well. As I have just found out, you can do what you want without any issues, using dynamic_cast.

struct A{
virtual void uudelleensuoritus(){ printf("A\n"); }
};
struct B :public A{
virtual void uudelleensuoritus(){ printf("B\n"); }

void do_B_things(){ printf("B things done!\n"); }
};
struct C :public A{
virtual void uudelleensuoritus(){ printf("C\n"); }

void do_C_things(){ printf("C things done!\n"); }
};

int main(int argc, char *argv[])
{

std::vector<A *> list;

list.push_back(new A());
list.push_back(new A());
list.push_back(new B());
list.push_back(new A());
list.push_back(new C());
list.push_back(new C());

for(unsigned int i=0;i<list.size();i++){
A *item=list[i];

item->uudelleensuoritus();

B *itemB=dynamic_cast<B *>(item);
if(itemB!=NULL) itemB->do_B_things();

C *itemC=dynamic_cast<C *>(item);
if(itemC!=NULL) itemC->do_C_things();
}

return 0;
}


Output:
A
A
B
B things done!
A
C
C things done!
C
C things done!
>>
File: hallway hooks.webm (1MB, 626x714px) Image search: [iqdb] [SauceNao] [Google]
hallway hooks.webm
1MB, 626x714px
>>51553564
>>51553551
Ok I lied, I wasn't actually done with the maps. My autism wont let me rest.
Hallways are now valid targets for hooking more hallways onto, rooms have a chance to generate extra hallways with a few other neighbors, which makes the map more connected, rewrote method for doing hallways from scratch six times and counting.
I can now get naturally connected and looping maps withing having a ton of map spanning perfectly straight lines counterchanged against eachother.

It's 1am, there must be more to life than this.
>>
File: g_001.jpg (137KB, 643x643px) Image search: [iqdb] [SauceNao] [Google]
g_001.jpg
137KB, 643x643px
>>51554154
>uudelleensuoritus
hey, weren't you starting c++ only yesterday?

also this isn't what i want, i want to make a method which will cast base class into derived without any input from the person that actually invokes it.
>>
>>51554208
That's not me (>>51553887), if that's what you meant, there's just some other mongolian roaming these plains
>>
Anyone have any recommendations of books to pickup for Android app development via java? Newbie here.
>>
>>51554234
/g/ - mon/g/olia
[spoiler]я и caм нa aлтae живy[/spoiler]
>>
>>51554158
Do you really need those long hallways?
>>
>>51554208
Just copied his variable name, because it's hilarious. Don't know what it means.

>also this isn't what i want, i want to make a method which will cast base class into derived without any input from the person that actually invokes it.
But that's impossible by design of the language. When you call a function, you either have to know exactly what it is, in case of non-virtual functions, or where in virtual table to look for it.

A *item=getItemFromSomewhere();

item->get_derived()->do_derived_things();


If the return type of get_derived() in base class is A *, then then compiler can only look for do_derived_things() in virtual table of A. And that does not have do_derived_things.

What you really want is the thing I posted. For your object that has a list of base object, create a function children<T>(), which will construct and return a list with children of type T (using dynamic_cast). Then the user can iterate over it and do whatever he wants with objects of particular type. It looks more or less good and is easy to both use and write.
>>
>>51554279
>>51554158
Those are some really long hallways you have there. It would be a shame if something happened to them.
>>
File: 1417765018965.jpg (57KB, 564x518px) Image search: [iqdb] [SauceNao] [Google]
1417765018965.jpg
57KB, 564x518px
>>51554296
>tfw people find your native language to be hilarious.

Feels Fingoloid man.
>>
File: paivantsaja.jpg (36KB, 273x720px) Image search: [iqdb] [SauceNao] [Google]
paivantsaja.jpg
36KB, 273x720px
>>51554355
>>
>>51554386
B-b-but muh mid-day/day's equator. That's the straight translation for "Päiväntasaaja".
>>
>>51554416
Hey, man, I'm not complaining.

Your language makes me smile.

Not many other languages can do that.
>>
>>51554279
>>51554318
the hallways are long to mimic the experience of being stuck in a long hallway. I'm expecting IGN to give me at least a 9.5 on this one.
>>
>>51554435
I have always wanted to know how my language sounds to foreign people. I guess it sounds strange. For example Tolkien used Finnish to be the base for the Elven language, so that makes me wonder what it actually sounds like to others.
>>
>>51554467
https://translate.google.com/#auto/fi/The%20Equator%20usually%20refers%20to%20the%20Earth%27s%20equator%3A%20an%20imaginary%20line%20on%20the%20Earth%27s%20surface%20equidistant%20from%20the%20North%20Pole%20and%20South%20Pole%2C%20dividing%20the%20Earth%20into%20the%20Northern%20Hemisphere%20and%20Southern%20Hemisphere.

Sounds sort of far eastern to me.
>>
Should I take online courses for programming in UDEMY ? they are on sale
>>
>>51554653
> online courses for programming
just programm
>>
>>51554735
But how will I get online certificate for taking online coures for UDEMY if I do not I take online courses for programming in UDEMY ?
>>
>>51554467
Finnish sounds like someone dropped you when you were a baby.
t. Viru Valge
>>
>>51553021
Is EVERYTHING just related to pushing responsibility away?

>Make this Java-App thread-safe.
>...Add synchronized Keywords everywhere.
>Load grows.
>Throw Hardware at it.
>Meanwhile Management reacts: What do you mean by "You don't understand Locking."?
>>
>>51554793
>Estonian saying, that Finnish sounds like that
>Estonian is basically a bootleg version Finnish.
You guys even have the same god damn national hymn

t. Viru Valge drinker from Finland
>>
>>51552886
>and now the mere sight of beaches and waves makes me ANGRY.
lmao
>>
>>51555005
>You guys even have the same god damn national hymn
ours is better 2bh
>>
File: 1417428522131.jpg (65KB, 720x589px) Image search: [iqdb] [SauceNao] [Google]
1417428522131.jpg
65KB, 720x589px
>>51555111
>mfw
Also:
I guess we Finngoloids have shitposting in our genes or something, since I didn't even mean to, but I managed to derail this programming thread totally.
>>
>>51553887
IMO, for someone that just started (by your own, I suppose), it's OK
>>
Is it acceptable for an individual to ignore the possibility of truncation errors and their consequences when developing their own applications?
>>
>>51555197
Yeah, I started on my own. Been reading a lot of guides and analyzed other people's codes.

It's a start. Got some good tips here, so I can improve and head forward.
>>
>>51555198

It's acceptable for you to do anything when you're creating applications for your own use.
>>
>>51555198
As long as you don't use a trip, you're fine.
>>
>>51553887
You need descriptive variable names. Names that tell you what these variables are.

For instance if you have a list that store each of your clients you call the list "clientNames" or something similar. Code is meant to be produced in teams meaning others are meant to be able to understand your code if they see it.

Another example is, if you have a class for a person and you need to store the persons name, age, birthplace and job then you store it with variable names :

name
age
birthplace
job

These variables tell you what they store without having to look at documentation.
>>
>>51555272
Is it acceptable for an individual to declare himself anarcho-capitalist-libertarian-christian-statist while being racist and promoting "race" (whatever that means for ignorant murricans) mixing?
>>
Where would I go for help when I managed to completely break windows and turn my computer into a useless hunk of barren waste without even trying?
>>
C new fag here, question:
why \n is not necessary in printf when its followed by scanf?
example
printf("Enter first value: ");
scanf("%d", &val1);
printf("Enter the second value: ");
scanf("%d", &val2);


output will be, (on separate lines although \n was not used)
Enter the first value: 1
Enter the second value: 2
>>
>>51555294
jalkikysymys is more than descriptive you cunt. It has CHARACTER. I look at that and think, "Wow, what a nice looking variable name."
>>
>>51555320
https://www.gentoo.org/get-started/
>>
>>51555320
/g/
>>
>>51555320
Recycling plant
>>
>>51555364
Because you are the one who inputs the "\n" when scanf waits for input. The "\n" you input when you press Enter is shown on-screen because the standard input is your command prompt basically.
>>
So now that std.socketstream is deprecated in D, what do I use instead? Do I really have to go with the plain old C-style garbage way of dealing with data?
>>
javafag here
im replacing the RMI in my program with EJB. i have application clients, not web clients.

Question. in RMI, i manually implement observer pattern to notify all clients of changes in database. Does EJB have a feature to automatically notify clients or do i still have to observer pattern?
>>
>>51555428
Use C. It's more efficient than D by one letter.
>>
>>51554386
kek @ macedonian
>>
>>51555364
> When a stream is line buffered, characters are intended to be transmitted to or from the host environment as a block when a new-line character is encountered. Furthermore, characters are intended to be transmitted as a block to the host environment when a buffer is filled, when input is requested on an unbuffered stream, or when input is requested on a line buffered stream that requires the transmission of characters from the host environment.
7.19.3p3
IOW, reading from the console will flush output streams.
>>
>>51555316
>while being racist and promoting "race" (whatever that means for ignorant murricans) mixing?

What exactly does that mean?

>anarcho-capitalist-libertarian-christian-statist

Yee haw.
>>
>>51555422
>>51555455
Thanks a lot family <3
>>
>>51553727
>~600 pages or ~5k pages
>>
File: putin thumbs.gif (750KB, 280x205px) Image search: [iqdb] [SauceNao] [Google]
putin thumbs.gif
750KB, 280x205px
>>51555446
>>
>>51555443
Really funny m8.
>>
File: I5nFwsl.jpg (97KB, 690x769px) Image search: [iqdb] [SauceNao] [Google]
I5nFwsl.jpg
97KB, 690x769px
>>51555490
>>
>>51555493
Nigger do you think this is a game?
D for Dead
C for completely cute as fuck.
>>
>>51555294
I've been told this multiple times already in this thread. I do understand the point now.

They are Finnish words, tho. Now that I think about it, I bet that not even a Finnish programmer would understand the meaning of some of those, few of those are self-explanatory in Finnish.

But for the sake of logic, I'll just use English from here on.
>>
>>51555555
>>
>>51555535
More like C for Keks.
>>
>>51555576
That is a K, so you are dumb and wrong.
Typical Dong user.
>>
>>51555587
We both know that I meant Keks, it's just the 4chan filters.
>>
Should I make my own engine for C++ game
>>
>>51555673
If you enjoy wasting your time or have a unique approach with your game and no existing engine fits, go right ahead.
>>
File: c.png (63KB, 449x498px) Image search: [iqdb] [SauceNao] [Google]
c.png
63KB, 449x498px
>>51555576

wew
>>
>>51555650
Yes, I get it, Keks. K.
>>
>>51555556
nearly checked
>>
keks
>>
>>51555705
yes, not quite though : (
>>
>>51555650
>mfw cyrillic got replaced too
Absolute haram.
>>
>>51555673
Look at some other engines first and figure out what's basic good design. Otherwise you'll just waste your time producing an abomination.

The better option is probably to just extend http://godotengine.org/
>>
>>51555693
<code>kek</code>
>>
>>51551801
You don't need to transpose; just apply the operations in the opposite order.
>>
c∪ck
>>
I actually want to make not a big game in C++, should I write my own library for it
library << engine, right
>>
>>51555718
at least you tried
well, rolled
>>
>>51555775
Just make the fucking game, don't care about what you should call what you make in the process.
>>
>>51555775
Library bit shift left engine?
As >>51555788 said, just make a game.
>>
>>51555775
just get SDL2 and start
>>
File: 1446195063311.gif (995KB, 500x541px) Image search: [iqdb] [SauceNao] [Google]
1446195063311.gif
995KB, 500x541px
>mfw checking in a huge refactorization
no better feel than cutting away cancer code
>>
>>51555829
>new code is huge
>refactorisation

code monkeys like you will never become code monks like me
>>
>>51555845
and by huge i mean it covers many areas of the code
doesn't code monk enlightenment come with some basic read-between-the-lines skills?
>>
>>51555871
reading between the lines means ambiguity
>>
>>51555538
I'm not a native English speaker myself, however I program in English because it makes more sense. The terminology for programming is English so it just fits better to program in English.
>>
>>51555904
>English is the best programming language
>>
Working on something that involves dates and PHP.

Fuck dates and PHP
>>
File: 1443799265817.jpg (182KB, 800x528px) Image search: [iqdb] [SauceNao] [Google]
1443799265817.jpg
182KB, 800x528px
>>51555911
>English
>good for anything
only thing it has going is that everyone knows it
>>
File: thank you jesus.jpg (62KB, 504x470px) Image search: [iqdb] [SauceNao] [Google]
thank you jesus.jpg
62KB, 504x470px
>still trying to download MonoDevelop
>no mirrors in entire universe
>0.0 kbyte/s then Network Error

I want to get off Miguel de Icaza's wild ride.
>>
>>51555911
Documentation and naming conventions.
>>
>>51555944
Here's some C++ to make you feel better
>>
>>51555944
apt-get install monodevelop not working?
>>
>>51555957
>variable starting with an uppercase
TRIGGERED
>>
>>51555997

That works, but unfortunately I'm doing this from a [spoiler]WINDOWS[/spoiler] machine.
>>
Does anyone know a good weather api in java ?
>>
>>51556011
why use monodevelop? Why not Xamarin Studio?
>>
>>51556015
Your national weather service probably has an API.
>>
>>51556018

Nothing from Xamarin works. Anything hosted on their site is a no-go as far as downloads go.

I just wanted to test out Mono w/ D package, because some anon here said it was gudder than the Visual Studio plugin.

So far, the effort has been a shitfest.
>>
>>51555428
std.socket is still much nicer than C's raw sockets. I've used vibe.d quite a lot too, which is quite nice if it's execution model fits your application. I'm pretty sure there are also D 0MQ bindings.
>>
>>51556030
Indeed, thanks for your answer.
>>
>>51556009
>Identity monad
>normal variable
TRIGGERED
>>
>>51555904
pooo in looo
>>
>>51556035
I was the one who said that

It's true

http://wiki.dlang.org/Mono-D#How_to_install_Mono-D
>>
>>51556068

Eventually their servers will be unfuckulated and I'll be able to download it.
>>
ameriMc'fat
>>
>>51556078
sure it's their servers?
>>
>>51556053
>giving in to special snowflake status
public final static bool TRIGGERED = true;
>>
>>51556102
>overriding a variable
THROWN
>>
>>51556102
>using a typed language
shiggy
>>
>>51556078
I can download it just fine from http://www.monodevelop.com/download/
>>
>>51556123
if your language isn't typed it shouldn't be your type
>>
>>51556123
enjoy your undefined behaviour, fagot
>>
>>51556098

Could be on my end now, because I just tried to get the new rust nightly, and the same thing is happening.

But my connection looks fine, and aside from these two, I've noticed no issue.
>>
>>51556167
So you're either being cockblocked or friendzoned?
Shame you'll never get the best D
>>
>>51556167
Shitty DNS?
>>
>>51552031
>>
>>51556185

Looks like Amazon is niggering me, or something to that effect.

pinged both static.rust-lang.org and download.xamarin.com and what do you know, cloudfront everywhere.
>>
>>51547490
Writing a LLVM compiler for obscure meme lang.
>>
>>51551931
Anon/pl sql is programming. Search queries just require a literate brain.
>>
>>51556221
Does it compile LLVM yet?
>>
>>51555446
*FYROManian
>>
>>51553021
>asking reddit

Ouch. Worse than asking /g/; at least /g/ents know what they're doing
>>
>>51556278
sure they do
>>
>>51556278
this is bait
>>
>>51547700
>statically allocated
Wrong.
>>
>>51556235
No I mean the compiler outputs LLVM IR which is then passed to clang
>>
>>51556341
underachiever
>>
>>51556330
>not giving a solution
K.
>>
File: 1443130530048.jpg (3MB, 2512x2996px) Image search: [iqdb] [SauceNao] [Google]
1443130530048.jpg
3MB, 2512x2996px
>"Programming" in >"Java"
>>
>>51556349
ADT e is allocated at runtime on the stack. The only way you can staticially allocate shit is with global variables
>>
>>51556423

Here's a pity (you)
>>
Working on a proxy server in python. Thing doesn't work for shit, though. I keep getting
socket.gaierror: [Errno 11004] getaddrinfo failed

Here's the relevant code I've got so far:
 #conn is the client's connection.
#request is the request this program received from the client.
#req would later be used for local caching, but for now it does nothing.
req = request.partition(' ')[2]
req = req.partition(' ')[0]
if '//' in req:
port = req.partition('//')[2]
else:
port = req
port = port.partition(':')[2]
port = port.partition(' ')[0]
if port == '' or int(port) == 0:
port = 8080

if req == '':
return
respondDistant(conn, request, int(port))

def respondDistant(conn, req, port):
host = req.partition('Host: ')[2]
host = host.partition('\n')[0]
host = host.replace('www.','')
print host

diffconn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
diffconn.connect((host, int(port)))
diffconn.send(req)

#receiving an answer from the server here, left that bit out

The problem here seems to be the host. Can't figure out what I'm doing wrong, though.
>>
I'm making a program for testing other programs (writing it in Java). So far it's tested a lot of "cmd" programs for a giant list of inputs and worked well. Now I want to make it able to test other kinds of programs.
I'm liking this "testing" thing a lot.
>>
>>51556844
>give program inputs
>check if outputs match
don't get too stressed, we need people like you
>>
File: img.png (95KB, 832x309px) Image search: [iqdb] [SauceNao] [Google]
img.png
95KB, 832x309px
anybody interested?
>>
>>51556885
>implying that this is the only thing that I do
As I said, I'm doing for different kinds of programs and I'm doing it to save my time when programming bigger things. Don't get too cocky just because you spend your time only programming "fancy shit". You're not better than anyone here.
>>
>>51556627
I think your firewall might be blocking the DNS request
>>
>>51556927
system testing is part of developing "fancy shit" and "bigger things"
>>
>>51556958
I'm not sure that's it, anon. My firewall accepts Python, and I'm pretty sure if it blocked the DNS request I wouldn't have internet at all.
>>
>>51556927
>You're not better than anyone here.
Yes I am.
>>
Some kind person help a retard here:

Trying to write a script in python to surround all lines of text with
Appendline("
and
")
. This uses an api to the windows clipboard.

Here's the code:

def get():
OpenClipboard(None)
handle = GetClipboardData(CF_UNICODETEXT)
data = ctypes.c_wchar_p(handle).value
pcontents = GlobalLock(handle)
data = ctypes.c_wchar_p(pcontents).value if pcontents else u''
GlobalUnlock(handle)
CloseClipboard()
return data

if __name__ == '__main__':
LEFT = 'AppendLine("'
RIGHT = '")'

lines = str(get()).split('\n')
new_lines = []

for ln in lines:
print(ln)
new_lines.append(LEFT + ln + RIGHT)

for ln in new_lines:
print(ln)


For lines:
this is a
new test
it doesnt work


It prints:
")
")
AppendLine(" it doesnt work")


What's going on?
>>
So I went to an interview at google today and they asked me to print all the odd numbers from 1 to 99. I did it this way instead of using an if statement and 2 % != 0.

Does it matter that i didn't use modulo or not?

        for(int i = 1; i < 100; i = i+2){
System.out.println(i);
}
>>
>>51553703
NIGGER PLEASE don't say that storing passwords is easy. If you don't take in account the possibility that you might get compromised, DED.
https://www.youtube.com/watch?v=8ZtInClXe1Q
>>
>>51557396
>i = i+2
i+=2

no idea about your question
>>
>>51557396
It probably shouldn't? Odd question to ask on an interview, anyway.
>>
>>51557452
>If you don't take in account the possibility that you might get compromised, DED.
Which is incredibly easy to do right. Storing passwords securely is easy as fuck. You just need to be no brain dead and spend 5 minutes reading about how to do it properly.
>>
In C++, is it better to access vectors using iterators or is it okay to use an index and vector.size( )?
>>
>>51557456
>>51557469

I'm actually lying, it wasn't an interview for google at all, but i was asked to print numbers from 99 to 1 that were odd, I gave the question to a friend and he said he'd do it by subtracting 2 from i = 100 each time, I used modulo because I've been practising fizzbuzz on /g/ for years, but was just curious if doing it that way would be equally valid or they really just want to see if you know how to use modulo.
>>
>>51557469
>Odd question
ROTFLMFAO
>>
>>51557396
You fucked up.

Your solution is objectively worse than modulo
>>
>>51557521
How's that? Isn't modulo fairly expensive?
>>
>>51557517
>it wasn't an interview for google at all
Words can't express how non-surprised I am.

Anyway, another way to do the if-test would be to check for XOR with 1, I guess.

>>51557519
That wasn't even on purpose.
>>
>>51557590
>Words can't express how non-surprised I am.

Yeah, I'm gutted I had to settle for IBM instead, you win some you lose some.
>>
>>51557396
That's the simplest, most obvious and most efficient way to do it.
>>
File: Untitled5.png (27KB, 786x626px) Image search: [iqdb] [SauceNao] [Google]
Untitled5.png
27KB, 786x626px
>>
>>51557634

My question is though, is that what they would want to see. If you do it that way does it not just look like you're trying to avoid using modulo?
>>
>>51557663
why are you using python 3 you pathetic retard.
>>
>>51557723
cuz its newest? if it works, why not
>>
>>51557675
Looping over 100 numbers and testing if something is odd would be retarded when you can just loop over the 50 odd numbers directly.
>>
>>51557734
use python 2, fucking dumbass. nobody uses python 3, everyone uses python 2.
>>
>>51557782
Who pissed in your cornflakes today?
I bet it was you, because you use python at all :DDD
>>
>>51557808
>(
stopped reading there
>>
NEW THREAD

>>51557857
>>51557857
>>51557857
>>
>>51557521
>1, is it odd? yes print
>2, is it odd? no do nothing
>3, is it odd? yes print
or
>1 print
>3 print
>>
>>51553142
hello anon, do you have a repo of your work?

this is really, really interesting
>>
if i learn C++ will i learn C in the process?
Thread posts: 326
Thread images: 43


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]
Please support this website by donating Bitcoins to 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
If a post contains copyrighted or illegal content, please click on that post's [Report] button and fill out a post removal request
All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site. This means that 4Archive shows an archive of their content. If you need information for a Poster - contact them.