How to close current tab in a browser window?

How to close current tab in a browser window?

I want to create a link on a webpage that would close current active tab in a browser without closing other tabs in the browser. When user clicks close link, an alert message should appear asking user to confirm with two buttons, "YES" and

Why is the Java date API (java.util.Date, .Calendar) such a mess?

Why is the Java date API (java.util.Date, .Calendar) such a mess?

As most people are painfully aware of by now, the Java API for handling calendar dates (specifically the classes java.util.Date and java.util.Calendar) are a terrible mess.Off the top of my head:Date is mutableDate represents a timestamp, n

Why does division result in zero instead of a decimal?

Why does division result in zero instead of a decimal?

Teaching myself C and finding that when I do an equation for a temp conversion it won't work unless I change the fraction to a decimal. ie,tempC=(.555*(tempF-32)) will work but tempC=((5/9)*(tempF-32)) won't work. Why?According to C Prime

Python: Difference between class and instance attributes

Python: Difference between class and instance attributes

Is there any meaningful distinction between:class A(object): foo = 5 # some default valuevs.class B(object): def __init__(self, foo=5): self.foo = fooIf you're creating a lot of instances, is there any difference in performan

How to “properly” create a custom object in JavaScript?

How to “properly” create a custom object in JavaScript?

I wonder about what the best way is to create an JavaScript object that has properties and methods.I have seen examples where the person used var self = this and then uses self. in all functions to make sure the scope is always correct.Then

Change an element's class with JavaScript

Change an element's class with JavaScript

How can I change a class of an HTML element in response to an onClick event using JavaScript? 1:Modern HTML5 Techniques for changing classesModern browsers have added classList which provides methods to make it easier to manipulate class

Convert one date format into another in PHP

Convert one date format into another in PHP

Is there a simple way to convert one date format into another date format in PHP?I have this:$old_date = date('y-m-d-h-i-s'); // works$middle = strtotime($old_date); // returns bool(false)$new_date = date('Y-m-d H:i:s

Reference - What does this regex mean?

Reference - What does this regex mean?

What is this?This is a collection of common Q&A. This is also a Community Wiki, so everyone is invited to participate in maintaining it.Why is this?regex is suffering from give me ze code type of questions and poor answers with no explanati

How to scroll the window automatically when mouse moves bottom of the page using jquery

How to scroll the window automatically when mouse moves bottom of the page using jquery

I have 50 divs,But in my window it shows only 25,I do drag and drop activity on these divs.So If i drag my first div near 25th div,It should scroll automatically to show the remaining divs.How do i do this in jquery? any idea?I am using Nes

How to convert UTF8 combined Characters into single UTF8 characters in ruby?

How to convert UTF8 combined Characters into single UTF8 characters in ruby?

Some characters such as the Unicode Character 'LATIN SMALL LETTER C WITH CARON' can be encoded as 0xC4 0x8D, but can also be represented with the two code points for 'LATIN SMALL LETTER C' and 'COMBINING CARON', which is 0x63 0xcc 0x8c.More

Twitter Bootstrap - Print all tab content

Twitter Bootstrap - Print all tab content

I have the basic bootstrap tabs set up with no dynamically inserted content and print specific media queries in my base stylesheet. When the user prints from the browser I want all the tab content to print, not just the active tab. I know t

Hibernate: Dirty Checking and Only Update of Dirty Attributes?

Hibernate: Dirty Checking and Only Update of Dirty Attributes?

In the "good old JDBC days" I wrote a lot of SQL code that did very targeted updates of only the "attributes/members" that were actually changed:For example, consider an object with the following members:public String name;public String add

How to repeat string “n” times in java? [duplicate]

How to repeat string “n” times in java? [duplicate]

This question already has an answer here: Simple way to repeat a String in java 29 answers I want to be able to repeat a string of text "n" times:Somet

Browser specific CSS padding for firefox field

Browser specific CSS padding for firefox field

I have a dropdown list in my application whereby in order to center it I must add padding-top 10px while on Mozilla Firefox but on google chrome it does not need the padding. How can I target the select list to set this browser specific. I

Difference between ListView and ListBox in Visual Studio

Difference between ListView and ListBox in Visual Studio

What is the difference between "ListView" and "ListBox" in a "Windows 8" app. 1:The ListBox is an older control primarily for compatibility with other xaml frameworks. The ListView has build-in functionality for touch etc. Use the List

Has anyone found Garbage Collection tuning to be useful?

Has anyone found Garbage Collection tuning to be useful?

I've read plenty of articles about tuning GC in Java and have often wondered how many people really use some of the more advanced features.I've always avoided tuning where possible and concentrated on writing the simplest possible code I ca

How to choose an integer linear programming solver?

How to choose an integer linear programming solver?

I am newbie for integer linear programming.I plan to use a integer linear programming solver to solve my combinatorial optimization problem.I am more familiar with C++/object oriented programming on an IDE.Now I am using NetBeans with Cygwi

How to run a command as a specific user in an init script?

How to run a command as a specific user in an init script?

I'm writing an init script which is supposed to execute a single command as a user different than root. This is how I'm doing it currently:sudo -u username command This generally works as expected on Ubuntu/Debian, but on RHEL the script wh

I18n for model-specific Rails submit button

I18n for model-specific Rails submit button

I've found that Rails allows for generic i18n of submit buttons via the following in config/locales/en.yml:en: helpers: submit: create: "Create %{model}" submit: "Save %{model}" update: "Update %{model}"However, I'm looki

Get first element from a dictionary

Get first element from a dictionary

I have the following declaration:Dictionary> like = new Dictionary>();I need to get the first element out, but do not know the key or value. What's the best way to do this? 1:Edit To satisfy the commenters.Note that to call First here is

What are 3 kinds of Binding Contexts for?

What are 3 kinds of Binding Contexts for?

I know that there are 3 different binding contexts or load contexts:LoadLoadFromLoadNeitherWhat are load contexts?What are they for?Why make the assembly loading so complicated?In "LoadNeither", "neither" of what?Thanks in advance...-------

Cancel a AngularJS $timeout on routeChange

Cancel a AngularJS $timeout on routeChange

On a specific page in my application I think of doing a server-call to update information on a set interval.I stumbled upon a problem though. I want to cancel my $timeout when a user navigates away from the page in question so that the appl

Get hostname from Rails controller

Get hostname from Rails controller

I am trying to get the hostname of the machine which a rails application is running on from the controller.What would be the best way to do this taking into account it should work on both windows and linux? 1:There's always:require 'sock

How to to remove certain colors from an image with PHP or Ruby?

How to to remove certain colors from an image with PHP or Ruby?

Say there are 3 circles: red, blue, black.I only want the black circle to remain. How can I remove the red and blue circles? 1:Since you have asked for a PHP solution:First load your picture with imagecreatefrompng or the similar functio

Android Network Discovery Service (ish) before API 14

Android Network Discovery Service (ish) before API 14

I need to be able to discover the services on the local network (so say I am running a chat application and I want to discover other devices on local network running this chat), but sadly I need to be able to use it on devices with API Broa