[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 | Click for more| Home]

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: 369
Thread images: 30

File: 1422922224663.jpg (479KB, 2500x1000px) Image search: [iqdb] [SauceNao] [Google]
1422922224663.jpg
479KB, 2500x1000px
What are you working on?
>>
>>46450870
A tetris clone with pygame/python...

I can't do the clear line white flash still...

(It's almost done, only thing missing is the problem above.)
>>
>>46450838
how would i have made it smaller i.e. not relied on 100 assignments

all it does is add a series of numbers' squares or cubes

no fancy equations allowed
>>
did a thing in c to make sure a loop has a minimum frequency of 1 iteration per second. it seemed simple but ended up being a little involved.

http://pastebin.com/NpdF35d7
>>
>>46450870

Anyone got decent captcha generation libraries? I want to self-host it.
>>
>>46450931

>if(x >= 1)
>sleep(x);
>>
File: 1423283679855.jpg (62KB, 377x602px) Image search: [iqdb] [SauceNao] [Google]
1423283679855.jpg
62KB, 377x602px
>>46450908
Make methods for the red sections. That would clean it up a bit. You could also use more descriptive variable names, but other than that, it looks fine.
>>
>>46450931
>>46450949

oh and

>else sleep(1);
>>
>>46450949
yeah i know but a.) i wanted it to be able to handle less than one second for a fixed freq and b.) if the task being run through the loop took more than 1 second it should not pause for a hole nother second.
>>
File: oo.jpg (15KB, 400x299px) Image search: [iqdb] [SauceNao] [Google]
oo.jpg
15KB, 400x299px
>>46450964
thanks anon :DD
>>
>>46450990
Technically, I should have said "function" and not "method" in my post above.
I'm not sure how new you are, so if you had googled "methods in Python" rather than "functions in Python" you would probably have gotten slightly confusing results.
>>
>>46450972

Yeah, it gets a little bit more involved when that's what one wants to do.
>>
File: 1422804734289.jpg (27KB, 351x351px) Image search: [iqdb] [SauceNao] [Google]
1422804734289.jpg
27KB, 351x351px
An automated theorem prover modelled on human methods of performing algebra.
>>
>>46450931
Here's the opposite of that.

import Foundation

// Dispatch loop
dispatch_apply(10000, dispatch_get_global_queue(0, 0)) {i in
NSLog(String(i)) // Thread safe printing
}
>>
stupid question but can you have a java and C compiler in your environment variables at the same time? im making the transition to C because this year at uni we study C instead of Java
>>
>>46451171
yes you can
u trollin?
>>
>>46451177
no but i did say stupid question

how does the compiler distinguish between java and C in that case? syntax?
>>
>>46450870
How much harder is upper division CS compared to lower division? I'll be transferring to a university soon.. Sort of scared that I'm not actually prepared.
>>
>>46451299
At least at my university, they feel about as hard as the hardest lower division courses I took, but I think it's because you're more prepared for it. A lot of kids just coast by until the upper div classes without learning much and then get slammed when shit gets real. I didn't really learn much in my first couple CS classes because they were so basic and boring, and then when I got to data structures I had to teach myself a lot to catch up. Now I'm taking all upper division CS classes and I would have been so fucked for all of them if I didn't have the last quarter's experience under my belt.

tl;dr It's about the same if you actually learned things in lower div
>>
>>46451346
Yeah I took data structs my first year and now I'm pretty much done with lower division CS work... Just doing math + chem + general eds until I go to upper division next year.

I'm probably rusty as fuck and need to refresh this summer. Thanks
>>
>>46451346
Yeah I'm a biology major and double minor in chemistry and computer science. I graduate this semester, and made the decision to switch to a CS career too late, so I would've had to stay 2 more years to finish a CS major. I'm self taught except for the classes im taking for my minor. Gonna be scary as fuck applying for software engineer positions.
>>
File: image.jpg (25KB, 280x280px) Image search: [iqdb] [SauceNao] [Google]
image.jpg
25KB, 280x280px
Does anyone else cringe when people use code as a verb?
>>
>>46451402
no
>>
>>46451437
you must be an epik coder
>>
>>46451059
Free functions are methods of the module as of py3
>>
>>46451481
>not coding apps
lol, what a fag
>>
>>46451402
not at all
>>
File: helpme.png (918KB, 1366x768px) Image search: [iqdb] [SauceNao] [Google]
helpme.png
918KB, 1366x768px
Hey /g/uys, can you help me with the pic related?
i want the frame to display in the center of the screen, and without the frame being displayed in the top-left corner.

i am doing this in java and i have set
>mainFrame.setLocationRelativeTo(null);
>>
>>46451558
Go to bed Rahul.
>>
>>46451558
>Rahul
not me!
>>
>>46451567
>go to bed
>meme
nice way of saying you don't know how to code.
you should go to bed.
>>
File: 1398285632924.jpg (81KB, 800x669px) Image search: [iqdb] [SauceNao] [Google]
1398285632924.jpg
81KB, 800x669px
>>46451580
Oh. He has the same background as you. And runs un-Authorized Win8.1 in parallels on his Macbook. Sorry bro.
>>
>>46451558
setLocation(x + box_width/2, y + box_height/2)
>>
>>46451602
thanks mate.
what package do i need to import for box_width?
>>
>>46451600
>runs un-Authorized Win8.1 in parallels on his Macbook
Apple isn't going to shit on you with some 1366x768
>>
File: 1395415450086.jpg (53KB, 475x533px) Image search: [iqdb] [SauceNao] [Google]
1395415450086.jpg
53KB, 475x533px
>>46451596
Aww. Your awww-tism is showing.

Don't assume too much scrub.
>>
>>46451622
No clue, your library a shit if your mainFrame doesn't have a member function like "getWidth()" or the like.
>>
>>46451648
I'm a noob when it comes to GUI designing.
care to point me to the best way of making a frame? any help will be appreciated.

anyways, what do i do about that pesky little frame popping up as seen in the top-left corner of >>46451558
>>
>>46451185
The compiler compiles the language it is written to compile.

If you have an IDE that has support for multiple languages and compilers, then you would simply tell it which one to use for a given project or source file.
>>
File: UF2Ondb.png (214KB, 1744x1332px) Image search: [iqdb] [SauceNao] [Google]
UF2Ondb.png
214KB, 1744x1332px
>>46450870
Just wrote a little program to play audio files to see how it easy it is using built-in shit.

import Cocoa
import AVFoundation

var mainPlayer:AVAudioPlayer?

println("Choose file to play")

let panel = NSOpenPanel()
panel.showsHiddenFiles = false
panel.allowsMultipleSelection = false
let clicked = panel.runModal()

if clicked == 1 {
let url = panel.URL!

var err:NSError?
mainPlayer = AVAudioPlayer(contentsOfURL: url, error: &err)
}

mainPlayer?.prepareToPlay()
mainPlayer?.play()
CFRunLoopRun()


It's interesting to see how it's buffering the file while it's playing.
>>
Scala:
 object HelloWorld extends App {
println("Hello, World!")
}


>App
>dropped
>>
>>46451750
What the fuck language is this?
>>
>>46451808
Swift
>>
Please use an anime image next time.
>>
>>46451843
no respect for Knuth
>>
>>46451750
What program is in the pic?
>>
https://github.com/brettalcox/PiPlayer

halllllppppppp
>>
>>46451858
Xcode. It has a bunch of different profiling tools.
>>
>>46451898
Thanks
>>
dRatio keeps turning to 0 when I get an answer wrong.
Whas going on?
#include <iostream>
#include <stdlib.h>
#include <time.h>

using namespace std;

bool decision()
{
cout << "\nDo you want to play again? (y/n)" << endl;

char cAnswer;
cin >> cAnswer;

bool bAnswer = cAnswer == 'y' || cAnswer == 'Y';
if(bAnswer)
{
cout << "\nkk..\n" << endl;
}
else
{
cout << "rip" << endl;
}

return bAnswer;
}

