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
rolleyes
Nov 16, 2006

Sometimes you have to roll the hard... two?
I like that the first item on the list is recursion. I mean I'm all for courses being challenging but in an introductory course? Seems like that could scare a lot of people.

Adbot
ADBOT LOVES YOU

NinjaDebugger
Apr 22, 2008


Jam2 posted:

Does this summer course seem worthwhile?

have to agree, it'll either be so basic it's worthless, or will practically kill you. But if it's the latter, you'll be well prepared for later classes, so I'd say what the hell, unless it's money you really need for something else.

Physical
Sep 26, 2007

by T. Finninho

rolleyes posted:

Yep. I was already vaguely aware that it had caused some arguments, which ShoulderDaemon has pointed out the info about. I guess OSS licenses can become a bit of a minefield when you've got open and closed source programs provided by multiple parties interacting together on a consumer product which is then sold through yet more parties.

Maybe the best career choice is "become a software license lawyer".

So on top of that minecraft made a lot of money and it was built on an opensource library with the MIT license. So is he getting sued?

csammis
Aug 26, 2003

Mental Institution

Physical posted:

So on top of that minecraft made a lot of money and it was built on an opensource library with the MIT license. So is he getting sued?

Why would he be sued? Works licensed under MIT can be used in commercial applications as long as the original author's name is kept in the code along with the body of the license. It's one of the most permissive licenses around.

Jam2
Jan 15, 2008

With Energy For Mayhem

Bob Morales posted:

It'll either kill you or be so basic that you won't gain much from it. What school is that at?
It's at Harvard.

Nahrix
Mar 17, 2004

Can't afford to eat out
I'm trying to help a friend with the tedious task of adding a bunch of contacts to outlook. He needs to add some occupational therapists from here: https://secure.alinity.com/acot/webclient/registrantdirectory.aspx

I thought if I could just get the raw data, I could write a parser to translate it into a format compatible with outlook's import function. The problem I'm having is that the actual information is brought up with a javascript.ModalPopupOpen function, and I have no idea how to page scrape that data.

To see what I'm describing, just go to the link above, click on the search icon while leaving the textboxes empty, to receive all 1000 records. Then go about 8 pages in and click "view details" on a record (the records on the first 7 or so pages don't have enough information to be valuable). All I need to know is how to get at the raw data; it doesn't need to be pretty / cleaned up. Is this feasible?

N.Z.'s Champion
Jun 8, 2003

Yam Slacker

Nahrix posted:

The problem I'm having is that the actual information is brought up with a javascript.ModalPopupOpen function, and I have no idea how to page scrape that data.
It looks like the modal dialog just embeds a iframe at this url with a sequential user id so you could iterate through that and bypass the javascript. I'm a little uneasy about scraping people's details like that (privacy laws being what they are) but I guess if it's online a search engine could index it anyway... ah well.

Nahrix
Mar 17, 2004

Can't afford to eat out
Yeah, I assumed there wouldn't be any privacy issue if the information was publicly available on the site like that. I'll admit that I'm no lawyer, so I can't say for sure. If anyone here thinks that there's a problem with it, just let me know.

Edit: N.Z's Champion - Thank you for showing me about that embedded iframe. Learning something new about how a page design works is a lot more important to me than doing this favor, so thanks for that :)

Nahrix fucked around with this message at 06:06 on Apr 1, 2011

wicka
Jun 28, 2007


If I am getting a variable from the URL, can I POST that variable through a form? i.e. just have the form send that variable along with whatever the user enters

spiritual bypass
Feb 19, 2008

Grimey Drawer
Could you rephrase that?

wicka
Jun 28, 2007


rt4 posted:

Could you rephrase that?

I can try but I don't particularly know what I'm doing so it's sort of difficult. I have a page where you can click a link and it will append a variable to the URL, and then I just use GET to use that variable in the page. But I also want to pass that variable to a PHP script in a separate file, along with whatever the user enters in a form.

nielsm
Jun 1, 2009



Make a type="hidden" field in your form, that contains the GET variable's contents as well.

wicka
Jun 28, 2007


nielsm posted:

Make a type="hidden" field in your form, that contains the GET variable's contents as well.

This is it, thanks!

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

wicka posted:

This is it, thanks!

Make sure you watch out for people manually entering this:

code:
%22%20%2F%3E%3Cscript%20src%3D%22hax0r.com%2FevilScript.js%22%3E
%3C%2Fscript%3E%3Cinput%20type%3D%22hidden%22
(or something like that) into your URL as the parameter to be echoed into the page.

