Questions

Simple way to measure cell execution time in ipython notebook

I would like to get the time spent on the cell execution in addition to the original output from cell. To this end, I tried `%%timeit -r1 -n1` but it doesn't expose the variable defined within cell. `...

How do I clone a range of array elements to a new array?

I have an array X of 10 elements. I would like to create a new array containing all the elements from X that begin at index 3 and ends in index 7. Sure I can easily write a loop that will do it for me...

8 Jul at 22:56

How to create a delay in Swift?

I want to pause my app at a certain in point. In other words, I want my app to execute the code, but then at a certain point, pause for 4 seconds, and then continue on with the rest of the code. How c...

7 Nov at 10:43

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 wa...

2 Mar at 11:15

Show and hide a View with a slide up/down animation

I have a `LinearLayout` that I want to show or hide with an `Animation` that pushes the layout upwards or downwards whenever I change its visibility. I've seen a few samples out there but none of the...

21 Aug at 08:36

Create empty file using python

I'd like to create a file with path `x` using python. I've been using `os.system(y)` where `y = 'touch %s' % (x)`. I've looked for a non-directory version of `os.mkdir`, but I haven't been able to fin...

29 Sep at 17:30

Extract part of a string using bash/cut/split

I have a string like this: ``` /var/cpanel/users/joebloggs:DNS9=domain.example ``` I need to extract the username (`joebloggs`) from this string and store it in a variable. The format of the string w...

20 Jun at 10:25

Making HTTP Requests using Chrome Developer tools

Is there a way to make an HTTP request using the Chrome Developer tools without using a plugin like POSTER?

How to change the text on the action bar

Currently it just displays the name of the application and I want it to display something custom and be different for each screen in my app. For example: my home screen could say 'page1' in the actio...

17 Jan at 10:6

Improve INSERT-per-second performance of SQLite

Optimizing SQLite is tricky. Bulk-insert performance of a C application can vary from 85 inserts per second to over 96,000 inserts per second! We are using SQLite as part of a desktop application. We...

30 Jan at 15:19

How do you create nested dict in Python?

I have 2 CSV files: 'Data' and 'Mapping': - `Device_Name``GDN``Device_Type``Device_OS`- `Device_Name`- `Device_Name``GDN``Device_Type``Device_OS` I know how to use dict when only 2 columns are prese...

Convert data.frame column format from character to factor

I would like to change the format (class) of some columns of my data.frame object (`mydf`) from to . I don't want to do this when I'm reading the text file by `read.table()` function. Any help woul...

6 Dec at 08:37

Switch on Enum in Java

Why can't you switch on an enum in Java? It seems simple enough to do and would make for some convenient code. Also this question could apply to `String`'s. You can switch on a `char`, but not a `Stri...

31 May at 08:44

How to reload the current state?

I'm using Angular UI Router and would like to reload the current state and refresh all data / re-run the controllers for the current state and it's parent. I have 3 state levels: contains a table ...

ValueError: could not broadcast input array from shape (224,224,3) into shape (224,224)

I have a list say, temp_list with following properties : ``` len(temp_list) = 9260 temp_list[0].shape = (224,224,3) ``` Now, when I am converting into numpy array, ``` x = np.array(temp_list...

15 May at 10:43

Redirect to an external URL from controller action in Spring MVC

I have noticed the following code is redirecting the User to a URL inside the project, ``` @RequestMapping(method = RequestMethod.POST) public String processForm(HttpServletRequest request, LoginFor...

30 Jul at 19:32

How can I Install a Python module within code?

I need to install a package from [PyPI](https://en.wikipedia.org/wiki/Python_Package_Index) straight within my script. Is there maybe some module or `distutils` (`distribute`, `pip`, etc.) feature whi...

23 Feb at 05:30

SQL Data Reader - handling Null column values

I'm using a SQLdatareader to build POCOs from a database. The code works except when it encounters a null value in the database. For example, if the FirstName column in the database contains a null va...

20 Nov at 17:24

How do I clear/delete the current line in terminal?

If I'm using terminal and typing in a line of text for a command, is there a hotkey or any way to clear/delete that line? For example, if my current line/command is something really long like: ``` >...

21 Mar at 04:28

.ps1 cannot be loaded because the execution of scripts is disabled on this system

I run this code to execute PowerShell code from an ASP.NET application: ``` System.Management.Automation.Runspaces.Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRun...

19 Jun at 21:10

How to add directory to classpath in an application run profile in IntelliJ IDEA?

I'm trying to add a directory to the classpath of an application run profile If I override by using -cp x:target/classes in the VM settings, I get the following error: ``` java.lang.NoClassDefFoundE...

21 Jun at 21:24

Tree data structure in C#

I was looking for a tree or graph data structure in C#, but I guess there isn't one provided. [An Extensive Examination of Data Structures Using C# 2.0](http://msdn.microsoft.com/en-us/library/ms37957...

5 Dec at 17:22

Is it possible to run .APK/Android apps on iPad/iPhone devices?

All- I recently published an android app on Google Play. I also made it available on my website as an .apk file. I hate to ask this as I am not a big fan of Apple but could an Apple user download my a...

4 Jul at 22:29

SQL Server Text type vs. varchar data type

I have variable length character data and want to store in SQL Server (2005) database. I want to learn some best practices about how to choose TEXT SQL type or choose VARCHAR SQL type, pros and cons i...

13 Sep at 20:44

How to access /storage/emulated/0/

I have written a code to record audio and save it to below file location. ``` private String getFilename() { String filepath = Environment.getExternalStorageDirectory().getPath(); File file =...

11 Feb at 08:37