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

/dpt/ - Daily Programming Thread

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

Thread replies: 342
Thread images: 25

File: 1479016978346.jpg (33KB, 600x337px) Image search: [Google]
1479016978346.jpg
33KB, 600x337px
Previous thread: >>57515556

What are you working on, /g/?
>>
>>57520781
First for D
>>
File: you.jpg (156KB, 1023x665px) Image search: [Google]
you.jpg
156KB, 1023x665px
Friendly reminder that a purely functional programming language by definition cannot touch stdin/stdout.
>>
Whats the easiest way to make an infinite print in python that will never stop even if someone does ctrl break/ctrl c? I remember my prof showing us once and the only way to stop it was thru task manager. Anyone know it? Just curious thats all.
>>
>>57520825
./forever.py &
>>
>>57520576

please respond
>>
>>57520865
Everything clicked for me around the 5 month mark.
I'm self-taught.
>>
>>57520810
x86 can't run proper functional code anyways because the instruction pointer keeps being mutated
>>
void Printer (int x){
int turns = 1;
string spacing1 = "";
for(int i=x/2;i>0;i--){
spacing1 ="";
string spacing2 ="";
string line = "";
for (int z = 1; z<turns; z++){
spacing1+=" ";
}
for (int y=-i+turns; y<x/2 ;y++){
spacing2 += " ";
}
line = spacing1 + "*" + spacing2 + "*";
Console.WriteLine(line);
turns++;
}
if(x%2==1) Console.WriteLine(spacing1 + " *");
turns = 1;
for(int i=0;i<x/2;i++){
spacing1 ="";
string spacing2 ="";
string line = "";
for (int z = turns + i; z>0; z--){
spacing2+=" ";
}
for (int y=x/2- turns; y>0; y--){
spacing1 += " ";
}
line = spacing1 + "*" + spacing2 + "*";
Console.WriteLine(line);
turns++;
}
}
Printer(99);
>>
Ask someone (me) finishing a coding bootcamp anything
>>
Hey /g/, what should I do after I feel as though I am proficient in the current language that I am in (Java)? Should I branch off to other languages or should I master that language before I start trying to learn other languages?
>>
>>57520916
How does it feel knowing that you paid thousands of dollars to learn something you could have learned for free?

The same applies to CS graduates, but at least they get a little piece of paper so that employers don't trash your resume on contact.

What do you get?
Fucking nothing.
>>
>>57520929
based
>>
>>57520865
EE major. Only taken 3 courses. Everything has always clicked for me, thank god too because I dont think I wouldve been able to learn programming at all if it wasnt in a formal setting. Just the discipline needed to put it in the hours needed seems haunting if you arent in a class sometimes.
>>
>>57520929

Eh, got me a job and forced me to work with others. Would have probably taken me twice as long to learn on my own so it'll pay for itself in wages once I start.
>>
>>57520966
How was the job placement conducted?
Were you promised a job if you paid them money?
This sounds like a racket.
>>
>>57520969

They have a hiring network. I went in knowing I'd be top of the class and therefore was guaranteed a junior position at one of the best employers in the metro area, or they'd pay me back my tuition.

It's a racket if you're not up to the task of gaining competency in a few months. I feel very bad for my classmates who have no aptitude and are going to get hired anyway to do jobs that they will not enjoy.
>>
>>57520924
haskell or scheme. SICP uses scheme and is better for teaching concepts than Learn you a haskell, which teaches haskell. I recommend you finish whatever goal you're doing in java, then do SICP once over (lightly), then do LYAH. then maybe do SICP a second time, more thoroughly. you'll find java tiring by then, fair warning. java is extremely verbose and bothersome to work with
>>
ValueError: unsupported format character ' ' (0x20) at index 695

help
>>
>>57521119
What language?
>>
>>57521138
python
>>
>>57520865
i'd say around 2 years of full-time programming to really start getting good. work on different things and challenge yourself to write top-notch software in real languages like C++, don't just throw some half-assed shit together in python and call it a day.
>>
>>57521141
Post the code that's throwing the error
>>
>>57521156
def apiGetHeadlines(feed_id, offset=0, limit=200):
sql = "SELECT entry_id AS id, encode(digest(CAST(doc -> 'link' AS text), 'sha1'), 'hex') AS GUID, entry_unread AS unread, false as marked, false as published, CAST(extract(epoch from published_stamp) as bigint) AS updated, false as is_updated, doc -> 'title' as title, doc -> 'link' as link, feed_entries.feed_id, '[]' as tags, doc -> 'media_content' as attachments, doc -> 'content' as content, '[]' as labels, feeds.feed_name as feed_title, 0 as comments_count, '' as comments_link, false as always_display_attachments, doc -> 'author' as author, 0 as score, null as note, '' as lang from greyreader.feed_entries, greyreader.feeds WHERE feed_entries.feed_id = feeds.feed_id AND feed_entries.feed_id=% LIMIT % OFFSET %;"
data = (feed_id, limit, offset)
cur.execute(sql,data)
return cur.fetchall()
>>
>>57521201
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "db.py", line 164, in apiGetHeadlines
cur.execute(sql,data)
File "/home/noko/Projects/greyreader/env/lib/python2.7/site-packages/psycopg2/extras.py", line 223, in execute
return super(RealDictCursor, self).execute(query, vars)
ValueError: unsupported format character ' ' (0x20) at index 724
>>
>>57521201

Am I a noob or is that a gigantic query?
>>
>>57521236
i am augmenting features that api clients may or may not expect hence all the aliased columns. I thought about doing it in python instead of postgres but decided postgres would likely be faster than python
>>
>>57521252
what do you mean by using postgres vs python, like writing the logic solely with sql/stored procedures?
>>
>>57521283
each row of the query comes out as a dict and all the entire query is wrapped around in an array. this array is then placed into another dict which is then json encoded and sent off to the api client.
>>
i just had one of those moments while reading someones code that i started to like the language just because they were really good at it

then i remembered that C# is fucking cancer and submitted a merge request replacing all their comments with trigger warnings and gender neutral pronouns
>>
>>57521301
this way the api response can quickly be sent out without much fiddling about. if i only query exactly what i need and then have to loop through the array enter each dict and add all the necessary elements it would likely be slower than just using postgres
>>
So im doing my java hw, still a beginner but for problems that aren't complicated, is it fine to just do it all in main or does it go against some type of format?
>>
>>57521456
methods exist for a reason
>>
>>57521456
methods are what you want. then you call the methods from the main
>>
>>57521478
>>57521479
Alright, thanks
>>
I am a python beginner / intermediate. give me something to make that i can do in 2-3 weeks
>>
>>57520929
>The same applies to CS graduates,
Only in Murica :^)
>>
File: 45160481_p0.jpg (373KB, 1857x963px) Image search: [Google]
45160481_p0.jpg
373KB, 1857x963px
My company is looking to hire a front-end specialist in Los Angeles. I've been tasked with finding someone good enough. Link your portfolios. Weebs preferred.
>>
>>57521522
dont have a portfolio
tell me something to make and leave an email. ill link you in 2-3 weeks
>>
>>57520781
Damn that is an awesome quote. Too bad he's just a fucking business man and will never win against Hillary.
>>
>>57521500
A neural net based ocr software, without libraries
>>
>>57521532
>beginner / intermediate
>>
>>57521528
Have a github/Bitbucket?
>>
>>57521541
empty.
>>
File: akari beeemu.gif (2MB, 480x270px) Image search: [Google]
akari beeemu.gif
2MB, 480x270px
>>57521522
What kind of skills do you need?
My qualifications include a small portfolio of C89 programs and a folder with hundreds of pictures of akari akaza.
>>
>>57521547
That's unfortunate. I don't want to put any information up here. I've been coming here for years and every time someone puts any of their info out they get fucked with. I'm not in the mood.
>>
>>57521584
use a throwaway you jerkoff
>>
>>57521583