Oxyclean
Sep 23, 2007


Does anyone know of any places I could find articles about the time/effort/whats involved in changing program languages?

I need something decently source-able.

Thermopyle
Jul 1, 2003

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

Oxyclean posted:

Does anyone know of any places I could find articles about the time/effort/whats involved in changing program languages?

I need something decently source-able.

What do you mean changing program languages?

Porting existing software to a new language?

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Yeah is this:

A)Training someone (e.g. you) to use a new language?

or

B)Transporting a project from one language to another?

Regardless it'll be useless without knowing the language(s) involved, and the industry/application involved.

Oxyclean
Sep 23, 2007


Thermopyle posted:

What do you mean changing program languages?

Porting existing software to a new language?

Sorry, I meant like learning new languages. I have to write a proposal for a "solution to an existing problem" for one of my classes, I went with something to the degree of some sort of intelligent development tools that help you go between programming languages.

It's a bit of a fluff course, but I need something to source to show that there's a problem, and the solution is realistic and I'm certain there's some sort of statistic of that poo poo out there.

e: I'm just sort of looking for general studies/articles that would support the fact it's an issue of some degree.

spiritual bypass
Feb 19, 2008

Grimey Drawer
Do you have access to Ebsco or does your university library have a computer science section? Those ought to yield better results than a forum for such an academic topic.

Rad ROM Max
Mar 10, 2011

by XyloJW
Is there an assembly thread anywhere here? I might have some questions on stuff.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

baku posted:

Is there an assembly thread anywhere here? I might have some questions on stuff.

There's a thread where someone's doing a let's play ARM assembler on the Nintendo DS, maybe there's enough assembler folk there paying attention to help you out. Otherwise I don't recall seeing one anywhere.

I like turtles
Aug 6, 2009

I've been working on the rather daunting task of organizing a ~120GB music library.
I've used various utilities and have already pruned it down to about 80, removing duplicates and stuff completely lacking metadata or folder structure (and stuff I've literally never listened to), and where I am now is that I have quite a few instances of songs within a given folder that are available in .wma, .mp3 and .m4a format or some subset. I don't want to wholesale delete any given format, though, since there are some albums I only have in X or Y or Z.

Is there a decent way to write a bash script to recursively go through each folder and delete two of the three, if the third is there?

Else it'll be python time.

I like turtles fucked around with this message at 08:09 on Apr 5, 2011

HFX
Nov 29, 2004

I like turtles posted:

I've been working on the rather daunting task of organizing a ~120GB music library.
I've used various utilities and have already pruned it down to about 80, removing duplicates and stuff completely lacking metadata or folder structure (and stuff I've literally never listened to), and where I am now is that I have quite a few instances of songs within a given folder that are available in .wma, .mp3 and .m4a format or some subset. I don't want to wholesale delete any given format, though, since there are some albums I only have in X or Y or Z.

Is there a decent way to write a bash script to recursively go through each folder and delete two of the three, if the third is there?

Else it'll be python time.

In the time it takes you to do it in bash, you can probably do it in python / perl if you know the languages.

slotbadger
Jul 19, 2007
hey deadhead - take a bite of peach.
Okay, I am rubbish at C, and even worse at googling for C help.

Can anyone point me to some nice tutorials about arrays and pointers and C in general?

Other than that, I do have a specific question.

Why does this not seem to work? I think I need to clear the array somehow, but every technique I've found so far has failed me. It prints out the correct value for some of the retrieved arrays, and a different value for others. Here's a simplification of my code:
code:
int main()
{	
    unsigned short array1[16];
    
    getContents( 1, array1);
    printf("Should be 7996 and it is %hx\n", array1[0]);	
		
    getContents( 2, array1);
    printf("Should be 2020 and it is %hx\n", array1[2]);	
	
   
}

void getContents(int num, unsigned short wordArr[])
{
	switch (num)
	{
		memset(wordArr, 0, 16);
		
		
		case (1):
		{	
			unsigned short tempArray[5] = {0x7996, 0x9D65, 0x002B, 0x0002, 0x4143};
			memcpy(wordArr, tempArray, sizeof wordArr);		
			break;
		}
		case (2):
		{
			
			unsigned short tempArray[8] = {0x2020, 0x2020, 0x2020, 0x2020, 0x2020, 0x2020, 0x2020, 0x2020};
			memcpy(wordArr, tempArray, sizeof wordArr);		
			break;
		}
       }
}