int main()
{
srand(time(NULL)); //Give random a seed

int iRight = 0, iTotal = 0;
double dRatio;

do
{
/*
int iNum1 = rand() % 101;
int iNum2 = rand() % 101;
*/
int iNum1 = 1, iNum2 = 1;
int iProduct = iNum1 * iNum2;

printf("What is the product of %i and %i?\n", iNum1, iNum2);

int iResponse;
cin >> iResponse;

iTotal++;

if(iResponse == iProduct)
{
iRight++;
dRatio = (iRight / iTotal) * 100;
printf("%i is correct!\nThe correct answer is %i.\nYour percentage correctly answered is %g%%.\n", iResponse, iProduct, dRatio);
}
else
{
dRatio = (iRight / iTotal) * 100;
printf("%i is incorrect!\nThe correct answer is %i.\nYour percentage correctly answered is %g%%.\n", iResponse, iProduct, dRatio);
}
}while(decision());

system("Pause");
}
>>
>>46452237
It's because you're doing the division on two integers, so it's done as integer division before being cast to a double.
>>
>>46452256
I see.
How do I stop that from happening? Turn iRight and iTotal into doubles?
>>
Trying to mess around with node. I cloned two projects from github and whenever I run node server.js, it doesn't start up the server and it goes back to the command line prompt. What the fuck am I doing wrong?
>>
>>46452267
dRatio = ((double)iRight / (double)iTotal) * 100.0;


Also your code could easily be refactored so that you don't have all that code dplications.
>>
>>46452387
You could use
tolower(cAnswer) == 'y'
instead of explicitly checking between both cases.
>>
>>46452290
>>46452409
gotcha
this things starting to get on the grey about being readable or not
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <string.h>

using namespace std;

bool decision()
{
cout << "\nDo you want to play again? (y/n)" << endl;

char cAnswer;
cin >> cAnswer;

bool bReturn = tolower(cAnswer) == 'y';
cout << (bReturn ? "\nkk..\n" : "\nrip.\n") << endl;
return bReturn;
}

int main()
{
srand(time(NULL)); //Give random a seed

double iRight = 0, iTotal = 0, dRatio;

do
{
int iNum1 = rand() % 101, iNum2 = rand() % 101, iProduct = iNum1 * iNum2, iResponse;

printf("What is the product of %i and %i?\n", iNum1, iNum2);

cin >> iResponse;

iTotal++;

bool bIsRight = iResponse == iProduct;
iRight += bIsRight ? 1 : 0;

dRatio = (iRight / iTotal) * 100;
printf("%i is %scorrect!\nThe correct answer is %i.\nYour percentage correctly answered is %g%%.\n", iResponse, bIsRight ? "" : "in", iProduct, dRatio);
}while(decision());

system("Pause");

return 0;
}
>>
>>46452237
You can replace system("pause"); with cin.get() to make your code not Windows specific.
>>
>>46452456
gotcha
kk ty bro imma head to sleep
>>
File: Queens.webm (3MB, 1280x720px)
Queens.webm
3MB, 1280x720px
Reposting an earlier version of the last school assignment I did. I'll probably spiff up the program later on when I have the free time.
>>
File: maxresdefault.jpg (87KB, 1920x800px) Image search: [iqdb] [SauceNao] [Google]
maxresdefault.jpg
87KB, 1920x800px
>>46451750
>CFRRunLoopRun
>>
>>46450870
About to try to sort points clockwise around a center point

Procedural map generation is the final goal
>>
>>46452545
Pic related, some of the triangles aren't clockwise
>>
hey, how do I make abs show up on the same line as my request? say

I have this

cout << " Please enter number of cars";
cin >> car_number;
cout << abs(car_number);

this would show up with 2 inputs, the negative one and then the abs one on the next line, how do I convert the negative one for a positive on the same line?
>>
>>46452847
>hey, how do I make abs show up on the same line as my request?
You can't with cin. It might be possible with some other input grabbing method though.
>>
>>46453010
hmm, like? I'm just getting started on this, so I'm not too familiar with other input methods.
>>
>>46453020
>hmm, like?
No idea, you'd have to google it or wait for someone else in this thread to know. Just wanted to let you know so you wouldn't try to waste your time trying to do it with cin though.
I guess you could theoretically clear the console and re-output all the same text to make it look like it did work as you intend though.
>>
What the fuck is the point of abs?
>>
Is there a way to do have something like a DllMain but still allow static linking?
>>
>>46453075
absolute value (basically removes the sign accompanying any number)
>>
>>46453090
Seems redundant.
>>
>>46453075
Wanting to know the difference between 2 numbers, without having to worry about putting the larger number first in your subtraction.
abs(x - y);
>>
>>46452545
don't know much about what you're doing or trying to do but sounds like you want to extract a surface from a point cloud
>>
>>46453166
Give or take yes. I'm trying to triangulate a voronoi cell so I'm guaranteed its convex. I realized a few minutes ago I can just sort them along x small to large if y is less and large to small if y is greater
>>
>>46452847
no, it show up as an input, which is negative or whatever the user typed, and an output which is the abs. you can move the console cursor back then overwrite the input, but that's pretty dumb
>>
>>46453101
Your existence seems redundant to me.
>>
>>46453233
yes, that is pretty dumb, because my professor wants me to exchange any negative values for positive ones when they enter a product quantity or any number.
>>
>>46453419
Do you really understand what he wants you to do? I doubt he wants you to change what cin prints. Ask him/her.
>>
>>46453440
He wants abs for input bruh, I'm guessing I can run a loop or something too.
>>
I'm finishing my android game in libgdx you soon all will be playing and I'll dominate the world. Mark my words.
>>
I'm so sick and tired of working with Qt framework. I hate it.

Someone please kill me.
>>
>>46454043
At least it's not Java.

Have you run into the issue where, implementing a read-write data model for a QTreeView, you need to pass an index with column()==0 to beginInsertRows when inserting child rows or else the view won't be updated with them?
>>
File: newlayoutmeybbe.png (1MB, 3262x2748px) Image search: [iqdb] [SauceNao] [Google]
newlayoutmeybbe.png
1MB, 3262x2748px
babby's first ui
>>
>>46450935
Just use Google
>>
>>46454043
What does Qt have to do with MASM32..?
>>
>>46454043

>muh open source

Also why the fuck would anyone even be using masm32 these days? That shit only exists these days to teach people how to program with assembly in the shitty unsafe you-have-access-to-everything dos environment.
>>
>>46454205
i dont understand the epic meme of >muh open source, is open source now bad? someone care to explain?
>>
>>46454205
>>muh open source
So ?
>>
>>46451086
You're going to fucking fail. Just go with superposition calculus and friends. trust me.
>>
Enrolling at my local university to take their python course
>>
>>46452237
>hungarian notation
>filthy pig disgusting braces
>}while
>single line statements in braces
Kill yourself.
>>
>>46455234
i was about to rage at you for dissing hungarian notation but then i saw his code
>systems hungarian
>not apps hungarian
>kill you are self
>>
>>46455321
Hungarian notation is harmful. Use
int amount_of_faggots;

instead.
>>
>>46455334
>not faggotAmount
>>
>>46455346
mixedCase is harmful. Use underscores instead.
>>
>>46455352
no it isn't. and you can still use faggot_amount
>>
>>46455352
How so?
>>
>>46450870
>What are you working on?
my masturbation technique. MY GF IS AWAY
damn I am gonna marry my right hand its a better fuck than my gf
>>
>>46455360
Yes it is. When you read the variable name you want to spend as less time figuring out what it means as possible. So when you read
amount_of_faggots

you instantly know this is a counter for something of the type faggot.

>>46455362
Mixing case in your code is like mixing piss and shit. Use underscores. K&R are right.

>>46455381
>MY GF IS AWAY
So use your left.
>>
>>46455387
>Mixing case in your code is like mixing piss and shit. Use underscores. K&R are right.
Yes, okay.
What is the logical reasoning behind this?
>>
File: 1401378337222s.jpg (4KB, 166x250px) Image search: [iqdb] [SauceNao] [Google]
1401378337222s.jpg
4KB, 166x250px
>>46455352
>mixedCase is harmful
Never heard that one before.
>>
I'm tired of coding with vim
It's like impossible to manage code across more than 3 files with it..
What's a good IDE for retarded C programmers like me?
loonix compatible obviously
>>
>>46455439
Code::Blocks?
>>
>>46455439
>I'm too stupid to use vim correctly
vim with YCM and syntastic.

