Jump to content

Wikipedia:Reference desk/Archives/Computing/2012 July 20

From Wikipedia, the free encyclopedia
Computing desk
< July 19 << Jun | July | Aug >> July 21 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


July 20

[edit]

Java Security (Quick fix for hosting a local file?)

[edit]
Resolved

I am developing a java applet for independent research. The file is intended to read the directory the applet is running from, using the code:

String currentDir = new File(".").getAbsolutePath();

.... after that it flushes an image buffer to png image format. However, i forgot that, unlike java applications, java applets are highly restricted. As expected, the code above causes the applet to throw a security exception, because my applet isn't signed. I was reading this page:

http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html

... there seem to be many steps just to allow access to the local file system. Is there any easier way to just tell the browser that the applet it is loading is MINE and that i accept its use of my files? I would rather not go find out how to make a public key, a certificate, and a security policy. Thanks in advance!

172.163.3.207 (talk) 03:42, 20 July 2012 (UTC)[reply]

It's usually a simple task to adapt an applet into a standalone application, e.g. switching from a JApplet to a JFrame with a static main(String[]) method that properly instantiates your JFrame and invokes your init and start methods. Of course if you're only running the applet locally, then you probably have some reason why you need it to stay in applet form. Could you upload the file to a LAN server and have the applet fetch it? BigNate37(T) 04:46, 20 July 2012 (UTC)[reply]


So.... Container pane = getContentPane(); becomes a JFrame instead? Would the class still extend JApplet, or something else? Also, once i figure that all out, how do i run the thing? Your suggestion seems the best way to go. I don't need it to be an applet, so long as i can still display and interact with the graphics in the same way (mouse, button listeners still work i hope) :) 172.162.254.31 (talk) 12:41, 20 July 2012 (UTC)[reply]

You can exploit the fact that Applet and JApplet are subclasses of java.awt.Container by simply adding them to a frame (so you don't need to change the applet code to be a frame). Add the following main() to your applet's class:
    public static void main(String[] args) {
	JFrame f = new JFrame("Applet");
	f.setSize(600, 450);
	JApplet app = new swingapplet(); // CHANGE THIS
	f.getContentPane().add(app);
	app.init();

 	f.addWindowListener(new WindowAdapter() {
		public void windowClosing(WindowEvent w) {
		    System.exit(0);
		}});

	f.setVisible(true);
	app.start();
    }
and change the class swingapplet to the name of the applet class (I did write some code to figure this out automatically, but it was pure evil). At the top add some extra imports:
   import java.awt.event.WindowAdapter;
   import java.awt.event.WindowEvent;
And you've wrapped the applet up as a JFrame-application. Or you can use appletviewer, as I discussed below. -- Finlay McWalterTalk 15:18, 20 July 2012 (UTC)[reply]


The JDK comes with a program that allows you to run applets (as if they were applications) already - it's called appletviewer. Assuming you already have an html file index.html with the applet tag in, you just say

 appletviewer index.html

And that works for lots of simple applets. But if you try that with your code, you'll still get a security exception, because the appletviewer installs its own security manager, which checks signatures and limits permissions, just as the equivalent code in a web browser does. What you can do is create your own java security policy file which allows you to grant exceptions to this security sand box just for this invocation (so it's a safer and cleaner thing to do, rather than messing around with the equivalent for your browser, and then forget to undo that, leaving your browser very vulnerable). Here's a minimal security policy file (call it my.policy) which grants total access (so it's the same as a java application gets)

 grant {
   permission java.security.AllPermission;
 };

Now, with that in place, and your index.html and .class files in the same directory, you can invoke appletviewer and have it use that special policy file:

 appletviewer -J-Djava.security.policy=my.policy index.html

Which should allow total access. Naturally you have to trust the code (which is fine if you wrote it, and you trust yourself), so it's obviously not a wise thing to do in general with code you didn't write and whose source you don't have good reason to trust. -- Finlay McWalterTalk 13:48, 20 July 2012 (UTC)[reply]

I used the wrapper option. It works wonderfully, thank you all for the input! 172.162.132.72 (talk) 01:08, 21 July 2012 (UTC)[reply]

Resolved

Texniccenter

[edit]

When I type things like \begin{equation}, how do I make it automatically give \end{equation}? Money is tight (talk) 05:38, 20 July 2012 (UTC)[reply]

TFT monitor colours

[edit]

Does anybody know why colours displayed on a TFT monitor are darker at the top of the screen than at the bottom? Suppose I have a small window containing a simple graphic (eg a blue arrow). If the window is at the top of the screen, the blue is much darker than if the window is at the bottom of the screen. If happens in both Linux and Windows XP, so clearly it is something the monitor is doing. It does it in both daylight and artificial light too. It makes getting the colours right when editing graphics very tricky. Thanks! --TrogWoolley (talk) 09:58, 20 July 2012 (UTC)[reply]