> C89 programs

Very cool senpai, but we're looking for more hipster javascript developer types.

> hundreds of pictures of akari akaza

Those are some good qualifications.
>>
>>57521597
Not worth it.
>>
>>57520869
How far did you get at the 5 month mark though? What concept made it all click?
>>
File: 1435061410847.gif (619KB, 500x280px) Image search: [Google]
1435061410847.gif
619KB, 500x280px
Why is programming so hard? I thought you guys said I didn't have to do math yet all the apps I'm doing for hw are literally math questions. I can't imagine programming in the real world... This was a mistake... Also i'm only doing C#.
>>
>>57521522

You would be better off asking /wdg/. Most of /dpt/ doesn't do a lot of work with HTML/CSS/JavaScript stuff. I've seen plenty of Python, C, C++, C#, and Haskell stuff here though.
>>
File: 1478709517379.jpg (154KB, 800x457px) Image search: [Google]
1478709517379.jpg
154KB, 800x457px
>>57521622
If you don't want to do math, then get into web development. Or at least front-end development.
>>
>>57521625
this
>>
>>57521622
what book are you using? Nothing should be harder than linear algebra, which is easy to learn. Unless you bought a book specifically on programming for domain specific things (physics, etc.)
>>
>>57521622
>math questions
You mean logic. Math is also logic, so they sometimes get confused for each other.
>>
>>57521625
>>57521635

Yeah, I asked there too. It's hard to find competent web devs man. Most of them just build wordpress sites for restaurants and call it a day.
>>
>>57521622

Academic computer science is not necessarily like the real world work you'll be dealing with, unless you're doing some shit like compiler development or AI. That said, you should have a firm understanding of basic mathematics regardless of what you choose to write programs for. It is not so much that advanced mathematics is required for a good programmer, but it is the mathematical mind that is required to write good programs.
>>
>>57521598
I don't like javascript very much, but I'd be willing to commit to it more if I was being paid to use it.
How do you feel about using C for backend web development?
>>
>>57521662
>competent web dev
oxymoron
>>
File: 1447044768670.jpg (8KB, 412x314px) Image search: [Google]
1447044768670.jpg
8KB, 412x314px
>>57521637
No book. Just teacher throwing questions and following along with examples in class. I think the writings on the wall. If I'm having trouble with programming C within MS Visual, i think this is the end of road. I just wanted a one way ticket to getting bachelors in IS and work in IT or business related job but I think I might have gone over my head... Mad respects to you CS people
>>
>>57521617
At around 5 months, I figured out the value of hiding complexity behind simple interfaces (abstraction), and then I wrote an ID3 metadata parser and tag writer in C.

I should note that I started off very slow, my first attempt at programming had me spending 5 hours trying to do fizzbuzz without looking it up.
>>
>>57521672
I already built the backend myself with Django. I actually built the front end as well using React, Webpack, and NPM. Thing is, I had to learn how to front-end specifically for this application, so it's not really the best code. We have some more money available now, so we can actually afford a specialist.

I've always wanted to try using C for a backend toy project. For the most part though, C isn't really suited to web stuff.

>>57521678
They exist. It's mostly that they are programmers who happen to like working on web stuff.
>>
>>57521699
I'm a math person. It gets better--the CS courses deeper in the major are more about design and core CS concepts and less about math.

What course are you taking?
>>
>>57521662

I would be lying if I haven't at least given some consideration to learning some webdev shit purely for the money, but I'm thinking that with the kind of work I'm doing for my research right now, I might be able to get more interesting jobs (I might be able to get a Microsoft position purely based on the fact that by the time I have graduated, I'll have a good amount of experience with their driver stack).

Curious though, what kind of a portfolio would you consider hire-able for a web developer?
>>
>>57521662
>competent web devs
A competent programmer won't do webdev desu
>>
>>57521711
Were you struggling to do it efficiently, or at all?
>>
>>57521722
>Curious though, what kind of a portfolio would you consider hire-able for a web developer?

I don't even care about years of experience. I just want to find someone that is competent with a couple of languages and frameworks who knows the difference between an integer and a float. You'd be surprised how difficult that is.

I look at a resume where the person says that they know javascript and when I take a look at their "projects" all I find is a single badly written jQuery function that toggles a CSS class after an onClick event or something.

There's also a huge amount of people that consider web development to be working with Wordpress. It's like they've never even heard of anything else.

In short, If I take a look at a person's projects and they have 1 or 2 sites built with clean code and some interactive functionality, maybe an AJAX request or 2, I'll contact them. That is so uncommon it's ridiculous. That's specifically for front-end though. Back-end developers need a lot more understanding of more traditional programming. They also need to understand a bit of server administration and database schema design. Things like when to denormalize a schema and such.

I'd be surprised if 90% of the people I looked at today could even fizzbuzz.
>>
>>57521790
i couldn't get it to display FizzBuzz
my mistake was having the if (!(i % 3)) && (!(i % 15)) case at the very end of the loop
>>
>>57521794
Your standards are surprisingly low.
But then again, I never knew how low the bar was for "web development".

Do you have an email or something, or do you just wanna see people's githubs?
>>
>>57521820
>Your standards are surprisingly low.

I wish they didn't have to be.

>Do you have an email or something, or do you just wanna see people's githubs?

Just seeing some githubs or portfolios of any sort would be great.
>>
>>57521794

So sounds like something I could probably pick up in a week if I'm trying.
>>
Trying to overload operators in C++

Quick question,, what does this mean?
Object& operator=(const Object& src)
{
//Deep Copy
return *this
}


What does *this do?

Does it return a pointer, or is it working as the de-referencing operator?
>>
>>57521838
well if you want
https://github.com/microsounds
>>
>>57521856
"this" is a pointer to the current object so yeah you're essentially dereferencing it
>>
>>57521863
Unfortunately, not really the skillset we're looking for, but cool shit none the less.
>>
>>57521794
>>57521801
How is it possible for someone to not be able to fizzbuzz when even at the lowest level you can just use a ton of conditionals?
>>
>>57521912
Maybe you should actually describe the skillset you want?
Because you're not being helpful.
>>
>>57521721
It's called Fundamentals of Application Programming. Basically creating apps using forms and stuff through MS Visual.
>>
>>57521869
But if I'm returning a reference, why does *this return a reference?

This goes without saying, but I'm not a good programmer
>>
>>57521931
I did above. I said specifically a front-end web developer. Javascript. Specifically Vue or React, Single Page Application, experience with designing an application around a REST API. Experience with CSS, and modern HTML.
>>
>>57521943

Returning a value returns a reference. That's just how reference syntactic sugar works. Under the hood though, it's just returning the pointer this.
>>
File: 44817472.jpg (152KB, 614x900px) Image search: [Google]
44817472.jpg
152KB, 614x900px
Oh, speaking of jobs and shit. I posted about the Amazon online assessment a few threads ago and never posted how it went.

Coding part was pretty easy, I choked on two though. They were probably easy, but the pressure man.

The logic/reasoning part was kind of bullshit. The logic part was pretty straight forward and kind of easy, but some of the reasoning stuff was really fucking vague and ambiguous.

Don't expect to hear back.
>>
>>57521960
>front-end framework
>REST
Are you building some kind of porn aggregator site that scrapes content from other websites on the client-side?
>>
>>57521966
Okay... I guess that makes sense
>>
>>57521980
What are some examples of questions on the logic and reasoning tests?