>>46455414
Your eyes jump to the capital letter(s) instead of a smooth reading flow with underscores as everything is equal height.
>>
>>46455387
with amount_of_faggots you have to read and parse the entire thing. amount of... what? oh faggots

with faggotAmount you immediately know by the prefix that it has to do with faggots, and the camelCase allows you to start reading Amount without reading faggot (you visually recognize the faggot prefix, you don't have to actually read 'faggot')

faggotAmount lets you press ctrl+o (or the non-eclipse equivalent) or use auto-complete and immediately have every single variable related to faggots available to you and listed in alphabetical order, and easily find things related to faggots with ctrl+f and regex

callFaggotMethod... faggotI...? faggotQ...? faggotA... faggotAmount

vs

callFaggotMethod... int_f...? quantitity_of_f...? amount_of_f... amount_of_faggots
>>
>>46455457
see >>46455459
the camel prefix is just a "tag"... it's GOOD that you jump to the Case
>>
Go solved these questions before you write a single line of Go.
Why the hell haven't other languages just decided these inane questions up front?
>>
>>46455459
>eclipse
Entire post invalidated just by this word.
>>
>>46455481
epic meme!
>>
>>46455234
There's only one correct brace style and he's using the right one. It's not a matter of opinion.
>>
File: QW0S8QQ.png (14KB, 1025x250px) Image search: [iqdb] [SauceNao] [Google]
QW0S8QQ.png
14KB, 1025x250px
Is this Regex hotline? Noob here.
I've got a long string (see the pic), I need to extract the highlighted 67.900. Only thing I know that the word "Close" precedes it (with the some trash characters between them). Is there any way to extract the highlighted part without relying on the position of anything in the string or the amount of characters between it and "Close"?
>>
Ok guys, I'm using the mono IDE but I can't add any NuGet Packages, this is in a freshly created solution, any idea why ?
>>
>>46450870
Hi /g/
How do i code?
>>
>>46455759
first step is installing gentoo
>>
>>46455759
First delete system32
>>
File: F16.jpg (57KB, 1024x576px) Image search: [iqdb] [SauceNao] [Google]
F16.jpg
57KB, 1024x576px
>>46455759

for x in range (1, 2):
if x == 1:
print "Hello World"


Congratulations you are now an expert Python 2.7 Programmer Time for you to go out and get the job that youve always wanted! GOODLUCK AND GO GET 'EM TIGER
>>
female programmer LF boyfriend

please respond
>>
>>46451402
yes, just say 'write' fucking faggots.
>>
>>46455829
No anon, it obviously works like this
#include <cstdio>

void print(char first)
{
putchar(first);
putchar('\n');
}

template< typename... args>
void print(char first, char next, args... rest)
{
putchar(first);
print(next, rest...);
}

int main(int argc, const char * argv[])
{
print('H','e','l','l','o',' ','W','o','r','l','d');
}
>>
>>46455860
Language??
>>
>>46455968
based
>>
>>46455860
>Not having a CR+LF boyfriend
>>
>>46455968
haskell but I'm flexible
>>
>>46455700
Have you tried using an XML parser instead?
>>
>>46455989
Nope, I don't want to use anything except regex. By the way, I solved it with "Close:[\D]+([0-9.]+)" expression.
>>
>>46455989
I didn't chuckle till I read the filename.

10/10
>>
>>46450870
Gonna try tearing apart a proprietary file format
wish me luck
>>
>>46455989
dat stackoverflow question, top kek
>While it is true that asking regexes to parse arbitrary HTML is like asking Paris Hilton to write an operating system, it's sometimes appropriate to parse a limited, known set of HTML.
>>
>>46452512
This is what I picture every time I use CFRunLoopRun.
>>
>>46456115
>You actually can parse context-free grammars with regex if you break the task into smaller pieces. Your pattern needs to do each of these in order:

>Solve the Halting Problem.
>Square a circle (use the "ruler and compass" method for this).
>Work out the Traveling Salesman Problem in O(log n). It needs to be fast or your regex engine will hang.
>>
I was trying to learn some opengl.
Trying to rotate rectangle, got it working with common lisp but for some reason my java rectangles are not rotating.
It's using gl2.
//xx and yy are bottom left coordinates of square, side length = 10
gl.glPushMatrix();
gl.glColor3f(0f, 0f, 1f);

gl.glTranslated(-xx-5, -yy-5, 0);

gl.glRotatef(45f, 0f, 0f, 1f);
gl.glVertex2d(xx, yy+10);
gl.glVertex2d(xx +10, yy + 10);
gl.glVertex2d(xx + 10, yy);
gl.glVertex2d(xx, yy);
gl.glPopMatrix();

Currently drawing 5 squares with this kind of code with adjusted translation and rotation but none of them are rotated.
Any idea why?
>>
>>46456230
uhm, that's deprecated. Take a look into fragment and vertex shaders.
>>
>>46456230
>fixed function pipeline
don't... just don't

https://open.gl/
>>
>>46455716
Ok, I can add packages now but the list of official packages is empty ? I can't even find Json.NET, it just says "No matches found"
>>
Which paart in 4chan should i parse if i want to return all the images ive tried a class ive tried img class , ive tried alt="image"
God damn shit dont wana roll for me.
>>
I made a little client/server program using sockets in C.

In my client, I have a thread for taking input and sending it to the server, and a thread for receiving messages from the server and printing them out. When I input quit, it should exit the client program and close the socket.

My problem is, when I input quit, my print thread is already waiting for a message from the server, and even though both the server and the client program close the socket, the print thread continues waiting.

Is there a good way to resolve this issue?
>>
>>46456237
>>46456246
i hate how no opengl tutorial seems to tell you the basics straight up. it's always just some tiny snippet of code at a time too, never a complete example. i had to research and figure out the most basic things like glBufferData(), glBufferSubData() and glDrawArrays() and how to reduce CPU-GPU bandwidth usage on my own, there were no tutorial or guide to tell me how.
>>
>>46456331
You shouldn't be parsing jack-shit, look at the global rules, use the Json API instead
>>
>>46456365
>never a complete example
well maybe a complete example that sucks ass from a performance standpoint
>>
>>46456335
Wait for broken pipe or let the server send a "I QUIT, BITCH" message so the client can terminate immediately.
>>
>>46456381
ah man i dont even know how to reply to this shit.
>>
>>46456237
>>46456246
It will be exactly the same. The only difference is he'll be calling translate and rotate on a Matrix class in his own code instead of using the GL matrix calls.

>>46456230
You shouldn't call glPushMatrix, glTranslate, or glRotate between calls to glBegin and glEnd.
>>
>>46456425
this doesn't change the fact, that it is deprecated and if you run something like that on a large scale, you will suffer from incredible performance lacks. So enjoy your few polygons lagging around.
>>
>>46451171
Run the env command
The compiler will use whatever variables it chooses to use
>>
>>46451185
javac is a java compiler
GCC is a c compiler
They're 2 independent programs
>>
>>46456418
What language are you using anyway, I'm using C# with Json.NET for the exact same purposes

>captcha : Worms veryrot
>>
>>46451171
I think you are referring to your PATH enviroment variable? That is just a list of locations you append things to, the first hit for a program you look for in the path is the one used. There is no conflict here unless the compilers have the same name.
>>
>>46451759
Feel free to write a main method
>>
>>46456475
Python
import urllib
import urlparse
from bs4 import BeautifulSoup

url = "http://www.4chan.org/g/"

urls = [url] # stack of urls to scrape
visited = [url] # history record of urls

while len(urls) > 0:
try:
htmltext = urllib.urlopen(urls[0]).read()
except:
print urls[0]
soup = BeautifulSoup(htmltext)

urls.pop(0)
print len(urls)

for tag in soup.findAll('a',href=True):
tag['href'] = urlparse.urljoin(url,tag['href'])
if url in tag['href'] and tag['href'] not in visited:
urls.append(tag['href'])
visited.append(tag['href'])

print visited


Right now it just returns everything including replies, OP's and all that shit but i want to have it single out files with .jpg / .png / maybe .webm's too
>>
File: 1345999339976.png (35KB, 471x385px) Image search: [iqdb] [SauceNao] [Google]
1345999339976.png
35KB, 471x385px
I made a .NET program for reading the tags of my music files and transcoding/copying them to a separate folder if they contain certain tags (it also watches for new files and does the same thing).

I've used TagLib# for this but annoyingly I can't figure out how to read tags of Apple files. MP3, OGG/FLAC, WMA are all working fine. Anyone got any experience with this?
>>
>>46456387
I ended up just sending the message "quit" to the server, and the server sends back an empty message. That'll do for now, thanks.
>>
>>46452486
Link to code
>>
>>46456365
https://open.gl/drawing

This one does.
>>
>>46451759
underageb& detected
>>
Anyone have any pointers on where to start with making a custom parser?
>>
File: 1379542823061.jpg (42KB, 276x268px) Image search: [iqdb] [SauceNao] [Google]
1379542823061.jpg
42KB, 276x268px
I was told to read SCP because of my lack of knowledge, but I'm really having trouble with it. These exercises are totally kicking my ass, what do?
>>
>>46456734
What langauge and what are you parsing
>>
>>46456734
what exactly do you want to parse?
>>
>>46456541
glad I could help
>>
>>46456365
Forget the tutorial and read the fucking spec.
>>
>>46456756
there are about a million sicp guides on the internet. look through a few solutions until you start being less retarded
>>
I learned pythons syntax. What should I do now?
>>
>>46456793
this
>>
>>46456794
I've been doing that. I usually try for a few hours and then give up and look at the solution/explanation online.
>>
Any android devs willing to share some skeleton game loop? I am trying to write a basic game but there are so many theories and approaches to write a game loop (fixed fps, dynamic fps, time based animations, fps vs logic updates) etc that I have trouble picking a right way.

Is there any skeleton demo or something with just boilerplate code with a proper thread which calls something like boilerplate draw() and update() to be filled in? Or any direction where to find such a thing?
>>
>>46456815
learn x86 ASM
>>
>>46456757
>>46456777
Probably Python, may use Go since I'm mildly interested in using it. As for what I'm parsing...I want to parse a few thousand filenames and eventually track the files in a database.

I'm really just looking for something generic since the filenames aren't guaranteed to be correct.
>>
>>46456847
Surely you mean x86_64
>>
Is learning 2 languages at the same time a bad thing to do?

Python and Java.
>>
mips asm > x86_64 asm
>>
>>46456931
What a noob mistake of mine, ofcourse
>>
>>46457019
You should really be learning two proper lagnuages if you're going to learn two at a time, like C and x86_64
>>
>>46456690
i guess that's decent for an introduction, but it doesn't say anything about glBufferSubData or how to store things for later or even how to store multiple things next to each other. you shouldn't call glBufferData every frame if you're not updating everything on the CPU.

>>46456793
>maximum autism
>>
>>46457047
Wrong. PDP-11 and x86_64
>>
Does anyone have a link to last /dpt/ ?
>>
>>46457091
>>46438178
>>
>>46457111
Thanks :D
>>
>>46457138
np :DDD
>>
Trying to make my first game. Code probably sucks. Setting up the title screen now, will switch this up to a module that I import into a main game loop afterwards. Want to know what stands out as being shit/needing to change/bad style? Currently I just have the base screen and options screen working visually. They both use very similar code, so I should probably write functions for them, but they differ enough that I think I'd need to parse in loads of list info, so not 100% how I'd do it.

http://pastebin.com/QyAKfMgv
>>
>>46456519
btw, One thing I forgot when writing my first 4chan downloader (yes this is my second one, first one was in python) is that you can't send more than 1 request every second, if you send more you'll get timed out (I believe it gave me 403)
>>
>>46457263
>API Rules
>Do not make more than one request per second.
>>
>>46457263
Yeah in my pycharm its telling me im sending too many requests thatll have to be a must fix, Trying to learn as much python as i can before i go to class at uni for it but im still green as fuck.
>>
>>46457171
Here's some:

- Put the image names in a list, then load them in a loop instead of writing pygame.image.load(..).convert_alpha() dozens of times.
- Similarly, convert the button checks to use an array instead of hardcoding them in several "if" checks. Loop over them and see which one the mouse is hovering, and replace the button_hit_list array with one variable that simply contains the number of the menu item the mouse hovers, -1 if nothing.
- Read up on state machines. inoptions/inbase can be replaced with one variable that tells what state you're in. Convert the code to use state machines now, because after you add more you end up lost in the maze of dozens of discrete state variables.
>>
>>46457313
I fixed it using sleep() but when intially writing that shit I forgot
>>
>>46456519

I made a mess of one with 1 week of python knowledge :^) I can't get the thread name right for some reason.