I do not believe that holds true to any monitor.~It certainly isn't true to mine. Maybe yours is defective. 188.76.169.66 (talk) 12:03, 20 July 2012 (UTC)[reply]
Actually poor LCD viewing angle is the likely cause, see [1] or this old source [2] for example. Or try these tests [3] on a bunch of cheap LCDs and you'll probably see the problem yourself. I thought perhaps things had advanced since I last looked but it sounds like cheap LCDs still often have TN panels and so aren't great if you're planning to do serious graphical work, the CRT some random person is giving away is probably better from a colour standpoint (it may not be anywhere near as sharp particularly since it's old). Nil Einne (talk) 13:18, 20 July 2012 (UTC)[reply]
Resolved
Thanks for the links; the first one was very useful. My monitors at work and at home both have the problem, and it looks as though the solution is either buy a more expensive monitor (can't see work doing that) or live with it.--TrogWoolley (talk) 18:12, 20 July 2012 (UTC)[reply]

PS3 games: PAL and NTSC

[edit]

Hi, I live in Australia, and I'd like to buy some PS3 games from overseas, cos you know, gaming outlets love to overcharge us Aussies. Anyway, I'm wondering what the differences are between the Australian and UK PAL versions, as well as PAL versions from other countries, and whether they'd cause any significant changes in gameplay. I've been given to understand that NTSC games are also compatiable with my PAL PS3 provided that I've got HD connection with my TV (which I do) -- can somebody confirm this? Also, can somebody point me to an official article that explains the differences between: the PAL regions; and between PAL and NTSC versions? It'll be great if people can respond to my queries. Thanks --Sp33dyphil ©hatontributions 10:35, 20 July 2012 (UTC)[reply]

Our Regional lockout article suggests the PS3 has the technical ability to regionally lockout games but the only time it was tried, it was abandoned due to complaints. However it also suggests you may have prolems if you want to buy content from the PS3 store. Whether Australia is in a different region from the Europe when it comes to the PS3 I can't say. In less complicated regions systems Australia and NZ usually end up with Europe. Nil Einne (talk) 11:36, 20 July 2012 (UTC)[reply]
[edit]

Why (I think) only Wikipedia's addresses can have a space instead of a underscore? Even if it gets converted, why other web-sites don't perform this trick? Persominus (talk) 13:42, 20 July 2012 (UTC)[reply]

Strictly, your browser is performing the conversion ("percent-encoding"), not Wikipedia's server software. Space characters are not valid in a URL query string. Wikipedia's software - MediaWiki - has an intelligent mapping between spaces and underscore characters because wiki syntax is designed to streamline the conversion between human-readable and machine-readable text. Other websites that run MediaWiki automatically use these conventions. Other server-software may use a similar convention, at the discretion of the web designer. Nimur (talk) 13:49, 20 July 2012 (UTC)[reply]
Most other websites do perform that trick, at least for links to webpages within the same website. If you are seeing a "Contact_us" link instead of "Contact us", for example, it's very poor webpage design.--Shantavira|feed me 14:52, 20 July 2012 (UTC)[reply]

You're referring to simple URI remapping, Apache HTTP Server would do it like so, for example. A lot of websites using Content Management Systems that weren't designed by total goobers (not as many as you might think) promote such remapping. A lot of websites have no content management system or back end to speak of, and operate much more simply. ¦ Reisio (talk) 20:53, 20 July 2012 (UTC)[reply]

To really understand this sort of issue is confusing, because there are a lot of different things going on.

  1. Strictly speaking, URLs (web addresses) cannot contain spaces.
  2. Spaces must be encoded in URLs as %20.
  3. Since spaces in names and URLs are a nuisance, Wikipedia arranges that actual article names do not contain spaces, but rather underscores. But that would be a huge nuisance, too, so Wikipedia automatically does the right thing. Article titles are printed at the top of the screen with spaces instead of underscores (although you can still see the underscores in the URL in your browser's address bar). If you refer to an article title using spaces, Wikipedia automatically assumes the underscores. For example, this page's name is Wikipedia:Reference_desk/Computing, but it appears as the top of the page as "Wikipedia:Reference desk/Computing", and I can refer to it in wikitext as either [[Wikipedia:Reference desk/Computing]] or [[Wikipedia:Reference_desk/Computing]]. It shows in my browser's address bar as http://wiki.riteme.site/wiki/Wikipedia:Reference_desk/Computing.
  4. Most browsers jump into the DWIM act, too. If you type a space into the address bar, most browsers automatically convert it into %20 for you.

So what actually happens if you construct a URL for a Wikipedia article by hand, containing a space, is that your browser converts it to %20, and Wikipedia's web server translates it back to a space, and then the higher-level Wikipedia software converts the space into an underscore when looking up the article name in the database, but displays it to you as a space. Over the river and through the woods (and twice around the barn), to Grandmother's house we go... —Steve Summit (talk) 15:00, 22 July 2012 (UTC)[reply]

wikiasari

[edit]

what is the domain name for wikiasari — Preceding unsigned comment added by 90.194.140.253 (talk) 15:35, 20 July 2012 (UTC)[reply]

http://www.wikiasari.net Tombo7791 (talk) 17:20, 20 July 2012 (UTC)[reply]

Video "prt sc"

[edit]

I know there is such a thing a "prt sc" to print whatever there is on the screen and save as a JPG. Is there such a thing as a video "print screen" that will capture the video on the screen (e.g. mouse moving around the screen, clicks and different screens produced; YouTube video presentations on the screen) and save as a MPEG? I have a newer HP laptop with Windows 7. Is there something in Windows Live Movie Maker that will capture video on the screen?--Doug Coldwell talk 18:24, 20 July 2012 (UTC)[reply]

It sounds like you want to make a Screencast - that article and Comparison of screencasting software should get you on your way. -- Finlay McWalterTalk 18:50, 20 July 2012 (UTC)[reply]
Finlay got there before me. If you're into using MS products, apparently Microsoft Expression Encoder does it. I haven't used it myself. - Cucumber Mike (talk) 18:52, 20 July 2012 (UTC)[reply]
The "PrtSc" thing ("print screen", variously written PrntScr, PrtScr, and so on on keyboards) is called a "screenshot", and the video equivalent is (as Finlay McWalter pointed out) a "screencast". There are a number of other programs capable of producing these; among them are Fraps, which is especially well-liked by people who make videos of games, and Camtasia Studio.  dalahäst (let's talk!) 02:38, 21 July 2012 (UTC)[reply]
Thanks. You all have given me good leads.--Doug Coldwell talk 12:20, 21 July 2012 (UTC)[reply]