Do they have anything to do with programming?
>>
>>57521982
That sounds fun. Nope.
>>
>>57522065
Most of them were pretty much the same as the ones on google/glassdoor if you look those up.
>>
Should I just ignore that the C Programming Language book doesn't really explain the purpose or use of EOF?
>>
>>57522119
Indicates end of file, not much to it
>>
>>57522112
You mean questions like these?
http://gwan.ch/blog/20160405.html

>>57522119
There's more to C than blindly accepting input from the command line.
EOF is just a specific flag condition of a FILE pointer.
>>
>>57522149
I meant if you google it, not literally googles lol.

http://www.geeksforgeeks.org/amazon-interview-experience-set-137-assessment-test-sde/

That aptitude question was the same as one of mine
>>
>>57522164
>1) Some based on finding relationships between given number/strings and find the missing one
this seems arbitrary as fuck
>Given two words, find if second word is the round rotation of first word.
>For example: abc, cab
I don't even know what this means.
Does it want me to keep shifting letters to the right until the string matches?
>2) Given two hexadecimal numbers find if they can be consecutive in gray code
What's a gray code?

I'm pretty sure I would have failed your dumb test.
>>
>>57522220
>1) Some based on finding relationships between given number/strings and find the missing one

Basically find the pattern.

>Does it want me to keep shifting letters to the right until the string matches?

ABC slide the elements forward and wrap so CBA is a rotation.

>What's a gray code?
Check to see if they are neighbors, didn't have a question like this
>>
>>57522119
it's like '\n' but for files instead of strings
>>
>>57522380
I meant \0
>>
>>57522380
>>57522149
interesting okay.
I feel almost alittle overwhelmed going into this book with no real programming knowledge. It really jumps right in.
>>
>>57521327
i fuckin laughed
>>
I wonder, why only today we have expressive low-level languages like Rust, ATS and others? Why C won back then?
In the early days computers were a thing of engineers, i.e. people who created first languages had to know math. Since programmers back then knew math, it could be easier to introduce "complex" things like GADTs, typeclasses etc. Why we ended up using "dumb" and unreliable languages?
>>
File: 1452678625898.gif (131KB, 600x338px) Image search: [Google]
1452678625898.gif
131KB, 600x338px
I tried learning opengl months ago, but I stopped when it got to shaders because I didn't understand the vector math/trig concepts at all and it all went over my head, i learned how to use shaders and how to apply them when rendering vertex data in immediate mode, but I had no idea how to write a shader myself.

Is there a book or resource that teaches you the math concepts required for 3D graphics?
I don't even know what a dot product is.
>>
>>57522559
>don't even know what a dot product is.
That field of math is called linear algebra
It is usually taught along with or after calculus

https://www.khanacademy.org/math/linear-algebra
>>
>>57522530
You might like this discussion between some of the big players in the systems programming language field: https://www.youtube.com/watch?v=BBbv1ej0fFo

I think the problem is that the goalposts have changed. We want to build programs on concurrent systems that are safe and fast but also easy to code. So people set off to do their own stuff recently.
>>
>>57522573
Note that graphics only requires fairly basic linear algebra. E.g. you'll probably never need to compute eigenvectors, or work with complex numbers.

However, it helps if you can get a /thorough/ understanding of the basics: dot product, transformation, matrix multiplication, inverses, cross product, plane equations, homogeneous coordinates. By which, I mean /understanding/ why these do what you want, not just plug-and-chug.
>>
>>57521540
What's wrong?
>>
File: loli_forcing_her_way.webm (966KB, 1280x720px) Image search: [Google]
loli_forcing_her_way.webm
966KB, 1280x720px
/dpt/-chan, daisuki~

>>57522530
Great low level languages were already existing (eg: CPL) but you must know that C was targeting the shittiest computers of that era (PDP) which was very limited in memory; implementing a huge language on these machines was not possible. C is actually a rip of B which is a rip of BCPL which is a rip of CPL. Also, dennis ritchie being PLT illiterate did not help.

>>57522559
http://immersivemath.com/ila/index.html

>>57521622
Programming is one of the most difficult branches of applied mathematics; the poorer mathematicians had better remain pure mathematicians.

>>57521522
>Cuckfornia

>>57520929
>Fucking nothing.
https://techcrunch.com/2012/05/10/dev-boot-camp-is-a-ruby-success/

http://uk.businessinsider.com/coding-bootcamp-grad-goes-from-chick-fil-a-to-making-90000-after-6-months-of-study-2015-7

>>57520865
±6 months

>>57520825
https://en.wikipedia.org/wiki/Unix_signal

replace the default handlers

>>57520810
wrong
>>
>>57522892
sit on my lap faggot chan
>>
File: flying_duck_formation.jpg (89KB, 844x490px) Image search: [Google]
flying_duck_formation.jpg
89KB, 844x490px
Give me a good project to work on for a portfolio.

All I have atm is a shitty game I built in Lua.
>>
>>57522892
Source?
ource?
urce?
rce?
ce?
e?
?
>>
>>57522892
Source?
>>
>>57522991
>>57523042
Google Images, motherfuckers, do you use it?
Danchigai.
>>
File: pregbro.webm (3MB, 1280x720px) Image search: [Google]
pregbro.webm
3MB, 1280x720px
>>57522991
>>57523042
would be illegal to answer you. sorry.
>>
>>57521327
>C# is fucking cancer
Wrong.
>Merge request
You're the cancer.
>>
>>57523045
but I don't trust big brother-kun
>>
I have become so degenerate that I now order cinamon buns by bike messenger from the bakery that's 100m away
>>
>>57521327
>C# is fucking cancer
this

it's far worse than java regardless of what deluded shart in marts on here want to believe
>>
>>57523112
How is it worse? It have all the Java features + many of the features not present in Java. Also, no fucked-up primitives with boxing/unboxing. What makes it bad?
>>
>>57523084
You do, otherwise you won't be here. M00t is watching you.
>>
> tfw to intelligent for functional programming
>>
>>57523129
the entire point of java is that it's like C++ but much simpler so it can be used by large teams (hundreds of people) with ease. if you want more features, C++ is the better choice.
>>
File: 1478482353204.gif (982KB, 320x287px) Image search: [Google]
1478482353204.gif
982KB, 320x287px
>>57523112
>>57523181
Opinion discarded.
>>
File: 1478565512436.png (528KB, 602x815px) Image search: [Google]
1478565512436.png
528KB, 602x815px
>>57523209
shart
>>
>>57523217
I'm not American. Or Indian, before you spout another autistic meme.

Not like your opinion matters either way, you've probably programmed for less than a year.
>>
>>57523226
Not an argument.
>>
File: 1477915112314.gif (263KB, 480x479px) Image search: [Google]
1477915112314.gif
263KB, 480x479px
>>57523231
It is an argument, because you're not knowledgeable enough to make sweeping statements.

Shouldn't you be finishing your cs 101 assignment?
>>
>>57523241
whatever helps you sleep at night, kid
>>
Blog post, feel free to ignore. I have to get this off my chest.

Had a phone interview with a candidate. Since 90% of candidates failed SimpleFizzBuzz in real interviews, I have now added an UltraSimpleFizzBuzzYouOnlyNeedAbout60IQtoGetThis question to my phone interviews. Conversation went as follows:

Alright, I would like to ask you a simple programming questions. Got a paper and pen ready?
>Yes
Ok! In any language, write some code that can display all the odd numbers between 0 and 100.
>Ok. Give me one minute please.
*one minute passes*
>Ok, my code is like this. *reads perfect code in monotone*
Alright. Did you write this yourself?
>Yes, all of it is my code.
Can you tell me what the "percent" sign in the third line means?
>Percent? Uhhhhhh... what thats mean?
Yes, third line. if((i%2)==0). What does percent mean here?
>Ok, give me one more minute please.
*one minute passes*
>Ok, percent is means modulus.
And what does modulus do?
>Uhhh.... can you give me one minute please?
Alright
*one minute passes*
>Modulus means to check reminder.
Reminder?
>Yes, it is mean to checking reminder.
Reminder? Are you sure?
>Uhhh.... ok, can you give one minute?
Alright.
*one minute passes*
>Ok, sorry, modulus is means to check remainder, not reminder.
Alright. Have you used modulus before?
>Yes, I am use it many times before this.

Candidate was no longer a candidate after that.

Moral: Do not lie. If you do not know, just say so. You earn respect by being honest.
>>
What would be the best way to compare three sets of values in a multidimensional array?
For example, an array holds the score that a player got for answering a specific question ([][], left is player index, right is round index). I want to cycle through this array and get the scores that were given for each round, then compare them.
For example, there are three rounds and two players. I want to compare three complete values at the end (for each round) to see which one is the highest to lowest.

I have the array set up, but I don't know what would be the best way to get the values from them and compare them. Would three separate variables be needed? Or is there a more efficient way?
>>
>>57523311
>Implying not knowing modulo is okay
I see nobody cares about dealing with retards anymore
>>
>>57523311
I can't tell if you're indian or jst the candidate is Indian. Regardless, the only acceptable solution to that is quest is for (int i = 1; i < 100; i += 2). As soon as I heard "percent" I'd hang up.
>>
>>57523311
>mexican intellectuals
>>
>>57523395
I vary the question to get different answers. If I got your answer, I would ask: "And how would you print both odd and even numbers (and mark which is which) from 0-100?"

>As soon as I heard "percent" I'd hang up.
I am not that rude. And I told the candidate at the end: "You would get much tougher questions in a real life interview. If you cannot write your own code and need to google an answer for something like this, it will be very difficult to answer those real life questions. Work harder to learn more programming."
>>
>>57523436
>"And how would you print both odd and even numbers (and mark which is which) from 0-100?"
Same solution, just uncomment line 2.
for (int i = 1; i < 100; i += 2) {
//printf("%i -- even\n", i - 1);
printf("%i -- odd\n", i);
}
>>
Hey guys, could someone help me understand something? I am learning prolog and I’m currently doing some exercices, one of them is to create a 5th power of a number (n^5) and another is to create a general power function (a^n). So far I have this:

/* square of a */
sqr(A,N):- N is A*A.

/* cube of a */
cube(A,N):- N is A*A*A.

/* n^5 */
pus5(A, N):- cube(A, C), sqr(A, R), N is R*C.

/* a^n */
pus(A, 1, R):- R is A.
pus(A, N, R):- N1 is N-1, pus(A, N1, R1), R is A*R1.

For some reason, pus5(A, N). is showing me A^6 instead of A^5, but if I follow correctly the fuctions I have :
cube(A, C) = A*A*A
sqr(A, R) = A*A
pus5(A,N) = C*R = A*A*A*A*A
which should be correct

On the other hand, the pus function is perfectly working (at least of natural integers)
And I verified there is no other definition of the functions in my file.
Anyone who would have an idea of where the error is?

I also tried this:
pus5(A, N):- sqr(A, R), cube(R, C), N is C.

and it gives me the same result, which is A^6
But
pus4(A, N):- sqr(A, R), sqr(R, P), N is P.
pus5(A, N):- pus4(A, R), N is R*A.

works
>>
File: OhGod.jpg (106KB, 1024x683px) Image search: [Google]
OhGod.jpg
106KB, 1024x683px
>>57523488
>>
>>57523493
>a 5th power of a number
you can't just write
 N is A*A*A*A*A. 
?
>>
>>57523551
No, the point of the exercise is to use functions we already declared before.
>>
>>57523493
>prolog
for what purpose?
>>
>>57523568
>>57523577
Novel approach. Definitely acceptable. The small error of "even+=2" is unimportant; I just want to know that you can program.
>>
What is the best method/filetype for storing and retrieving specific strings using a file?
>>
>>57523585
for university purpose
>>
>>57523568
>Day 1545
>/dpt/ is still trying to figure fizzbuzz arithmetic
>>
does bjarne talks about how c++ manages memory and pointers in his book (Principles and Practice Using C++)?. I understand how arrays work in C, but that vector class of C++ feels weird. I don't know if it is a pointer or not.
>>
>>57523493
>cube(A, C), sqr(A, R)
if you cube A then square it you end up with A to the sixth power. in other words its like your functions are modifying their arguments. weird.
>>
>>57523644
The actual type is not a pointer, but it is just a datatype with safe wrappers to a set of pointers. You can pass it around like a custom data type and it will behave the same (memory is copied)
>>
>>57523660
where does it allocate memory? heap or stack?
>>
>>57523684
the heap
>>
>>57523568
that's disgusting, for these simple interview questions you should write the most simple and readable code, they obviously want you to loop through each number and do the even/odd test on each iteration
>>
>>57523688
thanks. I suppose it frees the memory automatically when a vector variable is out of scope.
What about other data types? are they allocated in the heap too?
>>
>>57523656
that would be in case we have (A^3)^2, but here we have C the result of A^3 and R the result of A^2, and then R*C which should be A^3*A^2=A^(3+2)=A^5.
A shouldn’t change with my current function definitions.
>>
>>57523722
pretty much. deallocating code is in the destructor
>>
>>57523715
I agree but the other guy said he'd put the phone down on anyone who deemed to use the modulus operator.

Other guy if you're still here -- would you accept a bitwise test??
if (x&1) then odd else even
>>
>>57523722
>thanks. I suppose it frees the memory automatically when a vector variable is out of scope.
unless you store pointers in the vector in which case .clear() will clear the contents but will *not* free the memory for you
but you shouldnt' be using raw pointers anyway
>>
>>57523844
>if (x&1) then odd else even
I would need to check that that is valid, working code. And do not misunderstand: I am the one whose knowledge is lacking, not you. I do not know what
>(x&1)
means!
>>
>>57523901
by "other guy" I meant >>57523395 not you

x&1 extracts the lowest bit of x, if this is 0 the number is a multiple of 2 i.e. even, if not it is a multiple of 2 plus 1 i.e. odd.
>>
>>57523844
>Other guy if you're still here -- would you accept a bitwise test??
This version is better performance-wise >>57523488

Readability I'd say is about the same. Anyway I said I'd hang up if you tried to use modulo on the original problem, which didn't call for it at all, because this is both faster and more readable:

for (int i = 1; i < 100; i += 2) { print(i); }
>>
>>57523493
pus(A, 1, R) :- R is A.

is the same as
pus(A, 1, A).

or even
pus(_, 0, 1).

which is even better.
>>
>>57522164
>>57522220
>>57522247
hexdigit :: Char -> Int
hexdigit '0' = 0
hexdigit '1' = 1
hexdigit '2' = 2
hexdigit '3' = 3
hexdigit '4' = 4
hexdigit '5' = 5
hexdigit '6' = 6
hexdigit '7' = 7
hexdigit '8' = 8
hexdigit '9' = 9
hexdigit 'a' = 10
hexdigit 'A' = 10
hexdigit 'b' = 11
hexdigit 'B' = 11
hexdigit 'c' = 12
hexdigit 'C' = 12
hexdigit 'd' = 13
hexdigit 'D' = 13
hexdigit 'e' = 14
hexdigit 'E' = 14
hexdigit 'f' = 15
hexdigit 'F' = 15
hexdigit _ = 0

hex2int :: String -> Int
hex2int xs = loop 0 xs where
loop t [] = t
loop t (x:xs) = loop (16 * t + hexdigit x) xs