import os
import urllib2
import re

thread = raw_input("Thread:")
board_2 = "".join(re.findall("org/.*?/", thread))

board_2 = board_2.lstrip("org")
board_2 = board_2.replace("/", "")

directory_name = thread.strip("".join(re.findall(".*/", thread)))
os.system("mkdir %s" % (directory_name))

#lib2 file save
request = urllib2.Request(thread)
response = urllib2.urlopen(request)
text = response.read()

url_strings = re.findall("i.4cdn.org/" + board_2 + "/.*?\"", text)

for i in range(len(url_strings)):
url_string_mod = url_strings[i].rstrip('\"')
request = urllib2.Request("http://" + url_string_mod)
response = urllib2.urlopen(request)
text = response.read()
file = open(directory_name + "\\" + url_string_mod[(len(url_string_mod) - 10) : len(url_string_mod)], "wb")
file.write(text)
file.close()
>>
>>46457445

Taking the thread name as the directory name I mean.
>>
>>46457361
>first point
Is this just a style point? I'll admit it looks ugly to have so many lists, I was just doing that so they all had very clear names.
>second point
button_hit=-1
button_coordinates=[[button1],[button2]...]
for i in range(len(button_coordinates)):
if is_mouse_within(button_coordinates[i]):
button_hit=i

Do you mean roughly like that? Or am I misunderstanding?
>third
I knew there had to be a better way of doing it. Thanks, I'll check out state machines.
>>
>>46456847
>x86
>Relevant
>Ever
>>
>>46456519
>>46457445
>>>/global/rules/14
>>
>>46457558
So what is the purpose of the API?
>>
>>46457584
To avoid breaking the rules.
>>
>>46457505
The first point is to reduce excessive typing. Your asset loading is basically nothing but copy-pasted code. You can reduce that to a list of files you need, and 2-line for loop, making adding new assets simple: just add the file name.

You understood the second point correctly. One variable that tells which button is selected, or -1 if nothing is.
>>
>>46457505
>I was just doing that so they all had very clear names
Use a dictionary?

assets = { 'path'  : 'user_interface_assets/main_menu'
, 'images': ['newgame', 'continue', 'load', 'gallery', 'options', 'exit']
, 'types' : ['normal', 'hover', 'click']
}

button = {}
for image in assets['images']:
button[image] = {}
for type in assets['types']:
file = '{0}/{1}_{2}.png'.format(assets['path'], image, type)
button[image][type] = pygame.image.load(file)
>>
is it appropriate to pose webdev question even though they aren't technically programming languages?
>>
>>46457935
If you don't mind us bashing you and telling you to learn a real language, sure they are appropriate.
>>
>>46457754
Alright, thanks. Looks good, I'll sort it out.
>>46457897
I've largely ignored dictionaries because they didn't seem too useful. Guess I was wrong. Will go through the documentation. Thanks.
>>
>>46458020
Dictionaries are extremely useful. However they are a bit slow.
>>
>>46458050
Most of the time O(log n) isn't going to be a performance issue.
>>
>>46458016
but I know scheme and C, but I'm not having problems with those :/
basically I'm wondering what I should be looking for to pull different .html files out of an array in php (I know, I know, it's for a project and I can't use javascript, which itself I also hate) I was thinking
 
<functionname> = rand(all.html, these.html, different.html, html.html, files.html, in.html, an.html, array.html)
echo: <functionname>

