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
raminasi
Jan 25, 2005

a last drink with no ice

Thermopyle posted:

Does anyone else find that every once in a while they get stuck on a simple problem that you know is a simple problem?

I spent an hour trying to get a stupid 6 line for loop working that looked for a column of data with the lowest number of elements in it with a couple of constraints on what kinds of elements got counted. Super simple Baby's First Programming 101 problem and I could have cried because I couldn't see where I hosed it up.

(Turns out that a ">" is not the same thing as a "<")

After enough times fruitlessly pulling my hair out from 4pm to 6pm, going home for the day, and then solving the problem in five minutes the next morning, I've started just going home at 4 when this happens. (It's nice to be able to do that.)

Adbot
ADBOT LOVES YOU

Seashell Salesman
Aug 4, 2005

Holy wow! That "Literally A Person" sure is a cool and good poster. He's smart and witty and he smells like a pure mountain stream. I posted in his thread and I got a FANCY NEW AVATAR!!!!

GrumpyDoctor posted:

After enough times fruitlessly pulling my hair out from 4pm to 6pm, going home for the day, and then solving the problem in five minutes the next morning, I've started just going home at 4 when this happens. (It's nice to be able to do that.)

Learning to give up on totally solving stuff TODAY is a big life lesson.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

Seashell Salesman posted:

Learning to give up on totally solving stuff TODAY is a big life lesson.

Also learning to schedule your deadline so that it doesn't have to be done TODAY :)

I'm still terrible at predicting how long a task will take me, honestly :doh:

Red Robin Hood
Jun 24, 2008


Buglord
This may or may not be a programming question but it does not deserve its own thread!

The company I work for is having a problem with a service crashing a lot. It very likely isn't out fault and at this point we just want to monitor it so that if it goes down we know and can get it turned back on. I thought a powershell script might work but I don't think it will monitor in real-time. This wouldn't be a permanent fix, just something to put in place until we can get SCOM up and running.

Any suggestions?

Seashell Salesman
Aug 4, 2005

Holy wow! That "Literally A Person" sure is a cool and good poster. He's smart and witty and he smells like a pure mountain stream. I posted in his thread and I got a FANCY NEW AVATAR!!!!

Red Robin Hood posted:

This may or may not be a programming question but it does not deserve its own thread!

The company I work for is having a problem with a service crashing a lot. It very likely isn't out fault and at this point we just want to monitor it so that if it goes down we know and can get it turned back on. I thought a powershell script might work but I don't think it will monitor in real-time. This wouldn't be a permanent fix, just something to put in place until we can get SCOM up and running.

Any suggestions?

