[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: 46

File: Mario_2.jpg (543KB, 1920x1200px) Image search: [Google]
Mario_2.jpg
543KB, 1920x1200px
Old thread >>57603365
>>
anyone got a more efficient solution to
>Check if a string is a rotation of another.
>e.g. "alleycat" is a rotation of "leycatal"
than creating a list of all the rotations of string 1, and checking if string 2 is a member of that list?
>>57605500
urusai. i was actually overthinking it. i just needed to make a list of all the points of the matrix, and then consume the list to iterate the matrix
>>
no leftists allowed in this thread!
>>
>>57606285
Try to code a non determinist regular expression automata.
>>
>>57606288
check'd mein nigger
>>
>>57606218
can we agree in this thread no one replies to the "virus" poster, he's just lying to get attention
>>
>>57606303
sounds easy enough
>>
File: 1479147196842.jpg (26KB, 479x479px) Image search: [Google]
1479147196842.jpg
26KB, 479x479px
post a screen shot of your programming environment
>>
>>57606303
>non-determinist
stop this meme
>>
n-th for why does installing texlive take so fucking long and does anyone know a good beginner tutorial?
>>
Found this article. Think you guys will get a kick out of it.
https://astroengineer.wordpress.com/2010/04/07/a-curiosity-of-spirit-full-document/
>>
>>57606328
>>
>>57606319
and you're just trying to push your leftist view on everyone else here who consented to talking to me.
fuck off. you'll be dead soon anyway lol
>>
>>57606319
well, i won't
>>
How the fuck do I get curses to accept input longer than one character with python?
>>
>>57606340
seems interesting but its too long

tl;dr?
>>
>>57606387
you could continue to eat characters in a loop until enter is pressed or you have N characters if curses doesn't provide anything for you
>>
I know there's a word for this but I can't remember. Let's say I have a value of 5 and I'm trying to interpolate it to a random value like -100. How do I increment slowly without 5 if/else statements
>>
>>57606328
just terminator with vim and nerdtree in one window and a terminal in the other, would post a screencap but not on the machine I do programming on sorry
>>57606383
good
>>
>>57606368
oh shit, looking at this there are two rather major errors in the final model, oops
>>
>>57606338
https://en.wikibooks.org/wiki/LaTeX
I pointed my sempai to this when he needed a beginner tutorial.
He actually read through the entire thing, and now he's better at LaTeX than i am.
>>
>>57606441
what?
>>
>>57606441
You are not making sense.
>>
Are C++ and C structs identical?

Stroustrop's C++ Programming Language refers to structs as objects. "The size of an object of a structure type..." "It is not possible to declare new objects of a structure type..."

Here does he mean "object" in the general sense of just any kind of logical grouping & designation of data? Or does he mean "object" in the narrower OOP sense of some data coupled with functions that operate on that data/pass messages?

Will a C++ struct written in the equivalent C be the same size? (assuming same architecture, computer, etc)
>>
>>57606537
No, C++ structs are the same thing as C++ classes, not C structs, with the only difference being the default member visibility (public as opposed to private). PODs might have the same size but I'm not sure whether it's guaranteed or not.
>>
File: 1476548237840.jpg (40KB, 431x420px) Image search: [Google]
1476548237840.jpg
40KB, 431x420px
>Looking for an example of something i need to do in X language
>foo and bar examples

Dropped faster than my MIT application
What's the purpose of this foo and bar bullshit? It looks dumb and it doesn't make it any more practical?
>>
>>57606537
He means 'object' as in 'instance'.
>>
>>57606574
t. autistic individual
>>
>>57606574
https://en.wikipedia.org/wiki/Foobar#History_and_etymology
>>
This may be more of a web-dev question, but it I trust the advice of the people here as well.

It's 2016, soon to be 2017. I want to create a commerce application, I'll take orders and process them.

There needs to be a front end and a back-end. I can do that. The question then becomes:
What technology to use?
What language, what web framework?


I'm leaning towards node.js, instinctively. But I loathe javascript and the thought of programming in it worries me. So what do you think, /g/?
>>
>>57606500
Ill probably already be finished once that fucking thing is finally installed
>>
>>57606617
Python + Flask + SQLAlchemy + PGSQL on the backend.
Bootstrap on the frontend.
>>
>>57606574
It's idiomatic to use Foo and Bar to distinguish things from predefined syntax, in an example.

Sort of like how cryptography always have Alice and Bob communicating with each other.
>>
>>57606328

Chromebook
>>
>>57606574
i know right?
a, b, c would make me understand it better than foo bar. And I'm not even being sarcastic.
>>
File: GuaranteedReplies.jpg (167KB, 1680x1050px) Image search: [Google]
GuaranteedReplies.jpg
167KB, 1680x1050px
>>57606328
>>
>>57606441
recursion?
>>
If the plan is to write libraries that I can use from scripting trough ffi, is C the only viable option? How would languages like fortran or pascal compare with the easiness of calling the functions from the scripting language?
>>
>>57606641
I can do python.

But, why wouldn't I be using Django instead?
>>
File: 1461607709173.jpg (66KB, 499x499px) Image search: [Google]
1461607709173.jpg
66KB, 499x499px
>>57606669
No, i feel the same, it's just some dumb as fuck thing virgins do to feel special because they think they ((know)) the history of programming.
>>
>>57606613
this literally made me hate foo and bar
never ever gonna use this shit again
>>
>>57606705
you FUBAR
>>
>>57606441

interpolate? are you using that word correctly?
>>
>>57606693
Because Django is a fucking behemoth and if you're not already familiar with it you'd take a while to learn so I suggest Flask because it's minimal yet good and easy to learn (well documented). Unless you want to "future proof" your knowledge and work with Django in the future in which case I guess you could go for Django for the learning experience.
>>
>>57606713
TARFUN in your life
>>
YOU HAVE 10 SECONDS TO TELL ME WHAT MUSIC YOU'RE LISTENING TO WHILE PROGRAMMING
>>
>>57606780
melodeath
>>
File: schnell.gif (2MB, 480x320px) Image search: [Google]
schnell.gif
2MB, 480x320px
>>57606780
EUROBEAT DESU
>>
>>57606780
https://www.youtube.com/watch?v=XV7c6gSqPkc
and ignoring the host whenever he speaks
>>
>>57606780
Movie/video game/anime soundtracks
>>
>>57606735
I'm already familiar with django having made some apps with it already, and the whole "behemoth" thing is a serious exaggeration. I've also done Java web applications, so don't tell me about behemoths.

Flask is something I've toyed with only on the level of "hello world" and prototyping a dashboard application. Its cool and it werks, but I'm going to handle money, and that requires some safety.

What about tornado?
>>
>>57606780
 aplay /dev/urandom 
>>
>>57606811
best choice
>>
>>57606810
Tsunami is better
>>
File: out.png (2KB, 190x159px) Image search: [Google]
out.png
2KB, 190x159px
Does anyone have examples of big C programs that takes an input from a text file and produces an deterministic output?

e.g. take a list of 10000 words and print odd-sized words

i can't find anything from github
>>
>>57606780
https://www.youtube.com/watch?v=z-mxBDuRaZ8
>>
>>57606823
I dunno, seems pretty ded m8.
>>
>>57606780
death grips and anime ops
>>
>>57606810
>but I'm going to handle money, and that requires some safety.
Flask provides you with facilities for sanitization (so does SQLAlchemy and Jinja which are essential to Flask for database and templating respectively) but if you're already familiar with Django I'd say roll with it.

I'm indifferent about Tornado, haven't heard about it used much for web backends in Python (it's usually either Django or Flask that are mentioned) and I've not used it myself either.
>>
>>57606887
>e.g. take a list of 10000 words and print odd-sized words
that's fucking easy to do
>>
>>57606887
Why would you need a big program for that?
>>
>>57606887
>Big c program
>About 10 lines
Wew
>>
>>57606904
holy fuck this is so fucking shit
>>
>>57606929
no one said it wasn't
>>57606951
requirements
i just need programs with more than 200 lines
>>
>>57606887
you're confusing "big program" with "program doing big things"
>>
>>57606977
>more than 200 lines
what?
>>
>>57606977
here's an easy trick to make those 200 lines:
int
main
(
)
{
return
0
;
}
;

no need to thank me
>>
>>57606977
There's a bunch of smallish programs in an array of languages
http://benchmarksgame.alioth.debian.org/
>>
>>57606977
So you thought you'd rip something from github instead of doing your own homework.
Fuck you.
>>
>>57607024
lol
>>
>>57606780
https://www.youtube.com/watch?v=BuNBLjJzRoo
>>
>>57607034
are you fucking retarded?
>>
>>57606977
baka, just write a program that loops and outputs a case statement to a file of 200 lines, in psuedo code

for i = 0 while i < 200 i++
tofile ("case: " + i + "\n")
tofile ("print(\"Your number is\"" + i + ");");


then wrap that with int main() and you're good
>>
http://en.m.wikipedia.org/wiki/Grace_Hopper

Introducing Admiral Grace Hopper, who basically invented high level programming languages that are still used today.
>>
>>57606780
none
>>
>>57607024
i\
n\
t
m\
a\
i\
n
(
)
{
r\
e\
t\
u\
r\
n
0
;
}
>>
>>57607100
no she didn't, but she did make the first almost-compiler for one
>>
>>57606977
the program in your example would take, like 15 lines max
>>
>>57607100
first programmer was a woman, first compiler was written by a woman. and newfags say that crossdressing is a meme
>>
>>57607100
>a nigger
somehow i believe this is fake
>>
>>57607115
that's how you make 2000 lines
>>
>>57606340
Well it doesn't seem to be written by someone that knows a whole lot about physics. The comments on the faster than light information and such (the quantum shit) makes me doubt he has taken college courses on the subject as he claims. Because he presents a very basic misunderstanding as something that's potentially true.
>>
>>57606397
Fuck off you dumb ADHD kid.
>>
>>57607346
calm down reddít
>>
File: AMERICA.jpg (111KB, 1920x1200px) Image search: [Google]
AMERICA.jpg
111KB, 1920x1200px
What is the simplest way to stream video to a device file, so it can be read through V4L2? How about audio?
>>
>>57606328
i3 + Emacs
>>
>>57607158

>inb4 dozens of replies calling the enchantress of numbers a 'leftist meme'
>>
>>57606328
>>57607407
>>
>>57606887

http://git.savannah.gnu.org/cgit/grep.git/tree/src
>>
>>57606441
You interpolate.
You could Google that but basically:
(1-t)*a+b*t
Is linear interpolation.
Where t is a value between 0 and 1,a is your starting value and b is your end value.
When you pass 0 as t it returns a. When you pass 1 as t it returns b. If you pass a value outside the range you get a linear extrapolation. It should be very simple to understand even if you're bad at math (just look at the terms cancel when t = 1 or 0)
This works for a lot of things. You might also want to look into other interpolation functions.
>>
>>57606887
#include <stdio.h>
#define wnz while (*s
int oddword(char **w) {
char *p,*s=*w,c;
size_t n;
wnz&&*s<=' ')++s;p=s;wnz&&*s>' ')++s;
n=s-p;
if(n&1)c=*s,*s='\n',fwrite(p,1,n+1,stdout),*s=c;
return*(*w=s);
}
char s[BUFSIZ],*p;
int main(void){
size_t n;
while ((n=fread(s,1,sizeof s-1,stdin))){
if(n>1){
p=s,s[n]=0;
while(oddword(&p));
}
if(feof(stdin))return 0;
}
}