but lack the server required to test this at my current facility.
>>
>>46458117
For large sets it can be slow.
>>
>>46458050
>>46458117
Incidentally, I've only been programming for ~1 year. I've pretty much ignored most of the theory in favour of learning to actually do shit. Any recommendations going forward wrt that? I'm getting to the point where it is actually hindering my now and then. Python is my only language if it matters.
>>
>>46458117
O(log n) by itself doesn't mean much nowadays unless you're Facebook or Google.
The constant time is important. If you're trashing the cache, you'll run hundreds of times slower than a naive O(n) implementation.
>>
Do people here use an IDE or just a simple text editor to program? I've always used an IDE but the way /g/ goes on about how great vim is makes me want to give it a try but it just seems like it be an inconvenience to use something like that especially when dealing with large programs with many classes.
>>
>>46458510
Visual Studio (and obligatory ReSharper) with a Vim extension. Not very proficient with it yet.
>>
>>46458510
I use an IDE, except when I work on *very* large projects. Then bash+vim do wonders.
>>
>>46458185
You can traverse a dictionary in constant time.
>>
>>46458585
You obviously can't. Just think for a second before posting.
>>
>>46458585
>traverse
> constant time.
If you had the same amount of processors as dictionary entries maybe.
>>
So...this big O thing. I've never really understood how to determine which one a particular algorithm is. Anyone know of any really good introductions or something? Something with actual code?
>>
>>46458603
>>46458636
s/constant/linear

The point is, traversing a dictionary is cache friendly.
>>
File: ecb.png (347KB, 1280x777px) Image search: [iqdb] [SauceNao] [Google]
ecb.png
347KB, 1280x777px
>>46458510
I use Emacs, and I don't think it's fair to call it "a simple text editor." Emacs can be used as a full IDE with packages like CEDET and ECB.

>Emacs already is a great environment for writing software, but there are additional areas that need improvement. Many new ideas for integrated environments have been developed in newer products, such as Microsoft's Visual environment, JBuilder, or Eclipse. CEDET is a project which implements several advanced features developers have come to expect from an Editor.

http://cedet.sourceforge.net/
http://ecb.sourceforge.net/

I don't know about Vim though, I would assume they have an equivalent.
>>
>>46458671
Dictionaries are not friendly to traverse at all because they are generally not designed for it, if it's hash based for example the goals of a good hash function is completely at odds with predictable traversal.
>>
>>46457584
any idea what hes talking about? ill avoid breaking rules if i can but im tryina fuck with python not Json
>>
Can somebody please explain to me in simple terms what is a shim and how and why do I use it.
>>
>>46458800
json is dead simple to use in python. It's effectively used just like a dictionary.
>>
>>46458658
>Something with actual code?
There's no code involved. It's math.

x=O(y) means that you can always find a C so that for a sufficiently big n, Cy > x.
That is, y "grows" as fast or faster than x.

So log n = O (log n) and log n = O(n)
But n*n != O(n) and n*n != O(log n)

So if you want to be a pedantic faggot, when asked for the complexity, you can just say that it's O(infinite), that's technically always right.
>>
>>46458828
You missed the point.

I know what it represents.

I don't know how to determine what any particular piece of code runs at. Hence the want for examples.
>>
>>46458824
do i need to import a certian module for it? ive made chrome addons in json to view 4chan mutliple boards at once but thats it.
>>
>>46457445
>>46456519
I found my next training for python. I still want to do a thread parser that can analyse the themes of threads.
Fucking lot of work to do, I think.
>>
>>46458862
import json
fList = json.loads(page[script+18:endScript+1])
images = fList['items'] #example


Sorry, it's straight out of something I wrote ages ago. But after that you access it (fList in the case above) just like you would a dictionary.
>>
>>46458856
Just look at your algo and try to look at how many operations it will do in the worst possible case.

Example of searching a needle in a haystack of n elements :
for (value(n) in haystack) {
if (value(n) = needle)
return value(n);
}


^ This will search the whole haystack element by element for the needle.
There are n elements, so in the worst case you'll do n operations. Therefore, it's O(n).

I realize that I'm wasting my time with you, but at least I tried.
>>
>>46458900
I jus got a module called simplejson for python 2.7 ever dabble with it?
>>
>>46458909
>I realize that I'm wasting my time with you, but at least I tried.

I bet you wonder why so many people are "stupid"
>>
feedback on my random string generationer

public class StringGenerator {

public final static int ALL_ALPHABET = 0, ALL_ALPHABET_AND_NUMBERS = 1,
LOWERCASE_ALPHABET = 2, LOWERCASE_ALPHABET_AND_NUMBERS = 3,
UPPERCASE_ALPHABET = 4, UPPERCASE_ALPHABET_AND_NUMBERS = 5,
NUMBERS = 6;

private Random random;
private int generatorType;
private final String numbers = "0123456789";
private final String uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private final String lowercase = "abcdefghijklmnopqrstuvwxyz";
private String characters;

public StringGenerator() {
random = new Random();
setGeneratorType(ALL_ALPHABET_AND_NUMBERS);
}

public StringGenerator(int generatorType) {
random = new Random();
setGeneratorType(generatorType);
}

public String generateString(int length) {
String generatedString = "";
for (int i = 0; i < length; i++)
generatedString += characters.charAt(random.nextInt(characters.length()));
return generatedString;
}

public int getGeneratorType() {
return generatorType;
}

public void setGeneratorType(int generatorType) {
if (generatorType >= 0 && generatorType <= 6)
this.generatorType = generatorType;
else
this.generatorType = ALL_ALPHABET_AND_NUMBERS;

characters = "";
switch (this.generatorType) {
case ALL_ALPHABET_AND_NUMBERS: characters += numbers + uppercase + lowercase;break;
case ALL_ALPHABET: characters += uppercase + lowercase; break;
case UPPERCASE_ALPHABET: characters += uppercase; break;
case UPPERCASE_ALPHABET_AND_NUMBERS: characters += numbers + uppercase; break;
case LOWERCASE_ALPHABET: characters += lowercase; break;
case LOWERCASE_ALPHABET_AND_NUMBERS: characters += numbers + lowercase; break;
case NUMBERS: characters += numbers; break;
default: characters += numbers + uppercase + lowercase;
}
}
}
>>
>>46458941
Probably. I think the code I showed above was meant for python 3. It's quite possible that it's the same module, just renamed.
>>
>>46458050
Reg seems interesting and powerful, I see it everywhere, but I still don't get how it works.
>>
>>46458946
I'm not calling anyone stupid.
I suck at explaining, that's all there is to it.

I know plenty of stupid people and I wouldn't even try to explain anything to them.
>>
>>46458714
emacs a shit
>>
>>46458967
In that case, you need to work on phrasing. That sentence makes it seem like you are blaming the other party.
>>
>>46458812
Let's say you have some software that needs to be ported to two platforms. Your code needs access to aes encryption. Platform A has an aes function that looks like this
aes_encrypt(key, ciphertext, plaintext)

and platform B has a function that looks like this
encryptAES(ciphertext, plaintext, key)

You can use a shim that will iron over platform differences
myaes(key, ciphertext, plaintext)

On platform A, the function body can be
myaes(key, ciphertext, plaintext) { aes_encrypt(key, ciphertext, plaintext); }

and on platform B it can be
myaes(key, ciphertext, plaintext) { encryptAES(ciphertext, plaintext, key); }

That way, you won't have to rewrite your code for each platform.
>>
>>46458658
It statistically describes the way your algo will work for large extent runs.
One function can be O(n), the other one O(log(n)), ect...
It help to structure your code and optimize it.

Or maybe that's just a geek thing...

Still wondering.
>>
>>46458987
>you need to work on phrasing.
My point exactly, anon.
I'm trying.
>>
>>46458989
Isn't this slowing the code?
>>
>>46459004
Should you only look at the most inner loop? Or perhaps a slightly larger picture?
>>
>>46458773
I'm talking about self-balancing binary trees.
>>
>>46458989
Great, thanks.
>>
>>46459020
inline your myaes function

the compiler might do it anyways
>>
>>46459004
>It statistically describes the way your algo will work for large extent runs.
Not really. Most of the time it describes how your algo will work in the worst case.
>>
>>46459020
It adds an extra function call as I wrote it I guess.
>>
>>46459065
Never inline yourself. Good compilers will ignore you and do their own inlineing anyways, but it's still bad practice without a very solid profile showing that it's a good idea.
>>
>>46456473
GCC is a collection of compilers you dumbfuck
>>
>>46458568
>and obligatory ReSharper
that thing wants me to change everything to "var", is that normal and/or recommended?
>>
>>46456473
You don't know what gcc stands for do you?
Gnu Compiler Collection.
>>
>>46459080
Yep, but isn't the shim function? Isn't it better to rewrite the code?
>>
>>46458963
this could be fun working with, im glad that hidden mod was getting angry.
>>
>>46459152
Easier than scraping. Incidently in the code I showed, json was embedded in the page, so I had to load the page then scrape the json out of it.
page[script+18:endScript+1]


