Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Xguard86
Nov 22, 2004

"You don't understand his pain. Everywhere he goes he sees women working, wearing pants, speaking in gatherings, voting. Surely they will burn in the white hot flames of Hell"
ah I see, I guess I assumed most people would switch to 3.0 and I would be learning old tech. Nice to know I can just follow my book without a bunch of extra work. Thanks!

Adbot
ADBOT LOVES YOU

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
If your book's in Python 2, just use Python 2. Once you're through your book, the differences between 2 and 3 won't be a big deal for you.

pokeyman fucked around with this message at 05:23 on Jan 16, 2012

Strong Sauce
Jul 2, 2003

You know I am not really your father.





That seems like a really bad book to follow if they suggest students use eval to convert input like that. What happens when students transfer this idea and apply this to some query string input in a web app.

Xguard86
Nov 22, 2004

"You don't understand his pain. Everywhere he goes he sees women working, wearing pants, speaking in gatherings, voting. Surely they will burn in the white hot flames of Hell"

Strong Sauce posted:

That seems like a really bad book to follow if they suggest students use eval to convert input like that. What happens when students transfer this idea and apply this to some query string input in a web app.

my book is for 2.0, I found the 3.0 example stuff somewhere else.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Xguard86 posted:

my book is for 2.0, I found the 3.0 example stuff somewhere else.

Doesn't matter what version you're using. eval()ing anything is still usually not a good idea, especially when introducing a language to beginners. That was a good opportunity to introduce int() and ValueError handling and instead they told you to do something dangerous.

Soup in a Bag
Dec 4, 2009
Anybody have suggestions on where to get started with audio programming? My stupid day job is as a dev, but I've never dealt with audio before. I'm interested in realtime synthesis and processing with an eventual goal of writing audio plugins (VST/AU) and maybe iOS/OS X audio apps.

I found these at Amazon:
Real Sound Synthesis for Interactive Applications
The Audio Programming Book

At this point, I figure I'll start with the second of those two, but I'd appreciate advice from somebody who's done this already.

Advice on where to start with OS X/iOS audio would be good too. Maybe there are some good online guides?

coaxmetal
Oct 21, 2010

I flamed me own dad

Xguard86 posted:

ah I see, I guess I assumed most people would switch to 3.0 and I would be learning old tech. Nice to know I can just follow my book without a bunch of extra work. Thanks!

yea, 3 breaks compatibility with most third party libraries so it isn't used much. Realistically, i'm not sure it will ever be.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Soup in a Bag posted:

Advice on where to start with OS X/iOS audio would be good too. Maybe there are some good online guides?

Come say hi next door!

Look Around You
Jan 19, 2009

Just adding input on the eval issue. You should almost never eval anything to begin with, but you never want to run eval on raw user input like that. As was said already, eval just executes what it is passed. So that doesn't seem too bad with what you're intending it to be used as, but what happens if someone puts in sys.exit()? (answer: your program exits, which if it is a web server in production is probably Not Good).

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Note that ast.literal_eval is safe to use if you want something that can take a bunch of random Python objects. literal_eval supports strings, ints, floats, tuples, lists and dicts (and in Python 2.7, sets).

Modern Pragmatist
Aug 20, 2008

Munkeymon posted:

Doesn't matter what version you're using. eval()ing anything is still usually not a good idea, especially when introducing a language to beginners. That was a good opportunity to introduce int() and ValueError handling and instead they told you to do something dangerous.

I believe that what he is saying is that the actual text he is working from didn't suggest this technique (I hope that's the case). I'm assuming that it was from terrible Stack Overflow answer or something. But yes, don't do that.

Hot drat! Good to know.
VVV

Modern Pragmatist fucked around with this message at 06:01 on Jan 17, 2012

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
It said to use input, which has an implicit eval inside of it.

Look Around You
Jan 19, 2009

Suspicious Dish posted:

It said to use input, which has an implicit eval inside of it.

Holy gently caress. I just checked the docs. Apparently in python2.x input() is just eval(raw_input()). That's so loving terrible.