pipe a file into it
>>
>>57607423
hmm that's too big.
what i have to do is basically, grab a random program with more than 200 lines, written in C, and find bugs in them, inject bugs( fault injection),etc

basically run experiments in programs
>>
>>57607502
why are you posting this?

did someone ask you to post this?
>>
>>57607500
Oh and maybe you were looking for the word 'lerp'? Which is short for linear interpolation. Very often used by game programmers so that's what you get as results if you Google usually.
>>
>>57607158
Well, duh. Neither Ada nor Grace were crossdressers.

Although, from what i've heard about Ada's personality, she might have done so on occasion.
>>
>>57607530
find the bug (or rather, a potential edge case)
>>
>>57607100
>high level programming languages
She gets a lot of credit for a small invention when I'm sure she has done far greater things.

It's not high level in the sense that functional programming languages are. She made a program that takes opcodes and outputs machine code.
>>
>>57607446
That's not a good thing.
A good number of CL jobs are e-mail miners, or ID thieves.

So you either got mined yourself, made yourself a target, or applied to be an adult actress.
>>
>>57607513

So what you really wanted was a small C program.
>>
>>57607502
Wouldn't you want to reuse BUFSIZ instead of sizeof s?
>>
>>57607656
yeah
>>
is it true that I will become a better programmer if I get some Indian blood in me?
>>
>>57607713
"Murder is wrong"
>>
>>57607713
Yes. Find and cannibalise your nearest Indian.
>>
File: IndiaPrenatalHIV.jpg (57KB, 450x489px) Image search: [Google]
IndiaPrenatalHIV.jpg
57KB, 450x489px
>>57607713
No you're relatively likely to get aids though.
Just, don't consume other people's blood. Their knowledge is in the brain.
>>
Threadly reminder that you should not refer to the act of programming as coding. It is improper and makes you look like a 16 year old

