How do I round a decimal value to 2 decimal places (for output on a page)

How do I round a decimal value to 2 decimal places (for output on a page)

When displaying the value of a decimal currently with .ToString(), it's accurate to like 15 decimal places, and since I'm using it to represent dollars and cents, I only want the output to be 2 decimal places. Do I use a variation of .ToStr

How to get UTF-8 working in Java webapps?

How to get UTF-8 working in Java webapps?

I need to get UTF-8 working in my Java webapp (servlets + JSP, no framework used) to support äöå etc. for regular Finnish text and Cyrillic alphabets like ЦжФ for special cases.My setup is the following:Development environment: Windows XPPr

Parsing JSON with Unix tools

Parsing JSON with Unix tools

I'm trying to parse JSON returned from a curl request, like so:curl 'http://twitter.com/users/username.json' | sed -e 's/[{}]/''/g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}'The above splits the JSON int

How to create a MySQL hierarchical recursive query

How to create a MySQL hierarchical recursive query

I have a MySQL table which is as follows:id | name | parent_id19 | category1 | 020 | category2 | 1921 | category3 | 2022 | category4 | 21......Now, I want to have a single MySQL query to which I simply supply the id [for inst

Flexbox: center horizontally and vertically

Flexbox: center horizontally and vertically

How to center div horizontally, and vertically within the container using flexbox. In below example, I want each number below each other (in rows), which are centered horizontally..flex-container { padding: 0; margin: 0; list-style: none

Validate decimal numbers in JavaScript - IsNumeric()

Validate decimal numbers in JavaScript - IsNumeric()

What's the cleanest, most effective way to validate decimal numbers in JavaScript?Bonus points for:Clarity. Solution should be clean and simple.Cross-platform.Test cases:01. IsNumeric('-1') => true02. IsNumeric('-1.5') => true03. Is

How to deal with floating point number precision in JavaScript?

How to deal with floating point number precision in JavaScript?

I have the following dummy test script:function test(){ var x = 0.1 * 0.2; document.write(x);}test();This will print the result 0.020000000000000004 while it should just print 0.02 (if you use your calculator). As far as I understood

How can I disable a service via Delphi?

How can I disable a service via Delphi?

I use a routine that can start and stop services via Delphi but I also need to be able to disable them, is it possible? 1:ShellExecute(0, nil, 'cmd.exe', 'sc config "the service name" start=disabled', nil, SW_HIDE);ShellExecute(0, nil, '

How can I disable a view behind my SlidingDrawer in Android?

How can I disable a view behind my SlidingDrawer in Android?

I have a SlidingDrawer that pops up from the bottom of the screen and fills the screen about 80%. Even though the SlidingDrawer view is in focus, it is still possible to click on items, buttons and other elements in the view that is behind

How do I select a .Net application configuration file from a command line parameter?

How do I select a .Net application configuration file from a command line parameter?

I would like to override the use of the standard app.config by passing a command line parameter. How do I change the default application configuration file so that when I access ConfigurationManager.AppSettings I am accessing the config fi

How to do “late” string interpolation in Ruby

How to do “late” string interpolation in Ruby

>> string = '#{var}'=> "\#{var}">> proc = Proc.new { |var| string }=> #>> proc.call(123)=> "\#{var}"Not really what I want. Double quotes around string result in the obvious undefined local variable. 1:Although this is possible, it's not

How do I debug a WordPress plugin?

How do I debug a WordPress plugin?

I've recently inherited a WordPress plugin that has a few bugs in it. My problem is that I'm also new to WordPress and I don't know how to log debug messages so that I can figure out what's going on. I really just need a way to create a pop

How to increment a JavaScript variable using a button press event

How to increment a JavaScript variable using a button press event

Can I create a javascript variable and increment that variable when I press a button (not submit the form).Thanks! 1:Yes:andIncrement 2:The purist way to do this would be to add event handlers to the button, instead of mixing behavior

Is it possible to prefill a input() in Python 3's Command Line Interface?

Is it possible to prefill a input() in Python 3's Command Line Interface?

I'm using Python 3.2 on Ubuntu 11.10 (Linux). A piece of my new code looks like this:text = input("TEXT=")Is it possible to get some predefined string after the prompt, so I can adjust it if needed? It should be like this:python3 fileTEXT=t

Why does my favicon not show up?

Why does my favicon not show up?

The following is used to set the favicon in my html code:However, the icon does not show. Why?Note:I have confirmed that the file is on-disk at the correct path. 1:Is it really a .ico, or is it just named ".ico"?What browser are you tes

How to start/stop a monitoring Delphi thread on demand?

How to start/stop a monitoring Delphi thread on demand?

I've been looking for a way to monitor for specific registry changes in Delphi. Found a solution at about.com:procedure TRegMonitorThread.Execute;begin InitThread; // method omitted here while not Terminated do begin if WaitForSingleO

Handling Android application pause on incoming call and resume after call end

Handling Android application pause on incoming call and resume after call end

I want to pause my android application when the phone receives an incoming call. After the call ends, I want my applications to resume automatically.How would this be implemented in an Android application? 1:you have to implement a List

How to properly link libraries with cmake?

How to properly link libraries with cmake?

I can't get the additional libraries I am working with to link into my project properly.I am using CLion, which uses cmake to build it's projects. I am trying to use several libraries in conjunction with OpenGL to texture some objects. I in

linked list in C

linked list in C

I am creating a linked list as in the previous question I asked. I have found that the best way to develop the linked list is to have the head and tail in another structure. My products struct will be nested inside this structure. And I sho

Magento Grid Container Block not loading grid

Magento Grid Container Block not loading grid

I just set up an admin module with a grid view using the module creator, and it works great, but now I need to add another grid view within the same module.I copied and renamed all the files relevant to the grid view(controllers and block f

sort tableview with drag and drop (rows)

sort tableview with drag and drop (rows)

my aim is to sort a tableview with drag and drop.I followed this example: http://docs.oracle.com/javafx/2/fxml_get_started/fxml_tutorial_intermediate.htmFor drag and drop I added the fxml via Scene Builderand made the [email protected] pr

JavaScript: How to find out width and height of viewpoint in browser window?

JavaScript: How to find out width and height of viewpoint in browser window?

How to find out width and height of viewpoint in browser window? And How to find out how much document scrolled to down and to right? 1:Try this function... and call it when needed :)function getViewPortSize(){ var viewportwidth; v

Compiling with gcc (cygwin on windows)

Compiling with gcc (cygwin on windows)

I have cygwin on windows through which I run gcc. But after creating .exe files, if I run them on other computers which dont have cygwin, it says cygwin1.dll not found. Is there a way to compile them so that they run on any system? 1:In

DataContractSerializer: How to serialize classes/members without DataContract/DataMember attributes

DataContractSerializer: How to serialize classes/members without DataContract/DataMember attributes

DataContractSerializer requires classes and members to be marked with the DataContract and DataMember attributes. However, in my case the classes are auto-generated with the EFPocoAdapater framework and these attributes are not present.How

small cycle finding in a planar graph

small cycle finding in a planar graph

I have a geometric undirected planar graph, that is a graph where each node has a location and no 2 edges cross, and I want to find all cycles that have no edges crossing them.Are there any good solutions known to this problem?What I'm plan