It seems that you're using an outdated browser. Some things may not work as they should (or don't work at all).
We suggest you upgrade newer and better browser like: Chrome, Firefox, Internet Explorer or Opera

×
avatar
Tallima: snip
Looks like you're most of the way there anyway.

To attach a button you just need to find somewhere on the page to add it and grab a reference to that element (forgive me, but I tend to use jQuery so need to look up the plain javascript stuff and it may not be 100% accurate) using

var div = document.getElementById('insertIdhere')

then create your link to click on (a button may be more appropriate, but I can never remember which is better)

var aTag = document.createElement('a');

and append that to the div

div.appendChild(aTag);

then just wrap your current code in a function and set the link to call it when you click it:

aTag.onclick = function() {};


As for passing it on to others to use, if they have something like TamperMonkey or GreaseMonkey you can just make a userscript (you just need to slap some headings on the top) and then host it somewhere like Gist (which I use for Fundamentals) and give them the link to install it.

If you're not using userscripts I'm not sure what alternatives there are.. I believe there is a way to save a javascript to your favourites (a Bookmarklet I think it's called) and just run it from your favourites menu.
avatar
Tallima: snip
avatar
adaliabooks: Looks like you're most of the way there anyway.

To attach a button you just need to find somewhere on the page to add it and grab a reference to that element (forgive me, but I tend to use jQuery so need to look up the plain javascript stuff and it may not be 100% accurate) using

var div = document.getElementById('insertIdhere')

then create your link to click on (a button may be more appropriate, but I can never remember which is better)

var aTag = document.createElement('a');

and append that to the div

div.appendChild(aTag);

then just wrap your current code in a function and set the link to call it when you click it:

aTag.onclick = function() {};

As for passing it on to others to use, if they have something like TamperMonkey or GreaseMonkey you can just make a userscript (you just need to slap some headings on the top) and then host it somewhere like Gist (which I use for Fundamentals) and give them the link to install it.

If you're not using userscripts I'm not sure what alternatives there are.. I believe there is a way to save a javascript to your favourites (a Bookmarklet I think it's called) and just run it from your favourites menu.
Thank you for all your help! I'll get looking into this.

I think most of us will be prevented from installing GreaseMonkey (I'm not even allowed Chrome -- IE only). So I think a favorite's menu item will be the way to go.

Thanks!
I'm having a bit of trouble with my script at the moment (as anyone following the thread may have noticed) and I wondered if anyone here might be able to shed some light on it...

It's an issue with manual sorting, I've eliminated most of the obvious possible issues and it seems to boil down to this:

When I sort an array of objects, duplicates are created in the array (this is bad for a number of reasons, but that isn't so important as why it's happening).
Even more puzzling, I can't recreate the error myself, but all the users who are testing for me can. The only difference I can see is library size (I only have 118 games whereas everyone else testing has between 300 and 1200), but my efforts to emulate a larger library haven't led to errors or duplicates either.

I've come across one mention of sorting an array in Java leading to duplicates if you don't properly implement the results for equal to, greater than or less than (or 0, 1 and -1) in your sort function but I think I've got that all right.

Here's the relevant sorting function copied to pastebin.
The full script is here, and the whole section of relevant code is between line 2643 and line 3133 (though a lot of the last functions in that group are more for moving things then the sorting and displaying).

So, any ideas as to what the issue is?
low rated
avatar
adaliabooks: I'm having a bit of trouble with my script at the moment (as anyone following the thread may have noticed) and I wondered if anyone here might be able to shed some light on it...

It's an issue with manual sorting, I've eliminated most of the obvious possible issues and it seems to boil down to this:

When I sort an array of objects, duplicates are created in the array (this is bad for a number of reasons, but that isn't so important as why it's happening).
Even more puzzling, I can't recreate the error myself, but all the users who are testing for me can. The only difference I can see is library size (I only have 118 games whereas everyone else testing has between 300 and 1200), but my efforts to emulate a larger library haven't led to errors or duplicates either.

I've come across one mention of sorting an array in Java leading to duplicates if you don't properly implement the results for equal to, greater than or less than (or 0, 1 and -1) in your sort function but I think I've got that all right.

Here's the relevant sorting function copied to pastebin.
The full script is here, and the whole section of relevant code is between line 2643 and line 3133 (though a lot of the last functions in that group are more for moving things then the sorting and displaying).

So, any ideas as to what the issue is?
Just looking at it, I see something strange in the naturalCompare function:
You are passing, to replace(), a function that has a side effect. This is, in general, not a good idea because you don't know exactly how the function is used, and in particular, how many times it will be called. Unless there is a guarantee regarding the implementation (like there might me for something like "map"), it is generally not a good idea to do this.

Consider also the fact that there may be more matches than you expect.

Edit: One more thing: In situations like this, different implementations of the language might yield different results. Since the code appears to be JavaScript, try running it in different browsers.
Post edited January 09, 2016 by dtgreene
avatar
adaliabooks:
Remind me. Did you try removing the naturalCompare() function altogether and using the default Javascript compare instead?

Because, frankly, this function is a pure waste of time for GOG's library, as I believe there are no more than a handful of titles that are sorted differently with it (off the top of my head, I can think of only three: 11th Hour, 1849, 1954 Alcatraz, and even these will move by no more than a row or two).
Post edited January 09, 2016 by mrkgnao
avatar
dtgreene: Just looking at it, I see something strange in the naturalCompare function:
You are passing, to replace(), a function that has a side effect. This is, in general, not a good idea because you don't know exactly how the function is used, and in particular, how many times it will be called. Unless there is a guarantee regarding the implementation (like there might me for something like "map"), it is generally not a good idea to do this.

Consider also the fact that there may be more matches than you expect.

Edit: One more thing: In situations like this, different implementations of the language might yield different results. Since the code appears to be JavaScript, try running it in different browsers.
I will freely admit I have no idea what that function even does.. I copied and pasted it from StackOverflow as the default sort wouldn't sort numbers properly, it was intended for a different part of the script and I just borrowed it for this bit assuming it would serve the same purpose...

It shouldn't actually get called often as it's basically the back up (if the other sorting method is equal then just sort alphabetically)

We've tried it in both Chrome and Firefox; it works for me in both, but doesn't work for anyone else in either...

avatar
mrkgnao: Remind me. Did you try removing the naturalCompare() function altogether and using the default Javascript compare instead?

Because, frankly, this function is a pure waste of time for GOG's library, as I believe there are no more than a handful of titles that are sorted differently with it (off the top of my head, I can think of only three: 11th Hour, 1849, 1954 Alcatraz, and even these will move by no more than a row or two).
As far as I remember I tried replacing it with 0 (so they would compare as equal if the sorting was the same or didn't exist) but I'd have to check the revision log to make sure. I don't think it made a difference.

See above... the actual sort is mostly a fallback as I couldn't (to my knowledge) sort alphabetically within the other sort function without having my own separate sort function, and that one happened to be handy as I'd used it to sort the results of the forum search.
low rated
I thought of an interesting problem and am wondering what hardware would work best for this purpose.

The task: Connect a Game Boy emulator, via link cable, to a real Game Boy. It must be possible to play multiplayer games over this connection.

Some people have managed to connect an Arduino to a Game Boy, allowing one to transfer hacked Pokemon to a legit cartridge, and even allowing the execution of arbitrary code on the Game Boy (Pokemon's link cable routines are not secure against ACE). So, there is precedent.

It looks like the device will need the following capabilities to work:
1. Must be powerful enough to run an accurate Game Boy emulator.
2. Must be possible to connect it to a link cable. Apparently, it's just a serial connection, so GPIO and a modified link cable should do the trick. (That's how people got it working with an Arduino.)
3. Apparently, the timing is very sensitive. In other words, we have a hard real time problem here, so a computer running a general purpose OS (like a Raspberry Pi) is not suitable for this purpose. (Then again, apparently TASBot uses a Raspberry Pi, and the playback of a TAS on real hardware is definitely a hard real time problem.)

Any ideas what sort of device would work for this purpose?
I've switched to Visual Studio 2015 (from 2013) and I must say - I'm really impressed. I'm not a great fan of MS, but in regard to this IDE they are doing something right. Every new version has new really useful features.
avatar
toxicTom: I've switched to Visual Studio 2015 (from 2013) and I must say - I'm really impressed. I'm not a great fan of MS, but in regard to this IDE they are doing something right. Every new version has new really useful features.
Could you offer some examples? BTW, I'm still using VS 2008 at work.
avatar
mrkgnao: Could you offer some examples? BTW, I'm still using VS 2008 at work.
Well... I'm developing in C#, so that's my reference:
- Debugging LinQ is now possible (at least sometimes, still needs improvement)
- Methods and properties now have a little link, listing all occurrences where the things are references, which even works halfway reliable with Razor templates (ASP.NET MVC).
- The old "jump to definition" (CTRL-Click) on method or property calls now opens an "inline window" which is actually editable. Very useful for quick peek or change, and can of course be transformed to a fully opened file.
- "Edit and continue" has been further improved and now sometimes even works with LinQ or Lambda expression edits
- The live code analysis, which actually works really well giving hints about unused stuff, simplification hints etc.
- The new compiler is really a huge step forward, esp. for 64 bit machines.
avatar
mrkgnao: Could you offer some examples? BTW, I'm still using VS 2008 at work.
avatar
toxicTom: Well... I'm developing in C#, so that's my reference:
*snip - list of features*
Do you know if it can open solutions from previous versions without converting the *.sln file in the file system?
avatar
Wishbone: Do you know if it can open solutions from previous versions without converting the *.sln file in the file system?
I don't know about versions earlier than 2013, but it doesn't convert solutions from that one. Instead it creates a folder ".vs" with it's own solution settings. Could be that it handles all older versions like this, but I currently have no way of checking.
avatar
Wishbone: Do you know if it can open solutions from previous versions without converting the *.sln file in the file system?
avatar
toxicTom: I don't know about versions earlier than 2013, but it doesn't convert solutions from that one. Instead it creates a folder ".vs" with it's own solution settings. Could be that it handles all older versions like this, but I currently have no way of checking.
Okay, because that's one of the things that have always annoyed me about VS. Here's the issue. My company maintains a lot of integration solutions for a lot of customers. These are saved in our central TFS repository, and they do not all use the same VS version. Now, when making new solutions for customers, occasionally we run into a scenario that we know we have dealt with before at another customer. Hence, we go and open that customer's solution to see how we solved it before. However, if that solution is from a previous version of VS, the *.sln file is converted to the new format as soon as it is opened, and is immediately locked for editing in TFS. This means that when you've looked at an older solution, you have to remember to manually roll back all changes, even though you haven't actively made any changes, or nobody else can edit the file.
avatar
Wishbone: Okay, because that's one of the things that have always annoyed me about VS. Here's the issue. My company maintains a lot of integration solutions for a lot of customers. These are saved in our central TFS repository, and they do not all use the same VS version. Now, when making new solutions for customers, occasionally we run into a scenario that we know we have dealt with before at another customer. Hence, we go and open that customer's solution to see how we solved it before. However, if that solution is from a previous version of VS, the *.sln file is converted to the new format as soon as it is opened, and is immediately locked for editing in TFS. This means that when you've looked at an older solution, you have to remember to manually roll back all changes, even though you haven't actively made any changes, or nobody else can edit the file.
Yeah, I know the problem. Would be a matter to test if VS2015 leaves solutions older than 2013 alone too. I would think so.
low rated
Here is something I just learned that could trip you up if writing security-sensitive software:

First, here is a toy C example that illustrates the problem.

#include<string.h>

int main(void)
{
char x[16];
memset(x, 0, 16);
return 0;
}

Now, compile it with a command like the following:
gcc -S -O2 sample.c

If you look at the resulting assembly file, you will notice that no memset appears at all. In other words, the compiler has optimized it away!

This may seem harmless, but it's not in security sensitive software. Consider code like the following:

char *private_key = malloc(size);
get_private_key(private_key);
use_private_key(private_key);
/* We don't want the key to be leaked, so let's zero out the memory */
memset(private_key, 0, size);
free(private_key);

It is legal for a compiler to optimize out the memset, which means that the attempt to remove the private key from memory did not actually occur, allowing another bug to leak the key.

See:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=8537
https://www.securecoding.cert.org/confluence/display/c/MSC06-C.+Beware+of+compiler+optimizations