int2bin :: Int -> [Bool]
int2bin 0 = []
int2bin int = zeroOrOne lsb : int2bin restOfInt
where
zeroOrOne 0 = False
zeroOrOne _ = True
(restOfInt, lsb) = int `divMod` 2

eor :: Bool -> Bool -> Bool
eor False x = x
eor True x = not x

popcnt :: [Bool] -> Int
popcnt [] = 0
popcnt (False : b) = popcnt b
popcnt (True : b) = 1 + popcnt b

isNextGray :: Int -> Int -> Bool
isNextGray x y = 1 == popcnt (zipWith eor (int2bin x) (int2bin y))

Is this right?
>>
>>57523993
end your life
>>
>>57522411
>It really jumps right in.
most books are like that. the only one that I really liked was microsoft's c# steb by step
>>
What's the best sort of data structure for representing intersections and complements of sets?

Let's say I have millions of possible traits and thousands of people, each of whom can have any combination of traits. I want to be able to efficiently find all traits shared by a particular group of people, all traits found in one group of people but not another etc.

Currently I'm doing this via a relational database but it feels kind of cumbersome.
>>
>>57524059
A relational DB sounds spot on desu senpai.
>>
>>57524059
Are they binary traits? If so, why don't you try bitsets?
Do people only have few traits on average, and traits are not binary? try sparse matrices.

Is this a serious project/semi-commercial product? Look elsewhere.
>>
>>57524059
construct text file listing one trait per line, first column is the trait, second column is a comma-separated list of people who have it

if you are looking for all traits that people in group A have but people in group B don't, pipe the file through grep for each person in group A, then grep -v for each person in group B

that's how I'd do it
>>
Can someone help me test my Facebook bot?

>>57524147
>>
>>57523846
>but you shouldnt' be using raw pointers anyway
What if I want to create my own vector class? Should I use new/delete instead of malloc/free?
>>
>>57524204
you should always be using new/delete instead of malloc/free in c++
i didn't mean malloc/free by raw pointers by the way, i meant smart pointers (std::unique_ptr, std::shared_ptr and std::weak_ptr)
>>
File: masterpiece.jpg (200KB, 1280x720px) Image search: [Google]
masterpiece.jpg
200KB, 1280x720px
>If the program is in several source files, and a variable is defined in file1 and used in file2 and file3, then extern declarations are needed in file2 and file 3 to connect the occurrences of the variable. The usual practice is to collect extern declarations of variables and functions in a separate file, historically called a header, that is included by #include at the front of each source file.
So if there's a source file with
int fag;
in it, and another source file needs to use fag, then instead of doing
extern int fag;
I make a header file with
extern int fag;
in it then #include that in the source file that needs to use the variable fag? Or is the variable defined in the header and not the source file?

Also what's the difference between a definition and a declaration? The syntax looks the same.
>>
>>57524126
>>57524172
>>57524146
I've considered bitsets but I keep adding more traits which I think would make it a bit annoying.

It's all just searching for stuff in several large sets I'm doing in my PhD project on. I used to grep for it (takes ~2 hours) but that didn't scale very well so I cooked up a SQLite thing in one afternoon which takes 10 minutes, but now I'm in bit of a lull and considering a way to do this properly.

It's nothing central to the thesis, just convenience. Still, the normally used ways to do it use awful Perl scripts running as slow as my earlier grep abomination so there could be some utility in publishing the result.
>>
>>57524222
Declarations:
int a;
void f();


Definitions:
int a = 5;
void f() { /* something */ }


Declarations are essentially prototypes needed by other source (whereas declarations are not necessarily needed until the linking process).
>>
File: dsf.jpg (52KB, 500x500px) Image search: [Google]
dsf.jpg
52KB, 500x500px
Mummy beat me up for using Python.

I told her it was just to test something real quick and I was going to convert it C later, but she was having none of it.
>>
>>57524610
I would prefer if you stopped posting.
>>
>>57524610
good parenting. dont forget to free up your used space when youre done.
>>
Anyone here familiar with Visual Studio?
In Project Properties, what's the difference between "Include Directories" and "Additional Include Directories"?
>>
>>57524243
you wont get much faster than using multithreaded sqlite if its read-only access. just make sure preload the sqlite into ram before querying (ex. copy to /tmp).
>>
>>57524671
<> and ""
>>
>>57524610
Old ppl prefer C because they havn't got so long to live to wait for python program to finish.
>>
>>57524694
<> Doesn't seem to be working for me either way.
>>
>>57524671
>>57524694
you can use " or < no matter which ui setting you used (tested VS2010). looking at the generated compiler-cli, the difference is simply that "Include D..." will get included/searched first, so i'd assume you get two options only for organizational/structural purposes.
>>
>>57524730
PS: this is mainly used like this:
>include program and library in first option
>use "Additional Include.." only for debug builds
So the value of "Include Directories" doesnt change between debug and release builds.
>>
>>57524610
She did good, you'll understand when you get older
>>
scraping awwni.me
>>
>>57524726
Never mind. It helps if you actually include the correct directory.

>>57524730
>>57524748
Cool. Thanks.
>>
what do i do if my embedded processor doesn't have hardware floating point operations
>>
>>57524821
use fixed point
>>
>>57524708
Programming in Python:
>takes 5 minutes to write
>finishes in 10 minutes

Programming in C:
>takes 20 minutes to write
>compiling...
>"error: You forgot a semicolon somewhere you fucking faggot"
>add semicolon
>compiling...
>"segmentation fault you fucking pajeet"
>build logging api and log everything
>compile
>look through hundreds of lines of logging
>find error
>fix it
>compiling...
>takes 5 minutes to run.

Prove me wrong.
>>
>>57524828
what about making a rational data type

typedef struct {
int numerator;
int denominator;
} rational;
>>
>>57524859
Programming in Python:
>be a faggot
Programming in C:
>be a trap

Prove me wrong
>>
>>57524885
I guess.
But working with embedded processor that doesn't have floating point, i'm wondering if you have the processing power to spare for rationals.
>>
>>57524885
How do you order arbitrary rationals without performing division?
>>
>>57524859
Nah, that's assuming that anything written in C is going to be faster.

It's easier to write really bad algorithms in C.

I can't stand Python, but high-level doesn't = slower in all cases, mostly due to the human element involved.
>>
>>57520865
you must [spoiler]install gentoo[/spoiler]
>>
>>57524888
WTF I want to prgram in C now
>>
File: trap.jpg (13KB, 220x290px) Image search: [Google]
trap.jpg
13KB, 220x290px
>>57524888
>>
File: hacker_on_sterons.jpg (152KB, 1073x728px) Image search: [Google]
hacker_on_sterons.jpg
152KB, 1073x728px
Will there ever be competition against this setup? IDA is just so far beyond anything else. And that's without the tren.
>hired to audit vendor's binaries
>>
>>57525158
that's true, even translating python to C directly will make for a program that's not that much faster than the original

need to write good C
>>
What's an opaque structure?
>>
>>57525619
struct f;


You can declare pointers to one and pass them around to functions, but you cannot dereference or sizeof() them. It is a form of encapsulation.
>>
>>57525671
Seems extremely useless.
>>
>>57520781
Basically learning VHDL from scratch for a final group project. None of the previous projects are even remotely useful. It's supposed to find the prime factors of an input number which can be 0 - 200 and output them to a bunch of 7 segment displays.
>>
>>57525790
That's pretty standard desu, I was the only one who liked that class in our group tho
>>
I'm having a derp moment.
What exactly does bitwise "right shift" mean, in the context of bitwise shifts?
>>
>>57526006
0110 -> 0011

