Questions

Python: Removing spaces from list objects

I have a list of objects appended from a mysql database and contain spaces. I wish to remove the spaces such as below, but the code im using doesnt work? ``` hello = ['999 ',' 666 '] k = [] for i i...

12 Jul at 23:4

How do I get the name of a Ruby class?

How can I get the class name from an ActiveRecord object? I have: ``` result = User.find(1) ``` I tried: ``` result.class # => User(id: integer, name: string ...) result.to_s # => #<User:0x3d07cd...

Accessing dict keys like an attribute?

I find it more convenient to access dict keys as `obj.foo` instead of `obj['foo']`, so I wrote this snippet: ``` class AttributeDict(dict): def __getattr__(self, attr): return self[attr] ...

18 Dec at 20:11

How to fix: Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list

I am configuring an MVC 3 project to work on a local install of IIS and came across the following 500 error: > Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in i...

Passing a dictionary to a function as keyword parameters

I'd like to call a function in python using a dictionary with matching key-value pairs for the parameters. Here is some code: ``` d = dict(param='test') def f(param): print(param) f(d) ``` This...

Creating Unicode character from its number

I want to display a Unicode character in Java. If I do this, it works just fine: `String symbol = "\u2202";` symbol is equal to "∂". That's what I want. The problem is that I know the Unicode num...

7 Apr at 18:40

Easy way to concatenate two byte arrays

What is the easy way to concatenate two `byte` arrays? Say, ``` byte a[]; byte b[]; ``` How do I concatenate two `byte` arrays and store it in another `byte` array?

9 May at 11:40

How do I concatenate or merge arrays in Swift?

If there are two arrays created in swift like this: ``` var a:[CGFloat] = [1, 2, 3] var b:[CGFloat] = [4, 5, 6] ``` How can they be merged to `[1, 2, 3, 4, 5, 6]`?

10 Jun at 10:56

Enter key pressed event handler

I want to capture the text from the textbox when enter key is hit. I am using WPF/visual studio 2010/.NET 4. I dont know what event handler to be used in the tag ? I also want to do the same for m...

PHPUnit assert that an exception was thrown?

Does anyone know whether there is an `assert` or something like that which can test whether an exception was thrown in the code being tested?

8 Nov at 15:41

How to substring in jquery

How can I use jquery on the client side to substring "nameGorge" and remove "name" so it outputs just "Gorge"? ``` var name = "nameGorge"; //output Gorge ```

8 Nov at 18:25

Characters allowed in a URL

Does anyone know the full list of characters that can be used within a GET without being encoded? At the moment I am using A-Z a-z and 0-9... but I am looking to find out the full list. I am also int...

6 Dec at 22:10

What's the fastest way to loop through an array in JavaScript?

I learned from books that you should write for loop like this: ``` for(var i=0, len=arr.length; i < len; i++){ // blah blah } ``` so the `arr.length` will not be calculated each time. Others...

23 May at 03:41

Simple check for SELECT query empty result

Can anyone point out how to check if a select query returns non empty result set? For example I have next query: ``` SELECT * FROM service s WHERE s.service_id = ?; ``` Should I do something like ...

21 May at 19:30

How to get unique device hardware id in Android?

How to get the unique device ID in Android which cannot be changed when performing a phone reset or OS update?

26 Sep at 22:20

Animate the transition between fragments

I'm trying to animate the transition between fragments. I got the answer from the following [Android Fragments and animation](https://stackoverflow.com/questions/4817900/android-fragments-and-animatio...

23 May at 12:2

Determine the line of code that causes a segmentation fault?

How does one determine where the mistake is in the code that causes a [segmentation fault](https://stackoverflow.com/questions/2346806/what-is-a-segmentation-fault)? Can my compiler (`gcc`) show the ...

26 Jan at 22:43

Read XML Attribute using XmlDocument

How can I read an XML attribute using C#'s XmlDocument? I have an XML file which looks somewhat like this: ``` <?xml version="1.0" encoding="utf-8" ?> <MyConfiguration xmlns="http://tempuri.org/myOw...

11 Jan at 14:27

How to refresh a Page using react-route Link

I am trying to refresh a page using react-route Link. But the way I have implemented it goes to the URL one step back.(as an example if the URL was ../client/home/register and when I press the reload ...

5 Jan at 09:37

HttpServletRequest to complete URL

I have an `HttpServletRequest` object. How do I get the complete and exact URL that caused this call to arrive at my servlet? Or at least as accurately as possible, as there are perhaps things that ...

15 Jan at 07:24

How do I add items to an array in jQuery?

``` var list = []; $.getJSON("json.js", function(data) { $.each(data, function(i, item) { console.log(item.text); list.push(item.text); }); }); console.log(list.length); ``` ...

26 Mar at 18:21

Git push error: "origin does not appear to be a git repository"

I am following the [instructions given here](http://qugstart.com/blog/ruby-and-rails/create-a-new-git-remote-repository-from-some-local-files-or-local-git-repository/) to create a Git repository. All ...

16 Nov at 14:32

Table is marked as crashed and should be repaired

I am getting this error in wordpress phpMyadmin ``` #145 - Table './DB_NAME/wp_posts' is marked as crashed and should be repaired ``` When I login to phpMyadmin, it says wp_posts is "in use" My we...

15 Dec at 15:8

How can I select all children of an element except the last child?

How would I select all but the last child using CSS3 selectors? For example, to get only the last child would be `div:nth-last-child(1)`.

11 Jan at 21:43

Lock screen orientation (Android)

I'm writing an android application that uses tabs with different contents (activities). In one of these activities, I would like to lock the screen orientation to "Landscape"-mode, but in the other ac...

2 Feb at 13:35