Finding the index of an item given a list containing it in Python

Finding the index of an item given a list containing it in Python

For a list ["foo", "bar", "baz"] and an item in the list "bar", what's the cleanest way to get its index (1) in Python? 1:>>> ["foo", "bar", "baz"].index("bar")1Reference: Data Structures > More on Lists 2:One thing that is really h

mysql_field_name to the new mysqli

mysql_field_name to the new mysqli

I have a way to get the name of the columns of a table. It works fine but now I want to update to the new mysqli ? (I tried the mysqli_fetch_field but I don't know how to apply to this case and I am not sure if it is the wright option)How t

Test bundle could not be loaded because an unanticipated error

Test bundle could not be loaded because an unanticipated error

Recently I have started writing test case for one old static library. I have loaded the library to Xcode 5,Since Static Library is old , I have to manually add TestProject with Test Target. When I am trying "ProductTest" , It launches emula

Extra padding in

Extra padding in

It seems that every browser adds some magic hardcoded padding inside . Some browsers (IE, Safari, Chrome) make the input box a bit taller, but they properly top align as if it was a regular HTML element. I can live with the extra height. Bu

Rails 3 and Devise: Redirecting to page following signup (confirmable)

Rails 3 and Devise: Redirecting to page following signup (confirmable)

I have a Rails 3 project with Devise, confirmable enabled so the user has to confirm their account through email after registration. Currently the project returns the user to the login page and throws a "You've signed up successfully..." no

The most Pythonic way of checking if a value in a dictionary is defined/has zero length

The most Pythonic way of checking if a value in a dictionary is defined/has zero length

Say I have a dictionary, and I want to check if a key is mapped to a nonempty value. One way of doing this would be the len function:mydict = {"key" : "value", "emptykey" : ""}print "True" if len(mydict["key"]) > 0 else "False" # prints t

How does docker's `net=host` setting work, and how can I do something similar with e.g. Virtual

How does docker's `net=host` setting work, and how can I do something similar with e.g. Virtual

Docker has a run option net=host documented here that allows you to run a virtual machine that shares the network stack with the host — for example, processes inside the docker container can connect to the host machine via localhost and vic

Type.GetProperties() missing in Xamarin PCL

Type.GetProperties() missing in Xamarin PCL

In Xamarin PCL, I'm trying to get the System.Reflection.PropertyInfo of a class I've written so that I can access its properties by their string name to get/set, and Type.GetTypeInfo() is missing, as well as Type.GetProperties. But System.R

“dyld: could not load inserted library '/usr/lib/libgmalloc.dylib' because image not found

“dyld: could not load inserted library '/usr/lib/libgmalloc.dylib' because image not found

When I run the app in Xcode IOS 6 beta 2 firmware on the device 8 Beta 2, I get the error message: "dyld: could not load inserted library '/ USR / Library / libgmalloc.dylib", because the image was not found. "What could be the problem?

In google analytics property settings, what difference does the Default URL makes

In google analytics property settings, what difference does the Default URL makes

I'm setting a new property on my google analytics account, and one of the fields I have to fill out is Default URL:My question is what does it matter? What does it affect?I see that GA collects data I send no matter what URL I've defined th

Missing script/generate in Rails 3

Missing script/generate in Rails 3

I just installed Rails 3 and created my first app. The install of Rails3 + ruby 1.9 went very smoothly but I am missing the generate script in script/generate.I have created a new app from scratch with no options to verify.Any idea why thi

Find content of one file from another file in UNIX

Find content of one file from another file in UNIX

I have 2 files. First file contains the list of row ID's of tuples of a table in the database.And second file contains SQL queries with these row ID's in "where" clause of the query.For example:File 11610657303161065846416106591691610668135

Why is php5isapi.dll missing after installing PHP for Windows?

Why is php5isapi.dll missing after installing PHP for Windows?

It's been a while since I've installed PHP for Windows, but every guide I've seen online tells me to set IIS to recognize .PHP files with php5isapi.dll. However, I can't seem to find php5isapi.dll anywhere after installing PHP 5.3.0 and PH

jQuery Duplicate Selector error

jQuery Duplicate Selector error

I am currently trying to set up a table with 6 clickable cels that allow for a input box to appear so you can add comments but I am getting a duplicated jQuery selector error and also through debugging my second function I found that .html(

Clear session cookies in ie11?

Clear session cookies in ie11?

in previous versions of IE the F12 dev tools had several option for cache and cookie management, but in the new IE 11 version (on the network tab) the option to clear / delete session cookies seems to be missing, does anyone know where to f

Rhino Mocks stubs and mocks are only good for interfaces?

Rhino Mocks stubs and mocks are only good for interfaces?

Is it correct that Rhino Mocks stubs and mocks are only good for interfaces, not concrete classes? I spent quite a time trying to make this piece of code working. I did not expect the stubbed pubSubClient to always call Send method from the

What's the purpose of the “__package__” attribute in Python?

What's the purpose of the “__package__” attribute in Python?

All I want to know is what exactly does __package__ mean? Didn't find any explanation in the official doc, even on SO.If you could provide some examples I would be very happy. 1:See the PEP 366 and import system reference documentation:

how to use jQuery installed with npm in Express app?

how to use jQuery installed with npm in Express app?

I have a node.js + express app and I installed jQuery with npm.in the app.js file I usedvar jquery = require('jquery');In the html file header I included javascript that uses jQuery and I get `jQuery is not defined'.Is it a metter of order

text field not working in safari

text field not working in safari

I'm working on an online eBay profit forecasting calculator hereI can't seem to get the input fields to work in safari and mobile safari. They work fine in FF & Chrome. I click into them, but nothing shows when I type. I've been searching g

How to “select distinct” across multiple data frame columns in pandas?

How to “select distinct” across multiple data frame columns in pandas?

I'm looking for a way to do the equivalent to the sql "SELECT DISTINCT col1, col2 FROM dataframe_table"The pandas sql comparison doesn't have anything about "distinct".unique() only works for a single column, so I suppose I could concat t

Run a NodeJS app with Apache

Run a NodeJS app with Apache

I have a ubuntu server running a few apache websites. I want to run a nodejs app on the same server. I have the app running on the server now out of port 3000 (www.example.com:3000) no problems there.I now want to direct a new domain to the

Node.js: Connecting to a Server Using Sockets

Node.js: Connecting to a Server Using Sockets

I'm just starting to play with Node.js today, and thought I'd start with what I thought would be a simple script: Connecting to a server via sockets, and sending a bit of data, and receiving it back. I'm creating a command line utility. Not

Html parsing with JSoup

Html parsing with JSoup

I am trying to parse the html of the following URL:http://ocw.mit.edu/courses/aeronautics-and-astronautics/16-050-thermal-energy-fall-2002/to obtain the text of the "" tag which contains the name of an instructor. The required information i

Error running make: missing separator (did you mean TAB instead of 8 spaces?)

Error running make: missing separator (did you mean TAB instead of 8 spaces?)

I'm trying to get PHP phar command line tool installed on my Debian VM, how here described: (1) download the php-src, I assume it's in /tmp/php/src (2) make the dir /tmp/phar (3) Save this as /tmp/php-src/ext/phar/Makefile. (4) cd

converting Akka's Future[A] to Future[Either[Exception,A]]

converting Akka's Future[A] to Future[Either[Exception,A]]

Is there a method in Akka (or in the standard library in Scala 2.10) to convert a Future[A] which might fail into a Future[Either[Exception,A]]? I know that you can writef.map(Right(_)).recover { case e:Exception => Left(e)}It just seems t