So page was, well the actual page. script and endScript were the locations that I searched for and the integers were offsets so it would encompass the entirety of the json data.
>>
>>46459141
Sometimes you can't/don't want to. Imagine rewriting/reordering system libraries across all platforms, or using a preprocessor to select the right function. It can get pretty messy.
>>
I am making a paginated collection view with MarionetteJS.

http://jsfiddle.net/ElderMael/q8hndsvt/8/
>>
>>46459376
you are a terrible programmer, never program again
>>
Hi /g/uys,
I'm trying to use a regex to find the board in a 4chan url. This is what I have but it doesn't seem to be working, Is there a mistake in my regex or in the rest of my program ?
>>
>>46459420
derp, forgot the actual regex
"^4chan\.org\/*.?\/thread$"
>>
File: 1422807796442.jpg (97KB, 640x640px) Image search: [iqdb] [SauceNao] [Google]
1422807796442.jpg
97KB, 640x640px
Why not workin? python3


print 'ax2+bx+c=0'
a=int(input('a: '))
b=int(input('b: '))
c=int(input('c: '))
delta = b**2-4*a*c
if delta > 0:
x1 = (-b-delta**(1/2))/(2*a)
x2 = (-b+delta**(1/2))/(2*a)
print 'x1 = ', x1, ', x2= ', x2
elif delta == 0:
x0 = -b/(2*a)
print 'x0 = ', x0
else:
print 'lack of solutions'
>>
>>46459420
Why the fuck are you using regex for that?
>>
>>46459399
Why?
>>
File: 1408137931900.png (36KB, 220x153px) Image search: [iqdb] [SauceNao] [Google]
1408137931900.png
36KB, 220x153px
>>46456819
do you understand the basic concepts that book gives you early on? Just work on understanding how the programs work. Go over stuff you understand and try to figure out why you don't understand what you don't. This ain't rocket science anon. Learn2Learn
>>
>>46459455
What should I use then ? this is the initial input where the user types the URL so you can't extract it from anywhere else execpt the URL string. I'm using C# btw.
>>
Just solved the third problem on Project Euler, feels pretty good. I managed to write up a working solution in about 30 minutes, the problem was making it run fast enough that it would complete before the heat death of the universe. My final solution solves it in under a second.
>>
>>46459470
because i don't like you, or your face, todd
>>
>>46459434
Are you trying to extract it? In sed you can do
echo 'https://boards.4chan.org/g/thread/46450870#p46458510' | sed 's_.*boards.4chan.org/\(.*\)/thread/.*_\1_'
>>
>>46459434

Try

.*? Not *.?
>>
>>46459503
top lel
>>
>>46459440
bump ;_;
>>
>>46459504
I need to set
string vars.board
to the board letter/identifier/WhateverYouWantToCallIt
>>
>>46459553
print is a normal function in Python 3, so you need parenthesis around its arguments.
>>
>>46458856
if you take n as input. then if you only have to do one constant thing C for every n it is O(n). if you have to do C*n for every n it is O(n^2). like if the time taken to run your algorithm as a function of n is something like A*n^2 + B*n + C (A,B,C constants) then it is O(n^2) because n^2 is the highest degree of the polynomial.

example of an O(n^3) algorithm for finding pythagorean triples:
for(int a = 1; a < n; ++a)
for(int b = 1; b < n; ++b)
for(int c = 1; c < n; ++c)
if(a * a + b * b = c * c) //pythagorean triple found


pythagorean triples can be found in O(n^2) time, this O(n^3) algorithm is just a simple example.
>>
>>46459696
*should be c <= n instead of c < n
>>
Now it does compile, but does not work at all...

print ('ax2+bx+c=0')
a = int(input('a: '))
b = int(input('b: '))
c = int(input('c: '))
delta = b**2-4*a*c
if delta > 0:
x1 = (-b-delta**(1/2))/(2*a)
x2 = (-b+delta**(1/2))/(2*a)
print ('x1 ='), x1 , (', x2 ='), x2
elif delta == 0:
x0 = -b/(2*a)
print ('x0 = '), x0
else:
print ('lack of solutions')
>>
>>46459721
Use code tags, newfriend.

This isn't fucking stackoverflow.
>>
If one vertex has multiple texture coordinates I should just treat it as multiple vertices
y/n
>>
Better?
print ('ax2+bx+c=0')
a = int(input('a: '))
b = int(input('b: '))
c = int(input('c: '))
delta = b**2-4*a*c
if delta > 0:
x1 = (-b-delta**(1/2))/(2*a)
x2 = (-b+delta**(1/2))/(2*a)
print ('x1 ='), x1 , (', x2 ='), x2
elif delta == 0:
x0 = -b/(2*a)
print ('x0 = '), x0
else:
print ('lack of solutions')
>>
>>46459696
>if(a * a + b * b = c * c)
whoops, should be == instead of =
but you get the point
>>
>>46459757
Yes.
>>
>>46459757
Yes. Modern GPUs have enough memory, you can duplicate vertices if needed. Trying to "optimize" this will usually lead to worse performance. GPUs are basically just dumb brute-force devices, clever optimization tricks don't always play well with them.
>>
>>46459774
You have to put a single pair of parenthesis around all of the arguments together, just like you would for a normal function.

So,
print ('x1 ='), x1 , (', x2 ='), x2

should be
print('x1 =', x1, 'x2 =', x2)
.

It's also kind of weird to have a space between the function name and the parenthesis after it.
>>
>>46458959
Done it too. Was fun.
import random
StrRand = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'

n = int(input('Length?\n'))

delta = [random.choice(StrRand) for j in range(n)]
print(''.join(delta))
>>
>>46459965
Yours doesn't have 7 different possible states though, that is what the bulk of my code is handling.
>>
>>46459788
>>46459843
k, so the hard part is gonna be figuring out how many unique vertecies there actually are and ordering them properly
>>
>>46459995
What states? Didn't see them well.
>>
>>46458856
Every loop is an "n".
Every recursive call is... uh... use master theorem/proof by induction/whatever for this shit.
That's literally almost all that it takes.
>>
File: 250px-258Mudkip.png (33KB, 250x250px) Image search: [iqdb] [SauceNao] [Google]
250px-258Mudkip.png
33KB, 250x250px
>>46459911
Thanks, werks. Im kinda new to this stuff
>>
>>46459996
Are you hard-coding the data?
>>
I'm gonna create a data structure that'll make one thing really easy and it'll probably be super gross and inefficient but it won't have to be used very often if at all during runtime
is that acceptable
>>
>>46460191
I'm using some files my friend gave me
>>
I wonder if you lot might know a formula I'm trying to remember. It's the probability of getting some number of objects in a set in some state when the states have different probabilities. I thought it might be something like nCr * r^p * (n-r)^(1-p) where p is the probability, but that's returning results greater than one, like its the number of combinations for that macrostate.
>>
>>46460225
Most 3D file formats are already in the correct order. Which one is it?
>>
>>46460207
That depends. You might actually lose performance due to icache misses introduced by all the new functions that implement your data structure.

If you care about performance, you keep your code small, you use arrays, and you traverse them in a predictable fashion.
>>
>>46459434
Not coming along too well, does anyone have any other ideas for how to get the board in a 4chan from a 4chan URL as a C# string ?
>>
>>46460207
What exactly?
>>
File: Max_Bait_Def.gif (72KB, 200x200px) Image search: [iqdb] [SauceNao] [Google]
Max_Bait_Def.gif
72KB, 200x200px
>>46459843
>>
hey guys, how I make a loop that tells the USER to input integers only and no characters?

I wanna do a while loop

so
while (coming_int = ???)

the question mark is where I'm stuck. I don't know what I can put on there to include all characters, do I just make it equal to char? I'm confused on this part.

if the user inputs abdcd, then he should be sent back with a warning specifying for whole numbers only.
>>
>>46460314
while (coming_int < '0' || coming_int > '9')