everything moves right a binary digit
>>
>>57526028
But what is 'right'? Memory doesn't have a 'left' or 'right'. Just less significant bits and more significant bits.
>>
>>57526085
"right" is towards the least significant bit, i guess because we tend to write numbers with the most significant digit first.
>>
>>57525908
Yeah, I mean I'm basically just debugging the code now, it wasn't too difficult to figure out the structure, I just wish the professor had actually taught us about VHDL programming rather than manually doing Boolean algebra for a month and a half.
>>
>>57525502
> even translating python to C directly will make for a program that's not that much faster than the original

That just means it's possible to write really bad Python in C.
>>
>>57526137
Always? Regardless so of endianness of the system?

So do i understand it correctly that a right shift of n bits is equivalent to an integer division by to the power of n?
And left shift would be multiplication with 2 to the power of n.
>>
>>57526214
>Always? Regardless so of endianness of the system?
It depends. If you mean just doing an operation like 123 >> 2 then it will work regardless of endianness. But if you are, for example, reading from a network stream of the opposite endianness and you try to bitshift directly on that data you might get weird results.
>>
>>57526214
>So do i understand it correctly that [...]
yes, the bit i snipped is correct.

endianness is irrelevant to bit order in a byte though. it's only observable for the order of bytes in a multi-byte memory access.
>>
>>57526245
Sigh. Confusing.
I guess you just have to be careful to make sure the endianness of your data matches the endianness of your system.
>>
>>57520781
I'm going to try to get back into programming with C. I've had experience with it throughout the years, but have never stayed with it. What cute clothes would you guys recommend I buy to improve my abilities?
>>
>>57526214
>>57526137

bit shift is always in form of values, not bits or bytes which would be affected by endianness. right shift is always division, left shift always multiplication. when doing left shift on little endian computers it will still be done in big endian order.
>>
>>57526161
>manually doing Boolean algebra for a month and a half.
Ah the beauty of digital design class, we did karnaugh maps a lot
>>
>>57526270
>endianness is irrelevant to bit order in a byte though. it's only observable for the order of bytes in a multi-byte memory access.
Right. I've had this conceptual problem before. I still don't quite grasp why bit endianness is irrelevant.
Yeah, sure, you're going to say it's because you don't have bit level pointer access. But that doesn't stop me from accessing individual bits, through bit fields or bit masks.
>>
>>57526324
Full floor length victorian dress, with high collar and covering your arms.
>>
>>57526293
Yeah in C there's functions to flip data-endianness to and from "network order". You just have to make sure you flip it to the right order before you try to use any math on it in general.
>>
In IDA, what does the following means?

LDR R0, =label


Let's say "label" is in ROM at 0x100000, with a value of 0.
What's actually loaded in R0 after executing this instruction? The value of what's at label or the address of the value?
Damn IDA mnemonics are so confusing.
>>
>>57526340
because there is no bit endianness. a byte-value of one is always "00000001". endianness applies only for larger types; an int value of 1, assuming your int is 4 bytes in size, can be
>00000000 00000000 00000000 00000001
(big endian) or can be
>00000001 00000000 00000000 00000000
(little endian)
>>
>>57526329
>bit shift is always in form of values
But value is still determined by bit order interpretation
>>
>>57526423
This must be purely by convention, right?
>>
>>57526426
no. also see
>>57526423
there is no two bit orders. only byte orders.
>>
>>57526465
>there is no two bit orders
Why not?
>>
sh-3.2# python pipeline.py
Traceback (most recent call last):
File "pipeline.py", line 10, in <module>
features = np.delete(tpot_data.view(np.float64).reshape(tpot_data.size, -1), tpot_data.dtype.names.index('class'), axis=1)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/records.py", line 498, in view
return self.__array__().view(dtype)
ValueError: new type not compatible with array.
Help
>>
>>57526478
I mean, if there can be two byte orderings, why not two bit orderings?
>>
>>57526478
what sense would that make? big endianness exists because on motorola cpus you used to count memory downward, so it made sense to have the most signficant byte first (for load/comparison operations).
>>
I have 2 variables like this
{
..
A++
B++
...
}
Can I guarantee that the A++ will always happen before B++ without a mutex?
>>
>>57526529
I don't know. To me it doesn't make sense to have different byte orderings either.
But it made sense for some hardware implementation, so i guess bit ordering might also make sense for some hardware implementation.
>>
>>57526584
a byte is the smallest addressable unit for most microcontrollers/cpus. since you cant individually address the bits in a byte, the representation of this is byte is arbitrary (so there is no pro or contra regarding in which order you represent a byte). having different order mechanisms would require all corresponding hardware (ram, buses, timers, etc) to make different versions for different processors instead of having general purpose components. these components need to have the same bit-order, but dont care about bytes so they cant be used with both byte-orders.
>>
>>57526550
What exactly are you doing that requires this?

If there's no operator overloading involved I think the CPU can reorder them at run time even if the assembly output puts them in one order.
>>
>>57526550
mutuxes are only used for multiple threads. code is always executed in the order you define. however, internal memory representations are not guaranteed to be as you expect.
>>
>>57526340
it's irrelevant because it's completely hidden.
(blah & (1<<n)) != 0
is still true iff blah has bit n set, regardless of how the cpu has it in its register.
>>
why is this giving me a null pointer exception when i try to add something to the hash tale?

package hashTable;

import linkedList.LinkedList;

public class HashTable<T> {
private LinkedList<T>[] table = new LinkedList[100];

public void add(T t){
System.out.println(t);
System.out.println(t.hashCode());
System.out.println(table.length);
int index = t.hashCode() % table.length;
System.out.println(index);
System.out.println(table[index]);
table[index].add(t);
}

public void member(T t){
table[t.hashCode() % table.length].member(t);
}

public void remove(T t){
table[t.hashCode() % table.length].remove(t);
}
}



output
5
Exception in thread "main" 5
100
5
null
java.lang.NullPointerException
at hashTable.HashTable.add(HashTable.java:15)
at main.mainclass.hashTableTest(mainclass.java:33)
at main.mainclass.main(mainclass.java:44)
>>
>>57525134
What do you mean by order? Do you mean less than/greater than?

A simple way is to cross multiple the top elements by the other denominator and then preform the operation. eg:
a1/b1 < a2/b2
b2* a1 < b1 * a2

This works by getting a common base.

With addition/subtraction. The method is still the same. Multiple, just multiple numerator with numerator, denominator with denominator. Division is inverse, then multiple.

You might also want to get a really fast prime factorization function going. You need to preform it whenever a numerator/denominator is greater than sqrt(max value of int). Just so you can be free of worry that it won't overflow. I'd recommend just keeping a list of primes around.
>>
>>57526550
Not after it goes through optimization and an out of order execution CPU.
>>
Question.
I have a homework where I have to manipulate a CSV file so I can change the things in it. I'm planning on using Java but I heard a lot that it's not the best langage for that kind of exercice.

Why ?
And since I'm more familiar with I'll use it anyway so any advices on how I should do it ?
>>
>>57526333
I liked K-maps. I really like VHDL, but I haven't had a chance to really sit down and learn it and now I HAVE to, it just feels really rushed and sloppy and that bothers me.
>>
>>57526763
This is good info. Not the guy who needed it, but i'll mentally file this away for future reference. Thanks.
>>
>>57526798
Literally any modern language is going to be able to do that trivially.

If you know Java best, go with that.

What are you trying to do specifically?
>>
>>57526798
Also, are you french? Or which Euro country?

Why do you people insist on whitespace prior to ending punctuation?
>>
>>57526876
If all else fails, just look up what other people have done and copy it.