You are a programmer, not a coder

Software Alchemist is GOAT
Developer is okay
Magician is okay
Software Magus is okay
Software Engineer is okay
Software Architect is okay
Computational Conjurer is okay
Information Systems Sorcerer is okay
Purveyor of Programs is okay
Code Guru is questionable

Archmage is reserved for only the most senior of programmers

Writing in HTML and CSS is not programming, therefore it should be referred to as designing
>>
>>57607749
Is it though? We're talking about Indians here, not real people.
>>57607750
I'll try. You should find and cannibalize the nearest American to help with that spelling disorder.
>>57607767
Fuck... Should I just consume the brain then?
>>
>>57607786
can you kys
>>
>>57607823
I don't think he wants to kiss you
>>
>>57607810
>consume the brain
Well maybe that'd help if you're a stupid as you are.

Consuming the brain is not the way to extract information. You kidnap them and question them for the secrets to their programming excellence. Torture optional. Mixed reports on the efficiency of that.
>>
File: 7BIlFccT.jpg (17KB, 400x327px) Image search: [Google]
7BIlFccT.jpg
17KB, 400x327px
>>57607810
>spelling disorder
Hey fuck you fatty yank wank, you're the ones who butchered the Queen's English.

>>57607830
>pic related, hard
>>
>>57607786
Threadly fuck off.
>>
>>57606887
>>57607686
Here is a small text-processing program that I wrote a little while ago for someone in /dpt/:
http://pastebin.com/y1wiPRBR

It counts the word frequencies in a text file and prints them in alphabetical order.
>>
>>57607839
I would assume that's the most efficient way to do it but I don't care about that. I have a lot of Indians at my disposal so if consuming the brain would give me even 5% of what questioning them would, I'd go for that.
>>57607846
But I'm not even American. I'm Australian but I still use proper English and not the butchered version of it you """use""" on your shitty islands.
>>
Spent the afternoon writing an implementation of cdecl (pic related). I'm interested in writing my own C compiler so I think this is a good first step in terms of improving my understanding.

Would appreciate input from anyone with similar experience..
>>
>>57607879
>colonist getting uppity
Charles, deploy the nukes.
>>
>>57607879
Keep good data on how much you learn/brain mass.
Also have them take tests to measure how information dense they are.

There's very little information on this type of learning.
>>
>>57607901
Colonists have been uppity since 1774
>>
>>57607901
You don't even have them mate. They're fake
>>57607911
I'll try. I have some people I know in the meat industry who are willing to help out with processing them. I've set up a fake company to lure them in under the pretense of hiring them for programming jobs.
>>
Programming is deprecated.
>>
>>57607938
>>57607952
>>
>>57607956
This! Coding is all the rage these days!
>>
>>57607952
>calling others nukes fake east of the Pacific
You're playing with fire here bushman.
>>
>>57607984
>east
West.
Fuck.
Ruined.
>>
>>57607882
I guess /g/ is more interested in shitposting than programming. disappointing...
>>
>>57607999
we all only know haskell
>>
>>57607984
Every single nuke is a fake. I've disarmed them all a few weeks ago.
The only working one is somewhere in Israel. Couldn't get to that one for some reason
>>
>>57607882
Nice anon but why bother with this when you could be learning something useful? Like how to optimise code, for real.
>>
>>57607882
What do you wanna hear?
Good job? Congratulations? Pat yourself on the head?
>>
>>57608052
>optimize
seems like you made a typo anon
>>
a 1 night project for funzies
https://github.com/majestrate/stop-the-bullshit
https://www.youtube.com/watch?v=PJgiOOGpytE
>>
>>57607882
hi jon balls
>>
>>57607882
Second to last case is a bit weird right? It says 'a' when the array is clearly a plural.
>>
>>57608078
Oh no you're correct. How will I ever redeem myself?
>>
>>57608055
As I said input from other anons who have done similar tasks and are interested in compiler development. /dpt/ is a friendly programming thread and your rudeness is not appreciated.
>>
>>57608078
programming is british so the anon is actually correct.
>>
>>57608238
But this is an American site. Use English here please.
>>
>>57608259
> this is an American site
>>
>>57608264
This is an American/Japanese site. Use American or Japanese here and please refrain from using your shitty language.
>>
>>57608293
לא
>>
File: shitwizzle.png (94KB, 1680x1010px) Image search: [Google]
shitwizzle.png
94KB, 1680x1010px
>>57606218
writing an optimization cycle for a machine learning routine.
I defined the "script language" that the program accepts as a scheme for the data flow graph and have implemented the interpreter.