If you want a stop-gap until you get on-premises SCOM up then you can monitor your app using Microsoft Monitoring Agent (http://www.microsoft.com/en-us/download/details.aspx?id=40316). I'll try to dig up a blog post with good instructions on how to use it. Basically it will run the SCOM agent and can either output log files locally or connect to a System Center Manager endpoint to output to a SCOM database. Not sure if this is what you're looking for.

For PowerShell you can use the IIS management library [e: Microsoft.Web.Administration.dll was what I was thinking of] to check the status of your app and/or app pool and send off emails in real-ish time?

Seashell Salesman fucked around with this message at 18:31 on Oct 9, 2013

Jethro
Jun 1, 2000

I was raised on the dairy, Bitch!

Red Robin Hood posted:

This may or may not be a programming question but it does not deserve its own thread!

The company I work for is having a problem with a service crashing a lot. It very likely isn't out fault and at this point we just want to monitor it so that if it goes down we know and can get it turned back on. I thought a powershell script might work but I don't think it will monitor in real-time. This wouldn't be a permanent fix, just something to put in place until we can get SCOM up and running.

Any suggestions?
It's been a while since I had to play around with that sort of stuff, but assuming it's a standard Windows service, isn't there a "Restart on crash" setting somewhere in the service properties?

my cat is norris
Mar 11, 2010

#onecallcat

I don't really know if this question is for CoC or if I should go over to the Haus.

I am pretty pathetic with SQL queries beyond a very very very basic point. Problem is, today I've been handed some work my coworker would normally handle. She's out sick. My available resources are pretty limited. I'm turning to you guys for a bit of guidance.

I'm sure you'll find this laughably simplistic.

I have 475 records in one table which need to be added into another table in addition to several other values.

If I was doing this one record at a time, it'd be pretty easy for me --

code:
insert into tblcGenesis (sCommand, sCode, nForm, sLanguage, nStatus, 
nAtrionVerified, dTransferred, nPriority, nHasPreviouslyGenerated, nForceValidate)
values ('GVA', 'CODE', 54, 'Ger', 0, 0, '2013-10-11 08:45:00.000', 5, 0, 0);
But I need to do this 475 times for 475 unique codes contained in another table.

The sCode column in tblcGenesis will be populated by codes contain in the sCode column from tblzzzzzDA5. I'm guessing this is a join situation? Is left join the way to go? How do I then insert the rest of the new data? Everything needs to be identical with the exception of the new codes inserted from tblzzzzzDA5.

I haven't touched this stuff in like five years. I'd like to knock off the rust, though, so I'm not looking for the answer, just a nudge in the right direction.

Ugh I feel so dumb for asking at all but seriously I am bad with this.

nielsm
Jun 1, 2009



There is an SQL thread too, but from skimming your question, what you want is an INSERT INTO table (fields, ...) SELECT fields, constants, etc, ... FROM othertable WHERE something.

my cat is norris
Mar 11, 2010

#onecallcat

nielsm posted:

There is an SQL thread too, but from skimming your question, what you want is an INSERT INTO table (fields, ...) SELECT fields, constants, etc, ... FROM othertable WHERE something.

Is it titled something odd? I couldn't find it, at a glance. :ohdear:

Edit: I worked out my solution and now I feel really dumb.

code:
insert into tblcGenesis 
select 'GVA', sCode, 54, 'GER', 0, 0, NULL, 5, 0, 0 from dbo.tblzzzzzDA5;
:haw:

my cat is norris fucked around with this message at 15:40 on Oct 11, 2013

nielsm
Jun 1, 2009



my cat is norris posted:

Is it titled something odd? I couldn't find it, at a glance. :ohdear:

SELECT * FROM Questions WHERE Type = 'Stupid'

Yes.

my cat is norris
Mar 11, 2010

#onecallcat

The perfect thread for my question on all levels. Thank you.

Pollyanna
Mar 5, 2005

Milk's on them.



Naturally, as it is an SQL thread. :haw:

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.
Is there a good alternative to org mode because I am feeling so done with emacs right now.

Morkfang
Dec 9, 2009

I'm awesome.
:smug:

Pollyanna posted:

vvvv The problem with C# is that I'm running OSX, which is apparently incompatible with .NET, even for developing it.
Miles behind, I know, but: OSX doesn't prevent you from programming in C#: http://xamarin.com/

Strong Sauce
Jul 2, 2003

You know I am not really your father.





OK so I have a question about MVC.

We have a relatively big web app written in Node.js that we are trying to organize better structurally. It has been proposed that we also abstract our business logic out into a separate domain layer as well.

So my question is, if all the business logic is in the domain layer, what are we putting into the Models? Working with Rails it seems like they essentially tell you to put everything into Models.

Also what is a good resource to look up questions similar to this?

Modern Pragmatist
Aug 20, 2008
I have a small webapp where the user supplies some information and a plot is generated. The data is sent to my backend (flask + python) via javascript and the resulting JSON is used to generate the plot. I have an option for the user to download a CSV file of the data. Obviously, if I create results.csv somewhere on the server, if someone uses the app prior to another user selecting to download the file, they will get the CSV for the wrong information. What is the best way to handle generating these CSV files?

I thought of something like storing the results of the webapp in a database with a unique identifier that is passed back to the webpage within the JSON and then the CSV download link posts the id to the webapp to obtain the results. Is there a much simpler way to go about this?

The data being generated and plotted consists of ~50 rows with two columns.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
That is the standard process when just returning the data directly isn't an option for whatever reason.

piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



Modern Pragmatist posted:

I have a small webapp where the user supplies some information and a plot is generated. The data is sent to my backend (flask + python) via javascript and the resulting JSON is used to generate the plot. I have an option for the user to download a CSV file of the data. Obviously, if I create results.csv somewhere on the server, if someone uses the app prior to another user selecting to download the file, they will get the CSV for the wrong information. What is the best way to handle generating these CSV files?

I thought of something like storing the results of the webapp in a database with a unique identifier that is passed back to the webpage within the JSON and then the CSV download link posts the id to the webapp to obtain the results. Is there a much simpler way to go about this?

The data being generated and plotted consists of ~50 rows with two columns.

If you're just generating a csv file just so someone can download it then couldn't you just gather the information to make the csv file and then just render it as a webpage but with the MIME type set to csv?

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

piratepilates posted:

If you're just generating a csv file just so someone can download it then couldn't you just gather the information to make the csv file and then just render it as a webpage but with the MIME type set to csv?

Yup I'd go this route. The CSV file never actually has to exist on your server, you just set the mime type (and optionally the content-disposition header so they get the file download dialog) and stream out your CSV data in the response.

nielsm
Jun 1, 2009



fletcher posted:

Yup I'd go this route. The CSV file never actually has to exist on your server, you just set the mime type (and optionally the content-disposition header so they get the file download dialog) and stream out your CSV data in the response.

Expect maybe if the data takes a long time to generate and users would try to hit the download URL several times in a row. (Depending on your hit rate, "a long time" might be at half a second upwards a whole minute, whatever would put too much load on the server.) In that case, you probably should store the generated result.
But yeah, start by just returning the data on the fly, you can add caching of the result later.

Modern Pragmatist
Aug 20, 2008
Thanks for all of the helpful replies. The processing can take 5-10 seconds depending upon the inputs, so if I'm understanding you guys correctly, it would take 5 seconds to perform the query for visualization and then when the download link is clicked it would perform the same query again prior to outputting a csv?

I guess I could try that for now, and I could keep track of how many people go on to download the csv file. I presume most users will just visualize the results in the browser.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
Seems reasonable enough. The alternative is to generate the CSV file when they visualize it in the browser, but use a unique filename for the CSV like a UUID. Then when they download it you could optionally give it a filename that is more friendly looking. But then you have to deal with cleaning up those temporary files after a certain amount of time, so they don't accumulate.

Modern Pragmatist
Aug 20, 2008

fletcher posted:

Seems reasonable enough. The alternative is to generate the CSV file when they visualize it in the browser, but use a unique filename for the CSV like a UUID. Then when they download it you could optionally give it a filename that is more friendly looking. But then you have to deal with cleaning up those temporary files after a certain amount of time, so they don't accumulate.

I actually thought about this and using time stamps for filenames then clear them out based on the oldest one.

nielsm
Jun 1, 2009



fletcher posted:

Seems reasonable enough. The alternative is to generate the CSV file when they visualize it in the browser, but use a unique filename for the CSV like a UUID. Then when they download it you could optionally give it a filename that is more friendly looking. But then you have to deal with cleaning up those temporary files after a certain amount of time, so they don't accumulate.

I would really suggest using a structured front-end cache then, something like memcached or possibly redis. Just cache the raw results of the query using the user's session id and/or hash of query parameters for key, a reasonable expiry time (maybe 5-10 minutes) and be over with it. No need to manage temporary files and risk all kinds of oddities then. (Setting up a front-end cache is a hassle the first time, but saves you the hassle of making and managing web-server writable directories in the long run.)

mister_gosh
May 24, 2002

Is there a thread in SHSC or CoC where we discuss text editors for coding?

I'm on Windows and am using Sublime 3 (after having switched from Notepad++, Komodo Edit and Textpad) but am wondering about other options/what people are using?

piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



mister_gosh posted:

Is there a thread in SHSC or CoC where we discuss text editors for coding?

I'm on Windows and am using Sublime 3 (after having switched from Notepad++, Komodo Edit and Textpad) but am wondering about other options/what people are using?

There used to be one here but I'm pretty sure it's in the archives, might have been a year or so ago?

edit: Show off your development environment, there's also been Vim and Emacs threads but come on.

piratepilates fucked around with this message at 16:47 on Oct 16, 2013

Seashell Salesman
Aug 4, 2005

Holy wow! That "Literally A Person" sure is a cool and good poster. He's smart and witty and he smells like a pure mountain stream. I posted in his thread and I got a FANCY NEW AVATAR!!!!
My vote is IDE: Visual Studio, Text editor: (g)Vi(m).

mister_gosh
May 24, 2002

piratepilates posted:

There used to be one here but I'm pretty sure it's in the archives, might have been a year or so ago?

edit: Show off your development environment, there's also been Vim and Emacs threads but come on.

Wow, thanks!

stubblyhead
Sep 13, 2007

That is treason, Johnny!

Fun Shoe
I have a long list of RPM packages that contain multiple versions and architectures of the same thing. For instance:
code:
aide-0.13.1-2.0.4.el5.x86_64
aide-0.13.1-6.el5.x86_64
aide-0.13.1-6.el5_8.2.x86_64
aide-0.13.1-8.el5.x86_64
alsa-lib-1.0.14-1.rc4.el5.i386
alsa-lib-1.0.14-1.rc4.el5.x86_64
alsa-lib-1.0.17-1.el5.i386
alsa-lib-1.0.17-1.el5.x86_64
I need to filter this down to only the most recent version for all architectures, so the above would become
code:
aide-0.13.1-8.el5.x86_64
alsa-lib-1.0.17-1.el5.i386
alsa-lib-1.0.17-1.el5.x86_64
There's enough variability in the names though that I'm having trouble coming up with a way to reliably get just the version number. Neither - nor . is suitable to split on, and then there's poo poo like java-1.7.0-openjdk-javadoc-1.7.0.9-2.3.8.0.el5_9.x86_64 where one thing's version number is part of another thing's name which just adds to the confusion. Any suggestions on how I might go about this? The application I'm using has a decent python API so that's what I'll be using to do this if possible.

Carthag Tuek
Oct 15, 2005

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



stubblyhead posted:

I have a long list of RPM packages that contain multiple versions and architectures of the same thing. For instance:
code:
aide-0.13.1-2.0.4.el5.x86_64
aide-0.13.1-6.el5.x86_64
aide-0.13.1-6.el5_8.2.x86_64
aide-0.13.1-8.el5.x86_64
alsa-lib-1.0.14-1.rc4.el5.i386
alsa-lib-1.0.14-1.rc4.el5.x86_64
alsa-lib-1.0.17-1.el5.i386
alsa-lib-1.0.17-1.el5.x86_64
I need to filter this down to only the most recent version for all architectures, so the above would become
code:
aide-0.13.1-8.el5.x86_64
alsa-lib-1.0.17-1.el5.i386
alsa-lib-1.0.17-1.el5.x86_64
There's enough variability in the names though that I'm having trouble coming up with a way to reliably get just the version number. Neither - nor . is suitable to split on, and then there's poo poo like java-1.7.0-openjdk-javadoc-1.7.0.9-2.3.8.0.el5_9.x86_64 where one thing's version number is part of another thing's name which just adds to the confusion. Any suggestions on how I might go about this? The application I'm using has a decent python API so that's what I'll be using to do this if possible.

Maybe for each package/architecture combo (assuming they all start on package & end on architecture, they should be easy to group), you could sort those combos alphabetically & take the last in each group?

nielsm
Jun 1, 2009



stubblyhead posted:

I have a long list of RPM packages that contain multiple versions and architectures of the same thing.

Do you only have the filenames, or do you have the option to actually open and look inside the files? Because if you do, I'd suggest using the metadata present inside the files. There should be some libraries available to work with RPM files that can give you the information you want.

Otherwise, start from the back of the filename. First make a list of all legal architecture names, that will make it easy to chop those off the end of a filename. After that, you know the version number is the last thing in the name. Build a regular expression to match those, it shouldn't be too hard I'd say. In the case of the OpenJDK Javadoc package, the version number is probably 2.3.8.0.el5_9, which is version of the package. What the actual package name is, no idea. You might need to make special cases for some packages you want to sort together, e.g. if you want to groun Java 6 JDK Javadoc packages with OpenJDK 1.7 Javadoc packages.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





I guess I should just shorten my question since I didn't get any replies: What is a good resource about learning MVC? (past just basic concepts for someone who has an understanding of how Rails does it)

Suspicious Dish
Sep 24, 2011

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

Strong Sauce posted:

I guess I should just shorten my question since I didn't get any replies: What is a good resource about learning MVC? (past just basic concepts for someone who has an understanding of how Rails does it)

"MVC" is a wishy-washy name, and it can represent a lot of different architectures. Let's go back to your first question:

Strong Sauce posted:

OK so I have a question about MVC.

We have a relatively big web app written in Node.js that we are trying to organize better structurally. It has been proposed that we also abstract our business logic out into a separate domain layer as well.

So my question is, if all the business logic is in the domain layer, what are we putting into the Models? Working with Rails it seems like they essentially tell you to put everything into Models.

Also what is a good resource to look up questions similar to this?

Basically, what this advice means is to put your "business logic" away from the part that serves the web pages. I don't know much about your case specifically, so I can't give you much advice about how to implement this, but the idea is that inputs from a web page get translated into a plain model, and then these models get operated on and validated in something that has no idea about the web, even, and then errors/successes get passed back up to something that aggregates the results back into a web page.

I know that's extremely generic, so let's give a simple example. Let's say you're building a calendar app, and you're building the "Add Event" page.

There's a form where a bunch of things (date/time, event name, participants) are selected. When you get the request on the server, you translate all that data into a series of models, and then have another layer like a Calendar object that has an addEvent(String eventName, DateTime time, List<Person> participants) method. This addEvent method does not know anything about the "web page" front end -- somebody also could have written an app that used it by replying to an email, or from an IRC client, or a desktop app, or from a REST API.

The idea is that you have an underlying "business layer" which has all the real important stuff, and your web interface just talks to that API.

Jared592
Jan 23, 2003
JARED NUMBERS: BACK IN ACTION
This is a ding-dong question that is completely tripping me up. So I have this XML file full of parameters that we're editing by hand at the moment (yep). Here's an example of what I'm working with:

code:
<?xml version="1.0"?>
<inifile>
	<section name="\\barfserv\cough.zip" paramct="6">
		<parameter name="Required">False</parameter>
		<parameter name="Copy">True</parameter>
		<parameter name="DataFileType">ZippedDataFile</parameter>
		<parameter name="Description">Zip File</parameter> 
		<parameter name="WorkingDirName">scrote</parameter>
		<parameter name="LogFilename">log.txt</parameter>
	</section>
	<section name="\\barfserv\ejac.zip" paramct="5">
		<parameter name="Required">True</parameter>
		<parameter name="DataFileType">GenericDatafile</parameter>
		<parameter name="Copy">False</parameter>
		<parameter name="Description">gametes</parameter>
		<parameter name="table">raw_DNA</parameter>
	</section>
	<section name="\\barfserv\ejac2.zip" paramct="5">
		<parameter name="Required">False</parameter>
		<parameter name="DataFileType">GenericDatafile</parameter>
		<parameter name="Copy">False</parameter>
		<parameter name="Description">gametes2</parameter>
		<parameter name="table">raw_DNA2</parameter>
	</section>
I'm trying to write a regular expression that'll add the following element to any section that:
A. contains a "table" parameter
AND
B. contains either a "Required" parameter set to "TRUE" or no "Required" parameter at all

Element to add:
code:
<parameter name="Dump">True</parameter>
So far this is the basic pattern I've got:

<section name=.*?>(?:table)(?:"Required">True)(?!"Required").*?</section>

breakdown:
code:
<section name=.*?>                          <-- match the opening tag for a section
(?:table)(?:"Required">True)(?!"Required")  <-- search for occurrence of "table" and "required" set to TRUE or no "required" at all
.*?</section>                               <-- match everything after that though the end of the section

Any guidance here would be much appreciated.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
no. Nope. NOPE. NOPE.

Jared592
Jan 23, 2003
JARED NUMBERS: BACK IN ACTION
Yeah I know, I just don't feel like crapping out a program for such a simple change.

JawnV6
Jul 4, 2004

So hot ...
You're crapping one out. You came to us mid-poo poo. We're advocating exactly the opposite: take an XML parser off the shelf.

shrughes
Oct 11, 2008

(call/cc call/cc)
I thought you wanted the Required element to be set to TRUE. But then you want it set to True. Which is it?

Edit: It's a good thing you have those paramct attributes. Otherwise you'd never be able to traverse the tree.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

shrughes posted:

Edit: It's a good thing you have those paramct attributes. Otherwise you'd never be able to traverse the tree.

Haha didn't notice those at first. Someone should spend some time learning how to XML!

Adbot
ADBOT LOVES YOU

Jared592
Jan 23, 2003
JARED NUMBERS: BACK IN ACTION
Just because I post XML doesn't mean I wrote what creates it you big mean jerks! :cry: For the record no one here has any idea who stuck paramct in there and nothing we use does anything with it.


Edit:

shrughes posted:

I thought you wanted the Required element to be set to TRUE. But then you want it set to True. Which is it?

Note that the element being set to TRUE if the "Required" element is TRUE is called "Dump", not "Required".

Jared592 fucked around with this message at 20:02 on Oct 17, 2013

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