enumerate() for dictionary in Python
I know we use `enumerate` for iterating a list but I tried it on a dictionary and it didn't give an error. CODE: ``` enumm = {0: 1, 1: 2, 2: 3, 4: 4, 5: 5, 6: 6, 7: 7} for i, key in enumerate(enumm):...
- Modified
- 6 Dec at 23:10
Image resizing in React Native
I am trying to resize an image (smaller to fit screen) in my react native app but am unable to do it as it is too big. Here is the code: ``` 'use strict'; var React = require('react-native'); var {...
- Modified
- 13 Mar at 22:12
How to change default database in SQL Server without using MS SQL Server Management Studio?
I dropped a database from SQL Server, however it turns out that was set to use the dropped database as its default. I can connect to SQL Server Management Studio by using the 'options' button in the ...
- Modified
- 15 Sep at 20:1
PHP Warning: Module already loaded in Unknown on line 0
On Mac OSX Mavericks using homebrew php55 whenever I run a a php command I get the following error message (everything runs fine it's just annoying) ``` PHP Warning: Module 'intl' already loaded in ...
- Modified
- 12 Oct at 14:27
Checking if a collection is null or empty in Groovy
I need to perform a null or empty check on a collection; I think that `!members?.empty` is incorrect. Is there a groovier way to write the following? ``` if (members && !members.empty) { // Some ...
How to view the Folder and Files in GAC?
I want to view the folders and sub folders in [GAC](https://en.wikipedia.org/wiki/Global_Assembly_Cache). Also want to know about adding and removing from [GAC](https://en.wikipedia.org/wiki/Global_As...
- Modified
- 5 Nov at 07:16
LINQ query to return distinct field values from list of objects
``` class obj { int typeId; //10 types 0-9 string uniqueString; //this is unique } ``` Assume there is a list with 100 elements of objs, but only 10 unique typeIDs. Is it possible to write ...
Uploading/Displaying Images in MVC 4
Anyone know of any step by step tutorials on how to upload/display images from a database using Entity Framework? I've checked out code snippets, but I'm still not clear on how it works. I have no cod...
- Modified
- 5 Dec at 14:1
Easiest way to change font and font size
which is the easiest way to change Font size with C#. with java it can all be done easily by calling Font constructor with necessary arguments. ``` JLabel lab = new JLabel("Font Bold at 24"); lab....
POST Content-Length exceeds the limit
I get similar errors in my error_log in php when users are uploading their files > PHP Warning: POST Content-Length of 11933650 bytes exceeds the limit of 8388608 bytes in Unknown on line 0 In my ...
- Modified
- 12 Aug at 09:25
Error: free(): invalid next size (fast):
What is this strange error I'm getting? I'm compiling C++ using g++ on Ubuntu 10.10. It pops up randomly when I run the executable (maybe 2 times in 8 hours, with 10 compiles an hour). However, if I m...
How to initialize a List<T> to a given size (as opposed to capacity)?
.NET offers a generic list container whose performance is almost identical (see Performance of Arrays vs. Lists question). However they are quite different in initialization. Arrays are very easy to...
- Modified
- 20 Aug at 21:44
nodejs - first argument must be a string or Buffer - when using response.write with http.request
I'm simply trying to create a node server that outputs the HTTP status of a given URL. When I try to flush the response with res.write, I get the error: throw new TypeError('first argument must be a ...
ERROR 1067 (42000): Invalid default value for 'created_at'
When I tried to alter the table it showed the error: ``` ERROR 1067 (42000): Invalid default value for 'created_at' ``` I googled for this error but all I found was as if they tried to alter the ti...
- Modified
- 11 Feb at 13:13
java.io.IOException: Broken pipe
We are currently migrating a legacy application to Jetty. And I have somehow an exception regarding a broken pipe. - - - I am trying to migrate a Glassfish web application to Jetty. In our testing ...
- Modified
- 3 Apr at 11:33
Login credentials not working with Gmail SMTP
I am attempting to send an email in Python, through Gmail. Here is my code: ``` import smtplib fromaddr = '......................' toaddrs = '......................' msg = 'Spam email Test' ...
- Modified
- 29 Nov at 20:53
Splitting string with pipe character ("|")
I'm not able to split values from this string: `"Food 1 | Service 3 | Atmosphere 3 | Value for money 1 "` Here's my current code: ``` String rat_values = "Food 1 | Service 3 | Atmosphere 3 | Value...
How to create a logfile in php
I want to create a logfile for my system to register/log every action they do inside the system. But I have no idea how to do it. For example, I have this php code that does the login function. ``` pu...
What is the correct format to use for Date/Time in an XML file
What format do I use for Date/Time when writing to an XML file using .NET? Do I simply use `DateTime.ToString()`, or do I have to use a specific format?
Exact time measurement for performance testing
What is the most exact way of seeing how long something, for example a method call, took in code? The easiest and quickest I would guess is this: ``` DateTime start = DateTime.Now; { // Do some ...
- Modified
- 30 May at 09:27
Simple way to read single record from MySQL
What's the best way with PHP to read a single record from a MySQL database? E.g.: ``` SELECT id FROM games ``` I was trying to find an answer in the old questions, but had no luck.
mysqldump & gzip commands to properly create a compressed file of a MySQL database using crontab
I am having problems with getting a `crontab` to work. I want to automate a MySQL database backup. The setup: - - - - From the shell this command works ``` mysqldump -u user -p[user_password] [da...
"continue" in cursor.forEach()
I'm building an app using meteor.js and MongoDB and I have a question about `cursor.forEach()`. I want to check some conditions in the beginning of each `forEach` iteration and then skip the element i...
- Modified
- 12 Dec at 15:50
Android 8.0: java.lang.IllegalStateException: Not allowed to start service Intent
On application launch, app starts the service that should to do some network task. After targeting API level 26, my application fails to start service on Android 8.0 on background. > Caused by: java...
- Modified
- 14 Jan at 08:56