learn about ascii
>>
>>46460314
Depends on the language. If it's java, for example, you try to convert the input to an int using the Integer wrapper class, and catch the exception thrown by it if the input isn't an int. Put this inside a loop until a proper input comes in.

I can post a snippet if you'd like.
>>
Where can i find some tutorial for python3, to not post stupid codes liek that?
Why it does not work this time?
print('Check your age')
age = int(input('Age: '))
if age < 12:
print('You old piece of shit')
elif age > 18:
print('tfw you are no longer kid')
else:
print('youngster')
>>
>>46460363
i'm trying this out in C++.

convert input to an int? what if I declare coming_int as an int though?
>>
>>46460260
I don't think you understand the problem
I have 60 positions and 66 texture coordinates
I have to define the vertex data for each unique position/texcoord combination necessary and know where each combination is indexed so I can define the faces properly

I was using fbx but I gave up after trying to parse a 17KB file that defined a fucking cube
>>
>>46460390
Check your indents. Yah, muh whitespace.
Shift else and elif at the same level as if.
>>
>>46460390
indentation is important

https://docs.python.org/3/reference/lexical_analysis.html
>>
>>46460390
Check your age
Age: 12
youngster
Check your age
Age: 11
You old piece of shit
Check your age
Age: 99
tfw you are no longer kid
Check your age
Age: 18
youngster
Check your age
Age: 19
tfw you are no longer kid


ok

Also, look at your indentation.

print('Check your age')
age = int(input('Age: '))
if age < 12:
print('You old piece of shit')
elif age > 18:
print('tfw you are no longer kid')
else:
print('youngster')
>>
File: blue sc.png (14KB, 641x431px) Image search: [iqdb] [SauceNao] [Google]
blue sc.png
14KB, 641x431px
im suppose to write a program that does this:

1. think of a postive number
2. subtract the sum of the DIGITS of this number from the orignial number
3.If you tell me all but 1 digit from this new number, i can tell you which digit you did not tell me
4. Enter in any order the digits and i will tell u which one u did not tell me

I tried doing this on paper but i can never find the missing digit. is there some algorithm to find missing number?
>>
>>46460363
oh yea, please post a snippet.
>>
>>46460390
print('Check your age')
age = int(input('Age: '))
if age < 12: print('You old piece of shit')
elif age > 18: print('tfw you are no longer kid')
else: print('youngster')

No need to indent for one line codes.
>>
>>46460433
.fbx is proprietary, you need to use a library.

Why don't you have triangle data?
>>
>>46459757
You should just treat it as multiple tex coords, you just pass another set of coordinates to the fragment shader.
>>
>>46460499
but if vertecies have varying numbers of texcoords then it would cause branching in behavior
>>
>>46460474
Shit son, you have to write a program that thinks ? Good luck with that one
>>
>>46460474
guess == first_digit ? second_digit : first_digit
>>
>>46460433
Using texture coordinates to determine faces or geometry doesn't make any sense.
If you have more tex coords than vertices then that usually indicates multiple textures to be blended, static light/shadow mapping or things like masked blitting.
>>
>>46460263
https://stackoverflow.com/questions/841883/regular-expressions-c-sharp-is-it-possible-to-extract-matches-while-matching
>>
>>46458856
>>46458658
I'm going to try giving this a shot here, because this is how I came to understand at least one way of spotting it, and that's nested loops.

First, have some python code

n = 3
for i in range(n):
for j in range(n):
do some shit to i and j


Okay, so this code, regardless of what you're doing to i and j, is at least O(n^2)
Now we have to ask ourselves why is it O(n^2)
The answer is surprisingly simple.
i has the values 0,1,2 j also has the values 0,1,2
so the first time through the loop, we'd have i=0, j=0, second i=0,j=1, etc. Formatted into a square so that we can see all the possible values easily

00 01 02
10 11 12
20 21 22

We have nine combinations that we would have to go through for n=3, we would have 16 for n=4, 25 for n=5, etc. You should be able to find out what the big O notation is for pretty much any program from this.
>>
>>46460608
>If you have more tex coords than vertices then that usually indicates multiple textures to be blended, static light/shadow mapping or things like masked blitting.

Or, you know, a vertex with shared faces.
>>
>Watching a couple of Pythonistas with Vim open loudly criticize people using Visual C++ and Ruby
>>
File: 1422803301479.jpg (39KB, 362x400px) Image search: [iqdb] [SauceNao] [Google]
1422803301479.jpg
39KB, 362x400px
>>46460471
Lol, i was trying to figure out why it does say old, when its 12 or less, and after 10 minutes i discovered that i derp in description
mfw
>>
>>46460498
I know it's proprietary, but will not gonna tie my program with the FBX SDK
I have a list of positions, texcoords, normals, and three pos/tex/norm indecies defining each triangle
>>
>>46460295
but it's true. GPUs have gigabytes of memory and a vertex only takes up some bytes. and you can't optimize for GPUs like you would with a CPU, you definitely want to avoid divergent branching, so just blast it whatever you've got.
>>
>>46460608
I have the faces
It's just if a face uses a given vertex position, another face using the same vertex position may have a different texcoord associated with that position
How fucking hard is this to understand
>>
>>46460422
>>46460477
Ok, there's two ways to do it actually. I don't really know C++, but at least in Java this is how you do it:

    int option;
boolean success;
Scanner in = new Scanner(System.in);

do {
try {
option = in.nextInt();
success = true;
} catch(InputMismatchException e) {
success = false;
} finally {
in.nextLine();
}
} while(success == false);


And then there's using the Integer wrapper class, which is basically the same except you try to use Integer.parseInt(whatever), and which throws NumberFormatException if it fails to parse the int. Why use this second way, you might ask? I honestly can't think of any case where it's better right now.
>>
>>46460634
If it's a shared vertex with the same texture all faces will have the same texture coord at that point.
If it's a shared vertex where each face has a different texture - say the corner of a cube and each face a different texture - then you still need additional information about what texture to use, and if you have that you usually have some kind of index table.
>>
>>46458959
IMPLEMENTATION: You should build the string in a StringBuilder in generateString(); it's *much* faster for even modest string lengths.
DESIGN: Your concept of generator types is a bit shaky. It might be better to take the symbol alphabet as a direct argument (in a String) and to supply those selected combinations as defined string constants.
>>
>>46460474
dafuq is this wizardry
>>
>>46460263
var match = Regex.Match("https://boards.4chan.org/g/thread/46450870/daily-programming-thread", "boards.4chan.org/(.+)/thread");
var board = match.Groups[1].Value; // "g"


Research capture groups.
>>
>>46460474
Two hints:
1) Think back to 1st grade. What is that "trick" to determine if a number is divisible by 9?
2) Pretend you have a 3 digit number abc. Write yourself an expression to determine what you get when you subtract a, b, and c from that number.
>>
>>46460474
wait, wut?

I think of the numbers 1,2,3,11,12,13,21,22,23
I sum the digits of each (new list is 1,2,3,2,3,4,3,4,5)
I subtract each number in the second list from the original list, new list generated is 0,0,0,9,9,9,18,18,18
How are you supposed to tell me the original number when you've lost that much information?
>>
>>46460682
That is solved by passing different tex coords and/or bind a different sampler in the fragment shader.
You don't need to figure anything out.
>>
>>46460614
Thank you very much sir :)
>>
>>46460787
Hell, the trick wouldn't even work for numbers below 20, because they wouldn't be able to give you any numbers.
>>
>>46460738
You are so fucking retarded
Say you make a texture for a 3d model of a person
The texture is 2d
If you have a point at the bottom of the arm it will be connected to a face that uses something from the upper half of the arm section of the texture as well as being connected to a face that uses something from the lower half of the arm section of the texture
Because the texture fucking WRAPS AROUND THE ARM YOU FUCKING RETARD
>>
>>46460738
Typically if the faces of a cube are supposed to look different you will put them in the same texture.

>>46460672
>three pos/tex/norm indecies defining each triangle

You already have the indices then. What's the problem?
>>
>>46460787
The resulting number is going to have some special properties that you can figure out using 8th-grade (at most) math.

Run a script for 1-100, applying the "subtract the sum of the digits" rule. Do you see any pattern?
>>
>>46460794
>sir