From Python's source code:
def _add(a, b):
"""a + b"""
return Fraction(a.numerator * b.denominator +
b.numerator * a.denominator,
a.denominator * b.denominator)
def _sub(a, b):
"""a - b"""
return Fraction(a.numerator * b.denominator -
b.numerator * a.denominator,
a.denominator * b.denominator)
def _mul(a, b):
"""a * b"""
return Fraction(a.numerator * b.numerator, a.denominator * b.denominator)
def _div(a, b):
"""a / b"""
return Fraction(a.numerator * b.denominator,
a.denominator * b.numerator)
>>
>>57520810
Monads faggot
>>
Doing C. I want to get the last directory in some string representing a path, like "/path/to/a/file/is/here" such that regex matches only "/here"

I've actually got the regex down, it's

\/([^\/])+(?=[^\/]*$)


but I actually have never used regular expressions in C before. How would I use this to get the index where the matched substring first occurs, so that I can truncate it (I have to write a simple `cd` function, and I'm trying to get `..` to move up one directory
>>
>>57527067
Why the fuck are you using regex for this?
>>
>>57527078
why not?
>>
>>57527067
find the 1st and 2nd "/" in the string. between them you have the folder.
>>
>>57527102
that would match /path/
>>
>>57527093
Doesn't C have an easy way of splitting a string based on the nth index of a character?

If so, use that.

If not, why are you using C for this particular task?
>>
>>57527120
i forgot to add "from behind"
>>
>>57527126
Systems programming class
>>
>>57527067
what regex library are you using? regex.h's regexec() gives you an array of match indices.
>>
>>57527093
#include <stdio.h>

int main(int a, char **v)
{
for (v++; *v; v++)
{
char *last_slash = 0;
char *c;

for (c = *v; *c; c++)
{
if (*c == '/')
last_slash = c;
}

if (last_slash && last_slash[1])
{
printf("%s: basename: %s\n", *v, last_slash+1);
}
else
{
printf("%s: basename not found\n", *v);
}
}

return 0;
}


$ ./a.out /etc/passwd blargh
/etc/passwd: basename: passwd
blargh: basename not found
>>
>>57526991
Yeah Belgium and I speak french. Funny how you guessed it on the spot.

>>57526984
Well I have to export a .csv file from Odoo with contacts, their name, ID, phone number and all and I have to get that and be able to modify them like I want.
I've never done that so I don't know how to proceed but I think of making a JTable with each info on a case and allow the case to be modified with a button enter where it'll take all the new info and put them in a new .csv file.
Sounds retarded as fuck but it's my first idea. Any advice ?
>>
>>57523311

Goddamn. Another retard. What's funny is that this is another case where you don't even need the modulus operator. Just start at one and increment by 2. Half as many iterations, and no if statements, effectively translating to one quarter as many conditional branches.
>>
>>57527192
I don't write Java, but I could knock that out in a few minutes in C# to be sure.

I'd imagine it's not much harder in Java than C#.

I've written a small snippet to pull from a database/API from a CRM tool like Odoo and exports to .CSV. You're only looking at a few lines of code, depending on how much transformation you're doing.

Like I said earlier, pretty much any modern language is going to work fine for this.

Also, you never explained why you frogs put a space before the question mark at the end of a sentence.
>>
>>57527067
\/[^/]*$
>>
>>57527135
2bh I'd fail you in 5 seconds if you gave me that code.
>>
Learn You a Haskell for Great Good!
>>
>>57527232
Not much really, the teacher said it's supposed to basic in fact and I'm pretty sure there are simplier ways of doing it since Odoo already gives you the .csv file. You don't even have to extract it from Odoo since Odoo already has the extract option.
I'm searching for a totorial or an already made code, if you know where I can find that, tell me.

For the space before the question mark, I have no idea man. It looks better but only with the question mark. With all the other punctuation, we don't put a space. I have no idea where it comes from tough.
>>
>>57527126
C is retarded when it comes to strings.
>>
File: learnmeahaskell.jpg (68KB, 720x960px) Image search: [Google]
learnmeahaskell.jpg
68KB, 720x960px
>>57527304
>>
>>57527330
u r dum
>>
How long would it take to learn C# if I know C/C++ and java pretty well?
>>
>>57527247
this
#include <stdio.h>
#include <regex.h>

int main(void)
{
const char *string = "/path/to/a/file/is/here";
const char *regex = "\\/[^/]*$";

regex_t re;
regmatch_t matches[1];

regcomp(&re, regex, 0);

regexec(&re, string, 1, matches, REG_EXTENDED);

printf("%.*s\n", matches[0].rm_eo - matches[0].rm_so, string + matches[0].rm_so);

regfree(&re);
}

http://ideone.com/BxT5A6
>>
>>57527399

If you know Java pretty well, C# should be a breeze. It's just a matter of learning a new standard library and a few language features.
>>
Is anyone here familiar with ALSA?
>>
>>57527437
alsa my salsa
>>
>>57527426
I see, thanks.
>>
>>57527334
No.
>>
>>57527182
findBaseName :: String -> Maybe String
findBaseName name = loop Nothing name where
loop m [] = m
loop m ('/':[]) = Nothing
loop _ ('/':xs) = loop (Just xs) xs
loop m (_:xs) = loop m xs


*Main> findBaseName "/etc/"
Nothing
*Main> findBaseName "/etc"
Just "etc"
*Main> findBaseName "/etc/x"
Just "x"
*Main> findBaseName "/etc/x/"
Nothing
*Main> findBaseName "/"
Nothing
*Main> findBaseName ""
Nothing
>>
>>57527286
For using regex? Why?
>>
Is it really true that 90% of programmers can't even FizzBUzz?
>>
>>57527334
>C is retarded

fixed that for you
>>
>>57527565
Bad code. Not portable.
>>
>>57527583
No, anyone who could be reasonably called a programmer can do FizzBuzz.

It's 90% of __applicants for programming jobs__ who can't FizzBuzz.
>>
>>57527569
not him but it is over-complicating things a lot, if you just want the bit after the last slash its much simpler to just look backwards through the string.
>>
>>57527585
That's exactly how I recognize code monkeys. They say bad things about C.
>>
>>57527583
>is it true that

redundant. "can 10% of programmers fizzbuzz"
>>
>>57526382
>
LDR R0, =label


http://www.keil.com/support/man/docs/armasm/armasm_dom1359731149945.htm

label_start:
do_x();
do_y();
LDR "Register0" =label_start
puts(Register0)


Register is now "&label_start" (address of)
>>
>>57527632
I hope that, throughout my career, I never have to use C after college. Web dev 4 life.
>>
>>57527669
You're embarrassing yourself.
>>
>>57523311
>these literal retards can get interviews every day of the week and nobody will even send me a rejection email
they're not even looking at my github portfolio
i don't want to be a neet anymore
>>
>>57527690
>github portfolio
lol
>>
>>57527632
What's wrong with being a codemonkey exactly? It's low effort and good pay. It's impossible not to land a job if you do webdev, good luck finding a job with your C fizzbuzz skills.
>>
>>57527690
The problem with real life is that jobs are gotten through connections. Unfortunately, this means that only pajeets and chads can get interviews, and will often be hired due to daddy working in finance or something.

Business types are trash desu senpai
>>
>>57527703
>good luck finding a job with your C fizzbuzz skills
It's OK I was hired for writing a C generator in OCaml. You'll do stupid things and I will do interesting things.
>>
>>57524888
>Programming in C:
>be a trap

girl *her = (girl *) malloc(sizeof(boy));
>>
>>57527722
>interesting things

Not that guy, but I'm in it for the money. When I get home from work, I'm done. No more programming. Time to have a life

Honestly, I hope I'm in management by the time I'm in my late 20s and don't have to do any programming anymore
>>
>>57527722
I do interesting things on my own time. I go to work to make money. Congratulations on finding a C job, but it's an objective fact that you will find it a lot easier to find a job for some shit like JS than C.
>>
>>57527569
regex is much slower than simply iterating over the char* looking for '/'

>>57527583
for(int i = 1; i<100; i++)
{
if( i==1 ) puts("1")
if( i==2 ) puts("2")
if( i==3 ) puts("fizz")
if( i==4 ) puts("4")
if( i==5 ) puts("buzz")
if( i==6 ) puts("fizz")
if( i==7 ) puts("7")
if( i==8 ) puts("8")
if( i==9 ) puts("fizz")
if( i==10 ) puts("buzz")
...
if( i==95 ) puts("buzz")
if( i==96 ) puts("fizz")
if( i==97 ) puts("97")
if( i==98 ) puts("98")
if( i==99 ) puts("fizz")
}

Did I do good?
>>
>>57527747
>easier to find a job for some shit like JS than C.
I agree. But the job with JS are often no brainer jobs.
>>
>>57527735
>(girl *)
delete this
>>
>>57527752
use switch and it will be faster
>>
>>57527763
>no brainer jobs

>easy
>good pay

This is the point of being an American/capitalism. Do little work for higher pay.

Anon, it's all about the money. I couldn't give a shit about what I'm working on, as long as I make at least 6 figs by the time I'm 30
>>
>>57527763
That's true, but I like that. It's free money, I have to invest precisely 0 mental energy into my job and I make enough money to live very comfortably. I don't get people who want to be challenged at their work, why put in more effort than necessary?
>>
>>57527785
>>57527794
We'll talk about that when you'll be 60 guys.
>>
>>57527777

var fizzArray = ["1", "2, "fizz", "4", "buzz" ... ] //etc

for(var i = 0; i < 100; i++){
console.log(fizzArray[i]);
}


accessing array is always faster
>>
>>57527794
Why would anyone pay anyone for something that takes no effort?
>>
>>57527811
>60

good luck getting a job as a developer when you're 60

If you save well, you won't have to work past your late 50s
>>
>>57527812
>...]//etc
Not even Haskell will do this for you.
>>
>>57527814
It's low effort for someone who knows what they're doing. You might hire an electrician to do something that they would consider an incredibly menial task, doesn't mean it is also a menial task for you.
>>
>>57527814
Because they don't understand it.
geek squad charges you hundreds of dollars to install windows, and that's basically as easy as pressing ENTER 5 times and waiting for a progress bar.
>>
>>57527814
So businessmen don't have to learn Javascript
>>
>>57520781

Is there any sane WebSocket server library for C/C++ or for some other language (except Java, .NET and JavaScript) or do I have to come up with my own?

Note: I'm not interested in stupid request/response style all WebSocket libraries showcase. I don't need to reply to client events (messages). I need to send data to client anytime I want, for example when SIGALRM arrives on the server.

Why all software has to suck?
>>
>>57527892
afaik, websockets are bidirectional, so the web browser doesn't need to query the server for a response. I don't know any libraries, but this should be trivial with really any library
>>
>>57527892
Berkley sockets. If that's not good enough for you, then write a wrapper that conforms to your use case.
>>
>>57527067
Why would you need a regex for this?
>>
>>57527852
>>57527866
But why would they need the same thing done over and over again?
>>
>>57527919

The fomer part is correct. That's why I want to use WebSockets. If I needed request/response style I'd use plain HTTP. But I need to update clients with some ongoing process sate.

I'm not really sure about the second part after today's research. They all have interface for registering hooks on client's connect/message/disconnect but if you dig on how to send messages asynchronously, it's all hazy. No relevant examples or documentation.
>>
File: sline.png (74KB, 189x250px) Image search: [Google]
sline.png
74KB, 189x250px
>>57527841
Excel might, just put in a few fizz buzz thingies and drag the box down
>>
>>57527934

WebSocket protocol is not easy to implement for me, let alone coming up with a good API design.
>>
>>57527967
Who knows, but they do, and it puts money in my bank account.
>>
>>57527987
That's the thing with rolling your own wrappers. You don't need a generally good API, just one that fits your use case and nothing else.
>>
>>57527967
You're not

>work at web dev company
>businessman chad/pajeet finds contract
>"alright guys mario's pizza wants a website so people can order pizza online"
>Make the same frontend as every other site with bootstrap (because no customer ever wants a unique looking website)
>Make a simple script which relays orders to a queue that the chef or manager can see on an iPad (choose any one of your favorite frameworks/backends: php/mysql, nodejs, rails, etc.)
>take 1 person 2 days
>charge $5k

This shit is easy, cheap, and requires a dev to change a little bit every time they deploy one of these, plus you can charge a small monthly fee to host this site because pizza chefs don't give a fuck about loonix.

1000x easier than getting paid to crawl around C code hunting for memory leaks and segmentation faults
>>
>>57528070
shit I want pizza. Going to school in a fucking hipster town and haven't had pizza in so long
>>
>>57527735

Cast of malloc isn't needed on C
return of malloc is agender.
>>
>>57528182
I wanna malloc my girl pointer.
>>
EASY HELP PLEASE
Im making java gui swing and I need two tick box's next to each other e.g Male [] Female[]
How do I put it next to each other using Grid Layout?
Do I need to just use a different Layout?
>>
>>57528222
try using jQuery
>>
>>57528222
jesus
>>
>>57528250
>2016
>not using Angular
>>
>>57528276
That's at least 20 minutes old, there's a replacement by now.
>>
>>57528222
Consider replacing it with a free-form text box -- and on submission, discarding any input found in it.
>>
>>57528222
Add a panel with its own gridlayout containing the two tick boxes to the main panel's gridlayout?
>>
>>57528250
>>57528276
I cant use any of that stuff, im also just using java not java script?
>>
File: 1460115987647.png (30KB, 246x200px) Image search: [Google]
1460115987647.png
30KB, 246x200px
>>57528222
>java gui programming
https://docs.oracle.com/javase/tutorial/uiswing/layout/grid.html

I think Eclipse has a gui builder with drag-drop functionality if you're really struggling.
>>
>>57528302
Thanks!!!!! this seems legit
>>
>>57528305
They're fucking with you
>>
>>57528313
ye its just say if my gridLayout was (4,2) I couldn't really figure out how id put 2 JCheckBox and fit them into the same cell. Since I got told to use Grid in class really stumped me!
>>
>>57528222
>Male [] Female[]
Are you assuming whoever is using this is going to identify as either of these? Goddamn CIS scum
>>
>>57520781
Where's the new thread my dudes
>>
NEW THREAD!

>>57528432
>>
Okay I have an idea.
We need to identify genders as a decimal number:
(-1 = Attractive) --- (0 = Neutral/Alien) --- (1 = Dominant)

What do you think?
>>
>>57528453
STFU
>>
>>57527892

You mean like this?
https://libwebsockets.org/
>>
>>57528504
>libwebsockets
Most bloated shit available.
>>
>>57527892
https://tools.ietf.org/html/rfc6455
It's actually simpler than it looks.
>>
>>57520781
I'm supposed to implement a ternary tree that holds generic objects in Java. I can't figure out how I'm supposed to compare different values if they're not simple numbers. This is bullshit.
>>
>>57529014
you can compare things other than numbers. google it
>>
>>57523311
Hypothetically, if you inteviewed me and I answered all of those questions, what kind of work would I do and what kind of pay would I get?
>>
>>57523311
[x | x <- [1..100], odd x]
>>
>>57523311
>>57529515
filter odd [1..100]
>>
>>57524859
>>build logging API and log everything
>GDB
>Valgrind
Unless your program is more complicated than 20 minutes of writing, you probably don't need your own API.
Thread posts: 342
Thread images: 25


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

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


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