Retrieve a Fragment from a ViewPager
I'm using a `ViewPager` together with a `FragmentStatePagerAdapter` to host three different fragments: - - - When I want to get `Fragment1` from the `ViewPager` in the `FragmentActivity`. What is...
- Modified
- 26 Apr at 16:25
Create dynamic URLs in Flask with url_for()
Half of my Flask routes requires a variable say, `/<variable>/add` or `/<variable>/remove`. How do I create links to those locations? `url_for()` takes one argument for the function to route to but I...
How to embed an autoplaying YouTube video in an iframe?
I am trying to embed the new iframe version of a YouTube video and get it to auto play. As far as I can tell, there is no way of doing this by amending flags to the URL. Is there a way to do it by u...
- Modified
- 12 Aug at 18:24
How to express a One-To-Many relationship in Django?
I'm defining my Django models right now and I realized that there wasn't a `OneToManyField` in the model field types. I'm sure there's a way to do this, so I'm not sure what I'm missing. I essentially...
- Modified
- 4 May at 23:19
curl : (1) Protocol https not supported or disabled in libcurl
I'm trying to install the Rails environments on Ubuntu 11.04. When I launch the command `rvm install 1.9.2 --with-openssl-dir=/usr/local` the following error is received: ``` curl : (1) Protocol http...
- Modified
- 25 Feb at 15:28
How to display HTML tags as plain text
I have an input form on my website where HTML is allowed and I'm trying to add instructions about the use of HTML tags. I'd like the text to ``` <strong>Look just like this line - so then know how to...
Check if a string has a certain piece of text
> [Check if text is in a string](https://stackoverflow.com/questions/6614424/check-if-text-is-in-a-string) [JavaScript: string contains](https://stackoverflow.com/questions/1789945/javascript-str...
- Modified
- 20 Nov at 15:2
Converting a date string to a DateTime object using Joda Time library
I have a date as a string in the following format `"04/02/2011 20:27:05"`. I am using Joda-Time library and would like to convert it to `DateTime` object. I did: ``` DateTime dt = new DateTime("04/02...
How can I render inline JavaScript with Jade / Pug?
I'm trying to get JavaScript to render on my page using Jade (http://jade-lang.com/) My project is in NodeJS with Express, eveything is working correctly until I want to write some inline JavaScript ...
Refresh a page using JavaScript or HTML
How can I refresh a page using JavaScript or HTML?
- Modified
- 6 Sep at 11:15
Print JSON parsed object?
I've got a javascript object which has been JSON parsed using `JSON.parse` I now want to print the object so I can debug it (something is going wrong with the function). When I do the following... ``...
- Modified
- 14 Nov at 10:48
Using a dictionary to count the items in a list
Suppose I have a list of items, like: ``` ['apple', 'red', 'apple', 'red', 'red', 'pear'] ``` I want a dictionary that counts how many times each item appears in the list. So for the list above the r...
Can I access variables from another file?
Is it possible to use a variable in a file called `first.js` inside another file called `second.js`? `first.js` contains a variable called `colorcodes`.
- Modified
- 31 Jan at 04:26
Creating an empty list in Python
What is the best way to create a new empty list in Python? ``` l = [] ``` or ``` l = list() ``` I am asking this because of two reasons: 1. Technical reasons, as to which is faster. (creating ...
- Modified
- 23 Mar at 08:27
How should I write a Windows path in a Python string literal?
What is the best way to represent a Windows directory, for example `"C:\meshes\as"`? I have been trying to modify a script but it never works because I can't seem to get the directory right, I assume ...
- Modified
- 13 Jan at 08:24
Accept server's self-signed ssl certificate in Java client
It looks like a standard question, but I couldn't find clear directions anywhere. I have java code trying to connect to a server with probably self-signed (or expired) certificate. The code reports t...
Python Sets vs Lists
In Python, which data structure is more efficient/speedy? Assuming that order is not important to me and I would be checking for duplicates anyway, is a Python set slower than a Python list?
- Modified
- 12 Aug at 05:59
Eclipse copy/paste entire line keyboard shortcut
Anyone know the keyboard shortcut to copy/paste a line into a new line in `Eclipse`, without having to highlight the entire line? -- turns my whole screen upside down (I'm on windows). Interestingly...
- Modified
- 18 Jul at 15:43
Mocking Extension Methods with Moq
I have a preexisting Interface... ``` public interface ISomeInterface { void SomeMethod(); } ``` and I've extended this intreface using a mixin... ``` public static class SomeInterfaceExtensio...
- Modified
- 19 Feb at 12:43
How to slice an array in Bash
Looking the "Array" section in the bash(1) man page, I didn't find a way to slice an array. So I came up with this overly complicated function: ``` #!/bin/bash # @brief: slice a bash array # @arg1:...
delete word after or around cursor in VIM
I'm now switching to `VIM` from TextMate. I found `^+W` in INSERT mode very useful. However, I'd like to delete not only the word before cursor, but the word after or around cursor as well. I did som...
- Modified
- 19 Jan at 15:35
What's the function like sum() but for multiplication? product()?
Python's [sum()](http://docs.python.org/library/functions.html#sum) function returns the sum of numbers in an iterable. ``` sum([3,4,5]) == 3 + 4 + 5 == 12 ``` I'm looking for the function that ret...
- Modified
- 1 Feb at 12:24
Cancel a UIView animation?
Is it possible to cancel a `UIView` animation while it is in progress? Or would I have to drop to the CA level? i.e. I've done something like this (maybe setting an end animation action too): ``` [U...
- Modified
- 31 Aug at 05:8
Will code in a Finally statement fire if I return a value in a Try block?
I'm reviewing some code for a friend and say that he was using a return statement inside of a try-finally block. Does the code in the Finally section still fire even though the rest of the try block ...
Markdown and image alignment
I am making a site that publishes articles in issues each month. It is straightforward, and I think using a Markdown editor (like the [WMD](http://code.google.com/p/wmd/) one here in Stack Overflow) w...