slotbadger fucked around with this message at 16:15 on Apr 5, 2011

nielsm
Jun 1, 2009



slotbadger posted:

Can anyone point me to some nice tutorials about arrays and pointers and C in general?

code:
void getContents(int num, unsigned short wordArr[])
{
			memcpy(wordArr, tempArray, sizeof wordArr);		

Arrays in C don't carry their allocated size, except as far as the compiler can see at compile-time.
In this case, your wordArr is a parameter to the function, and doesn't carry any size. It's just a pointer to one or more unsigned shorts. So sizeof(wordArr) doesn't give what you expect it to. If you want to know the size or length of an array passed into a function, you also need to pass the size as a separate parameter, or pack the array + metadata into a struct, which you can then pass.
In this case, you'd also be overrunning the tempArray arrays' lengths in the memcpy(), because if the sizeof(wordArr) operator gave what you expected you'd be copying 32 bytes from the source array, regardless of how long it is. What happens when you copy 32 bytes from a 10 byte source? You get 22 bytes of garbage from the end, or an access violation if you're lucky.

It's worth remembering that the sizeof operator is resolved at compile time, it translates into a constant in the machine code. You can only measure sizes that are known at compile time.

Edit: Why is your function called getContents() when it doesn't return anything? I'd use the word "fill" rather than "get", in this case.

nielsm fucked around with this message at 16:29 on Apr 5, 2011

slotbadger
Jul 19, 2007
hey deadhead - take a bite of peach.

nielsm posted:

Arrays in C don't carry their allocated size, except as far as the compiler can see at compile-time.
In this case, your wordArr is a parameter to the function, and doesn't carry any size. It's just a pointer to one or more unsigned shorts. So sizeof(wordArr) doesn't give what you expect it to. If you want to know the size or length of an array passed into a function, you also need to pass the size as a separate parameter, or pack the array + metadata into a struct, which you can then pass.
In this case, you'd also be overrunning the tempArray arrays' lengths in the memcpy(), because if the sizeof(wordArr) operator gave what you expected you'd be copying 32 bytes from the source array, regardless of how long it is. What happens when you copy 32 bytes from a 10 byte source? You get 22 bytes of garbage from the end, or an access violation if you're lucky.

It's worth remembering that the sizeof operator is resolved at compile time, it translates into a constant in the machine code. You can only measure sizes that are known at compile time.

Edit: Why is your function called getContents() when it doesn't return anything? I'd use the word "fill" rather than "get", in this case.

You're right about the function name. It was initially intended to return an array of bytes, but that didn't seem possible in C. So I decided to update by reference and switched it to use unsigned shorts as I'm working in 2-byte words anyway.

This is only intended as a way to access some test data, and help me build up a bit of C knowledge. I suppose the most straight-forward thing to do is maintain a set array size of 16, and copy that over every time, padding with 0s at the end? Or will that still prove problematic?

I might be going about this in completely the wrong way too, which is why I wouldn't mind pointing towards any good tutorials.

Thankyou for your help.

NinjaDebugger
Apr 22, 2008


slotbadger posted:

You're right about the function name. It was initially intended to return an array of bytes, but that didn't seem possible in C. So I decided to update by reference and switched it to use unsigned shorts as I'm working in 2-byte words anyway.

If you want to pass back an array of bytes, your return value is actually a pointer to the first value in the array. If your size isn't predefined, you'll also need to pass a size argument by reference in order to get back the size of the array, or pass back a struct which includes both.

The #1 difficult thing to wrap your head around when going from a modern language back to C is that unless you are working with a struct, you are working with a primitive. You don't pass around an array, you pass around a pointer to the first object in an array. You can then play with that pointer to get the other objects in the array, but all you are passing around is literally an integer that you are treating as a pointer.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

What are some good algorithms to use for finding nearby places on a globe?

Let's say you are given some random latitude and longitude coordinates, and you want to find every place of interest in a 5 or 10 mile radius.

This is a SQL database and there are 690,000 sets of coordinates (locations), and the idea would be to present to the user the ones within the 5 or 10 mile radius, without having to step through the whole database (which is being done now...)

select * from waypoints where function_regarding_my_location <= function_regarding_the_waypoints_location

My first thought is to subdivide the map into squares, but since it's a globe and not 2D, you have to compensate that the squares aren't square and change shape quite a bit depending on how far from the equator your are.

I think the current suggestion is something like:

select * from waypoints where lat between 53.4716971079 and 53.7594668920 and lng between -74.4356778876 and -74.0587461123

pseudorandom name
May 6, 2007

You'd be better off using your database's native GIS functionality, if it has it.

PostgreSQL has PostGIS, MySQL has Spatial Extensions, Oracle has Oracle Spatial, DB2 has DB2 Spatial Extender, SQL Server has ... something, etc.

quackquackquack
Nov 10, 2002
I have a plugin for an existing program, and I need to automate the install of the plugin for distribution.

The process is:
Download Plugin.dll
Open elevated command prompt if UAC is enabled
Run %programfiles%\Common Files\Vendor\Register.exe /s fullpathto\Plugin.dll (or %programfiles(x86)%, depending on the OS)

Relying solely on instructions is a bit of a pain due to most people having no clue about whether they are running 32 or 64 bit, not to mention elevated command prompts.

I'm not supposed to spend too much time on this, and it should be very easy for the programmer to update without me. What would you recommend?

A batch script run elevated, distributed in a zip file with the dll?
NSIS?
Suck it up and have long instructions?

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Bob Morales posted:

What are some good algorithms to use for finding nearby places on a globe?


This is actually a relatively big question that a lot of people have spent time trying to answer. There's a few goodish solutions out there but no silver bullets. A lot depends on your set up, the data, the criteria, etc.

This stackoverflow link has some good links, but I didn't read them in detail:
http://stackoverflow.com/questions/3740657/whats-a-good-algorithm-for-nearest-neighbour-problem-in-two-dimensions

There is a GIS goon who pops up in these threads but I can't remember his name.

nielsm
Jun 1, 2009



quackquackquack posted:

I have a plugin for an existing program, and I need to automate the install of the plugin for distribution.

I'm not supposed to spend too much time on this, and it should be very easy for the programmer to update without me. What would you recommend?

A proper installer, I'd say. Personally I prefer Inno Setup, I like its declarative style over the more procedural style of NSIS.

A working installer shouldn't take a long time to write and requires very little maintenance.
When making a new release, if there aren't any new files to distribute, and the installation procedure hasn't changed otherwise, you'll just need to increment the version number in the installer source and click Build Installer again. (After dumping the updated Plugin.dll and other files where the setup compiler looks for them.)

RitualConfuser
Apr 22, 2008

Bob Morales posted:

What are some good algorithms to use for finding nearby places on a globe?

Let's say you are given some random latitude and longitude coordinates, and you want to find every place of interest in a 5 or 10 mile radius.

This is a SQL database and there are 690,000 sets of coordinates (locations), and the idea would be to present to the user the ones within the 5 or 10 mile radius, without having to step through the whole database (which is being done now...)

select * from waypoints where function_regarding_my_location <= function_regarding_the_waypoints_location

My first thought is to subdivide the map into squares, but since it's a globe and not 2D, you have to compensate that the squares aren't square and change shape quite a bit depending on how far from the equator your are.

I think the current suggestion is something like:

select * from waypoints where lat between 53.4716971079 and 53.7594668920 and lng between -74.4356778876 and -74.0587461123


Seconding the database GIS extensions suggestion, if it's an option, as it would make a radius based query pretty simple and it would provide some nice indexing options as well. Also, the last query you supplied will break when you hit the 180/-180 longitude line (some info here); and, you'd still need to cull the results anyways since you'd be pulling a bounding decimal degree rectangle for the circle you really wanted (w/ a radius in statute miles). I'm not a GIS expert but there are probably some other non-obvious edge cases that the GIS extensions would handle for you as well.

RitualConfuser fucked around with this message at 08:23 on Apr 6, 2011

IMlemon
Dec 29, 2008
Anyone have any experience with automated tests via selenium? I have a bunch of test cases I'd like to automate but those require changing the date. I can change the server time but that breaks many things so I'd rather not do that. Any ideas? It's Java EE project + tomcat for deployment.

quackquackquack
Nov 10, 2002

nielsm posted:

A proper installer, I'd say. Personally I prefer Inno Setup, I like its declarative style over the more procedural style of NSIS.

A working installer shouldn't take a long time to write and requires very little maintenance.
When making a new release, if there aren't any new files to distribute, and the installation procedure hasn't changed otherwise, you'll just need to increment the version number in the installer source and click Build Installer again. (After dumping the updated Plugin.dll and other files where the setup compiler looks for them.)

Holy poo poo, thank you. I'm not sure how I missed this in all of the times I have gone out looking for an installer creator.

MrMoo
Sep 14, 2000

nielsm posted:

A working installer shouldn't take a long time to write and requires very little maintenance.
When making a new release, if there aren't any new files to distribute, and the installation procedure hasn't changed otherwise, you'll just need to increment the version number in the installer source and click Build Installer again.

It's really easy with CPack and NSIS, it's just that NSIS doesn't have a native 64-bit version to target installs in Program Files instead of Program Files (x86).

It was pretty much the following at the end of CMakeLists.txt
code:
include (InstallRequiredSystemLibraries)
include (CPack)
Then build the installer for Win32 or Win64:
code:
nmake package

The King of Swag
Nov 10, 2005

To escape the closure,
is to become the God of Swag.
In years of programming this has never come up until now, but do #define statements work in main.c/main.m (using ObjC)? I started getting suspicious when GLEW_STATIC wouldn't be recognized unless it was declared inside an included or imported header, but this latest problem has me sure that they don't.

Windows.h (or at least its included headers) change their types and declarations if you're using ObjC (they look for __OBJC__), but the ObjC library headers don't declare this as they actually look for it themselves (depending on the compiler, some functionality may already be implemented). This isn't a big deal as it just means you need to define __OBJC__ some point after <objc/objc.h> but before <windows.h>, but declaring this in main makes no difference and the compilation fails. Add it into objc.h or into any other header imported in between those two though, and it is immediately recognized.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Bob Morales posted:

What are some good algorithms to use for finding nearby places on a globe?

Let's say you are given some random latitude and longitude coordinates, and you want to find every place of interest in a 5 or 10 mile radius.

This is a SQL database and there are 690,000 sets of coordinates (locations), and the idea would be to present to the user the ones within the 5 or 10 mile radius, without having to step through the whole database (which is being done now...)

select * from waypoints where function_regarding_my_location <= function_regarding_the_waypoints_location

My first thought is to subdivide the map into squares, but since it's a globe and not 2D, you have to compensate that the squares aren't square and change shape quite a bit depending on how far from the equator your are.

I think the current suggestion is something like:

select * from waypoints where lat between 53.4716971079 and 53.7594668920 and lng between -74.4356778876 and -74.0587461123

If you're still set on doing this yourself, you could definitely use the square subdivision as a first pass, and iterate over the locations from there to filter out the things that aren't truly in the radius, similar to how axis-aligned bounding box algorithms work.

The King of Swag
Nov 10, 2005

To escape the closure,
is to become the God of Swag.
If you're already using latitude and longitude to store the locations, why can't you just calculate the range of lats and longs that will be within your search radius?

1* of lat/long = 60 minutes
1 minute lat/long = 60 seconds

Length of latitude changes by about 1% from the poles to the equator, and averages out to about 69 miles/degree, or ~1.917 * 10^-2 miles/second.

You can calculate the length of longitude using: (PI / 180) * alpha * cos (beta), where alpha is Earth's equatorial radius (6,378,137 m - ~3963.19 miles). beta is equal to b/a * tan(theta), where b/a = 0.99664719, and theta is your longitude in degree decimal format.

Put it all together, you get: (PI / 180) * 3963.19 mi * cos(0.99664719 * tan(theta)).

I'm assuming you're already storing your coordinates in decimal format, but its very easy to convert if you aren't already.

Putting these calculations together, you can find the range of latitude and longitude from your position that will fall within your specified range, and just filter the database for coordinates that fall within that range.

Adbot
ADBOT LOVES YOU

Difference Engine
Mar 30, 2009
Let me start off by saying I am completely unfamiliar with programming, and anything outside of Windows, so I might be using some terms incorrectly, but...

I am doing research for my university and need to use a program that was designed for use on UNIX systems, however I am using a windows machine. The IT department has been no help so I am going to try and compile it into an .exe myself. The source code comes in a .tar.tgz file. The website where the download can be found is here. It says that it requires "Requires Fortran 77, C compilers, windowing support." but I am still a little unsure of what exactly I should download.

I basically want to have a .exe file that will open a command window where I can use the program. The same guy who wrote the program has a different program very similar to it, that was compiled into a .exe by somebody else, so it should be possible. If someone could at least tell me what specifically I need to download, I could probably figure it out. I am just completely lost as of right now and I feel like this is the most basic poo poo for somebody who knows anything about programming.

Thanks guys.

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