Questions Tagged with #Sorl thumbnail

Thumbnails for Django

Android Studio does not show layout preview

I'm using Android Studio 1.4 It has passed some time since the last time I've created a new project in android studio and today when I did it the android studio does not show anything from the layout..

How to retrieve form values from HTTPPOST, dictionary or?

I have an MVC controller that has this Action Method: [HttpPost] public ActionResult SubmitAction() { // Get Post Params Here ... return something ... } The form is a non-trivial form with a ..

Getting the current date in visual Basic 2008

I dont know how to get the current date in visual basic 2008. Here is a sample code regDate = Format(Date.Now(), "ddMMMyyyy") The output is like 7/02/1900 Need help..

For loop in multidimensional javascript array

Since now, I'm using this loop to iterate over the elements of an array, which works fine even if I put objects with various properties inside of it. var cubes[]; for (i in cubes){ cubes[i].dim..

The service cannot accept control messages at this time

I just stopped an Application Pool in IIS. When trying to start it, IIS complains that, The service cannot accept control messages at this time. (Exception from HRESULT: 0x80080425). What gives? Fro..

How can I compile and run c# program without using visual studio?

I am very new to C#. I have just run C# 'Hello World' program using Visual Studio. Can I run or compile a C# program without using Visual Studio? If it is possible, then which compiler should I use?..

Getting distance between two points based on latitude/longitude

I tried implementing this formula: The aplet does good for the two points I am testing: Yet my code is not working. from math import sin, cos, sqrt..

How do I remove blank pages coming between two chapters in Appendix?

Is there a way to remove blank pages appearing between two chapters, in Appendix?..

Best Timer for using in a Windows service

I need to create some windows service which will execute every N period of time. The question is: Which timer control should I use: System.Timers.Timer or System.Threading.Timer one? Does it influence..

Print to the same line and not a new line?

Basically I want to do the opposite of what this guy did... hehe. Python Script: Print new line each time to shell rather than update existing line I have a program that is telling me how far along ..

IIS_IUSRS and IUSR permissions in IIS8

I've just moved away from IIS6 on Win2003 to IIS8 on Win2012 for hosting ASP.NET applications. Within one particular folder in my application I need to Create & Delete files. After copying the f..

Sass Nesting for :hover does not work

I've written this code, but it does not work. What is my problem? .class { margin:20px; :hover { color:yellow; } } ..

Error: Java: invalid target release: 11 - IntelliJ IDEA

I am trying to build an application which was built using java 8, now it's upgraded to java 11. I installed Java 11 using an oracle article in my windows machine and I use IntelliJ IDEA 2017 as my IDE..

Visual Studio 2013 error MS8020 Build tools v140 cannot be found

I had previously been using VS2013 express without issue, but suddenly it began crashing whenever I tried edit the code while it ran existing code fine. I tried uninstalling and switching over to VS2..

Vector erase iterator

I have this code: int main() { vector<int> res; res.push_back(1); vector<int>::iterator it = res.begin(); for( ; it != res.end(); it++) { it = res.erase(it); ..

Change Timezone in Lumen or Laravel 5

I am using Lumen framework. How can I change Timezone to Europe/Paris CEST? I added a varaible in my .env file: APP_TIMEZONE=Europe/Paris But this doesnt work. What is the right way to update time..

Why does javascript replace only first instance when using replace?

I have this var date = $('#Date').val(); this get the value in the textbox what would look like this 12/31/2009 Now I do this on it var id = 'c_' + date.replace("/", ''); and the result is ..

Set value for particular cell in pandas DataFrame using index

I've created a Pandas DataFrame df = DataFrame(index=['A','B','C'], columns=['x','y']) and got this x y A NaN NaN B NaN NaN C NaN NaN Then I want to assign value to particular cel..

Excel column number from column name

How to get the column number from column name in Excel using Excel macro? ..

Concatenating null strings in Java

Why does the following work? I would expect a NullPointerException to be thrown. String s = null; s = s + "hello"; System.out.println(s); // prints "nullhello" ..

Copy array by value

When copying an array in JavaScript to another array: var arr1 = ['a','b','c']; var arr2 = arr1; arr2.push('d'); //Now, arr1 = ['a','b','c','d'] I realized that arr2 refers to the same array as ar..

Is it possible to register a http+domain-based URL Scheme for iPhone apps, like YouTube and Maps?

I'd like to have iOS to open URLs from my domain (e.g. with my app whenever the app is installed on the phone, and with Mobile Safari in case it is not. I read it is possible to..

jQuery Remove string from string

I am trying to remove a string from a string in jQuery. Here is the string: username1, username2 and username3 like this post. I would like to remove username1, from this list. I tried adding the ..

Get MIME type from filename extension

How can I get the MIME type from a file extension?..

How can you determine a point is between two other points on a line segment?

Let's say you have a two dimensional plane with 2 points (called a and b) on it represented by an x integer and a y integer for each point. How can you determine if another point c is on the line seg..

How do I store and retrieve a blob from sqlite?

I have used sqlite in c++, python and now (perhaps) in C#. In all of these I have no idea how to insert a blob into a table. How do I store and retrieve a blob in sqlite?..

How to make popup look at the centre of the screen?

When i click a link, a pop up comes out. The thing is that it is not aligned to the centre of the screen. By the way my code also helps the website (and the pop up) to look perfectly in a mobile versi..

How to open an existing project in Eclipse?

I have just created several project using Eclipse. Now restart Eclipse and want to see one of the projects. How can I do it? I have tried File -> Import -> General -> Existing Project into Workspace...

How to give a pandas/matplotlib bar graph custom colors

I just started using pandas/matplotlib as a replacement for Excel to generate stacked bar charts. I am running into an issue (1) there are only 5 colors in the default colormap, so if I have more ..

How to save a Python interactive session?

I find myself frequently using Python's interpreter to work with databases, files, etc -- basically a lot of manual formatting of semi-structured data. I don't properly save and clean up the useful b..

Raise to power in R

This is a beginner's question. What's the difference between ^ and **? For example: 2 ^ 10 [1] 1024 2 ** 10 [1] 1024 Is there a function such as power(x,y)? ..

Passing multiple variables in @RequestBody to a Spring MVC controller using Ajax

Is it necessary to wrap in a backing object? I want to do this: @RequestMapping(value = "/Test", method = RequestMethod.POST) @ResponseBody public boolean getTest(@RequestBody String str1, @RequestBo..

React onClick and preventDefault() link refresh/redirect?

I'm rendering a link with react: render: -> `<a className="upvotes" onClick={this.upvote}>upvote</a>` Then, above I have the upvote function: upvote: -> // do stuff (ajax) ..

What is a clean, Pythonic way to have multiple constructors in Python?

I can't find a definitive answer for this. As far as I know, you can't have multiple __init__ functions in a Python class. So how do I solve this problem? Suppose I have a class called Cheese with the..

Java: Add elements to arraylist with FOR loop where element name has increasing number

I have an arraylist where I want to add elements via a for loop. Answer answer1; Answer answer2; Answer answer3; ArrayList<Answer> answers = new ArrayList(3); for (int i=0;i<3;i++) { a..

Differences between arm64 and aarch64

I have two "unlocked" devices, an iPad mini 3, and a Galaxy Edge 6, both endowed with a terminal and a minimalistic set of unix commands. I thought both devices have arm64 processors but when I ran u..

How to pass command line argument to gnuplot?

I want to use gnuplot to draw figure from data file, say Currently, I hardcoded the data file name in the command file, say foo.plt, and run command gnuplot foo.plg to plot data. However, I ..

jquery - fastest way to remove all rows from a very large table

I thought this might be a fast way to remove the contents of a very large table (3000 rows): $jq("tbody", myTable).remove(); But it's taking around five seconds to complete in firefox. Am I doing s..

Close/kill the session when the browser or tab is closed

Can somebody tell me how can I close/kill the session when the user closes the browser? I am using stateserver mode for my web app. The onbeforeunload method is not proper as it fires when use..

multiple figure in latex with captions

How can I insert multiple figures each of them has a caption and label, without using minipage. I wrote this code, but just there is one caption :( \begin{figure}[htp] \centering \label{figur}..

Pass by pointer & Pass by reference

Possible Duplicate: What are the differences between pointer variable and reference variable in C++? Are there benefits of passing by pointer over passing by reference in C++? In both cas..

Check whether a string is not null and not empty

How can I check whether a string is not null and not empty? public void doStuff(String str) { if (str != null && str != "**here I want to check the 'str' is empty or not**") { ..

SMTPAuthenticationError when sending mail using gmail and python

when i try to send mail using gmail and python error occurred this type of question are already in this site but doesn't help to me gmail_user = "[email protected]" gmail_pwd = "password" TO = 'friend@gm..

Spring MVC UTF-8 Encoding

At the moment I'm trying to get started with Spring MVC. While trying things out I ran into an encoding issue. I want to display UTF-8 characters on my JSP-Pages so I added a String with UTF-8 chara..

How to initialize an array in Java?

I am initializing an array like this: public class Array { int data[] = new int[10]; /** Creates a new instance of Array */ public Array() { data[10] = {10,20,30,40,50,60,71,80,..

Netbeans 8.0.2 The module has not been deployed

I just installed netbeans and I have problems deploying a new Java Web App. I simply create the project without editing anything, this is what project has by default (using apache): index.html <!..

How to force view controller orientation in iOS 8?

Before iOS 8, we used below code in conjunction with supportedInterfaceOrientations and shouldAutoRotate delegate methods to force app orientation to any particular orientation. I used below code snip..

How to check if my string is equal to null?

I want to perform some action ONLY IF my string has a meaningful value. So, I tried this. if (!myString.equals("")) { doSomething } and this if (!myString.equals(null)) { doSomething } and this ..

Getting full URL of action in ASP.NET MVC

Is there a built-in way of getting the full URL of an action? I am looking for something like GetFullUrl("Action", "Controller") that would return something like

Get type name without full namespace

I have the following code: return "[Inserted new " + typeof(T).ToString() + "]"; But typeof(T).ToString() returns the full name including namespace Is there anyway to just get the class name (..

Vuex - passing multiple parameters to mutation

I am trying to authenticate a user using vuejs and laravel's passport.I am not able to figure out how to send multiple parameters to the vuex mutation via an action. - store - export default new Vuex...

SQL Server CASE .. WHEN .. IN statement

On SQL server 2005 I am trying to query this select statement SELECT AlarmEventTransactionTableTable.TxnID, CASE AlarmEventTransactions.DeviceID WHEN DeviceID IN( '7', '10', '62', '5..

Media query to detect if device is touchscreen

What is the safest way, using media queries, to make something happen when not on a touchscreen device? If there is no way, do you suggest using a JavaScript solution such as !window.Touch or Moderniz..

Spring Maven clean error - The requested profile "pom.xml" could not be activated because it does not exist

I'm trying to build a Spring-Boot *.war with maven, but I keep getting: [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] -------------------..

Display all views on oracle database

Is there a way to display all the views currently set on an oracle database via sql developer? Thanks...

setContentView(R.layout.main); error

package com.elfapp; import; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; i..

Custom events in jQuery?

I'm looking for some input on how to implement custom eventhandling in jquery the best way. I know how to hook up events from the dom elements like 'click' etc, but I'm building a tiny javascript libr..

How to move/rename a file using an Ansible task on a remote system

How is it possible to move/rename a file/directory using an Ansible module on a remote system? I don't want to use the command/shell tasks and I don't want to copy the file from the local system to th..

How to update multiple columns in single update statement in DB2

I want to update multiple columns of a table in DB2 with single Update statement. Any hint or idea will be appreciable. Thanks...

HTML - how can I show tooltip ONLY when ellipsis is activated

I have got a span with dynamic data in my page, with ellipsis style. .my-class { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; width: 71px; } <span id="myId" class="m..

How to pass an array to a function in VBA?

I am trying to write a function that accepts an array as an argument. The array can have any number of elements. Function processArr(Arr() As Variant) As String Dim N As Variant dim finalSt..

How to handle a lost KeyStore password in Android?

I have forgotten my Keystore password and I don't really know what to do anymore (I can't or won't give any excuses for it). I want to update my app because I just fixed a bug but it's not possible an..

How do you get the list of targets in a makefile?

I've used rake a bit (a Ruby make program), and it has an option to get a list of all the available targets, eg > rake --tasks rake db:charset # retrieve the charset for your data... rake db:..

How to make spring inject value into a static field

I know this may looks like a previously asked question but I'm facing a different problem here. I have a utility class that has only static methods. I don't and I won't take an instance from it. pub..

Cannot use mkdir in home directory: permission denied (Linux Lubuntu)

I am trying to create a directory in my home directory on Linux using the mkdir command, but am getting a 'permission denied' error. I have recently installed Lubuntu on my laptop, and have the only ..

ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value

In a nutshell the exception is thrown during POSTing wrapper model and changing the state of one entry to 'Modified'. Before changing the state, the state is set to 'Detached' but calling Attach() doe..

A required class was missing while executing org.apache.maven.plugins:maven-war-plugin:2.1.1:war

Here is my clean install -x result: [INFO] Scanning for projects... [INFO] [INFO] --------------------------------------------..

Writing sqlplus output to a file

Using sqlplus.exe I'm looking for a way to write sqlplus output to a file. Is there anyway I can do that, currently the output is written only to the console...

How can I print a quotation mark in C?

In an interview I was asked Print a quotation mark using the printf() function I was overwhelmed. Even in their office there was a computer and they told me to try it. I tried like this: void m..

How to check if element exists using a lambda expression?

Specifically, I have TabPane, and I would like to know if there is element with specific ID in it. So, I would like to do this with lambda expression in Java: boolean idExists = false; String idToCh..

MongoDB: How To Delete All Records Of A Collection in MongoDB Shell?

I've tried db.users.remove(*) Although it returns an error so how do I go about clearing all records?..

Find what 2 numbers add to something and multiply to something

Hey so I'm making a factoring program and I'm wondering if anyone can give me any ideas on an efficient way to find what two numbers multiple to a specified number, and also add to a specified number...

AppendChild() is not a function javascript

this is my javascript <head runat="server"> <script type="text/javascript" language="javascript"> function createQuestionPanel() { var element = document.createE..

Get last record of a table in Postgres

I'm using Postgres and cannot manage to get the last record of my table: my_query = client.query("SELECT timestamp,value,card from my_table"); How can I do that knowning that timestamp is a unique..

Python develop vs install

Two options in develop and install are confusing me. According to this site, using develop creates a special link to site-packages directory. People have suggested that I use python

How do I pass along variables with XMLHTTPRequest

How do I send variables to the server with XMLHTTPRequest? Would I just add them to the end of the URL of the GET request, like ?variable1=?variable2=, etc? So more or less: XMLHttpRequest("GET", "b..

How to check if keras tensorflow backend is GPU or CPU version?

I understand that when installing tensorflow, you either install the GPU or CPU version. How can I check which one is installed (I use linux). If the GPU version is installed, would it be automatica..

Remove an array element and shift the remaining ones

How do I remove an element of an array and shift the remaining elements down. So, if I have an array, array[]={1,2,3,4,5} and want to delete 3 and shift the rest so I have, array[]={1,2,4,5} H..

How to clone all remote branches in Git?

I have a master and a development branch, both pushed to GitHub. I've cloned, pulled, and fetched, but I remain unable to get anything other than the master branch back. I'm sure I'm missing somethin..

Listing files in a directory matching a pattern in Java

I'm looking for a way to get a list of files that match a pattern (pref regex) in a given directory. I've found a tutorial online that uses apache's commons-io package with the following code: Colle..

How can I pretty-print JSON in a shell script?

Is there a (Unix) shell script to format JSON in human-readable form? Basically, I want it to transform the following: { "foo": "lorem", "bar": "ipsum" } ... into something like this: { "foo"..

Android Layout Animations from bottom to top and top to bottom on ImageView click

I have created a view in Android and I need to animate it from bottom to top and vice-versa. when I clicked on ImageView I need to animate the complete RelativeLayout from bottom to top and it is succ..

check if file exists in php

if (!(file_exists( { $filefound = '0'; } why won't this work?..

Jquery each - Stop loop and return object

Can anybody tell me why the loop did not stop after the 5 entry? $(document).ready(function() { someArray = new Array(); someArray[0] = 't5'; someArray[1..

How to install latest version of git on CentOS 7.x/6.x

I used the usual: yum install git It did not install the latest version of git on my CentOS 6. How can I update to the latest version of git for CentOS 6? The solution can be applicable to newer v..

How to edit CSS style of a div using C# in .NET

I'm trying to grab a div's ID in the code behind (C#) and set some css on it. Can I grab it from the DOM or do I have to use some kind of control? <div id="formSpinner"> <img src="image..

Windows 7, 64 bit, DLL problems

I have a problem with our executable. I'm running this C++ 32-bit executable on my Windows 7 64-bit development box that also has all those Microsoft applications (Visual Studio 2008 + 2010, TFS,..

In Swift how to call method with parameters on GCD main thread?

In my app I have a function that makes an NSRURLSession and sends out an NSURLRequest using sesh.dataTaskWithRequest(req, completionHandler: {(data, response, error) In the completion block for thi..

How to write a multiline Jinja statement

I have an if statement in my Jinja templates which I want to write it in multines for readability reasons. Consider the case {% if (foo == 'foo' or bar == 'bar') and (fooo == 'fooo' or baar == 'baar'..

Allow user to select camera or gallery for image

What I'm trying to do seems very simple, but after a few days of searching I can't quite figure it out. I have an application that allows the user to select multiple(up to 5) images. I'm using an Im..

Format date as dd/MM/yyyy using pipes

I'm using the date pipe to format my date, but I just can't get the exact format I want without a workaround. Am I understanding pipes wrongly or is just not possible? //our root app component import..

OnclientClick and OnClick is not working at the same time?

I have a button like the following, <asp:Button ID="pagerLeftButton" runat="server" OnClientClick="disable(this)" onclick="pager_Left_Click" Text="<" /> When I use my button like that, onc..

UIScrollView not scrolling

I have a UIScrollView which contains many UIImageViews, UILabels, etc... the labels are much longer that the UIScrollView, but when I run the app, I cannot click and scroll down... Why might this be?..

Visual Studio : short cut Key : Duplicate Line

Is there a shortcut for Duplicate Line command in Visual Studio 2008? Some similar examples: in Notepad++, I can duplicate the current line with: Ctrl+D in EditPlus: Ctrl+J in NetBeans: Ctrl+Shift+..

Cell spacing in UICollectionView

How do I set cell spacing in a section of UICollectionView? I know there is a property minimumInteritemSpacing I have set it to 5.0 still the spacing is not appearing 5.0. I have implemented the flowo..

Are there bookmarks in Visual Studio Code?

How can I set bookmarks in Visual Studio Code? I can't find any keyboard shortcuts. Or is there anything else that I can use instead?..

How to post data using HttpClient?

I have got this HttpClient from Nuget. When I want to get data I do it this way: var response = await httpClient.GetAsync(url); var data = await response.Content.ReadAsStringAsync(); But the problem ..

git: fatal: I don't handle protocol '??http'

I copy and pasted an git clone command from a web page: I got this: user@host> git clone ?? C..

Access Form - Syntax error (missing operator) in query expression

I am receiving a syntax error in a form that I have created over a query. I created the form to restrict access to changing records. While trying to set filters on the form, I receive syntax errors ..

ImportError: No module named model_selection

I am trying to use train_test_split function and write: from sklearn.model_selection import train_test_split and this causes ImportError: No module named model_selection Why? And how to overcom..

C++ undefined reference to defined function

I cannot figure out why this is not working. I will put up all three of my files and possibly someone can tell me why it is throwing this error. I am using g++ to compile the program. Program: #in..

PHP refresh window? equivalent to F5 page reload?

Is there anything in PHP that is the equivalent of manually pressing the F5 page reload button? My php script is in a frame and isn't the parent script but it needs to refresh the entire page and not..

"Are you missing an assembly reference?" compile error - Visual Studio

I am currently working on a server control for other applications in our company to interface with a WCF service. Every time I make a change code change and recompile the control, I increment the th..

Where do I find some good examples for DDD?

I'm learning about Domain Driven Design, however there are some practical issues that are confusing to me that I think seeing some good samples might clear up. Does anyone know of some good working c..

How do I define and use an ENUM in Objective-C?

I declared an enum in my implementation file as shown below, and declared a variable of that type in my interface as PlayerState thePlayerState; and used the variable in my methods. But I am getting e..

Add Favicon to Website

Possible Duplicate: HTML Title Image Can someone please tell me how to make icons appear on browser tabs in PHP? I want my icon to appear on the tabs when my site is being accessed...

Asp.Net WebApi2 Enable CORS not working with AspNet.WebApi.Cors 5.2.3

I tried to follow the steps at to have my RESTful API (implemented with ASP.NET WebAPI2) work with cross origin requests (CORS Enabled). It's not working unle..

Create mysql table directly from CSV file using the CSV Storage engine?

I just learned that MySQL has a native CSV storage engine which stores data in a Comma-Separated-Value file per table. Is it possible to create a table directly from a uploaded CSV file, something li..

Reading CSV file and storing values into an array

I am trying to read a *.csv-file. The *.csv-file consist of two columns separated by semicolon (";"). I am able to read the *.csv-file using StreamReader and able to separate each line by using the..

Python - PIP install trouble shooting - PermissionError: [WinError 5] Access is denied

I get the following error when using PIP to either install new packages or even upgrade pip itself to the latest version. I am running pip on a windows 8.1 machine with Python 3.4. The message is tel..

How can I check if a single character appears in a string?

In Java is there a way to check the condition: "Does this single character appear at all in string x" without using a loop?..

How to convert hex to ASCII characters in the Linux shell?

Lets say that I have a string 5a. This is the hex representation of the ASCII letter Z. I need to know a Linux shell command which will take a hex string and output the ASCII characters that the str..

php artisan migrate throwing [PDO Exception] Could not find driver - Using Laravel

I have a bad experience while installing laravel. However, I was able to do so and move to the next level. I used generators and created my migrations. But when I type the last command php artisan ..

How do you make an element "flash" in jQuery

I'm brand new to jQuery and have some experience using Prototype. In Prototype, there is a method to "flash" an element — ie. briefly highlight it in another color and have it fade back to norma..

C++ templates that accept only certain types

In Java you can define generic class that accept only types that extends class of your choice, eg: public class ObservableList<T extends List> { ... } This is done using "extends" keyword. ..

SOAP request in PHP with CURL

Since the SOAP manual on is not very noob friendly and I could not find any good examples I will post my question here. How can I create PHP SOAP request to look like this? POST /MySERVER/my..

ini_set("memory_limit") in PHP 5.3.3 is not working at all

I had this working before : echo ini_get("memory_limit")."\n"; ini_set("memory_limit","256M"); echo ini_get("memory_limit")."\n"; That would input this : 32M 256M on a php script executed by c..

SQL - Rounding off to 2 decimal places

I need to convert minutes to hours, rounded off to 2 decimal places.I also need to display only up to 2 numbers after the decimal point. So if I have minutes as 650.Then hours should be 10.83 Here's ..

Does Java have something like C#'s ref and out keywords?

Something like the following: ref example: void changeString(ref String str) { str = "def"; } void main() { String abc = "abc"; changeString(ref abc); System.out.println(abc); //pri..

bash: npm: command not found?

I'm learning laravel and follwing this tutorial, But when I went try and install npm, is says bash: npm: command not found ..

Why do people write #!/usr/bin/env python on the first line of a Python script?

It seems to me like the files run the same without that line...

Deploying just HTML, CSS webpage to Tomcat

I am just getting started on developing a website. All I have at the moment is a HTML page supported by a couple of CSS stylesheets. Can I create a WAR file from the HTML and CSS pages? How do I dep..

Convert a String to Modified Camel Case in Java or Title Case as is otherwise called

I want to convert any string to modified Camel case or Title case using some predefined libraries than writing my own functions. For example "HI tHiS is SomE Statement" to "Hi This Is Some Statement..

Turning a Comma Separated string into individual rows

I have a SQL Table like this: | SomeID | OtherID | Data +----------------+-------------+------------------- | abcdef-..... | cdef123-... | 18,20,22 | abcdef-..... | 4554a24-... | 17,1..

open_basedir restriction in effect. File(/) is not within the allowed path(s):

I'm getting this error on an avatar upload on my site. I've never gotten it before and nothing was changed recently for me to begin getting this error... Warning: is_writable() [

What's the difference between Invoke() and BeginInvoke()

Just wondering what the difference between BeginInvoke() and Invoke() are? Mainly what each one would be used for. EDIT: What is the difference between creating a threading object and calling invok..

Correct way to write loops for promise.

How to correctly construct a loop to make sure the following promise call and the chained logger.log(res) runs synchronously through iteration? (bluebird) db.getUser(email).then(function(res) { logge..

How do I clone a generic list in C#?

I have a generic list of objects in C#, and wish to clone the list. The items within the list are cloneable, but there doesn't seem to be an option to do list.Clone(). Is there an easy way around thi..

How to check if a String is numeric in Java

How would you check if a String was a number before parsing it?..

Python: read all text file lines in loop

I want to read huge text file line by line (and stop if a line with "str" found). How to check, if file-end is reached? fn = 't.log' f = open(fn, 'r') while not _is_eof(f): ## how to check that end i..

How to compare two dates in php

How to compare two dates in php if dates are in format '03_01_12' and '31_12_11' . I am using this code: $date1=date('d_m_y'); $date2='31_12_11'; if(strtotime($date1) < strtotime($date2)) echo..

How to store directory files listing into an array?

I'm trying to store the files listing into an array and then loop through the array again. Below is what I get when I run ls -ls command from the console. total 40 36 -rwxrwxr-x 1 amit amit 36720 20..

iPhone Safari Web App opens links in new window

I have problem with web after adding icon to Home Screen. If the web is launched from Home Screen, all links will open in new window in Safari (and lose full screen functionality). How can I prevent i..

Python module os.chmod(file, 664) does not change the permission to rw-rw-r-- but -w--wx----

Recently I am using Python module os, when I tried to change the permission of a file, I did not get the expected result. For example, I intended to change the permission to rw-rw-r--, os.chmod("/tmp..

How to upload, display and save images using node.js and express

I need to upload an image, and display it, as well as save it so that I don't lose it when I refresh the localhost. This needs to be done using an "Upload" button, which prompts for a file-selection. ..

What is the difference between json.load() and json.loads() functions

In Python, what is the difference between json.load() and json.loads()? I guess that the load() function must be used with a file object (I need thus to use a context manager) while the loads() funct..

How to check if element in groovy array/hash/collection/list?

How do I figure out if an array contains an element? I thought there might be something like [1, 2, 3].includes(1) which would evaluate as true...

Sorting JSON by values

I have a very simple JSON object like the following: { "people":[ { "f_name":"john", "l_name":"doe", "sequence":"0", "title":"president", "url":"..

One DbContext per web request... why?

I have been reading a lot of articles explaining how to set up Entity Framework's DbContext so that only one is created and used per HTTP web request using various DI frameworks. Why is this a good i..

Stacked Bar Plot in R

I've looked at the similar questions on here regarding stacked bar plots in R, but I'm still not having any luck. I have created the following data frame: A B C D E F G 1 4..

How to create a drop shadow only on one side of an element?

Is there a way to drop the shadow only on the bottom?. I have a menu with 2 images next to each other. I don't want a right shadow because it overlaps the right image. I don't like to use images for t..

Create hive table using "as select" or "like" and also specify delimiter

Is it possible to do a create table <mytable> as select <query statement> using row format delimited fields terminated by '|'; or to do a create table <mytable> like <ot..

Using NSLog for debugging

I have the following code snippet in my Xcode: NSString *digit [[sender titlelabel] text]; NSLog([digit]); I tried to build the application and am getting the following warning message for the line..

Create list or arrays in Windows Batch

Can I declare a list or array in a batch file like this: set list = "A B C D" And then I need to write these to a file, with the spaces between: A B C D ..

What are the differences between a multidimensional array and an array of arrays in C#?

What are the differences between multidimensional arrays double[,] and array-of-arrays double[][] in C#? If there is a difference, what is the best use for each one?..

Deserialize JSON string to c# object

My Application is in Asp.Net MVC3 coded in C#. This is what my requirement is. I want an object which is in the following format.This object should be achieved when I deserialize the Json string. var..

Android: How to use webcam in emulator?

I'm connecting a webcam to my emulator by setting the front camera to "webcam0" in the AVD Manager. When I start the emulator's camera application, I get the error CameraService::connect X (pid 702)..

Installing Python library from WHL file

Skill level: beginner I am trying to add a library in python. The extension is wheel. Can somebody tell stepwise approach in installing wheel file?..

How to change background color in android app

I want to be able to change the background color to white in my android app in the simplest way possible. ..

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, LoginForm lo..

Call web service in excel

In a VBA module in excel 2007, is it possible to call a web service? If so, any code snippets? How would I add the web reference?..

Conditional replacement of values in a data.frame

I am trying to understand how to conditional replace values in a dataframe without using a loop. My data frame is structured as follows: > df a b est 1 11.77000 2 0 2 10.90000 3 0 ..

Simplest way to merge ES6 Maps/Sets?

Is there a simple way to merge ES6 Maps together (like Object.assign)? And while we're at it, what about ES6 Sets (like Array.concat)?..

How to get multiple counts with one SQL query?

I am wondering how to write this query. I know this actual syntax is bogus, but it will help you understand what I am wanting. I need it in this format, because it is part of a much bigger query. SE..

Difference between JPanel, JFrame, JComponent, and JApplet

I'm making a physics simulator for fun and I was looking up graphics tutorials when I tried to figure out the difference between all these J's. Can somebody elaborate on them or perhaps provide a lin..

How can I set the font-family & font-size inside of a div?

This is my complete test html: <!DOCTYPE> <html> <head> <title>DIV Font</title> <style> .my_text { fon..

Detect if the device is iPhone X

My iOS app uses a custom height for the UINavigationBar which leads to some problems on the new iPhone X. Does someone already know how to reliable detect programmatically (in Objective-C) if an app..

How to get thread id from a thread pool?

I have a fixed thread pool that I submit tasks to (limited to 5 threads). How can I find out which one of those 5 threads executes my task (something like "thread #3 of 5 is doing this task")? Execut..

How to have a transparent ImageButton: Android

<ImageButton android:id="@+id/previous" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/media_skip_backward" android:background="@drawable/transparen..

Convert a string to an enum in C#

What's the best way to convert a string to an enumeration value in C#? I have an HTML select tag containing the values of an enumeration. When the page is posted, I want to pick up the value (which wi..

C split a char array into different variables

In C how can I separate a char array by a delimiter? Or is it better to manipulate a string? What are some good C char manipulation functions? ..

Angular 4 default radio button checked by default

I'm trying to mark as a default a radiobutton depending on the value I get from my object, it can be True or False. What could I do to mark as a default radiobutton depending on the option? <label..

How to scan multiple paths using the @ComponentScan annotation?

I'm using Spring 3.1 and bootstrapping an application using the @Configuration and @ComponentScan attributes. The actual start is done with new AnnotationConfigApplicationContext(MyRootConfiguration..

How to count the NaN values in a column in pandas DataFrame

I want to find the number of NaN in each column of my data so that I can drop a column if it has fewer NaN than some threshold. I looked but wasn't able to find any function for this. value_counts is..

How to set focus on an input field after rendering?

What's the react way of setting focus on a particular text field after the component is rendered? Documentation seems to suggest using refs, e.g: Set ref="nameInput" on my input field in the render ..

Visual Studio popup: "the operation could not be completed"

When I try to open a project, local or on a Team Foundation Server (TFS), I get a modal window telling me that: The operation could not be completed: Unspecified error Or the same message, but w..

How do Common Names (CN) and Subject Alternative Names (SAN) work together?

Assuming the Subject Alternative Name (SAN) property of an SSL certificate contains two DNS names domain.tld host.domain.tld but the Common Name (CN) is set to only one of both: CN=domain.tld. Does..

Subtracting Number of Days from a Date in PL/SQL

I would like to subtract a given x number of days from sysdate, can someone assist me on how to do that, I am using the PL/SQL language. THANKS!..

Get pixel's RGB using PIL

Is it possible to get the RGB color of a pixel using PIL? I'm using this code: im ="image.gif") pix = im.load() print(pix[1,1]) However, it only outputs a number (e.g. 0 or 1) and not t..

Method Call Chaining; returning a pointer vs a reference?

I have a Text class that has certain methods that return a pointer to itself, allowing calls to be chained. (The reason being I merely like how the chaining looks and feels, honestly!) My question i..

How can I print variable and string on same line in Python?

I am using python to work out how many children would be born in 5 years if a child was born every 7 seconds. The problem is on my last line. How do I get a variable to work when I'm printing text eit..

Is there a naming convention for git repositories?

For example, I have a RESTful service called Purchase Service. Should I name my repository: purchaserestservice purchase-rest-service purchase_rest_service or something else? What's the convention..

How to force a line break on a Javascript concatenated string?

I'm sending variables to a text box as a concatenated string so I can include multiple variables in on getElementById call. I need to specify a line break so the address is formatted properly. docu..

What should be the sizeof(int) on a 64-bit machine?

Possible Duplicate: size of int, long, etc Does the size of an int depend on the compiler and/or processor? What decides the sizeof an integer? I'm using a 64-bit machine. $ uname -m x..

Online PHP syntax checker / validator

Could someone refer me to an online PHP validator? It would be of much help. Thanks in advance!..

How is the 'use strict' statement interpreted in Node.js?

I have started to explore the Node.js and wrote many demo web application, to understand the flow of Node.js, Express.js, jade, etc.. But one thing I came across recently, is the statement "use stri..

How do I fix a NoSuchMethodError?

I'm getting a NoSuchMethodError error when running my Java program. What's wrong and how do I fix it?..

Tomcat view catalina.out log file

In Red Hat, cd /var/lib/tomcat tail -f logs/catalina.out I can see the log in the console. In Ubuntu, cd /var/lib/tomcat6 tail -f logs/catalina.out Nothing show out in the console. May I know ..

SQL Query to concatenate column values from multiple rows in Oracle

Would it be possible to construct SQL to concatenate column values from multiple rows? The following is an example: Table A PID A B C Table B PID SEQ Desc A 1 Have A 2 ..

Status bar and navigation bar appear over my view's bounds in iOS 7

I recently downloaded Xcode 5 DP to test my apps in iOS 7. The first thing I noticed and confirmed is that my view's bounds is not always resized to account for the status bar and navigation bar. In ..

check android application is in foreground or not?

I went through a lot of answers for this question.But it's all about single activity..How to check whether the whole app is running in foreground or not ?..

When to use AtomicReference in Java?

When do we use AtomicReference? Is it needed to create objects in all multithreaded programs? Provide a simple example where AtomicReference should be used...

endsWith in JavaScript

How can I check if a string ends with a particular character in JavaScript? Example: I have a string var str = "mystring#"; I want to know if that string is ending with #. How can I check it? I..

How to set dropdown arrow in spinner?

I tried to set spinner with drop down arrow but i couldn't fix it can anyone help me with this? I have attached the source code. my class file: import android.os.Bundle; import android.view...

What is stdClass in PHP?

Please define what stdClass is...

Directing print output to a .txt file

Is there a way to save all of the print output to a txt file in python? Lets say I have the these two lines in my code and I want to save the print output to a file named output.txt. print ("Hello st..

Mergesort with Python

I couldn't find any working Python 3.3 mergesort algorithm codes, so I made one myself. Is there any way to speed it up? It sorts 20,000 numbers in about 0.3-0.5 seconds def msort(x): result = []..

How to convert Map keys to array?

Lets say I have the following map: let myMap = new Map().set('a', 1).set('b', 2); And I want to obtain ['a', 'b'] based on the above. My current solution seems so long and horrible. let myMap = ne..

Return index of greatest value in an array

I have this: var arr = [0, 21, 22, 7]; What's the best way to return the index of the highest value into another variable?..

Calling Python in Java?

I am wondering if it is possible to call python functions from java code using jython, or is it only for calling java code from python?..

Watching variables contents in Eclipse IDE

How can I watch the contents of several variables (for example, TreeSet's) simultaneously? I can watch contents of one TreeSet, clicking on it in "Variables" window, but I have no idea how to do that ..

StringStream in C#

I want to be able to build a string from a class that I create that derives from Stream. Specifically, I want to be able to write code like this: void Print(Stream stream) { // Some code that ope..

What is the difference between cache and persist?

In terms of RDD persistence, what are the differences between cache() and persist() in spark ? ..

Excel VBA Automation Error: The object invoked has disconnected from its clients

I know I've seen references to this issue before, but I have tried several of the suggestions and I am still getting the error. I have a workbook that assembles data from another book and generates a..

ADB error: cannot connect to daemon

I need help to get ADB working on my PC (win7 64bit) with the Samsung Galaxy S2. I have installed the drivers coming along Kies, I think under sub folder "25_escape". The drivers appear correctly as ..

Adding a splash screen to Flutter apps

How would you approach adding a splash screen to Flutter apps? It should load and display before any other content. Currently, there is a brief flash of color before the Scaffold(home:X) widget loads...

How to run a script at a certain time on Linux?

I have a text file containing a specific date and time. I want to be able to run a script at the time specified in that file. How would you achieve that? Create another script that runs in background..

Suppress InsecureRequestWarning: Unverified HTTPS request is being made in Python2.6

I am writing scripts in Python2.6 with use of pyVmomi and while using one of the connection methods: service_instance = connect.SmartConnect(host=args.ip, user..

How to remove a class from elements in pure JavaScript?

I would like to know how to select all elements with class names "widget" and "hover" and then remove class "hover" from these elements. I have the following JavaScript code that selects all elements..

Difference between decimal, float and double in .NET?

What is the difference between decimal, float and double in .NET? When would someone use one of these?..