It looks like they changed it for python3.x to just getting a string though (which is probably why his stuff was breaking in that example anyway).

Jewel
May 2, 2009

Hooly poo poo. Nice going python. I know a lot of people who used raw_input for strings and input for ints. Look at this.

Crosscontaminant
Jan 18, 2007

In all likelihood input() is only there as a shim so Python 3 code doesn't completely poo poo a brick when passed over by a Python 2 interpreter, since there's supposed to be some sort of compatibility guff going on between the two which I don't fully understand. I wasn't aware it was as huge a security hole as literally being a wrapper around eval() though.

nielsm
Jun 1, 2009



Crosscontaminant posted:

In all likelihood input() is only there as a shim so Python 3 code doesn't completely poo poo a brick when passed over by a Python 2 interpreter, since there's supposed to be some sort of compatibility guff going on between the two which I don't fully understand. I wasn't aware it was as huge a security hole as literally being a wrapper around eval() though.

Python 1.4 docs:

quote:

input([prompt])
Almost equivalent to eval(raw_input(prompt)). Like raw_input(), the prompt argument is optional. The difference is that a long input expression may be broken over multiple lines using the backslash convention.

It has been that way since forever.

Xguard86
Nov 22, 2004

"You don't understand his pain. Everywhere he goes he sees women working, wearing pants, speaking in gatherings, voting. Surely they will burn in the white hot flames of Hell"

Modern Pragmatist posted:

I believe that what he is saying is that the actual text he is working from didn't suggest this technique (I hope that's the case). I'm assuming that it was from terrible Stack Overflow answer or something. But yes, don't do that.

Hot drat! Good to know.
VVV

This is correct but the text makes no mention that input() is actually eval( raw_input()).

Thats a little scary, I mean the book isn't about python but more for learning fundamental CS (or in my case, relearning it) but drat they could have at least put a little asterik with a warning not to run off and use it for anything outward facing.

Based on that, I am considering scrapping this book since god knows what other terrible things it will teach me. Anyone have any suggestions for CS 101 books I can use for self study that won't teach me terrible things? I do have basic knowledge of general concepts, I took a couple of coding classes in school a couple of years ago, I just need practice and some handholding when things get more advanced.

EDIT: oh hey someone asked exactly that question in the python thread, so answer if you want but I already found some good info.

Xguard86 fucked around with this message at 23:35 on Jan 17, 2012

Johnny Cache Hit
Oct 17, 2011
Hi all, hiring/job search question -- I thought about putting this in the megathread but that looked more tailored for finding a first job, and that's not me.

My startup may be winding down over the next few weeks, so I'm looking to get my personal webpage updated to show off my talents. Thanks to this startup I've done a shitton of web work that I've never done before, including implementing some (nice looking) designs. Is it legit to show screenshots of the finished product on my website and call it part of a "portfolio"? Or will people immediately think "oh hey he can do graphic design work as well" when in reality I can turn a PSD into nice CSS but I can't design my way out of a paper bag? Is there any way I can word this so that people understand?

tef
May 30, 2004

-> some l-system crap ->
Put a shot of the psd along side the final product, and hope the writing surrounding it explains enough context?

Sab669
Sep 24, 2009

I'd just say you were given a design and were able to accurately implement it. Infact, if you DIDN'T create it, couldn't that cause you problems if you didn't clearly state they're not your design?

Johnny Cache Hit
Oct 17, 2011

Sab669 posted:

I'd just say you were given a design and were able to accurately implement it. Infact, if you DIDN'T create it, couldn't that cause you problems if you didn't clearly state they're not your design?

Yeah, exactly - that's what I want to avoid. I don't want to take any credit for something I didn't do and misrepresent. I was wondering how (if?) other devs handled this.

Thanks to you & tef :)

Rello
Jan 19, 2010
Hey, would anyone happen to know a decent resource I could use to help me learn automata theory?

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Rello posted:

Hey, would anyone happen to know a decent resource I could use to help me learn automata theory?

It kinda depends on why you want to learn it. There are a bunch of textbooks with titles like "Introduction to Computability Theory" that cover the basics, but if you have some specific applications in mind, they probably won't cover them.

