In Python 2, what is the difference between '/' and '//' when used for division?

In Python 2, what is the difference between '/' and '//' when used for division?

Is there a benefit to using one over the other? In Python 2, they both seem to return the same results:>>> 6/32>>> 6//32 1:In Python 3.0, 5 / 2 will return 2.5 and 5 // 2 will return 2. The former is floating point division, and the lat

Formatting a number with leading zeros in PHP

Formatting a number with leading zeros in PHP

I have a variable which contains the value 1234567.I would like it to contain exactly 8 digits, i.e. 01234567.Is there a PHP function for that? 1:Use sprintf :sprintf('%08d', 1234567);Alternatively you can also use str_pad:str_pad($value

Transitioning from Windows Forms to WPF

Transitioning from Windows Forms to WPF

For a long time now, I have been stuck with Windows Forms development (started with VB6, and has continued through to C# .NET 4.5), and I have pretty much hit the limit of what Windows Forms can do, both using pure .NET, and special effects

Create a dictionary with list comprehension in Python

Create a dictionary with list comprehension in Python

I like the Python list comprehension syntax.Can it be used to create dictionaries too? For example, by iterating over pairs of keys and values:mydict = {(k,v) for (k,v) in blah blah blah} # doesn't work 1:In Python 2.6 and earlier, the

How to capture the browser window close event?

How to capture the browser window close event?

I want to capture the browser window/tab close event.I have tried the following with jQuery: jQuery(window).bind( "beforeunload", function() { return confirm("Do you really want to close?") })But it works on form submissi

How do I reverse an int array in Java?

How do I reverse an int array in Java?

I am trying to reverse an int array in Java.This method does not reverse the array. for(int i = 0; i < validData.length; i++){ int temp = validData[i]; validData[i] = validData[validData.length - i - 1]; validData[validData.length

Difference between append vs. extend list methods in Python

Difference between append vs. extend list methods in Python

What's the difference between the list methods append() and extend()? 1:append: Appends object at end.x = [1, 2, 3]x.append([4, 5])print (x)gives you: [1, 2, 3, [4, 5]]extend: Extends list by appending elements from the iterable.x = [1,

Get escaped URL parameter

Get escaped URL parameter

I'm looking for a jQuery plugin that can get URL parameters, and support this search string without outputting the JavaScript error: "malformed URI sequence". If there isn't a jQuery plugin that supports this, I need to know how to modify i

One-liner to take some properties from object in ES 6

One-liner to take some properties from object in ES 6

How one can write a function, which takes only few attributes in most-compact way in ES6?I've came up with solution using destructuring + simplified object literal, but I don't like that list of fields is repeated in the code.Is there an ev

How to do 3 table JOIN in UPDATE query?

How to do 3 table JOIN in UPDATE query?

I asked a question and got this reply which helped. UPDATE TABLE_A a JOIN TABLE_B b ON a.join_col = b.join_col AND a.column_a = b.column_b SET a.column_c = a.column_c + 1Now I am looking to do this if there are 3 tables involvedsome

Remove HTML tags from a String

Remove HTML tags from a String

Is there a good way to remove HTML from a Java string? A simple regex like replaceAll("\\<.*?>","") will work, but things like & wont be converted correctly and non-HTML between the two angle brackets will be removed (i.e. the .*? in

dispatch_after - GCD in swift?

dispatch_after - GCD in swift?

I've gone through the iBook from Apple, and couldn't find any definition of it :Can someone explain the structure of dispatch_after?dispatch_after(<#when: dispatch_time_t#>, <#queue: dispatch_queue_t?#>, <#block: dispatch_block_t?#>) 1:A

How to merge two arrays in JavaScript and de-duplicate items

How to merge two arrays in JavaScript and de-duplicate items

I have two JavaScript arrays:var array1 = ["Vijendra","Singh"];var array2 = ["Singh", "Shakya"];I want the output to be:var array3 = ["Vijendra","Singh","Shakya"];The output array should have repeated words removed.How do I merge two arrays

git submodule update

git submodule update

I'm not clear on what the following means (from git submodule update docs): ...will make the submodules HEAD be detached, unless --rebase or --merge is specified... How does --rebase/--merge change things? My main use case is to hav

How do I create a transparent Activity on Android?

How do I create a transparent Activity on Android?

I want to create a transparent Activity on top of another activity.How can I achieve this? 1:Add the following style in your res/values/styles.xml file (if you don’t have one, create it.) Here’s a complete file:<?xml version="1.0" encodi

protected data in abstract class

protected data in abstract class

My question involves specifically Java, abstract classes, and the use of protected data. I am being told that all the data should be private, and protected getters/setters used only.Now, I understand we want to shield data from direct mani

Why do partial methods have to be void?

Why do partial methods have to be void?

I am currently learning C# with the book called Beginning Visual C# 2010 and I am in the chapter that discusses different aspects and characteristics of partial methods and classes.To quote the book: Consider at this point why partial meth

DesignInstance not working in VS2012

DesignInstance not working in VS2012

I just spent several hours on an issue when using VS2012, WPF 4.5 and design-time data, specifically the DesignInstance attribute.Goal: I wanted to have design-time data support in my WPF project (MVVM-based), both in VS2012 and Blend, and

Visual Studio: Configuration Manager missing

Visual Studio: Configuration Manager missing

I'm using Microsoft Visual Studio Team System 2008 Team Suite.The "Configuration Manager" menu item is missing for me. I've assigned a keyboard shortcut to the Configuration Manager, but it doesn't have any effect (actually, it produces a "

Installing a specific version of angular with angular cli

Installing a specific version of angular with angular cli

I searched through google and angular cli doc but couldn't find any way to install a specific version of angular using angular cli. is it even possible? 1:You can just have package.json with specific version and do npm install and it wil

PHP Convert String into Float/Double

PHP Convert String into Float/Double

I have list of string (size in bytes), I read those from file. Let say one of the string is 2968789218, but when I convert it to float it become 2.00.This is my code so far :$string = "2968789218";$float = (float)$string;//$float = floatval

Update AngularJS ng-model only on keypress enter?

Update AngularJS ng-model only on keypress enter?

I have this input field I am using for a search:There are many other filters I use as well (checkboxes, radio, etc) and I have a $watch on filter so any changes will fire a search. The problem is that I don't want the search to fire for the

Change EF 6 Code Generation Strategy from T4

Change EF 6 Code Generation Strategy from T4

In the past I have successfully created edmx files. This was using EF5 and Visual Studio 2012. I have since upgraded to Visual Studio 2013 and EF6. The existing EF 5 code still works, but now I have a problem. I can create edmx files, and a

How can I prevent overlapping in a family tree generator?

How can I prevent overlapping in a family tree generator?

I'm creating an interactive family tree creator, unlike more simpler versions which are simple pedigree charts/trees.The requirements for mine (based on familyecho.com) are: multiple partners vs just a simple 2 parent to 1 child that you no

How to style  in IE6 CSS?

How to style in IE6 CSS?

Is there any elegant way of applying a certain style to all elements under IE6? I can do it with some JavaScript, but I was wondering if there was a more elegant way of doing it.Note - I cannot apply a certain class to all textboxes by han