Why would you gender someone anonymous?
>>
>>46460808
Those texture coordinates will either be the same if it's a big texture atlas, or it will use different textures, in which case you'll probably have an indices table that specifies all the faces.

So, using tex coords to encode unions of vertices makes no sense.
>>
>>46456756
>These exercises are totally kicking my ass, what do?
Go back and read the other stuff. *Think about it.* Don't do other things at the same time, just find a quiet spot to work on just this. The exercises might be hard, but you aren't reading the book to get a bit of a chuckle, you're doing it to learn. You aren't doing it for e-peen either; you aren't going to be the first person to finish.

You can ask for help, but think very carefully about what exactly you want help with. The more exactly you can describe what is causing you problems, the easier it is to help you and the less you'll actually need help because you'll be closer to the solution.

Be aware that real life is harder than exercises in any book. Not because the problems are harder, but because very often there's no solution, or at least not unless you get creative...
>>
>>46460789
why the he'll are you so fucking dense
The model uses one fucking texture and the fragment shader gets its values from interpoating between vertex values
You can't just "pass multiple values" to a fragment shader it doesn't work like that

>>46460829
The problem is when you define one index per vertex when calling glDrawElements so if one vertex has two different values of texcoord then you have to have two seperate indexes with the same position value but different texcoord value
>>
>>46460874
that's not my point, how is he supposed to figure which number I selected from say, the 20's range, if I hand him 1 or 8.
or if I selected a number from the 90's and gave him 1 or 8.
>>
File: hqdefault.jpg (9KB, 480x360px) Image search: [iqdb] [SauceNao] [Google]
hqdefault.jpg
9KB, 480x360px
>>46460889
how can you actually be this fucking dense
>>
>>46460976
Choose 3 numbers. Subtract the sum of the digits. Look at the resulting number (let's say it is 251) and tell me all but one of the digits (e.g., 1 and 2).
>>
>>46460958
Temporarily load all of the vertices, texture coordinates and normals into separate arrays then create your triangle array using them.
>>
>>46461050
I already know what I have to do, you fuckers just keep responding to me with blatent stupidity
>>
>>46461089
You mean "blatant".
>>
>>46461007
I give you 1 and 2. It's trivial to find that the other digit should be 6, but how do you know if the number I selected is between 130 and 139, or between 270 and 279 or between 630 and 639.

The other problem is once you've figured out which of those three ranges it's in, which number is it within those ranges?
>>
>>46461124
I'm not an eglish major
>>
>>46461131
Roll for a random one and hope for the best.
>>
>>46461131
You don't. The program just tells you what that missing digit is. It doesn't care if the number is 126, 621, 261, or whatever
>>
>>46461089
Why do you keep referring to it as a problem then?
>>
>>46461157
oh, fuck that, the whole problem is trivial, then. you might as well say "think of a multiple of nine and give me all but the last digit"

>>46461155
kek.
>>
>>46461184
Yeah. I was confused why it was giving people so much difficulty.
>>
What happens when you get an input stream twice from the same httpurlconnection (or something like this) object in java? Does it return the same input stream both times, or does it get different ones?
>>
>>46461199
Evidently I misread the problem.
>>
>>46461182
because coming up with a solution doesn't mean a problem ceases to exist, you just have a way to deal with it
>>
>>46460876
Have you ever seen a woman that is capable of understanding regexes ? Because I sure as hell haven't.
>>
Where's the best place to learn C? as far as I've learned from lurking on /g/, it's the best coding language. If there's any websites, or just videos that will point me in the right direction, anything would help.
>Note: This is coming from someone with no prior coding experience
>>
>>46461396
More than I could count.
>>
Hey /g/entoomen, I'm picking up Haskell and was trying my luck with the following simple exercise: make a program that prompts the user to enter an arbitrarily-sized list of numbers and then display them in reverse. I got the reversing function working and am working on the IO.

-- Custom implementation of Prelude.reverse for teh lulz
numReverse :: Num a => [a] -> [a]
numReverse (x:xs) = foldr (\y zs -> zs ++ [y]) [] (x:xs)


I have a primitive knowledge of Haskell and I already think my code is beautiful.

captcha: falic
>>
>>46461523
so you're a woman then?
>More than I could count.
huehue
>>
>>46461523

Really?
>>
>>46461553
Really.
>>
I want to make the next big language!

I'm thinking of calling it C##. Also, I'm thinking of using my favorite names from anime instead of weird names you see in normal programming languages. So, something like grep would be Omanko, printf would be Kawaii, and scanf could be Kowaisou. I think I'll give the program the codename "Necko" and also a strong static type system to handle exceptions. Also, it will be designed to support hot switches of modules from old versions to new versions in a live environment. I'll call it an "Oppai Transfer." Also, modules will be called Oppai.

How does my design sound so far DPT?

Oppai Example.

Main :: Void -> Void.
Main =: {
System-KawaiiLine: "Hello, Sempai!";

System Kawaii: "How many kazu would you like? ";
val input := System Kowaiisou: Integer;
val result := case input of
Just(value) => (1 to: input) join: " ";
Nothing => "Baka!";
end
System Kawaii: result;
}


Oppai FizzBuzz.

Main :: Void -> Void.
Main := {
1 to: 100
map: { i in
System KawaiiLine: (case i of
i % 15 => "FizzBuzz";
i % 3 => "Fizz";
i % 5 => "Buzz";
else => i :To-Necko-Toy;
end)
}
}
>>
>>46461506
I don't know about any sites or videos that will teach you that. Probably there are thousands but I've never bothered to look. However, I can recommend you this book: C Primer Plus, 5th Ed., Stephen Prata.

I learned quite a bit of C++ with one of this guy's books (surprisingly called C++ Primer Plus), and the C one is pretty similar so you could start from there.

Oh, and one thing, by the way: C is not the best programming language there is. In fact, there is no such thing as the best programming language. Thought you should know that, because people in /g/ tend to trick the less knowledgeable into doing or thinking a lot of bullshit and that's not good.
>>
>>46461726
>System-KawaiiLine
>-

Is this a typo error?
>>
>>46461726
just leave
>>
>>46461772
Yea, the dash shouldn't have been there. It was supposed to be
System KawaiiLine: "Hello Sempai!"
.
>>
>>46461822
Given that I spotted that having never even seen this language before I'd say it's pretty well designed. Well done, would recommend to beginners.
>>
>>46460474
Was fun, if I get well the idea.
import random
import sys
n = 0

print('Press Enter ')

def log(n):
if n == 1 :
print('Choose a card')
print('1 2 3 4 5 6 7 8 9 10 J Q K')
print('(J/Q/K being equal to 11)')
if n == 2 : print('Add 4 to it')
if n == 3 : print('Multiply it by 2')
if n == 4 : print('Subract 6 to it')
if n == 5 : print('Divide it by 2')
if n == 6 : print('Substract your original number to it')
if n == 7 : print('Your result is ')
if n == 8 :
delta = result(random.randint(0,10))
print(str(delta)+'')

def result(n):
delta = ((((((n+1)+4)*2)-6)//2)-(n+1))
return delta

while True:
char = sys.stdin.read(1)
n += 1
log(n)
>>
>>46461726
I take it you're trying to make a functional language. I can see some Haskell and Kotlin heritage there.
>>
>>46461726
What does the '%' operator do?
>>
>>46461970
If the type of the return result is an integer, then it returns a remainder. If the type of the return result is a bool, then it returns the divisibility.
>>
>>46462090
Can you show the type definition for it please?
>>
>>46462117
return a - (a / b) * b;
>>
>>46461765
Thanks for the help, i'll definitely check out the book, and if you don't mind answering another question, what are the best coding languages to learn for a working enviroment, or just ones that give you a better probability of being hired?
>>
>>46462117
(%) :: Integer -> Integer -> Integer.
(%) := ...;

(%) :: Integer -> Integer -> Bool.
(%) := { a, b in a % b = 0; }
>>
>>46461199
OP here. I found out how to find the missing digit but wanna check if its correct. Lets say i pic the number 326. I add the digits and get 11. Subtract that with 326 and i get 315. I give the computer the digits 1 and 5. I add 1+5, getting 6 which i divid by 9. That leaves me with a remainder 6 which if i subtract from 9 i get the missing number which is 3.

That all correct?
Thread posts: 369
Thread images: 30


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