Sab669
Sep 24, 2009

e; SELECT * FROM users where IQ < 75 AND username = 'sab669'

Sab669 fucked around with this message at 22:40 on Jan 19, 2012

Benson Cunningham
Dec 9, 2006

Chief of J.U.N.K.E.R. H.Q.

Sab669 posted:

e; SELECT * FROM users where IQ < 75 AND username = 'sab669'

code:

--------------------------------------------------
|     username  |        iq      |   friends     |
--------------------------------------------------
|                                                |
|     sab669    |        75      |      0        |
|               |                |               |
--------------------------------------------------

edit: I bet there would be an array in friends. Horrible practice, Me.
2x edit: oohh noooo that wouldnt even work because 75 isn't less than 75, I am the idiot!

rolleyes
Nov 16, 2006

Sometimes you have to roll the hard... two?
And friends should be listed in a separate table. Normalisation! :science:

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Clearly users is a view and friends is an aggregate column.

Mr. Crow
May 22, 2008

Snap City mayor for life
So for someone with basically no web development experience, what's the recommended go-to language for making a web site? I've been suggested Ruby on Rails or node.js, any thoughts on either one? Or something else?

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Kim Jong III posted:

Yeah, exactly - that's what I want to avoid. I don't want to take any credit for something I didn't do and misrepresent. I was wondering how (if?) other devs handled this.

Thanks to you & tef :)

Something like "Implementation by Kim Jong III, design by Adolf Shitlord" maybe? And then ask Alf or whoever owns the rights for permission.

mobby_6kl
Aug 9, 2009

by Fluffdaddy
Any ideas on how I could go about generating all Latin squares of order n? So far I can create n such squares cyclically:
code:
void create_ls (int * ls, int n, int start)
{
   int i, j;
   for (i = 0; i<n; i++)
      for (j = 0; j<n; j++)
         ls[i*n+j] = (i+j+n+start-1)%n;
}

// and calling this repeatedly with start=1..n creates this:
0 1 2 3   1 2 3 0   2 3 0 1  3 0 1 2
1 2 3 0   2 3 0 1   3 0 1 2  0 1 2 3
2 3 0 1   3 0 1 2   0 1 2 3  1 2 3 0
3 0 1 2   0 1 2 3   1 2 3 0  2 3 0 1
That's clearly not all of them, but the best I could find so far was a way to create random ones using Markov chains. Yes, this is homework but not mine... I'm trying to help a friend who's completely clueless, but I'm not faring much better at the moment :ohdear:

Benson Cunningham
Dec 9, 2006

Chief of J.U.N.K.E.R. H.Q.

Mr. Crow posted:

So for someone with basically no web development experience, what's the recommended go-to language for making a web site? I've been suggested Ruby on Rails or node.js, any thoughts on either one? Or something else?

What do you want it to do?

Mr.Hotkeys
Dec 27, 2008

you're just thinking too much

mobby_6kl posted:

Any ideas on how I could go about generating all Latin squares of order n? So far I can create n such squares cyclically:

Create every possible square where each row contains one of each number and then run over the results and cull out the invalid ones? I'm sure someone'll come in with some beautiful way to do it but honestly that just sounds like the easiest way to me, though I don't know if that's C or C++.

qntm
Jun 17, 2009
The fact that there isn't an exact formula for the number of Latin squares of side n suggests pretty strongly to me that there also isn't a good procedure for generating all of them.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Mr.Hotkeys posted:

Create every possible square where each row contains one of each number and then run over the results and cull out the invalid ones? I'm sure someone'll come in with some beautiful way to do it but honestly that just sounds like the easiest way to me, though I don't know if that's C or C++.

Would probably use a huge amount of memory even for not very large n.

Two observations:

1) You can fix the first row of the square, find all magic squares (let's say there are k of them) with that first row, and then generate the remaining squares by applying permutations of the integers 0 through n - 1. (This gives you n! × k squares in total.)

2) To generate those magic squares in the first place, you could take the approach of generating a tree of height n by filling in rows one by one, filtering out partial squares that have already failed to satisfy the requirement of having each number appear at most once in each column. Here is a partial illustration in the case n = 4:

shrughes
Oct 11, 2008

(call/cc call/cc)

Hammerite posted:

2) To generate those magic squares in the first place,

FYI These are not magic squares.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

shrughes posted:

FYI These are not magic squares.

Oh yeah, I don't know what happened there. I was talking about Latin squares but saying "magic squares".

Mr. Crow
May 22, 2008

Snap City mayor for life

Benson Cunningham posted:

What do you want it to do?

Nothing in particular at the moment, just gonna be a personal website to learn on. I guess which have the most wide reaching applications for future use?

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Mr. Crow posted:

So for someone with basically no web development experience, what's the recommended go-to language for making a web site? I've been suggested Ruby on Rails or node.js, any thoughts on either one? Or something else?

Mr. Crow posted:

Nothing in particular at the moment, just gonna be a personal website to learn on. I guess which have the most wide reaching applications for future use?

First you should understand that Rails is a full-stack web framework built on Ruby and node.js is a collection of system functions/tools based in javascript designed for event-driven high-scale applications. Right now I believe the most popular web framework for node.js is Express.

If you are doing this in order to add to your list of skills in your resume (as in you want to use the most common languages/web frameworks), I would consider Django, then Rails, then node.js. I'm mainly doing Ruby now (not much Rails) and a lot of jobs are primarily looking for Python and Django developers. Not that there isn't positions with Rails/Ruby and Nodejs but from my own personal search these past couple of months there are a lot of people looking for Django and/or Python developers.

If you're just doing this to learn, then use whatever language you want. Express and node.js are relatively stable but for some libraries there is no definitive or even top 3 that you can choose from. A lot of it will rely on you evaluating the libraries yourself since nodejs is still relatively young. Rails and Ruby are pretty mature projects with lots of documentation and examples with only a couple of libraries for each specific category so if you need to choose one you can just use Google and read other people's evaluation of it.

In the end I think there is a future for node.js and Python and Ruby so just do the one you enjoy doing the most. When it comes time to getting a job employers will probably care more that you did something, even if its not in their preferred choice of stack/language.

mobby_6kl
Aug 9, 2009

by Fluffdaddy

Mr.Hotkeys posted:

Create every possible square where each row contains one of each number and then run over the results and cull out the invalid ones? I'm sure someone'll come in with some beautiful way to do it but honestly that just sounds like the easiest way to me, though I don't know if that's C or C++.

I'm usually the first one to apply brute force to such issues, but as Hammerite pointed out, this would be very likely to run into running time and/or memory issues with increasing n. The code I posted is C, but that's only because I want to learn it and no other reason. If it's supposed to be in Java or something, converting it would be left as an exercise for the reader.

Hammerite posted:

Would probably use a huge amount of memory even for not very large n.

Two observations:

1) You can fix the first row of the square, find all magic squares (let's say there are k of them) with that first row, and then generate the remaining squares by applying permutations of the integers 0 through n - 1. (This gives you n! × k squares in total.)

2) To generate those magic squares in the first place, you could take the approach of generating a tree of height n by filling in rows one by one, filtering out partial squares that have already failed to satisfy the requirement of having each number appear at most once in each column. Here is a partial illustration in the case n = 4:


After a bit more searching, it doesn't seem like there's a simple way of doing this, and your tree suggestion looks like a very nice approach for more efficiently generating all the possible combinations. I'll have a go at implementing this, and meanwhile try to find out what was the context for this task, perhaps there's a particular technique that was supposed to be used here.

Adbot
ADBOT LOVES YOU

JawnV6
Jul 4, 2004

So hot ...
gcc's being lazy about the stack. It's compiling a function and after the args are consumed it just slaps new data into [esp] and [esp+4] before calling another function. Are there any flags that will force it to play nice and actually push the args?

I'm doing some inline assembly that's getting mixed up and couldn't find any way to express "hey this is pushing something on the stack don't touch it". Right now I'm just modifying the machine code once it's done but that's annoying and I'd rather avoid it entirely.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply