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.
 
  • Locked thread
QuarkJets
Sep 8, 2008

Speaking of Makefiles, is there a Makefile thread or a good resource for learning about Makefiles? I don't loving understand Makefiles

I understand that the Python thread may not be the best place to ask these questions

Adbot
ADBOT LOVES YOU

Pollyanna
Mar 5, 2005

Milk's on them.


Done and done. URL's back to the way it used to be.

fletcher posted:

Hmmm that's not good...XSS vulnerability on here? I'm not getting any alerts on this page.

I don't either. I haven't seen any alerts anymore either, altho I did ask the page to stop popping boxes up eventually :v:

Pivotal Lever posted:

Well done, Pollyanna, I've watched you grow in this thread from someone most posters rolled their eyes at, to someone who created a working heroku app. Keep it up! </sincere>

edit: I say this as someone this thread would've rolled their eyes at during my most enthusiastic Python phase :) It's a compliment, my friend!

Thanks :) I have this issue where if I don't know exactly how to do something before I do it I freak the gently caress out over it, but now that I've started working on that things have finally gotten going.

QuarkJets posted:

Speaking of Makefiles, is there a Makefile thread or a good resource for learning about Makefiles? I don't loving understand Makefiles

I understand that the Python thread may not be the best place to ask these questions

Makefiles is for compiling things. Python scripts are interpreted rather than compiled (at least not by yourself, I dunno what the deal with .pyc files are). They're mostly used in C/C++.

Dren
Jan 5, 2001

Pillbug

QuarkJets posted:

Speaking of Makefiles, is there a Makefile thread or a good resource for learning about Makefiles? I don't loving understand Makefiles

I understand that the Python thread may not be the best place to ask these questions

What do you want to do, exactly?

I made this post one time: http://forums.somethingawful.com/showthread.php?threadid=2773485&pagenumber=365&perpage=40#post419124192

Maybe it could help you.

Generally you want to consult the 'GNU make manual'. http://www.gnu.org/software/make/manual/make.html

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

Thermopyle posted:

Yep.

Pollyanna, to be clear, your URL should look like:

http://rpazyaquian.herokuapp.com/stocks/GOOG,AAPL,MSFT
I think this is actually a little worse from an interface perspective. Most HTTP clients have great support already for taking arrays and properly making query arguments from them. Why shift this activity back down to the API consumer and make it more work for them?

It's not RESTful anyway, since it represents more than one resource. There's also no canonical URL for it since the arguments can come in any order, so the whole thing seems pointless.

Pollyanna
Mar 5, 2005

Milk's on them.


Okay well for now I have one version of that commented out and another version kept in.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

Misogynist posted:

I think this is actually a little worse from an interface perspective. Most HTTP clients have great support already for taking arrays and properly making query arguments from them. Why shift this activity back down to the API consumer and make it more work for them?
Depends on who you consider the API consumer. In this case, humans are entering the URLs, and this form definitely reduces the work for them.

Dren
Jan 5, 2001

Pillbug

Mustach posted:

Depends on who you consider the API consumer. In this case, humans are entering the URLs, and this form definitely reduces the work for them.

A url isn't really a great interface. Humans would be better served by a widget on the page that let them switch which stock(s) they were seeing without messing about in the URL bar.

salisbury shake
Dec 27, 2011

Pollyanna posted:

I don't either. I haven't seen any alerts anymore either, altho I did ask the page to stop popping boxes up eventually :v:

Are you passing debug=True when you start your Flask app? Might want to look into input validation and do a quick diff of the app on heroku vs your local code and then look at this.

QuarkJets
Sep 8, 2008

Pollyanna posted:

Makefiles is for compiling things. Python scripts are interpreted rather than compiled (at least not by yourself, I dunno what the deal with .pyc files are). They're mostly used in C/C++.

I'm well aware of that

Dren posted:

What do you want to do, exactly?

I made this post one time: http://forums.somethingawful.com/showthread.php?threadid=2773485&pagenumber=365&perpage=40#post419124192

Maybe it could help you.

Generally you want to consult the 'GNU make manual'. http://www.gnu.org/software/make/manual/make.html

I'll check that out, thanks

Pollyanna
Mar 5, 2005

Milk's on them.


As a way of organizing my thoughts re: getting my app going, I wrote up a little tutorial on embedding Bokeh plots in Flask. I've never written a tutorial before, so I'd like some critique/advice on it. Here's the tutorial. Is it confusing? Does it work properly when you follow it?

salisbury shake posted:

Are you passing debug=True when you start your Flask app? Might want to look into input validation and do a quick diff of the app on heroku vs your local code and then look at this.

They haven't popped up since. Whatever was causing them isn't around anymore, I guess. v:shobon:v

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Misogynist posted:

I think this is actually a little worse from an interface perspective. Most HTTP clients have great support already for taking arrays and properly making query arguments from them. Why shift this activity back down to the API consumer and make it more work for them?

It's not RESTful anyway, since it represents more than one resource. There's also no canonical URL for it since the arguments can come in any order, so the whole thing seems pointless.

But the client is a human being typing urls in.

Dren posted:

A url isn't really a great interface. Humans would be better served by a widget on the page that let them switch which stock(s) they were seeing without messing about in the URL bar.

Sure, but...that's not what Polyanna has.

evensevenone
May 12, 2001
Glass is a solid.

QuarkJets posted:

Speaking of Makefiles, is there a Makefile thread or a good resource for learning about Makefiles? I don't loving understand Makefiles

I understand that the Python thread may not be the best place to ask these questions

I'm not sure what you're looking for with regard to make and python (i have a makefile borrowed from a coworker for making pip-style packages, but it's kind of hacky) but the make documentation is pretty loving terrible and there are a ton a weird make behaviors that exist to make sure makefiles written 35 years ago still work.

The simplest way to understand it is that when you invoke make, it uses the makefile to build a tree. The base of the tree is the target your specify (or the one that is inferred). For each target, the makefile specifies list of dependencies, and a series of commands to make the target--this is called a 'rule'. Those dependencies are files, but those files can also be targets with their own rules. And that pattern goes all the way up until you get to source files. So make works its way up the tree, checks if any of the leaves are newer than their targets, and remakes the associated targets if they are, until you are back at the base and everything is up-to-date.

The tricky thing is that there a bunch of implicit rules. For example if make needs a .o file, it'll assume it can make it from a .c file of the same name using gcc, and so on. So a lot of the example makefiles you see rely on implicit rules heavily and it isn't always clear what is going on. There are also a few different syntaxes, which you're allowed to freely mix in the same makefile, making things extra confusing (especially because a lot of the tutorials use older syntaxes that aren't covered well in newer docs).

Pollyanna
Mar 5, 2005

Milk's on them.


Thermopyle posted:

Sure, but...that's not what Polyanna has.

That's what I have right now, but that's subject to change. I'd love to hear of any other ways I can solve this problem.

evensevenone
May 12, 2001
Glass is a solid.
I wonder if there is some sort of way that a user could click on something on a webpage and then the web browser would load a page based on what the user clicked. Seems pretty unlikely though.

My Rhythmic Crotch
Jan 13, 2011

Pollyanna posted:

That's what I have right now, but that's subject to change. I'd love to hear of any other ways I can solve this problem.
There are about a billion different little nuances, so I won't get into details, but in general:
- The user enters the stock symbol into a text box
- When the user clicks the "go" button, a javascript POST is done against a particular URL, sending the desired stock symbol to your app.
- Your app is listening for POST requests on that URL and it returns some kind of graph data.
- The javascript running in the browser receives that response, passes it to the graphing library.
- The graphing library displays the graph in the browser.

Now, your situation might be a little more complicated. I'm looking at Bokeh and how it works, and I'm not sure how much difficulty will be encountered when trying to get Bokeh to display a graph without refreshing the whole entire page (notice in my description above, the user never clicked the reload button and javascript never initiated a full page reload). If you do run into a lot of trouble getting Bokeh to display the graph, you might have to resort to more primitive means:
- The user enters the stock symbol in a text box
- When the user clicks the "go" button, do a full page reload: window.location.replace("www.whatever.com/stocks/AAPL") or window.location.href = "whatever.com/AAPL"

That's just how I would approach it personally. Take with a grain of salt.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

My Rhythmic Crotch posted:

There are about a billion different little nuances, so I won't get into details, but in general:
- The user enters the stock symbol into a text box
I know I've become a cranky old programmer when, after reading all of that, I thought "that seems like a lot of work to replicate a feature of every web browser". I know, I know, the web hasn't evolved that way, non-technical users have been trained by URLs filled with ?zhwa=afe8c798b7ad to ignore the address bar until they want to copy/paste, and if they didn't they shouldn't be expected to remember similar "tricks" across a variety of site, etc. But still, :sigh: the web.

My Rhythmic Crotch
Jan 13, 2011

To be honest, I have no clue what you're really trying to say, but never fear: the task at hand is not really all that hard. I bet Pollyanna will knock it out.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

My Rhythmic Crotch posted:

To be honest, I have no clue what you're really trying to say
I'm whinging about coding a text field, button, and ajax handling rather than being able to expect people to simply type the same text into the address bar. Just a fool's sad lament.

Dren
Jan 5, 2001

Pillbug

Mustach posted:

I know I've become a cranky old programmer when, after reading all of that, I thought "that seems like a lot of work to replicate a feature of every web browser". I know, I know, the web hasn't evolved that way, non-technical users have been trained by URLs filled with ?zhwa=afe8c798b7ad to ignore the address bar until they want to copy/paste, and if they didn't they shouldn't be expected to remember similar "tricks" across a variety of site, etc. But still, :sigh: the web.

lemme just pop http://forums.somethingawful.com/newreply.php?action=newreply&postid=423500815 in and make a new post here... yep. You're right this is pretty good. Much better than if there were a "reply" button.

The March Hare
Oct 15, 2006

Je rêve d'un
Wayne's World 3
Buglord

Dren posted:

lemme just pop http://forums.somethingawful.com/newreply.php?action=newreply&postid=423500815 in and make a new post here... yep. You're right this is pretty good. Much better than if there were a "reply" button.

I mean, he is arguing this specific use case wherein it really isn't any more difficult since you just type in the ticker symbol of your stock -- so this is not really a great point.

A better one would be that the form she could make would also allow for things like fuzzy matching &c. So, in this particular case, the argument is really that a form would be potentially more feature rich than just going by the URL in addition to his initial point of 'people don't use the addy bar'.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
A URL is part of your interface though. Kind of the point, an app that takes care to create good URLs can make it very easy to find the resource you want. This is especially true if you semi know your entry point, don't have a bookmark, and have addresses in your history. Auto complete can often get you to your URL in one go, provided the URLs are human readable.

No one is really arguing for them in place of your own UI work, but they certainly shouldn't be shunned as beneath concern.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Dren posted:

lemme just pop http://forums.somethingawful.com/newreply.php?action=newreply&postid=423500815 in and make a new post here... yep. You're right this is pretty good. Much better than if there were a "reply" button.

I wish there wasn't a Reply button just so I didn't have to see this awful post.

Pollyanna
Mar 5, 2005

Milk's on them.


Building pretty URLs is fine and dandy, but I can see end-users bitching about having to type in the address bar. I should probably let the user type in a list of symbols they want and just navigate to the requisite URL. Something like:

code:
Welcome! What symbols would you like to look up?

# textareas start here
[AAPL]
[GOOG]
[IBM ]
# textareas end here

[Submit]

Additionally, I can see that /AAPL,GOOG,IBM would be functionally identical to /GOOG,AAPL,IBM which sets off my "don't repeat yourself" alarm. I don't know if it's a false alarm, though.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
It's not your only interface. That's the point, you have a url which is friendly enough to be memorable, and then you have your actual interface with buttons and text fields and stuff.

BigRedDot
Mar 6, 2008

My Rhythmic Crotch posted:

Now, your situation might be a little more complicated. I'm looking at Bokeh and how it works, and I'm not sure how much difficulty will be encountered when trying to get Bokeh to display a graph without refreshing the whole entire page (notice in my description above, the user never clicked the reload button and javascript never initiated a full page reload). If you do run into a lot of trouble getting Bokeh to display the graph, you might have to resort to more primitive means:
- The user enters the stock symbol in a text box
- When the user clicks the "go" button, do a full page reload: window.location.replace("www.whatever.com/stocks/AAPL") or window.location.href = "whatever.com/AAPL"

That's just how I would approach it personally. Take with a grain of salt.
If you use Bokeh in server mode it is very easy to update the plot without any page reloads, the app just needs to update the data source on the server and the plot will update itself. You could even have the plot update continuously automatically as new data comes in.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Pollyanna posted:


Additionally, I can see that /AAPL,GOOG,IBM would be functionally identical to /GOOG,AAPL,IBM which sets off my "don't repeat yourself" alarm. I don't know if it's a false alarm, though.

Where have you repeated code?

There is no reason to not have good looking URLs and they do make your app look better, have more memorable URLs, feel more modern, and function better.

onionradish
Jul 6, 2006

That's spicy.

Pollyanna posted:

Additionally, I can see that /AAPL,GOOG,IBM would be functionally identical to /GOOG,AAPL,IBM which sets off my "don't repeat yourself" alarm. I don't know if it's a false alarm, though.
The URLs aren't functionally identical. Changing the order in the URL changes the order of display. So your first example puts APPL first; the second puts GOOG first. Allowing an easy method to specify that order in the URL is a GOODTHING.

Dominoes
Sep 20, 2007

Looking for some regex help. I'm trying to standardize lat/lon coordinates into degrees-decimals from different input formats.

Here's a regex to match degrees-min-decimals. It includes groupings to extract the data.
code:
r'([NS])\s*(\d{2})\s*(\d{2})\.?(\d*)'
For the end, I'd like to group the serach for a decimal, and digits after a decimal together. Ie: Only match digits at the end if the decimal's there.

So it would validly match: 'N52 40.1234' or 'N52 32', but not 'N52 230999'. The quoted one I posted above will match the last one, when it shouldn't. I could probably work around this with separate regexes, but I think there's a way to do it with one.

Dominoes fucked around with this message at 18:04 on Dec 22, 2013

onionradish
Jul 6, 2006

That's spicy.
You can do conditional regex matching with a look-ahead regex. It can make the regex pattern really gnarly, so you'll have to decide whether it's worth it for code readability.
Python code:
'(?=...)' # Positive lookahead assertion
# Matches if '...' matches next.

'(?!...)' # Negative lookahead assertion
# Matches if '...' does not match next.

'(?<=...)' # Positive lookbehind assertion
# Matches if the searched substring is preceded by a match for '...'.
# Note that the contained pattern must only match strings of some fixed length.

'(?<!...)' # Negative lookbehind assertion
# Matches if the searched substring is not preceded by a match for '...'.
# Note that the contained pattern must only match strings of some fixed length.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Python code:
>>> print re.match(r'(\d{2})(?:\.(\d*))?$', '230999')
None
>>> print re.match(r'(\d{2})(?:\.(\d*))?$', '23.0999').groups()
('23', '0999')
(?:) is a non-capturing grouping. Without the $ at the end the first matches as ('23', None), which may or may not be what you want.

semicolonsrock
Aug 26, 2009

chugga chugga chugga
What is a good IDE for Mac, for a total beginner who really would like installation + use to be as simple as possible. Using CodeAcademy's online one is probably not a long term solution.

Pollyanna
Mar 5, 2005

Milk's on them.


Definitely PyCharm. I have the Community (free) Version and it's great.

Dren
Jan 5, 2001

Pillbug

Dominoes posted:

Looking for some regex help. I'm trying to standardize lat/lon coordinates into degrees-decimals from different input formats.

Here's a regex to match degrees-min-decimals. It includes groupings to extract the data.
code:
r'([NS])\s*(\d{2})\s*(\d{2})\.?(\d*)'
For the end, I'd like to group the serach for a decimal, and digits after a decimal together. Ie: Only match digits at the end if the decimal's there.

So it would validly match: 'N52 40.1234' or 'N52 32', but not 'N52 230999'. The quoted one I posted above will match the last one, when it shouldn't. I could probably work around this with separate regexes, but I think there's a way to do it with one.

try this:
code:
([NS])\s*(\d{2})\s*((\d{2})(\.(\d+))|\d{2}(\s|$))?
worked for me on this test data:
code:
N52 40.1234
N52 230999
N52 32
@ http://regexpal.com/ with "^$ match at line breaks" checked

Dominoes
Sep 20, 2007

Dren posted:

try this:
code:
([NS])\s*(\d{2})\s*((\d{2})(\.(\d+))|\d{2}(\s|$))?
worked for me on this test data:
code:
N52 40.1234
N52 230999
N52 32
@ http://regexpal.com/ with "^$ match at line breaks" checked
Thanks dude - this works. It also matches 'N52'; even better.

Dominoes fucked around with this message at 19:56 on Dec 23, 2013

Dominoes
Sep 20, 2007

I love how easily cross-platform Python and its tools are. I've been in a transient period for the past three months, using a laptop with Ubuntu. Since then, I picked up some new habits like using Git, Pycharm,IPython etc. To transition back to the Windows desktop, all I had to do was copy and past my code folder, and install git/pycharm/ipython. My programs and Django apps run with no additional configuration, PyCharm looks the same after setting up the fonts, and it recognizes my Qt etc modules now.

My only gripe is that Qt fonts don't automatically scale.

Dominoes fucked around with this message at 20:20 on Dec 23, 2013

Pivotal Lever
Sep 9, 2003

Pollyanna posted:

Thanks :) I have this issue where if I don't know exactly how to do something before I do it I freak the gently caress out over it, but now that I've started working on that things have finally gotten going.

Trust me, I know the feeling. I was afraid that I was just cargo-culting for a long time. Recently, I feel like I am finally harnessing the power of Python and other programming languages for my own purposes! Keep up the good work :)

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

Dominoes posted:

I love how easily cross-platform Python and its tools are. I've been in a transient period for the past three months, using a laptop with Ubuntu. Since then, I picked up some new habits like using Git, Pycharm,IPython etc. To transition back to the Windows desktop, all I had to do was copy and past my code folder, and install git/pycharm/ipython. My programs and Django apps run with no additional configuration, PyCharm looks the same after setting up the fonts, and it recognizes my Qt etc modules now.

My only gripe is that Qt fonts don't automatically scale.

But why would you wanna develop on Windows?? Install an Ubuntu VM on your desktop :)

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

fletcher posted:

But why would you wanna develop on Windows?? Install an Ubuntu VM on your desktop :)

This is exactly what I've been doing for a few months after I moved back from an Ubuntu-on-the-metal setup. I've got Ubuntu installed and running via VMware Player on my Windows 7 machine. Pretty much all the time two monitors have Ubuntu with PyCharm and terminal windows and whatnot on them and the third monitor has my Windows desktop.

Dominoes
Sep 20, 2007

I've been putting off learning VMs. I play games sometimes and don't want to dual boot. The main downsides I've run into on Windows are it doesn't like to compile C, and the terminal's comparatively sparse.

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Dominoes posted:

I play games sometimes and don't want to dual boot.

That's exactly why I'm back on Windows using Ubuntu in a VM.

It will take you an hour to get Ubuntu running in a VM.

1. Download VMWare Player.
2. Download the latest Ubuntu ISO.
3. Run through the new VM wizard in Player.
4. Done.

  • Locked thread