>>57606328
closed everything personal and job-related and navigated into a third party package.
>>
>>57608238
>>57608259
I'm from Sweden, taught brittish English in elementary/middle school and learned most of my English from British literature and American media.

But optimize was autocorrected to optimise because I'm using SwiftKey keyboard with UK language. So when I write colo it completes to colour.

I didn't even consider the optimise to be a valid spelling though because I generally write optimize.
>>
>>57608322
>closed everything personal and job-related and navigated into a third party package.
but i wanted to see those
>>
>>57608322
Please tell me that you don't actually use your editor like that
>>
>>57608312
These look like Jewish runes. Please at least stick to a Latin alphabet if you wish to poop in this thread and taint it with your "language"
>>57608324
British is just so bad. Please learn American and tell your shitty government schools to teach it instead. And try using the US layout. It really is a lot better since it isn't British "English"
I'm Australian and I use a fork of American with a few Australian words like mate, cunt etc added in.
>colour
This just makes my head hurt. Please stick to the correct spelling which is "color"
>>
>>57608346
just imagine a project tree full with started and unfinished projects, some half assed attempts at fulfilling deadlines by writing C++ Wrappers for Python programs and the occasional "1 in a 100 Project that you actually like" like mentioned machine learning thingy
>>
>>57608387
Well in line with my country's political leanings I tend to mix it up :^)
>>
>>57608381
But I am. why?
>>
>>57608322
This colour scheme is a joke right?
>>
>>57608421
Everything about that literally couldn't look more disgusting
>>
>>57608426
No.

>>57608439
Looks okay to me.
>>
>>57608322
ah yes dark blue on dark grey, my favorite
>>
>>57608421
>shit colorscheme
>1 (ONE) space indentatation
>windows 7
>eclipse

just kys my man
>>
>>57608322
That color scheme couldn't be worse.
>>
i don't even know what to do right now.
my options are - play a game I've recently regained interest in, watch an anime (don't even know which one) or read a little before I get bored and fall back to the two previous options
is there a program to test this?
>>
>>57608448
>Looks okay to me.
are you colorblind?
>>
>BOX2D HELP PLEASE

I have a square rotating at 2f.

I also have a sprite with the same origin rotating at 2f.

They are slightly out of sync by a few degrees every second.

How do I fix this?
>>
>>57608494
from random import choice

choices = ["play game", "watch anime", "read"]

print (choice(choices)
>>
>>57608499
I just looked at it on my phone and I think my screen has a different way to handle contrast. The blue seems off, but I don't know why.

>>57608455
>windows 7
>eclipse
name a reason to change one of this.
>>
>>57608509
lobeSprite.setRotation(rotaryBodyTop.getAngle()*360/(2*(float)Math.PI));

lol, dw, i fixed it
>>
>>57608559
print(__import__('random').choice(['play game', 'watch anime', 'read']))
>>
File: Bert2000's.jpg (12KB, 368x298px) Image search: [Google]
Bert2000's.jpg
12KB, 368x298px
Im studying CS and may have realized recently that I would hate programming for 8 hours a day. I'm good with 2 or maybe 3 or 4 hours a day.

Do I drop out now or wait til I'm 30 and then kill myself
>>
>>57608581
Kill yourself right now
>>
>>57608579
nice

learned something today
>>
>>57608581
get a job that involves something else like project management.
Chances are you will waste half a day on useless shit like condensing emails to power point presentations and act as the groups answering machines.
>>
>>57608559
>>57608579
now run it for me please :)
>>
File: k.png (12KB, 584x97px) Image search: [Google]
k.png
12KB, 584x97px
>>57608655
:)
>>
File: k.png (16KB, 1135x363px) Image search: [Google]
k.png
16KB, 1135x363px
>>57608655
>>
>>57608669
no...
i don't wanna work right now.
use the other options :(
>>
>>57608685
thanks man!
do 2 more i have a lot of time left for everything.
so I can determine the order
>>
File: 123.png (22KB, 1060x269px) Image search: [Google]
123.png
22KB, 1060x269px
>>57608703
>>
>>57608732
thanks! :)
i'll go read now and then play 2 games. or just 1 game x2. haven't decided yet
>>
File: fix_.png (99KB, 1680x1010px) Image search: [Google]
fix_.png
99KB, 1680x1010px
>>57608499
>>57608493
>>57608454
>>57608426
better?
It looks gay now, I hate pastel.
>>
>>57607585
how so?

basically i just apply to jobs by cl through email so it gets the most recent postings and sends my resume then i sit back programming while applying.
>>
>>57608762
It's actually readable, so it's infinitely better.
>>
>>57608732
print('\n'.join([__import__('random').choice(['play game', 'watch anime', 'read']) for _ in range(3)]))


step it up m8 all of ur python should be one liners
>>
File: 1343606256089.jpg (29KB, 551x412px) Image search: [Google]
1343606256089.jpg
29KB, 551x412px
>>57608579
fuck off you python hobgoblin
>>
>>57608806
in this case, yes

bigger programs no

:)
>>
File: 1343611758492.jpg (27KB, 400x399px) Image search: [Google]
1343611758492.jpg
27KB, 400x399px
>>57608790
>>
>>57608845
>>57608806
fuck clicked wrong post
>>
>>57608835
>:)
>>>/r/eddit
kys painfully.
>>
File: 1343737361740.jpg (7KB, 213x237px) Image search: [Google]
1343737361740.jpg
7KB, 213x237px
>>57608806
>>
>>57608862
:)
>>
>>57606218
http://shmuplations.com/mario64/
fun interview with miyamoto and some of the programmers on sm64
>>
>>57608862
shut up virgin
>>
>>57608923
"virgin" on /g/ should be wordfiltered to "muh nigga"
>>
>>57608862
>kys
found the 14 year old
>>
>>57606285
I have an idea that would be more efficient than what you proposed. Assuming we only have lowercase characters in this example:
bool isRotation(string original, string rotation)
int characterFrequency[26] = {0}; //Indexes a-z, keeps track of how many of each char exists in original string
foreach char n in original
characterFrequency[n - 'a']++
foreach char n in rotation
if(!characterFrequency[n - 'a']--) //We're have no more of that character
return false
return true;


Unless I misunderstood what you meant by rotation. If it is what I think it is then all rotations of 'abc' would be:
{ 'abc', 'acb', 'bac', 'bca', 'cab', 'cba' }
>>
File: raytracing.png (335KB, 802x1878px) Image search: [Google]
raytracing.png
335KB, 802x1878px
I'm working on a GPU ray tracer for a school assignment. I haven't added support for textures yet so right now everything is just a gray scale.

Pic related.
>>
>>57609235
In your school, do they give you some template code, or do you have to code it from scratch?
>>
>>57609177
"bac" is not a rotation of "abc"; it is only a permutation
Rotations are a subset of permutations, for which the ordering holds (mod length)
>>
i'm making a game. something like GTA V but happening in the near future. And of course better, with more advanced physics, prettier graphics and such. It's not an easy task but i'm very optimistic
here's my code so far:
int main()
{

}
>>
>>57609247
They provided some template code but it was complete spaghetti and full of archaic Microsoft bullshit so I reused an old project I had for setting up the window and binding DirectX to it.
>>
>>57608581
Nobody "programs" 8 hours a day at work. There are lots of other things to be done, like bug fixing, bug replication, writing specs, going to meetings, talking to colleagues, talking to managers, helping QA/project managers to understand how some functionality works, understanding the client/business requirements, wasting time online, etc. It's rare to spend 4 hours a day just "programming".
>>
>>57609266
Looks great, but open world games should have the opening brace on the same line as the declaration
>>
>>57609266
very impressive. You're likely to get a lot of hate here but I'd like to see anyone present a game as optimised as yours is.
>>
>>57609314
>open world games should have the opening brace on the same line as the declaration
Lol no.
>>
>>57609266
Maybe start with determining the return values from main. Like 0 will mean you won the game, 1 means you got killed, 2 means perhaps something else, and so on. You'll need to return something and you seem not very busy right now so I think it's a good time to at least get that settled.
>>
>>57609266
thanks for making it open source
>>
>program all weekend
>lay down
>neck is fucked up
How do you program on a laptop without murdering your neck? My neck is forward when I program. If I try to keep it straight ahead and look down with my eyes, then I'd be straining my eyes.
>>
>>57609336
It's true, I've worked in game development for 10 years as lead engine developer. Open world needs same-line braces, while linear games need next-line braces.
>>
>>57609249
Ah, well in that case perhaps something like this:
bool isRotation(string original, string rotation)
int len = orignal.length();
for(int startPos = 0; startPos < len; startPos++)
bool returnValue = true;
int indexOrignal = startPos;
int indexRotation = 0;
while(indexRotation < len)
if(original[index] != rotation[indexRotation])
returnValue = false;
break;
indexRotation++;
indexOriginal = (indexOriginal + 1) mod len;
if(returnValue == true)
return true;
return false;


So if we have the orignal string 'abcdef' and rotation 'defabc' we will compare the following:
'abcdef' == 'defabc'
'bcdefa' == 'defabc'
'cdefab' == 'defabc'
'defabc' == 'defabc' //Match!
>>
>>57609314
>>57609318
>>57609354
>>57609374
thanks for the kind words and tips, guys. with this much motivational speech i'll finish the game in no time
>>
>>57609451
Silly me, I just realized I do exactly what he was trying to avoid. Creating all the rotations of "original".
>>
File: sit.png (4KB, 640x400px) Image search: [Google]
sit.png
4KB, 640x400px
>>57609380
I sit like this, back has been fine for years. Used to hurt when I sat perfectly straight up because my shoulders were too tense, and when I was younger I slouched in my chair and looked upwards too much causing neck problems.
>>
>>57609451
bloated c
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Command_Line; use Ada.Command_Line;
procedure Rot is
S : String := Argument(1);
Comp_S : String := Argument(2);

begin -- Rot
for I in Comp_S'Range loop
if(Comp_S(I..Comp_S'Last) & Comp_S(Comp_S'First..(I-1)) = S) then
Put_Line("Done");
end if;
end loop;

end Rot;
>>
I admit this is homework, but I'm asking for a conceptual explanation, not a finished product
I have to write a game where the player can change between different forms, and the provided headers (which I can't change) have these fields in the Game class definition
Character **m_character; // data structure holding all available character forms
Character *m_currentCharacter;//pointer to current form

I have to populate m_character on initialization, but I have no idea what kind of data structure could or should be used to store the instantiated forms. I understand how double pointers work/what they are, but I don't get why m_character is one instead of being a vector<Character>
what am I missing?
>>
File: 1422069034241.jpg (7KB, 211x290px) Image search: [Google]
1422069034241.jpg
7KB, 211x290px
emacs or pico for writing c?
>>
>>57609733
vim
>>
File: Capture.jpg (254KB, 1752x968px) Image search: [Google]
Capture.jpg
254KB, 1752x968px
>>57609742
>vim
not with this website I'm not
>>
What's the best language for someone who is stoned out of his mind 24/7?
>>
>>57609764
you mean the ugandans? who cares, it's one line of text when you start up vim without calling it to edit or create a file
>>
>>57609764
What's this animal on your image called? I forgot.
>>
>>57609779
probably something that doesn't require brain cells, so php
>>
>>57609801
i was thinking c# or c++ lol
>>
>>57609788
I have africans shoved down my throat enough on facebook; I don't need it on my text editor.
>>
>>57609779
Fuck off stoner
>>
>>57609695
some dummies prefer c raw arrays over c++ vectors, I guess.
>>
>>57609821
No!
How about YOU fuck off?
your probably neurotypical as well lol
>>
>>57607502
>c
>readable
pick one
>>
>>57609858
C is literally the best
>>
>>57609858
That's obviously a case of someone purposely writing shitty code.
>>
should i buy the art of unix programming? i'm kinda just bored
>>
REPOSTING FROM LAST THREAD:

next year I plan on doing atleast one project a month to learn python here's what I have so far
encrypted facebook client
encrypted server/client chat service
countdown time using config files
something to calculate accurate implied probability

anything else to add? also is there any negative caused by having a large number of repos on github? I mean smaller things I plan on just putting in my scripts folder but if all goes well I should have like 20+ repos by the end of next year, will this reflect badly on me?
>>
>>57607502
in haskell, this is just
import System.Environment
import System.IO

main = do
[f] <- getArgs
withFile f ReadMode $ \h -> do
c <- words <$> hGetContents h
mapM putStrLn $ filter (\x -> odd (length x)) c
>>
>>57606780
a nice vaporwave 2 hour mix on repeat
https://www.youtube.com/watch?v=ea_UOPzuyZU
>>
>>57609941
you're a fucking pleb
change the last line to
mapM putStrLn $ filter (odd . length) c

or better
c <- filter (odd . length) . words <$> hGetContents h
mapM putStrLn c
>>
>>57607686
here's a barebones snake
you need ncurses
http://0x0.st/_LL.tar
>>
>>57609864
denial is a bad thing
>>
>>57609451
Am I missing something?
Why not sort both arrays and check if the result is the same?
>>
File: karlos.jpg (19KB, 500x367px) Image search: [Google]
karlos.jpg
19KB, 500x367px
>>57609864
but can you say that C is OBJECTively the best?
>>
>nothing using the reddit enhancement suite
>>
>>57610027
Yes. Denying that C is literally the best is a bad thing.
>>57610050
its literally the best!
>>
File: die.png (211KB, 664x808px) Image search: [Google]
die.png
211KB, 664x808px
>tfw the code is shit
>the project is shit
>the documentation is shit
>the uml is shit
>tfw don't care anymore
>>
>>57610059
huh?
>>
>>57610062
how did you post this then?
stop lying on an anonymous forum you piece of shit
>>
>>57610061
please do this in c
main = interact id

if you're retarded and don't know, the above is unix's cat in haskell
>>
>>57610077
I'm stuck in a loop of c# shittery, death isn't a release.
>>
>>57609982
Why not just check the whole thing onto one line?
>>
>>57610121
too unreadable
>>
>>57610113
you deserve it then.
no human will ever empathize with you
>>
>>57610081
*does this in c*
your point?
>>
>>57610158
I didn't write it
>>
>>57610081
?? it's not you fucking idiot
>>
>>57610121
main = getArgs >>= \f -> withFile (head f) ReadMode $ \h -> (filter (odd . length) . words <$> hGetContents h) >>= mapM putStr
>>
>>57610167
*criticized your c*
nothing personal, "c"id
>>
>>57609929
make a program to tell if a number is odd or even
>>
>>57610081
using unix examples against c is really stupid
>>
>>57610195
Why not just use readFile?
>>
>>57610280
example?
>>
>>57609864
Nope >>57609683
>>
>>57610301
run = mapM_ putStrLn . filter (odd . length) . words
main = getArgs >>= (readFile.head) >>= run
>>
>>57610397
Yep >>57609864
>>
is "it just works" a valid way to explain my code to my professor
>>
>>57610397
>>57610435
Good points on both sides
>>
>>57610459
does it work?
>>
>>57610465
it works
>>
>>57610471
then i guess
>>
>>57610494
you guess what? this isn't a fucking game
>>
TV guy here again. I managed to get the webcam to work, but only in black and white so far (Y'UV to RGB)
>>
File: rxP35JW.jpg (173KB, 1200x735px) Image search: [Google]
rxP35JW.jpg
173KB, 1200x735px
How could I get this to work? (x is a string btw). I just want it to print one x, then two x's, then three x's. Is there a way of doing this without a constructor?

    for(int i = 1000; i <= 3000; i += 1000){
a = i / 1000;
full = a * x;
cout << full;
}
>>
>>57610683
I forgot to type in endl, but the goal output would be something like:

X
XX
XXX
>>
>>57610459
>explain my code to my professor
I'm a hobbyist, do people at college and shit have to explain there code? can they not just comment on it? I mean I guess it makes sense to make sure people understand the code and didn't just steal it but still I would have thought comments would be enough
>>
>>57610664
>>
>>57610683
cout << "X\nXX\nXXX" << endl;
>>
>>57610683
for I in 1..3 loop
Put_Line(I*'x');
end loop;
>>
File: oh no.jpg (3KB, 125x125px) Image search: [Google]
oh no.jpg
3KB, 125x125px
c noob here. what is wrong with this way of forking?

int producerId, consumerId, parentId;
parentId = getpid();

producerId = fork();
if(getpid() == parentId) {consumerId = fork();}


I'm trying to create two child processes and note their id's for later conditional statements like if(getpid() == consumerId).
>>
File: image002.png (2KB, 241x32px) Image search: [Google]
image002.png
2KB, 241x32px
>>57610664
>>57610702
I'm also working on a web crawler that takes random streams on the internet and forwards them to this TV network. What would /g/ want to see (assuming IP laws allowed it)?
>>
>>57610683
what's wrong with
int lines=5;
for(int i=0;i<lines;i++){
for(int q=0;q<i;q++){
cout << "X";
}
cout << endl;
}

and what's with the 1000 stuff
>>
>>57610683
...why are you incrementing by 1000? Why not just do a for loop from 1 to 3.

for (int i = 1; i <= 3; ++i) {
for (int j = 0; j < 1; ++j) std::cout << X;
std::cout << '\n';
}
>>
>>57610777
>>57610816
The 1000 stuff is because i'm nesting a few for loops inside of each other, so I'm using it because I'm fucking stupid.
>>
>>57610816
Why are you incrementing by 1? Why not just bitshift.
 for (int i = 1; i <= 4; i <<= 1) {
for (int j = 0; j < 1; ++j) std::cout << X;
std::cout << '\n';
}
>>
>>57610904
>The 1000 stuff is because i'm nesting a few for loops inside of each other, so I'm using it because I'm fucking stupid.
why are variable names not enough for you to keep track of what's what?
it's not like you're printing the index or anything
>>
File: code.png (80KB, 1366x768px) Image search: [Google]
code.png
80KB, 1366x768px
Am I a programmer now?
>>
File: wew.png (115KB, 1366x706px) Image search: [Google]
wew.png
115KB, 1366x706px
>>57610946
lmao, that was one of the first things I wrote when starting to program, in bash
almost forgot about that
>>
let me see if i understand this right: in haskell, even things like imports (e.g. matrix), you don't alter. like if you do setElem 0 (1,1) mymatrix, it doesn't actually alter mymatrix right? it's just a function that returns a matrix? always?
>>
File: code2.png (95KB, 1366x768px) Image search: [Google]
code2.png
95KB, 1366x768px
>>57611006
Now I'm truly a programmer
>>
File: flag-2016-11-20_20.22.36.webm (3MB, 1920x1080px) Image search: [Google]
flag-2016-11-20_20.22.36.webm
3MB, 1920x1080px
What kind of math do I need so that I can replace the white rays with warped circles?
>>
File: 1478046796106.png (307KB, 635x590px) Image search: [Google]
1478046796106.png
307KB, 635x590px
>>57606218
Whelp, just wasted the last eight hours trying to get a simple XOR neural network to converge and utterly failing

Is a two neuron wide network that's between 2-5 layers deep not enough?
>>
rate my optimizer
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

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

FILE *fp;
FILE *new_program;
char argument[64];
char compiler_argument[64];
char output[1035];
char *temp_file = "~hopefully_nothing_important.c";

if(argc < 1){
puts("No argument given");
exit(-1);
}

sprintf(argument, "./%-61s", argv[1]);
if ((fp = popen(argument, "r")) == NULL) {
puts("Failed to run command");
fclose(new_program);
pclose(fp);
exit(-1);
}

if(access(temp_file, F_OK ) == 0){
puts("File exists");
pclose(fp);
exit(-1);
}

if ((new_program = fopen(temp_file, "w")) == NULL) {
puts("Failed to open new");
pclose(fp);
exit(-1);
}

fputs("#include <stdlib.h>\n#include <stdio.h>\nint main(){\n", new_program);

while (fgets(output, sizeof(output)-1, fp) != NULL) {
fprintf(new_program, "puts(\"");
for(int i = 0; i < strlen(output); i++){
if(output[i] == '\n'){
output[i] = '\0';
break;
}
}
fprintf(new_program, "%s", output);
fprintf(new_program, "\");\n");
}

fputs("return 0;\n}", new_program);


fclose(new_program);
sprintf(compiler_argument, "gcc %s -o %-19s", temp_file, argv[1]);
system(compiler_argument);
remove(temp_file);
pclose(fp);

return 0;
}
>>
>>57611244
quantum physics
>>
>>57611490
shit
>>
>>57611340
nope. your mom's pussy is about 12 deep and that wasn't even enough to make me cum. keep trying
>>
How can I stop using so many conditionals?
>>
>>57611700
if it's going to be 12 deep that implies it's also pretty loose, in which case it's no surprise it would feel like nothing, the tighter the better lad
>>
>>57611685
>>57611698
>>57611700
Thank you for gracing our thread with your quality posts
>>
>>57611717
this isn't "our" thread you retarded commie
this thread is my private property.
now get the fuck out.
>>
>>57611716
what if her Z dimension is much larger than a normal human's and affords her a deep pussy

>>57611717
y-you too
>>
>>57611754
it would be very painful
>>
>>57611768
for you
*crashes this thread with no survivors!*
>>
File: 1459120813169.jpg (96KB, 940x625px) Image search: [Google]
1459120813169.jpg
96KB, 940x625px
>>57611738
>>57611754
>>57611768
>>57611785
>>
File: 1478671756241.png (3KB, 154x67px) Image search: [Google]
1478671756241.png
3KB, 154x67px
>>57611800
>>
>>57611490
It's OK anon, I thought it was funny
>>
>>57611244
trigonometry
>>
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
>>
File: Portal culling.png (8KB, 674x577px) Image search: [Google]
Portal culling.png
8KB, 674x577px
Well damn guys, sorry to ask this again, but I absolutely cannot fucking figure it out.
In Unity, how can I make a camera only render through a given area? I need the fragments rejected BEFORE it renders them, for performance reasons.

I can't figure out any way to do a stencil test on the camera itself, only on individual surface shaders... which isn't very useful, seeing as I can't expect users to apply a custom shader to literally everything in the entire god damn scene.
Why doesn't unity support raw GL calls? This would be so easy if I could enable a stencil test during the camera's rendering.
>>
File: phystals.webm (1MB, 605x373px) Image search: [Google]
phystals.webm
1MB, 605x373px
>>57611950
Oh, also:
A demo of what IS working, to show that I'm not an idiot begging for tutorials.
>>
>>57607407
My nigger
>>
>>57606218
do you guys ever have days where you'd rather look at the theory of how your backend works than actually try debug code for your file system?
>>
>>57611950
try in >>>/vg/agdg they're more familiar with unity
>>
>>57612016
I've asked there as well but they sometimes get caught up in weird drama shit and/or don't know a ton about low level rendering stuff.
>>
>>57612030
there's this:

https://alastaira.wordpress.com/2014/12/27/using-the-stencil-buffer-in-unity-free/

if you don't want to render to the stencil buffer then you'd want a scissor test instead but unity doesn't seem to give you access to it
>>
>>57612250
Right, but that doesn't fix the main issue I'm having, unfortunately:
That method only works for surface shaders. If I wanted to optimize using it, then every single shader in the entire game would have to have that stencil implementation or else it wouldn't optimize.. you can't execute shaders on the camera during prerender or during the render itself which is a real travesty.
>>
i think i made a mistake when trying to clone my prefrontal cortex via programming it from scratch
it escaped after compilation and is now somewhere in this thread
>>
File: just.jpg (40KB, 640x480px) Image search: [Google]
just.jpg
40KB, 640x480px
>>57606218
I'm so fucking mad right now. I've been working on a driver all day and I JUST realized that using a stack isn't safe in this situation because the pushes might not be in the same order as the pops since multiple threads call the same driver.

I was getting weird errors, but now I realized I basically have to make my own local heap in the driver.
>>
What's the easiest way to crash my computer with no survivors using C?
>>
>>57612833
#include <stdlib.h>

int main()
{
system("rm -rf ~");
}
>>
>>57612863
/* not ~ right?
>>
>>57612872
I assume that your program won't have the permissions to fuck up the entire filesystem hierarchy, but you may as well do as much damage as you can.
>>
>>57612863
NO! This will break my system! I just want to crash it with no survivors.
>>
>>57612881
im pretty sure calling panic() will do that
>>
oh maybe not anymore. I but think if you called panic like a million times you might get a real kernel panic eventually
>>
is f# a meme or not
>>
>>57613008
*rolls a dice*
nope
>>
>>57613008
yes
>>
>>57613008
maybe
>>
>>57613057
>>57613063
as a counter to these posts i must write: no
i have done multiple studies and the answer is "no" with 99.99999% probability
>>
>>57613087
probably
>>
>>57613008
I hope so, otherwise I may be in trouble here
>>
>>57613008
idk I use C# and just recently ported some of this tool to F# and it cleaned up a lot of ugly syntax and makes the source much easier to understand. It's a decent tool to have if you work with the runtime for sure.
>>
>>57613110
here's the takeaway: all good languages are also memes
>>
File: 1415995482008.jpg (27KB, 640x477px) Image search: [Google]
1415995482008.jpg
27KB, 640x477px
Let's say i need to make a map interface that has the location and tech details of some of my work's equipment.
Now this mapping service needs to be a) free, b) preferably Desktop and Mobile friendly (more emphasis on Desktop though) and c) all the data must be local ie not on Google's server.
What are the options?
I suppose I could pull map data from OpenStreetMaps, and put on some kind of overlay, but what satisfies the above criteria, considering that we'll probably used a lot of data?
>>
>>57613137
one man's meme is another man's treasure?
>>
>>57613110
C# is absolutely disgusting, doesn't take much to improve it, and you probably could have written it cleaner in C# anyway

>>57613137
>this kid in charge of determining which languages are good
>>
>>57613187
I didn't say F# was good, only that good languages are memes.
>>
I have made a certain pact with God himself and I am allowed to remove one language from existence. Which one should I choose?
>>
>>57613258
English lol
>>
>>57613258
haskell
>>
>>57613283
I don't even know what would happen then. That would probably create a lot of logical inconsistencies which would have to be solved by changing around major events in history.
>>57613284
I'm thinking C#
>>
What can you do with C? As someone who's intermediate.

I've checked elsewhere and everyone talks about writing drivers and operating systems. That shit sounds awesome but way out of my league.

After you read your first book on C then what?
>>
>>57613258
3SAT
>>
>>57613307
Learn c# for job
Learn c++ for memes
>>
>>57613303
Do Latin instead for even more logical inconsistencies and reality changes.
>>
>>57613326
Might as well just do Proto-Indo-European just for the memes.
>>
hahah! it worked
just looked it up and this language doesn't even fucking exist anymore!
LMFAO
>>
>>57613348
holy shit what did you do to esperanto?
>>
>>57613362
no mate...
i destroyed an ugly fucking language.
it was even worse than C# but we don't have to worry about it anymore.
>>
New thread: >>57613373
>>
>>57613366
how is c# ugly when c++ is a literal mess?
>>
>>57613399
It was even worse than both of them combined mate
it was fucking ... i can't even think of a word to describe it but i'm glad it's in the past
i would totally erase C++ as well if I could contact Him again
>>
>>57612833

Just make a forkbomb.
Thread posts: 342
Thread images: 46


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