Examples On Programing Languages

trim left characters in sql server?

I want to write a sql statement to trim a string 'Hello' from the string "Hello World'. Please suggest....

Loop over array dimension in plpgsql

In plpgsql, I want to get the array contents one by one from a two dimension array. DECLARE m varchar[]; arr varchar[][] := array[['key1','val1'],['key2','val2']]; BEGIN for m in select arr LOOP raise NOTICE '%',m; END LOOP; END; But...

How to resize array in C++?

I need to do the equivalent of the following C# code in C++ Array.Resize(ref A, A.Length - 1); How to achieve this in C++?...

Can't use WAMP , port 80 is used by IIS 7.5

I am trying to use WAMP on Windows 7, my WAMP is online, but when I open localhost I get the welcome page of IIS 7.5, although I have uninstalled IIS 7.5 from my PC! Apache server test says that port 80 is used my Microsoft-HTTPAPI/2.0 MS Visual St...

Free easy way to draw graphs and charts in C++?

I am doing a little exploring simulation and I want to show the graphs to compare the performance among the algorithms during run-time. What library comes to your mind? I highly prefer those that come small as I'd love if it's easy for my instructor...

adding x and y axis labels in ggplot2

How do I change the x and y labels on this graph please? library(Sleuth2) library(ggplot2) discharge<-ex1221new$Discharge area<-ex1221new$Area nitrogen<-ex1221new$NO3 p <- ggplot(ex1221new, aes(discharge, area), main="Point") p + geom_po...

socket.error: [Errno 10013] An attempt was made to access a socket in a way forbidden by its access permissions

I'm trying to create a custom TCP stack using Python 2.6.5 on Windows 7 to serve valid http page requests on port 80 locally. But, I've run into a snag with what seems like Windows 7 tightened up security. This code worked on Vista. Here's my samp...

How do I configure Maven for offline development?

Does maven require a connection to the internet at some point to be able to use it? Meaning specifically getting the internal maven plugins for compiling, cleaning, packaging, etc? ...

Video format or MIME type is not supported

This is the relevant code to run video: <video id="video" src="videos/clip.mp4" type='video/mp4' controls='controls'> Your brwoser doesn't seems to support video tag </video> This code work fine separately, but when trying to fade...

How to parse a String containing XML in Java and retrieve the value of the root node?

I have XML in the form of a String that contains <message>HELLO!</message> How can I get the String "Hello!" from the XML? It should be ridiculously easy but I am lost. The XML isn't in a doc, it is simply a String. ...

Get the client's IP address in socket.io

When using socket.IO in a Node.js server, is there an easy way to get the IP address of an incoming connection? I know you can get it from a standard HTTP connection, but socket.io is a bit of a different beast....

Splitting string into multiple rows in Oracle

I know this has been answered to some degree with PHP and MYSQL, but I was wondering if someone could teach me the simplest approach to splitting a string (comma delimited) into multiple rows in Oracle 10g (preferably) and 11g. The table is as foll...

String concatenation: concat() vs "+" operator

Assuming String a and b: a += b a = a.concat(b) Under the hood, are they the same thing? Here is concat decompiled as reference. I'd like to be able to decompile the + operator as well to see what that does. public String concat(String s) { ...

Fatal error: Call to undefined function mb_strlen()

I'm trying to make a donation center which I use the source code from Totorialzine. Everything works fine for me at this moment so far but the only problem I was struggling on and trying to look at for the whole day and can't figure what is actually...

HTML checkbox - allow to check only one checkbox

I have some checkboxes in each row in my table. Each one checkbox has name='myName' because I want to select only one checkbox in each row. But something I'm missing because I'm able to check all of them: but I want that result: what am I missing h...

Ignoring directories in Git repositories on Windows

How can I ignore directories or folders in Git using msysgit on Windows?...

random number generator between 0 - 1000 in c#

I need help in writing a program that will generate 100 random numbers between 0 and 1000. The out put needs to be displayed in a windows message box. i'm stuck as to what code I have use to get the numbers in the box and to only have 100 random numb...

Using jQuery's ajax method to retrieve images as a blob

I recently asked another (related) question, which lead to this follow up question: Submitting data instead of a file for an input form Reading through the jQuery.ajax() documentation (http://api.jquery.com/jQuery.ajax/), it seems the list of accept...

How to change the project in GCP using CLI commands

How can i change the current running project to another project in GCP (Google Cloud Platform) account using cli commands other than using gcloud init manually. $gcloud projects list will list the projects running on my account. I want to change the...

What is a practical, real world example of the Linked List?

I understand the definition of a Linked List, but how can it be represented and related to a common concept or item? For example, composition (EDIT: originally said 'inheritance') in OOP can be related to automobiles. All (most) automobiles in re...

Open Excel file for reading with VBA without display

I want to search through existing Excel files with a macro, but I don't want to display those files when they're opened by the code. Is there a way to have them open "in the background", so to speak?...

What does @media screen and (max-width: 1024px) mean in CSS?

I found this piece of code in a CSS file I inherited, but I can't make any sense out of it: @media screen and (max-width: 1024px){ img.bg { left: 50%; margin-left: -512px; } } Specifically, what is happening on the first line?...

How to connect to a docker container from outside the host (same network) [Windows]

I've created my first docker container, it's running a server using Go but I can't access it from outside the host computer. I've just started with docker so I'm a little lost here. So I have a very simple Go code that starts a server, I have built ...

JavaScript TypeError: Cannot read property 'style' of null

I have JavaScript code and below line has problem. if ((hr==20)) document.write("Good Night"); document.getElementById('Night).style.display='' ERROR Uncaught TypeError: Cannot read property 'style' of null at Column 69 My div tag details are: ...

How to read Data from Excel sheet in selenium webdriver

I'm trying to read username and password from the excel file, below is my code but it shows following error : log4j:WARN No appenders could be found for logger (org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager). log4j:WARN Please ...

How To Get Selected Value From UIPickerView

I know that with a UIDatePicker, you can use something like: NSDate *myDate = picker.date; But I am using a UIPickerView in my view. How can i similarly get the value selected? Or do I have to setup didSelectRow type of method to do this? ...

How to create custom config section in app.config?

I want to add a custom configuration section in my app.config file. Is there a way to do it and how can I access these settings in my program. Following is the config section I want to add to my app.config: <RegisterCompanies> <Companie...

Double free or corruption after queue::push

#include <queue> using namespace std; class Test{ int *myArray; public: Test(){ myArray = new int[10]; } ~Test(){ delete[] myArray; } }; int main(){ queue<Test> q Test t; q.pus...

How to download a file from server using SSH?

I need to download a file from server to my desktop. (UBUNTU 10.04) I don't have a web access to the server, just ssh. If it helps, my OS is Mac OS X and iTerm 2 as a terminal....

Proper use of mutexes in Python

I am starting with multi-threads in python (or at least it is possible that my script creates multiple threads). would this algorithm be the right usage of a Mutex? I haven't tested this code yet and it probably won't even work. I just want processDa...

How to place two forms on the same page?

I want to place both register and login form on the same page. They both starts with: if (!empty($_POST)) ... so, I need something like: if (!empty($_POST_01))... // regForm and if (!empty($_POST_02))... //loginForm Also how to prevent ...

How to calculate UILabel height dynamically?

I want to calculate number of lines and height of UILabel dynamically from given text for same....

jQuery Ajax Request inside Ajax Request

Is it possible to make an ajax request inside another ajax request? because I need some data from first ajax request to make the next ajax request. First I'm using Google Maps API to get LAT & LNG, after that I use that LAT & LNG to request ...

Use of def, val, and var in scala

class Person(val name:String,var age:Int ) def person = new Person("Kumar",12) person.age = 20 println(person.age) These lines of code outputs 12, even though person.age=20 was successfully executed. I found that this happens because I used def in ...

How to get UTC time in Python?

I've search a bunch on StackExchange for a solution but nothing does quite what I need. In JavaScript, I'm using the following to calculate UTC time since Jan 1st 1970: function UtcNow() { var now = new Date(); var utc = Date.UTC(now.getUTC...

jQuery If value is NaN

I am having some trouble with an if statement. I want to set num to 0 of NaN: $('input').keyup(function() { var tal = $(this).val(); var num = $(this).data('boks'); if(isNaN(tal)) { var tal = 0; } }); ...

The result of a query cannot be enumerated more than once

I am using the entity framework (ef) and am getting the following error: "The result of a query cannot be enumerated more than once.". I have a repository class which contains the ef data context. I then have a controller class (not to be conf...

append multiple values for one key in a dictionary

I am new to python and I have a list of years and values for each year. What I want to do is check if the year already exists in a dictionary and if it does, append the value to that list of values for the specific key. So for instance, I have a lis...

How to clear form after submit in Angular 2?

I have some simple angular 2 component with template. How to clear form and all fields after submit?. I can't reload page. After set data with date.setValue('') field is stil touched. import {Component} from 'angular2/core'; import {FORM_DIRECTIVES...

CSS rotation cross browser with jquery.animate()

I'm working on creating a cross-browser compatible rotation (ie9+) and I have the following code in a jsfiddle $(document).ready(function () { DoRotate(30); AnimateRotate(30); }); function DoRotate(d) { $("#MyDiv1").css({ '-...

String format currency

I have this line @String.Format("{0:C}", @price) in my razor view. I want it to display a dollar sign in front of the price but instead it display a pound sign. How do I achieve this?...

How to render string with html tags in Angular 4+?

In my angular 4 app, I have a string like comment: string; comment = "<p><em><strong>abc</strong></em></p>"; When I serve this text in my html, like {{comment}} Then it displays: <p><em><stro...

How can I analyze a heap dump in IntelliJ? (memory leak)

I have generated a heap dump from my java application which has been running for some days with the jmap tool -> this results in a large binary heap dump file. How can I perform memory analysis of this heap dump within IntellIJ IDEA? I know that th...

Format a JavaScript string using placeholders and an object of substitutions?

I have a string with say: My Name is %NAME% and my age is %AGE%. %XXX% are placeholders. We need to substitute values there from an object. Object looks like: {"%NAME%":"Mike","%AGE%":"26","%EVENT%":"20"} I need to parse the object and replace the...

sys.argv[1] meaning in script

I'm currently teaching myself Python and was just wondering (In reference to my example below) in simplified terms what the sys.argv[1] represents. Is it simply asking for an input? #!/usr/bin/python3.1 # import modules used here -- sys is a very s...

Can I force a UITableView to hide the separator between empty cells?

When using a plain-style UITableView with a large enough number of cells that the UITableView cannot display them all without scrolling, no separators appear in the empty space below the cells. If I have only a few cells the empty space below them in...

Unable to find valid certification path to requested target - error even after cert imported

I have a Java client trying to access a server with a self-signed certificate. When I try to Post to the server, I get the following error: unable to find valid certification path to requested target Having done some research on the issue, I t...

Declaring variables in Excel Cells

Is it possible to declare variables in Excel cells and use them as parameters for formulas in other cells? For example I would declare var1=10 in one of the cells. In another cell I would use var1 for calculation like: =var1*20....

Renaming part of a filename

I have loads of files which look like this: DET01-ABC-5_50-001.dat ... DET01-ABC-5_50-0025.dat and I want them to look like this: DET01-XYZ-5_50-001.dat ... DET01-XYZ-5_50-0025.dat How can I do this?...

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

Python: Tuples/dictionaries as keys, select, sort

Suppose I have quantities of fruits of different colors, e.g., 24 blue bananas, 12 green apples, 0 blue strawberries and so on. I'd like to organize them in a data structure in Python that allows for easy selection and sorting. My idea was to put the...

How to set alignment center in TextBox in ASP.NET?

How to set align center for an <asp:TextBox> control in an ASP.NET Web Application?...

Disabled form inputs do not appear in the request

I have some disabled inputs in a form and I want to send them to a server, but Chrome excludes them from the request. Is there any workaround for this without adding a hidden field? <form action="/Media/Add"> <input type="hidden" nam...

Laravel 5 call a model function in a blade view

I want to build a blade view from 3 tables: "inputs_details" - fields: article_type (values: 'p' for product,'s' for service), article_id, .... "products" - fields: id, name "services" - fields: id, name But, in browser, I have the error: "Clas...

Concatenate multiple node values in xpath

I have a XML that looks like this <element1> <element2> <element3> <element4>Hello</element4> <element5>World</element5> </element3> <element3...

How do I use installed packages in PyCharm?

In PyCharm, I've added the Python environment /usr/bin/python. However, from gnuradio import gr fails as an undefined reference. However, it works fine in the Python interpreter from the command line. GNURadio works fine with python outside of P...

changing the language of error message in required field in html5 contact form

I am trying to change the language of the error message in the html5 form field. I have this code: <input type="text" name="company_name" oninvalid="setCustomValidity('Lütfen isaretli yerleri doldurunuz')" required /> but on submit, even...

Limit file format when using <input type="file">?

I'd like to restrict the type of file that can be chosen from the native OS file chooser when the user clicks the Browse button in the <input type="file"> element in HTML. I have a feeling it's impossible, but I'd like to know if there is a sol...

Execute function after Ajax call is complete

I am new to Ajax and I am attempting to use Ajax while using a for loop. After the Ajax call I am running a function that uses the variables created in the Ajax call. The function only executes two times. I think that the Ajax call may not have enoug...

How can I get color-int from color resource?

Is there any way to get a color-int from a color resource? I am trying to get the individual red, blue and green components of a color defined in the resource (R.color.myColor) so that I can set the values of three seekbars to a specific level....

Apply vs transform on a group object

Consider the following dataframe: columns = ['A', 'B', 'C', 'D'] records = [ ['foo', 'one', 0.162003, 0.087469], ['bar', 'one', -1.156319, -1.5262719999999999], ['foo', 'two', 0.833892, -1.666304], ['bar', 'three', -2.026673, -0....

Disable/Enable button in Excel/VBA

I'm trying the following function in VBA/Excel: Sub function_name() button.enabled=false Call Long_Function ' duration: 10sec button.enabled=true End Sub For some reason, this button disabling does not work (it stays enabled in the exc...

Remove sensitive files and their commits from Git history

I would like to put a Git project on GitHub but it contains certain files with sensitive data (usernames and passwords, like /config/deploy.rb for capistrano). I know I can add these filenames to .gitignore, but this would not remove their history w...

How To limit the number of characters in JTextField?

How to limit the number of characters entered in a JTextField? Suppose I want to enter say 5 characters max. After that no characters can be entered into it....

How to implement a Boolean search with multiple columns in pandas

I have a pandas df and would like to accomplish something along these lines (in SQL terms): SELECT * FROM df WHERE column1 = 'a' OR column2 = 'b' OR column3 = 'c' etc. Now this works, for one column/value pair: foo = df.loc[df['column']==value] ...

ASP.NET custom error page - Server.GetLastError() is null

I have a custom error page set up for my application: <customErrors mode="On" defaultRedirect="~/errors/GeneralError.aspx" /> In Global.asax, Application_Error(), the following code works to get the exception details: Exception ex = Serve...

Selection with .loc in python

I saw this code in someone's iPython notebook, and I'm very confused as to how this code works. As far as I understood, pd.loc[] is used as a location based indexer where the format is: df.loc[index,column_name] However, in this case, the first in...

Error running android: Gradle project sync failed. Please fix your project and try again

Android Studio (1.2 RC0) keeps telling me Error running android: Gradle project sync failed. Please fix your project and try again. How can I find out what the problem is? Unfortunately the solutions from this SO thread did not help....

How to convert URL parameters to a JavaScript object?

I have a string like this: abc=foo&def=%5Basf%5D&xyz=5 How can I convert it into a JavaScript object like this? { abc: 'foo', def: '[asf]', xyz: 5 } ...

How to define static constant in a class in swift

I have these definition in my function which work class MyClass { func myFunc() { let testStr = "test" let testStrLen = countElements(testStr) } } But if I move 'testStr' and 'testStrLen' to the class level, it won't compil...

JWT (JSON Web Token) library for Java

I am working on a web application developed using Java and AngularJS and chose to implement token authentication and authorization. For the exercise purpose, I've come to the point where I send the credentials to the server, generate a random token s...

Reminder - \r\n or \n\r?

I just can't remember those. So, what is the right way to properly terminate old fashioned ASCII lines?...

X close button only using css

How to make a cross (X) only in CSS3, to use as a close button? I've been searching for a long time, and cannot found how.... When I look at source code on a website using it, there's always something weird which makes the code I take unusable. The X...

Meaning of "[: too many arguments" error from if [] (square brackets)

I couldn't find any one simple straightforward resource spelling out the meaning of and fix for the following BASH shell error, so I'm posting what I found after researching it. The error: -bash: [: too many arguments Google-friendly version: bas...

Can I convert a C# string value to an escaped string literal

In C#, can I convert a string value to a string literal, the way I would see it in code? I would like to replace tabs, newlines, etc. with their escape sequences. If this code: Console.WriteLine(someString); produces: Hello World! I want this ...

ListView with OnItemClickListener

I am using a custom ListView with RatingBar and ImageButton. Here is my problem: When I click on my ListView, my OnItemClickListener is not working. Please can any one help me. Code: ListView lv = getListView(); setContentView(lv); lv.setOnItemClick...

Python Pandas - Find difference between two data frames

I have two data frames df1 and df2, where df2 is a subset of df1. How do I get a new data frame (df3) which is the difference between the two data frames? In other word, a data frame that has all the rows/columns in df1 that are not in df2? ...

Where are SQL Server connection attempts logged?

Does SQL Server has an external log file or internal table for attempted connections, or is that kind of info put somewhere in the Windows Event Log? ...

raw_input function in Python

What is the raw_input function? Is it a user interface? When do we use it?...

What do two question marks together mean in C#?

Ran across this line of code: FormsAuth = formsAuth ?? new FormsAuthenticationWrapper(); What do the two question marks mean, is it some kind of ternary operator? It's hard to look up in Google....

How to define a circle shape in an Android XML drawable file?

I have some problems finding the documentation of the definitions of shapes in XML for Android. I would like to define a simple circle filled with a solid color in an XML File to include it into my layout files. Sadly the Documentation on android.c...

Spring Boot default H2 jdbc connection (and H2 console)

I am simply trying to see the H2 database content for an embedded H2 database which spring-boot creates when I don't specify anything in my application.properties and start with mvn spring:run. I can see hibernate JPA creating the tables but if I try...

How to set JAVA_HOME in Linux for all users

I am new to Linux system and there seem to be too many Java folders. java -version gives me: java version "1.7.0_55" OpenJDK Runtime Environment (rhel-2.4.7.1.el6_5-x86_64 u55-b13) OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode) When I a...

AttributeError: 'str' object has no attribute 'append'

>>> myList[1] 'from form' >>> myList[1].append(s) Traceback (most recent call last): File "<pyshell#144>", line 1, in <module> myList[1].append(s) AttributeError: 'str' object has no attribute 'append' >>>...

What is the difference between Google App Engine and Google Compute Engine?

I was wondering what the difference between App Engine & Compute Engine are. Can anyone explain the difference to me?...

How to save the contents of a div as a image?

Basically, I am doing what the heading states, attempting to save the contents of a div as an image. I plan on making a small online application for the iPad. One function that is a must is having a 'Save' button that can save the full webpage as a...

Failed to execute 'postMessage' on 'DOMWindow': https://www.youtube.com !== http://localhost:9000

This is the error message that I get: Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient window's origin ('http://localhost:9000'). I've seen other similar problems ...

How do I write a "tab" in Python?

Let's say I have a file. How do I write "hello" TAB "alex"?...

7-Zip command to create and extract a password-protected ZIP file on Windows?

On Mac/Linux to zip/unzip password protected zip files, I use: Zip: zip -P password -r encrypted.zip folderIWantToZip Unzip: unzip -P password encrypted.zip What are the equivalent command on Windows on the command line (assuming that 7zip has ...

POST JSON fails with 415 Unsupported media type, Spring 3 mvc

I am trying to send a POST request to a servlet. Request is sent via jQuery in this way: var productCategory = new Object(); productCategory.idProductCategory = 1; productCategory.description = "Descrizione2"; newCategory(productCategory); where n...

How do I monitor the computer's CPU, memory, and disk usage in Java?

I would like to monitor the following system information in Java: Current CPU usage** (percent) Available memory* (free/total) Available disk space (free/total) *Note that I mean overall memory available to the whole system, not just the JVM. I'...

How to configure Visual Studio to use Beyond Compare

I would like to configure Visual Studio to open Beyond Compare by default as the diff tool. How can I do this?...

How to show soft-keyboard when edittext is focused

I want to automatically show the soft-keyboard when an EditText is focused (if the device does not have a physical keyboard) and I have two problems: When my Activity is displayed, my EditText is focused but the keyboard is not displayed, I need to...

How Exactly Does @param Work - Java

How does the annotation @param work? If I had something like this: /* *@param testNumber; */ int testNumber = 5; if (testNumber < 6) { //Something } How would the @param affect the testNumber? Does it even affect the testNumber? Thanks. ...

How to add fonts to create-react-app based projects?

I'm using create-react-app and prefer not to eject. It's not clear where fonts imported via @font-face and loaded locally should go. Namely, I'm loading @font-face { font-family: 'Myriad Pro Regular'; font-style: normal; font-weight: normal...

Check a collection size with JSTL

How can I check the size of a collection with JSTL? Something like: <c:if test="${companies.size() > 0}"> </c:if> ...

Python List vs. Array - when to use?

If you are creating a 1d array, you can implement it as a List, or else use the 'array' module in the standard library. I have always used Lists for 1d arrays. What is the reason or circumstance where I would want to use the array module instead? ...

Error: EACCES: permission denied

I run npm install lodash but it throws Error: EACCES: permission denied error. I know it is permission issue but as far as I know, sudo permission is not required for installing node module locally. If I run it with sudo, it gets installed inside ~/n...

How to sum all the values in a dictionary?

Let's say I have a dictionary in which the keys map to integers like: d = {'key1': 1,'key2': 14,'key3': 47} Is there a syntactically minimalistic way to return the sum of the values in d—i.e. 62 in this case?...

Emulator in Android Studio doesn't start

I think it's a problem with the SDK reference in Project Structure, but when I click run and I choose Launch Emulator nothing appears....

SonarQube Exclude a directory

I am trying to exclude a directory from being analyzed by Sonar. I have the following properties defined in my sonar-project.properties file: sonar.sources=src/java sonar.exclusions=src/java/test/****/*.java The directory structure I have is: src...

How to implement the Android ActionBar back button?

I have an activity with a listview. When the user click the item, the item "viewer" opens: List1.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {...

How to delete all the rows in a table using Eloquent?

My guess was to use the following syntax: MyModel::all()->delete(); But that did not work. I'm sure it's super simple, but I've searched for documentation on the subject and can't find it!...

Combining Two Images with OpenCV

I'm trying to use OpenCV 2.1 to combine two images into one, with the two images placed adjacent to each other. In Python, I'm doing: import numpy as np, cv img1 = cv.LoadImage(fn1, 0) img2 = cv.LoadImage(fn2, 0) h1, w1 = img1.height,img1.width h2...

LaTeX: Multiple authors in a two-column article

I'm kind of new to LaTeX and I am having a bit of a problem.. I am using a twocolumn layout for my article. There are four authors involved with different affiliations, and I am trying to list all of them under the title so they span the entire widt...

How to turn IDENTITY_INSERT on and off using SQL Server 2008?

Why am I getting an error doing an insert when IDENTITY_INSERT is set to OFF? How do I turn it on properly in SQL Server 2008? Is it by using SQL Server Management Studio? I have run this query: SET IDENTITY_INSERT Database. dbo. Baskets ON Th...

Getting error while sending email through Gmail SMTP - "Please log in via your web browser and then try again. 534-5.7.14"

I'm having problems with gmail smtp server. I already read many posts here in StackOverflow about that subject. The best post I found about test the connection is this one. Although it is very well explained the error I'm getting I couldn't find a ...

How do I create batch file to rename large number of files in a folder?

I'd like to rename a large number of files within a folder on a WinXP system, preferably using a batch file. The files are currently named like this: Vacation2010 001.jpg Vacation2010 002.jpg Vacation2010 003.jpg And I'd like to change the...

What is the effect of encoding an image in base64?

If I convert an image (jpg or png) to base64, then will it be bigger, or will it have the same size? How much greater will it be? Is it recommended to use base64 encoded images on my website?...

Converting a float to a string without rounding it

I'm making a program that, for reasons not needed to be explained, requires a float to be converted into a string to be counted with len(). However, str(float(x)) results in x being rounded when converted to a string, which throws the entire thing of...

Tomcat Server not starting with in 45 seconds

Server Tomcat v7.0 Server at localhost was unable to start within 101 seconds. If the server requires more time, try increasing the timeout in the server editor. This is my error. I searched a lot but I can't able to find a solution for this pl...

how to read certain columns from Excel using Pandas - Python

I am reading from an Excel sheet and I want to read certain columns: column 0 because it is the row-index, and columns 22:37. Now here is what I do: import pandas as pd import numpy as np file_loc = "path.xlsx" df = pd.read_excel(file_loc, index_col...

Minimum and maximum value of z-index?

I have a div in my HTML page. I am showing this div based on some condition, but the div is displaying behind the HTML element where I pointed the mouse cursor. I have tried all values for z-index from 0 - 999999. Can anyone tell me why this is happ...

GROUP BY having MAX date

I have problem when executing this code: SELECT * FROM tblpm n WHERE date_updated=(SELECT MAX(date_updated) FROM tblpm GROUP BY control_number HAVING control_number=n.control_number) Basically, I want to return the most recent date for each con...

Broadcast Receiver within a Service

I am trying to start up a BroadcastReceiver within a Service. What I am trying to do is have a background running service going that collects incoming text messages, and logs incoming phone calls. I figured the best way to go about this is to have a ...

format statement in a string resource file

I have strings defined in the usual strings.xml Resource file like this: <string name="hello_world"> HELLO</string> Is it possible to define format strings such as the one below result_str = String.format("Amount: %.2f for %d days "...

Find kth smallest element in a binary search tree in Optimum way

I need to find the kth smallest element in the binary search tree without using any static/global variable. How to achieve it efficiently? The solution that I have in my mind is doing the operation in O(n), the worst case since I am planning to do an...

How would you count occurrences of a string (actually a char) within a string?

I am doing something where I realised I wanted to count how many /s I could find in a string, and then it struck me, that there were several ways to do it, but couldn't decide on what the best (or easiest) was. At the moment I'm going with something...

QuotaExceededError: Dom exception 22: An attempt was made to add something to storage that exceeded the quota

Using LocalStorage on iPhone with iOS 7 throws this error. I've been looking around for a resolvant, but considering I'm not even browsing in private, nothing is relevant. I don't understand why localStorage would be disabled by default in iOS 7, bu...

How to restart Activity in Android

How do I restart an Android Activity? I tried the following, but the Activity simply quits. public static void restartActivity(Activity act){ Intent intent=new Intent(); intent.setClass(act, act.getClass()); act.startActivi...

How to check if an appSettings key exists?

How do I check to see if an Application Setting is available? i.e. app.config <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key ="someKey" value="someValue"/> </appSettings> </...

Download a specific tag with Git

I'm trying to figure out how I can download a particular tag of a Git repository - it's one version behind the current version. I saw there was a tag for the previous version on the git web page, with object name of something long hex number. But ...

How do I run a terminal inside of Vim?

I am used to Emacs, but I am trying out Vim to see which one I like better. One thing that I like about Emacs is the ability to run a terminal inside Emacs. Is this possible inside of Vim? I know that you can execute commands from Vim, but I would ...

How can I find where I will be redirected using cURL?

I'm trying to make curl follow a redirect but I can't quite get it to work right. I have a string that I want to send as a GET param to a server and get the resulting URL. Example: String = Kobold Vermin Url = www.wowhead.com/search?q=Kobold+W...

Display filename before matching line

How can I get grep to display the filename before the matching lines in its output?...

How to vertically align text inside a flexbox?

I would like to use flexbox to vertically align some content inside an <li> but not having great success. I've checked online and many of the tutorials actually use a wrapper div which gets the align-items:center from the flex settings on the ...

Javascript checkbox onChange

I have a checkbox in a form and I'd like it to work according to following scenario: if someone checks it, the value of a textfield (totalCost) should be set to 10. then, if I go back and uncheck it, a function calculate() sets the value of total...

Convert a float64 to an int in Go

How does one convert a float64 to an int in Go? I know the strconv package can be used to convert anything to or from a string, but not between data types where one isn't a string. I know I can use fmt.Sprintf to convert anything to a string, and the...

Finding element's position relative to the document

What's the easiest way to determine an elements position relative to the document/body/browser window? Right now I'm using .offsetLeft/offsetTop, but this method only gives you the position relative to the parent element, so you need to determine h...

keyCode values for numeric keypad?

Do the numbers on a numeric keypad have a different keycode than the numbers at the top of a keyboard? Here is some JavaScript that is supposed to run on the keyup event, but only if the keycode is between 48 and 57. Here is the code: $('#rollNum')...

java create date object using a value string

I am using this to get the current time : java.util.Calendar cal = java.util.Calendar.getInstance(); System.out.println(new java.text.SimpleDateFormat("EEEE, dd/MM/yyyy/hh:mm:ss") .format(cal.getTime())); I want to put the value (w...

Eclipse: Enable autocomplete / content assist

How can I enable autocomplete in Eclipse? I can't find it!...

How do you reverse a string in place in C or C++?

How do you reverse a string in C or C++ without requiring a separate buffer to hold the reversed string?...

Could not load file or assembly 'xxx' or one of its dependencies. An attempt was made to load a program with an incorrect format

I just checked out a revision from Subversion to a new folder. Opened the solution and I get this when run: Could not load file or assembly 'xxxx' or one of its dependencies. An attempt was made to load a program with an incorrect format. This is ...

Can a java file have more than one class?

What is the purpose of having more than one class in a Java file ? I am new to Java. Edited: That can be achieved by creating a inner class inside a public class, right?...

How do I make case-insensitive queries on Mongodb?

var thename = 'Andrew'; db.collection.find({'name':thename}); How do I query case insensitive? I want to find result even if "andrew";...

regex.test V.S. string.match to know if a string matches a regular expression

Many times I'm using the string match function to know if a string matches a regular expression. if(str.match(/{regex}/)) Is there any difference between this: if (/{regex}/.test(str)) They seem to give the same result?...

Parsing domain from a URL

I need to build a function which parses the domain from a URL. So, with http://google.com/dhasjkdas/sadsdds/sdda/sdads.html or http://www.google.com/dhasjkdas/sadsdds/sdda/sdads.html it should return google.com with http://google.co.uk/dhas...

Target Unreachable, identifier resolved to null in JSF 2.2

I have a problem with JSF 2.2 and CDI, my managerbean is not solved and this error appear "value="#{userBean.user.name}": Target Unreachable, identifier 'userBean' resolved to null" This is my manager bean. @ManagedBean @RequestScoped public ...

What are examples of TCP and UDP in real life?

I know the difference between the two on a technical level. But in real life, can anyone provide examples (the more the better) of applications (uses) of TCP and UDP to demonstrate the difference?...

TLS 1.2 not working in cURL

I am having trouble curling an HTTPS url that uses TLS1.2, in my curl operation I post my login data into the website and save it in cookiefile. The error message I am getting is this error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert ...

How to redirect siteA to siteB with A or CNAME records

I have 2 hosts and I would like to point a subdomain on host one to a subdomain on host two: subdomain.hostone.com --> subdomain.hosttwo.com I added a CNAME record to host one that points to subdomain.hosttwo.com but all I get is a '400 Bad Req...

Does `anaconda` create a separate PYTHONPATH variable for each new environment?

I am starting to work with the Python Anaconda distribution from Continuum.io to do scipy work. I have been able to get Anaconda up and running, but I cannot tell whether Anaconda creates a new PYTHONPATH environment variable for each new environment...

How can I schedule a daily backup with SQL Server Express?

I'm running a small web application with SQL server express (2005) as backend. I can create a backup with a SQL script, however, I'd like to schedule this on a daily basis. As extra option (should-have) I'd like to keep only the last X backups (for ...

How to find locked rows in Oracle

We have an Oracle database, and the customer account table has about a million rows. Over the years, we've built four different UIs (two in Oracle Forms, two in .Net), all of which remain in use. We have a number of background tasks (both persistent ...

Call parent method from child class c#

This is a slightly different question from previous answers I have seen or I am not getting it. I have a parent class with a method named MyMethod() and a variable public Int32 CurrentRow; public void MyMethod() { this.UpdateProgressBar(); ...

PHP + curl, HTTP POST sample code?

Can anyone show me how to do a php curl with an HTTP POST? I want to send data like this: username=user1, password=passuser1, gender=1 To www.domain.com I expect the curl to return a response like result=OK. Are there any examples?...

SELECT list is not in GROUP BY clause and contains nonaggregated column .... incompatible with sql_mode=only_full_group_by

AM using MySQL 5.7.13 on my windows PC with WAMP Server Here my Problem is While executing this query SELECT * FROM `tbl_customer_pod_uploads` WHERE `load_id` = '78' AND `status` = 'Active' GROUP BY `proof_type` Am getting always error like...

Oracle SQL convert date format from DD-Mon-YY to YYYYMM

I have a to compare dates in 2 tables but the problem is that one table has the date in DD-Mon-YY format and the other in YYYYMM format. I need to make both of them YYYYMM for the comparison. I need to create something like this: SELECT * FROM off...

R Markdown - changing font size and font type in html output

I am using R Markdown in RStudio and the knit HTML option to create HTML output. However, the font used in the ouput for plain text blocks is rather small and I would like to change it to a differnt font and increase the font size. Can someone show a...

Registering for Push Notifications in Xcode 8/Swift 3.0?

I'm trying to get my app working in Xcode 8.0, and am running into an error. I know this code worked fine in previous versions of swift, but I'm assuming the code for this is changed in the new version. Here's the code I'm trying to run: let setting...

How can I add 1 day to current date?

I have a current Date object that needs to be incremented by one day using the JavaScript Date object. I have the following code in place: var ds = stringFormat("{day} {date} {month} {year}", { day: companyname.i18n.translate("day",...

Better way of getting time in milliseconds in javascript?

Is there an alternative in JavaScript of getting time in milliseconds using the date object, or at least a way to reuse that object, without having to instantiate a new object every time I need to get this value? I am asking this because I am trying ...

set pythonpath before import statements

My code is: import scriptlib.abc import scriptlib.xyz def foo(): ... some operations but the scriptlib is in some other directory, so I will have to include that directory in environment variable "PYTHONPATH". Is there anyway in which I can fi...

Why does the Visual Studio editor show dots in blank spaces?

I have a strange bug in the Visual Studio text editor. All my blank spaces are replaced by a "." public class Person { int age; } looks like this public..class..Person.......................... {.................. ..int age;................... ...

JPQL SELECT between date statement

I would like to convert this SQL statement to a JPQL equivalent. SELECT * FROM events WHERE events_date BETWEEN '2011-01-01' AND '2011-03-31'; This correctly retrieves the information from the table events. In my Events entity @Column(na...

jQuery find() method not working in AngularJS directive

I am having trouble with angularjs directives finding child DOM elements with the injected angular element. For example I have a directive like so: myApp.directive('test', function () { return { restrict: "A", link: function (sc...

Date formatting in WPF datagrid

I want to change is the date column from a format "DD/MM/YYYY HH:MM:SS" to "DD.MM.YYYY". <DataGrid Name="dgBuchung" AutoGenerateColumns="True" ItemsSource="{Binding}" Grid.ColumnSpan...

Javascript Regular Expression Remove Spaces

So i'm writing a tiny little plugin for JQuery to remove spaces from a string. see here (function($) { $.stripSpaces = function(str) { var reg = new RegExp("[ ]+","g"); return str.replace(reg,""); } })(jQuery); my regular e...

Undefined Reference to

When I compile my code for a linked list, I get a bunch of undefined reference errors. The code is below. I have been compiling with both of these statements: g++ test.cpp as well as g++ LinearNode.h LinearNode.cpp LinkedList.h LinkedList.cpp...

Spring Boot without the web server

I have a simple Spring Boot application that gets messages from a JMS queue and saves some data to a log file, but does not need a web server. Is there any way of starting Spring Boot without the web server?...

How to deep merge instead of shallow merge?

Both Object.assign and Object spread only do a shallow merge. An example of the problem: // No object nesting const x = { a: 1 } const y = { b: 1 } const z = { ...x, ...y } // { a: 1, b: 1 } The output is what you'd expect. However if I try this:...

How to force open links in Chrome not download them?

I want to open a link that is .psd format with Photoshop when clicked in Google Chrome like Firefox that asks me to open or download the file. But Google Chrome downloads the file automatically. How can I force to open the links in Chrome without dow...

SQL multiple columns in IN clause

If we need to query a table based on some set of values for a given column, we can simply use the IN clause. But if query need to be performed based on multiple columns, we could not use IN clause(grepped in SO threads.) From other SO threads, we...

Conversion from 12 hours time to 24 hours time in java

In my app, I have a requirement to format 12 hours time to 24 hours time. What is the method I have to use? For example, time like 10:30 AM. How can I convert to 24 hours time in java?...

How can I add an item to a IEnumerable<T> collection?

My question as title above. For example, IEnumerable<T> items = new T[]{new T("msg")}; items.ToList().Add(new T("msg2")); but after all it only has 1 item inside. Can we have a method like items.Add(item)? like the List<T>...

putting a php variable in a HTML form value

I've got a php variable like so.. $name = $_REQUEST['name']; I'd like to put it in a HTML form field's value e.g in here.. <input type="text" name="name" value=(php variable here) /> How would I do so? Thanks....

jQuery changing css class to div

If I have one div element for example and class 'first' is defined with many css properties. Can I assign css class 'second' which also has many properties differently defined to this same div just on some event without writing each property in line...

CASE statement in SQLite query

Why this query doesn't work? :( I tried to replace nested IF statement "...SET lkey = IF(lkey >= 11, lkey - 5, IF(lkey > 5, lkey + 2,lkey))" UPDATE pages SET lkey = CASE lkey WHEN lkey >= 11 THEN lkey - 5 ELSE CASE lkey WHEN l...

grep from tar.gz without extracting [faster one]

Am trying to grep pattern from dozen files .tar.gz but its very slow am using tar -ztf file.tar.gz | while read FILENAME do if tar -zxf file.tar.gz "$FILENAME" -O | grep "string" > /dev/null then echo "$FILENAME ...

Is there a <meta> tag to turn off caching in all browsers?

I read that when you don't have access to the web server's headers you can turn off the cache using: <meta http-equiv="Cache-Control" content="no-store" /> But I also read that this doesn't work in some versions of IE. Are there any set of ...

phpmailer: Reply using only "Reply To" address

I'm using phpmailer on my website and to help with spam issues I have created a mailbox to send these emails from (using SMTP). I have set the emails to come from the mailbox address and then I have added a reply to address for where I want the repl...

How to solve ADB device unauthorized in Android ADB host device?

When I'm using a rooted Android device as ADB host to send adb command "adb devices" to Samsung S4, I received device unauthorized error message. However when I tried adb to Samsung Galaxy Nexus, it is working fine. Can anyone advise how to solve my ...

Inserting HTML into a div

I am trying to insert a chunk of HTML into a div. I want to see if plain JavaScript way is faster than using jQuery. Unfortunately, I forgot how to do it the 'old' way. :P var test2 = function(){ var cb = function(html){ var t1 = documen...

Omitting one Setter/Getter in Lombok

I want to use a data class in Lombok. Since it has about a dozen fields, I annotated it with @Data in order to generate all the setters and getter. However there is one special field for which I don't want to the accessors to be implemented. How do...

CSS fill remaining width

I have this header bar. <div id="header"> <div class="container"> <img src="img/logo.png"/> <div id="searchBar"> <input type="text" /> </div> ...

Oracle Differences between NVL and Coalesce

Are there non obvious differences between NVL and Coalesce in Oracle? The obvious differences are that coalesce will return the first non null item in its parameter list whereas nvl only takes two parameters and returns the first if it is not null, ...

R: numeric 'envir' arg not of length one in predict()

I'm trying to predict a value in R using the predict() function, by passing along variables into the model. I am getting the following error: Error in eval(predvars, data, env) : numeric 'envir' arg not of length one Here is my data frame, n...

How to change the value of attribute in appSettings section with Web.config transformation

Is it possible to transform the following Web.config appSettings file: <appSettings> <add key="developmentModeUserId" value="00297022" /> <add key="developmentMode" value="true" /> /* other settings here that should sta...

Why can a function modify some arguments as perceived by the caller, but not others?

I'm trying to understand Python's approach to variable scope. In this example, why is f() able to alter the value of x, as perceived within main(), but not the value of n? def f(n, x): n = 2 x.append(4) print('In f():', n, x) def main()...

How to fix: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found

So I'm now desperate in finding a fix for this. I'm compiling a shared library .so in Ubuntu 32 bit (Have tried doing it under Debian and Ubuntu 64 bit, but none worked either) I keep getting: /usr/lib/libstdc++.so.6: version ``GLIBCXX_3.4.15' not f...

$.ajax( type: "POST" POST method to php

I'm trying to use the POST method in jQuery to make a data request. So this is the code in the html page: <form> Title : <input type="text" size="40" name="title"/> <input type="button" onclick="headingSearch(this.form)" value="Submit...

How to get the fields in an Object via reflection?

I have an object (basically a VO) in Java and I don't know its type. I need to get values which are not null in that object. How can this be done?...

split string only on first instance - java

I want to split a string by '=' charecter. But I want it to split on first instance only. How can I do that ? Here is a JavaScript example for '_' char but it doesn't work for me split string only on first instance of specified character Example : ...

How to create an Oracle sequence starting with max value from a table?

Trying to create a sequence in Oracle that starts with the max value from a specific table. Why does this not work? CREATE SEQUENCE transaction_sequence MINVALUE 0 START WITH (SELECT MAX(trans_seq_no) FROM TRANSACTION_LOG) INCREMENT BY 1...

How to use Global Variables in C#?

How do I declare a variable so that every class (*.cs) can access its content, without an instance reference?...

conflicting types error when compiling c program using gcc

I tried to compile following program with gcc. 0 #include <stdio.h> 1 2 main () 3 4 { 5 char my_string[] = "hello there"; 6 7 my_print (my_string); 8 my_print2 (my_string); 9} 10 11 void my_print (char *string) 12 { ...

C++ error 'Undefined reference to Class::Function()'

I was wondering if anyone could help me out with this - I'm only new to C++ and it's causing me a fair amount of troubles. I'm trying to make relatively simple Deck and Card class objects. The error is showing up in "Deck.cpp", declaration of an a...

Read specific columns with pandas or other python module

I have a csv file from this webpage. I want to read some of the columns in the downloaded file (the csv version can be downloaded in the upper right corner). Let's say I want 2 columns: 59 which in the header is star_name 60 which in the header is...

How to extract code of .apk file which is not working?

Actually I was trying to extract code of a .apk file called cloudfilz.apk and wanted to manipulate in its source code so I followed the steps given below:- make a new folder and put .apk file (which you want to decode) now rename this .apk file with ...

Does functional programming replace GoF design patterns?

Since I started learning F# and OCaml last year, I've read a huge number of articles which insist that design patterns (especially in Java) are workarounds for the missing features in imperative languages. One article I found makes a fairly strong cl...

ALTER TABLE DROP COLUMN failed because one or more objects access this column

I am trying to do this: ALTER TABLE CompanyTransactions DROP COLUMN Created But I get this: Msg 5074, Level 16, State 1, Line 2 The object 'DF__CompanyTr__Creat__0CDAE408' is dependent on column 'Created'. Msg 4922, Level 16, State 9, Line...

When is std::weak_ptr useful?

I started studying smart pointers of C++11 and I don't see any useful use of std::weak_ptr. Can someone tell me when std::weak_ptr is useful/necessary?...

VBA - Range.Row.Count

I have written a simple code to illustrate my predicament. Sub test() Dim sh As Worksheet Set sh = ThisWorkbook.Sheets("Sheet1") Dim k As Long k = sh.Range("A1", sh.Range("A1").End(xlDown)).Rows.Count End Sub What happens is thi...

Update one MySQL table with values from another

I'm trying to update one MySQL table based on information from another. My original table looks like: id | value ------------ 1 | hello 2 | fortune 3 | my 4 | old 5 | friend And the tobeupdated table looks like: uniqueid | id | value ------...

Call a function from another file?

Set_up: I have a .py file for each function I need to use in a program. In this program, I need to call the function from the external files. I've tried: from file.py import function(a,b) But I get the error: ImportError: No module named 'fi...

git status shows modifications, git checkout -- <file> doesn't remove them

I would like to remove all changes to my working copy. Running git status shows files modified. Nothing I do seems to remove these modifications. E.g.: rbellamy@PROMETHEUS /d/Development/rhino-etl (master) $ git status # On branch master # Changed b...

PIL image to array (numpy array to array) - Python

I have a .jpg image that I would like to convert to Python array, because I implemented treatment routines handling plain Python arrays. It seems that PIL images support conversion to numpy array, and according to the documentation I have written t...

How to format a Java string with leading zero?

Here is the String, for example: "Apple" and I would like to add zero to fill in 8 chars: "000Apple" How can I do so?...

Jquery Ajax Loading image

I would like to implement a loading image for my jquery ajax code (this is when the jquery is still processing) below is my code: $.ajax({ type: "GET", url: surl, dataType: "jsonp", cache : false, jsonp : "onJSONPLoad", jsonp...

NodeJS - Error installing with NPM

Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation. All rights reserved. C:\Windows\system32>npm install caress-server npm http GET https://registry.npmjs.org/caress-server npm http 304 https://registry.npmjs.org/caress-server np...

how to change onclick event with jquery?

I have create a js file in which i am creating the dynamic table and dynamically changing the click event for the calendar but onclicking the calender image for dynamic generated table, calendar popup in the previous calendar image. Please help me c...

How can I add an ampersand for a value in a ASP.net/C# app config file value

I've got a C# program with values in a config file. What I want is to store ampersands for an url value like... <appSettings> <add key="myurl" value="http://www.myurl.com?&cid=&sid="/> </appSettings> But I get errors b...

SQL- Ignore case while searching for a string

I have the following data in a Table PriceOrderShipped PriceOrderShippedInbound PriceOrderShippedOutbound In SQL I need to write a query which searches for a string in a table. While searching for a string it should ignore case. For the below mentio...

Troubleshooting BadImageFormatException

I have a Windows service written in C# using Visual Studio 2010 and targeting the full .NET Framework 4. When I run from a Debug build the service runs as expected. However, when I run it from a Release build I get a System.BadImageFormatException ...

How to reverse apply a stash?

I have a small patch saved away in my git stash. I've applied it to my working copy using git stash apply. Now, I'd like to back out those changes by reverse applying the patch (kind of like what git revert would do but against the stash). Does an...

Converting stream of int's to char's in java

This has probably been answered else where but how do you get the character value of an int value? Specifically I'm reading a from a tcp stream and the readers .read() method returns an int. How do I get a char from this?...

NSURLErrorDomain error codes description

This is my first experience of developing an ios app. I am trying to Post some data using Facebook graph api. I am constantly getting the following error: The operation couldn’t be completed. (NSURLErrorDomain error 400.) I cannot able to find t...

Clear screen in shell

Just a quick question: How do you clear the screen in shell? I've seen ways like: import os os.system('cls') This just opens the windows cmd, clears the screen and closes but I want the shell window to be cleared (PS: I don't know this helps, but ...

Saving a Numpy array as an image

I have a matrix in the type of a Numpy array. How would I write it to disk it as an image? Any format works (png, jpeg, bmp...). One important constraint is that PIL is not present....

Where is Python language used?

I am a web developer and usually use PHP, JavaScript or MySQL. I have heard lot about Python. But I have no idea where it is used and why it is used. Just like PHP, ASP, ColdFusion, .NET are used to build websites, and C, C++, Java are used to bui...

for or while loop to do something n times

In Python you have two fine ways to repeat some action more than once. One of them is while loop and the other - for loop. So let's have a look on two simple pieces of code: for i in range(n): do_sth() And the other: i = 0 while i < n: ...

eslint: error Parsing error: The keyword 'const' is reserved

I am getting this error from ESLint: error Parsing error: The keyword 'const' is reserved from this code: const express = require('express'); const app = express(); const _ = require('underscore'); I've tried removing node_modules and reinstal...

How to send email via Django?

In my settings.py, I have the following: EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' # Host for sending e-mail. EMAIL_HOST = 'localhost' # Port for sending e-mail. EMAIL_PORT = 1025 # Optional SMTP authentication information fo...

Do you know the Maven profile for mvnrepository.com?

I am trying to include some dependencies in my Maven project. These dependencies are not available in the default Maven 2 repository http://repo1.maven.org/maven2/. They are available at http://mvnrepository.com/. But I couldn't find the profile for ...

How can I find last row that contains data in a specific column?

How can I find the last row that contains data in a specific column and on a specific sheet?...

Find integer index of rows with NaN in pandas dataframe

I have a pandas DataFrame like this: a b 2011-01-01 00:00:00 1.883381 -0.416629 2011-01-01 01:00:00 0.149948 -1.782170 2011-01-01 02:00:00 -0.407604 0.314168 2011-01-01 03:00:00 1.452354 NaN 2011-01-01 04:00:00 -1.2248...

How do I implement a progress bar in C#?

How do I implement a progress bar and backgroundworker for database calls in C#? I do have some methods that deal with large amounts of data. They are relatively long running operations, so I want to implement a progress bar to let the user know tha...

How do I create a MessageBox in C#?

I have just installed C# for the first time, and at first glance it appears to be very similar to VB6. I decided to start off by trying to make a 'Hello, World!' UI Edition. I started in the Form Designer and made a button named "Click Me!" proceede...

private constructor

Possible Duplicate: What is the use of making constructor private in a class? Where do we need private constructor? How can we instantiate a class having private constructor? ...

Select query to get data from SQL Server

I am trying to run the SQL Select query in my C# code. But I always get the -1 output on int result = command.ExecuteNonQuery(); However, the same table if I use for delete or insert works... ConnectString is also fine. Please check below code...

fetch gives an empty response body

I have a react/redux application and I'm trying to do a simple GET request to a sever: fetch('http://example.com/api/node', { mode: "no-cors", method: "GET", headers: { "Accept": "application/json" } }).then((response) => { console...

Simplest way to serve static data from outside the application server in a Java web application

I have a Java web application running on Tomcat. I want to load static images that will be shown both on the Web UI and in PDF files generated by the application. Also new images will be added and saved by uploading via the Web UI. It's not a problem...

java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient

I am trying to make a get request from the GWT servlet to get JSON response from a web service. Following is the code in my servlet : public String getQueData() throws IllegalArgumentException { String message = null; try { ...

sys.argv[1], IndexError: list index out of range

I am having an issue with the following section of Python code: # Open/Create the output file with open(sys.argv[1] + '/Concatenated.csv', 'w+') as outfile: try: with open(sys.argv[1] + '/MatrixHeader.csv') as headerfile: fo...

c# open a new form then close the current form?

For example, Assume that I'm in form 1 then I want: Open form 2( from a button in form 1) Close form 1 Focus on form 2 ...

How often should you use git-gc?

How often should you use git-gc? The manual page simply says: Users are encouraged to run this task on a regular basis within each repository to maintain good disk space utilization and good operating performance. Are there some commands to ...

How do I convert a float number to a whole number in JavaScript?

I'd like to convert a float to a whole number in JavaScript. Actually, I'd like to know how to do BOTH of the standard conversions: by truncating and by rounding. And efficiently, not via converting to a string and parsing....

how to run mysql in ubuntu through terminal

trying to run mysql in ubuntu typing mysql in terminal and getting error ERROR 1045(28000): Access denied for user 'root'@'localhost' (using password: NO) Can anybody please sort out this problem......

How can I rename a conda environment?

I have a conda environment named old_name, how can I change its name to new_name without breaking references?...

Mysql select distinct

I am trying to select of the duplicate rows in mysql table it's working fine for me but the problem is that it is not letting me select all the fields in that query , just letting me select the field name i used as distinct , lemme write the query fo...

How to strip all non-alphabetic characters from string in SQL Server?

How could you remove all characters that are not alphabetic from a string? What about non-alphanumeric? Does this have to be a custom function or are there also more generalizable solutions?...

Odd behavior when Java converts int to byte?

int i =132; byte b =(byte)i; System.out.println(b); Mindboggling. Why is the output -124?...

Android and setting alpha for (image) view alpha

Is there really no XML attribute counterpart to setAlpha(int)? If not, what alternatives are there?...

jQuery Keypress Arrow Keys

I'm attempting to capture arrow key presses in jQuery, but no events are being triggered. $(function(){ $('html').keypress(function(e){ console.log(e); }); }); This generates events for alphanumeric keys, but delete, arrow keys, et...

How to supply value to an annotation from a Constant java

I am thinking this may not be possible in Java because annotation and its parameters are resolved at compile time. I have an interface as follows, public interface FieldValues { String[] FIELD1 = new String[]{"value1", "value2"}; } and another ...

Why use Ruby's attr_accessor, attr_reader and attr_writer?

Ruby has this handy and convenient way to share instance variables by using keys like attr_accessor :var attr_reader :var attr_writer :var Why would I choose attr_reader or attr_writer if I could simply use attr_accessor? Is there something like p...

Generating random, unique values C#

I've searched for a while and been struggling to find this, I'm trying to generate several random, unique numbers is C#. I'm using System.Random, and I'm using a DateTime.Now.Ticks seed: public Random a = new Random(DateTime.Now.Ticks.GetHashCode())...

What is the different between RESTful and RESTless

What is basic difference between restful and restless, i've been reading a few articles people seem to use them interchangeably....

In Git, how do I figure out what my current revision is?

I just want to know what my current version number is....

Checking version of angular-cli that's installed?

Is there a way to check the specific version of angular-cli that's installed globally on my machine? I'm in a Windows environment. *npm -v* and *node -v* only gives me the version of npm and node respectively, and I can't seem to find any commands wi...

How to generate a random alpha-numeric string

I've been looking for a simple Java algorithm to generate a pseudo-random alpha-numeric string. In my situation it would be used as a unique session/key identifier that would "likely" be unique over 500K+ generation (my needs don't really require an...

How do I get the file name from a String containing the Absolute file path?

String variable contains a file name, C:\Hello\AnotherFolder\The File Name.PDF. How do I only get the file name The File Name.PDF as a String? I planned to split the string, but that is not the optimal solution....

How do I install a color theme for IntelliJ IDEA 7.0.x

I prefer dark backgrounds for coding, and I've downloaded a jar file containing an IntelliJ IDEA color theme that has a dark background. How do I tell IntelliJ about it?...

How to display alt text for an image in chrome

The image with invalid source displays an alternate text in Firefox but not in chrome unless the width of an image is adjusted. <img height="90" width="90" src="http://www.google.com/intl/en_ALL/images/logos/images_logo_lg.gif" alt="Ima...

How to add an extra row to a pandas dataframe

If I have an empty dataframe as such: columns = ['Date', 'Name', 'Action','ID'] df = pd.DataFrame(columns=columns) is there a way to append a new row to this newly created dataframe? Currently I have to create a dictionary, populate it, then appe...

exception.getMessage() output with class name

I'm trying to fix an issue, in my application I have this code try { object1.method1(); } catch(Exception ex) { JOptionPane.showMessageDialog(nulll, "Error: "+ex.getMessage()); } and the object1 would do something like that: public void meth...

Is it possible to get element from HashMap by its position?

How to retrieve an element from HashMap by its position, is it possible at all?...

How do you get the selected value of a Spinner?

I am trying to get the selected items string out of a Spinner. So far I have gotten this: bundle.putString(ListDbAdapter.DB_PRI, v.getText().toString()); This does not work and gives a class casting exception (I thought I could cast a View to a wi...

Does Java have a path joining method?

Exact Duplicate: combine paths in java I would like to know if there is such a method in Java. Take this snippet as example : // this will output a/b System.out.println(path_join("a","b")); // a/b System.out.println(path_join(&qu...

How to set Highcharts chart maximum yAxis value

I've been trying for two days to find a way to set the maximum value of the yAxis on Highcharts. I got a percentage column graphic, but the highest value in the series is 60, so it adjusts the axis to top at 70, I found a way to choose the start poi...

CSS, Images, JS not loading in IIS

My all applications were working fine but suddenly all sites under IIS are not loading css, images, scripts. It redirect to login page. If i login it works fine. e.g. mysite.com/Account/LogOn?ReturnUrl=%2fpublic%2fimages%2ficons%2f41.png On my loc...

How do I apply a CSS class to Html.ActionLink in ASP.NET MVC?

I'm building an ASP.NET MVC application, using VB.NET and I'm trying to apply a css class to a Html.ActionLink using the code: <%=Html.ActionLink("Home", "Index", "Home", new {@class = "tab" })%> But when I run the code I receive the below e...

Efficiently convert rows to columns in sql server

I'm looking for an efficient way to convert rows to columns in SQL server, I heard that PIVOT is not very fast, and I need to deal with lot of records. This is my example: ------------------------------- | Id | Value | ColumnName | ---...

How to move the layout up when the soft keyboard is shown android

I have a login screen with two EditTexts and a login button in my layout. The problem is that, when I start typing, the soft keyboard is shown and covers the login button. How can I push the layout up or above the keyboard when it appears? I do not ...

How to make bootstrap 3 fluid layout without horizontal scrollbar

here is sample link: http://bootply.com/76369 this is html i use. <div class="row"> <div class="col-md-6">.col-md-6</div> <div class="col-md-6">.col-md-6</div> </div> bootstrap 3 has no container-fluid and ...

Spring Boot Program cannot find main class

I have a program which runs as a Spring boot App in eclipse. The program was running fine. Then i did the following: Right click on project -> Run As -> Maven Test . This was accidental. When i then tried to run the program as a spring boot app ag...

How to darken an image on mouseover?

My problem.. I have a number of images (inside hyperlinks), and I want each to darken on mouseover (i.e. apply a black mask with high opacity or something), and then go back to normal on mouseout . But I can't figure out the best way to do it. I've...

How to terminate a process in vbscript

How can I terminate process using vbscript. PLEASE NOTE, I need to terminate process that runs under windows 64-bit environment as native 64 (not using select * from win_32_Process) Thanks,...

SELECT CONVERT(VARCHAR(10), GETDATE(), 110) what is the meaning of 110 here?

When we convert or cast date in sql, see below sql code SELECT CONVERT(VARCHAR(10), GETDATE(), 110) AS [MM-DD-YYYY] it works fine, I just want to know the meaning of 110 in above code. what it does actually, sometimes we use 102, 112 etc. what is...

Liquibase lock - reasons?

I get this when running a lot of liquibase-scripts against a Oracle-server. SomeComputer is me. Waiting for changelog lock.... Waiting for changelog lock.... Waiting for changelog lock.... Waiting for changelog lock.... Waiting for changelog lock......

Laravel: Validation unique on update

I know this question has been asked many times before but no one explains how to get the id when you're validating in the model. 'email' => 'unique:users,email_address,10' My validation rule is in the model so how do I pass the ID of the record...

How can I exclude $(this) from a jQuery selector?

I have something like this: <div class="content"> <a href="#">A</a> </div> <div class="content"> <a href="#">B</a> </div> <div class="content"> <a href="#">C</a> </div&...

How to check internet access on Android? InetAddress never times out

I got a AsyncTask that is supposed to check the network access to a host name. But the doInBackground() is never timed out. Anyone have a clue? public class HostAvailabilityTask extends AsyncTask<String, Void, Boolean> { private Main main...

Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in C:\

I'm doing a tutorial in which the author has not updated his content to reflect changes in the PHP documentation. Anyways, I need to know what is parameter is being asked of me to provide. I've checked that all things are in order, but I literally do...

Grant all on a specific schema in the db to a group role in PostgreSQL

Using PostgreSQL 9.0, I have a group role called "staff" and would like to grant all (or certain) privileges to this role on tables in a particular schema. None of the following work GRANT ALL ON SCHEMA foo TO staff; GRANT ALL ON DATABASE mydb TO s...

transparent navigation bar ios

I'm creating an app and i've browsed on the internet and i'm wondering how they make this transparent navigationBar like this: I've added following like in my appdelegate: UINavigationBar.appearance().translucent = true but this just makes it ...

How to redirect the output of print to a TXT file

I have searched Google, Stack Overflow and my Python users guide and have not found a simple, workable answer for the question. I created a file c:\goat.txt on a Windows 7 x64 machine and am attempting to print "test" to the file. I have tried the f...

Which MySQL data type to use for storing boolean values

Since MySQL doesn't seem to have any 'boolean' data type, which data type do you 'abuse' for storing true/false information in MySQL? Especially in the context of writing and reading from/to a PHP script. Over time I have used and seen several appr...

How to set a maximum execution time for a mysql query?

I would like to set a maximum execution time for sql queries like set_time_limit() in php. How can I do ?...

Detecting TCP Client Disconnect

Let's say I'm running a simple server and have accept()ed a connection from a client. What is the best way to tell when the client has disconnected? Normally, a client is supposed to send a close command, but what if it disconnects manually or loses...

How to use 'find' to search for files created on a specific date?

How do I use the UNIX command find to search for files created on a specific date?...

Using the Jersey client to do a POST operation

In a Java method, I'd like to use a Jersey client object to do a POST operation on a RESTful web service (also written using Jersey) but am not sure how to use the client to send the values that will be used as FormParam's on the server. I'm able to...

I don't understand -Wl,-rpath -Wl,

For convenience I added the relevant manpages below. My (mis)understanding first: If I need to separate options with ,, that means that the second -Wl is not another option because it comes before , which means it is an argument to the -rpath optio...

How to generate and auto increment Id with Entity Framework

Revised entire post. I'm trying to post the following JSON POST request via Fiddler: {Username:"Bob", FirstName:"Foo", LastName:"Bar", Password:"123", Headline:"Tuna"} However I'm getting this error: Message "Cannot insert the value NULL into co...

How to get datas from List<Object> (Java)?

I`m new in Java and have a problem with showing data from a list of objects. I have a simple method, which should collect data across multiple tables and return it to my controller: public List<Object> getHouseInfo(){ Query q = em.createNativ...

How do I use Bash on Windows from the Visual Studio Code integrated terminal?

Visual Studio Code on Windows uses PowerShell by default as the integrated terminal. If you want to use Bash from Visual Studio Code, what steps should be followed?...

"unexpected token import" in Nodejs5 and babel?

In js file, i used import to instead of require import co from 'co'; And tried to run it directly by nodejs since it said import is 'shipping features' and support without any runtime flag (https://nodejs.org/en/docs/es6/), but i got an error imp...

What is the difference between match_parent and fill_parent?

I'm a little confused about two XML properties: match_parent and fill_parent. It seems that both are the same. Is there any difference between them?...

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 have something like this: class Dude(models.Model)...

Which variable size to use (db, dw, dd) with x86 assembly?

I am a beginner to assembly and I don't know what all the db, dw, dd, things mean. I have tried to write this little script that does 1+1, stores it in a variable and then displays the result. Here is my code so far: .386 .model flat, stdcall optio...

Retrieve version from maven pom.xml in code

What is the simplest way to retrieve version number from maven's pom.xml in code, i.e., programatically?...

Class type check in TypeScript

In ActionScript, it is possible to check the type at run-time using the is operator: var mySprite:Sprite = new Sprite(); trace(mySprite is Sprite); // true trace(mySprite is DisplayObject);// true trace(mySprite is IEventDispatcher); // true Is...

Android dependency has different version for the compile and runtime

After updating Android Studio from Canary 3 to Canary 4, the following error is thrown at the build time. Android dependency 'com.android.support:support-support-v4' has different version for the compile (25.2.0) and runtime (26.0.0-beta2) classp...

How to check for the type of a template parameter?

Suppose I have a template function and two classes class animal { } class person { } template<class T> void foo() { if (T is animal) { kill(); } } How do I do the check for T is animal? I don't want to have something that checks dur...

Where's my JSON data in my incoming Django request?

I'm trying to process incoming JSON/Ajax requests with Django/Python. request.is_ajax() is True on the request, but I have no idea where the payload is with the JSON data. request.POST.dir contains this: ['__class__', '__cmp__', '__contains__', '_...

How do I write output in same place on the console?

I am new to python and am writing some scripts to automate downloading files from FTP servers, etc. I want to show the progress of the download, but I want it to stay in the same position, such as: output: Downloading File FooFile.txt [47%] I'...

IntelliJ IDEA 13 uses Java 1.5 despite setting to 1.7

Despite specifying JDK 1.7 in all project settings (including in File -> Project Structure -> Project :: Project SDK), the following error is produced by IntelliJ 13 when trying to compile some simple Java 7 code which does use the diamond oper...

Dynamic instantiation from string name of a class in dynamically imported module?

In python, I have to instantiate certain class, knowing its name in a string, but this class 'lives' in a dynamically imported module. An example follows: loader-class script: import sys class loader: def __init__(self, module_name, class_name): ...

How to iterate over rows in a DataFrame in Pandas

I have a DataFrame from Pandas: import pandas as pd inp = [{'c1':10, 'c2':100}, {'c1':11,'c2':110}, {'c1':12,'c2':120}] df = pd.DataFrame(inp) print df Output: c1 c2 0 10 100 1 11 110 2 12 120 Now I want to iterate over the rows of t...

How to know if an object has an attribute in Python

Is there a way in Python to determine if an object has some attribute? For example: >>> a = SomeClass() >>> a.someProperty = value >>> a.property Traceback (most recent call last): File "<stdin>", line 1, in <m...

Undefined reference to 'vtable for xxx'

takeaway.o: In function `takeaway': project:145: undefined reference to `vtable for takeaway' project:145: undefined reference to `vtable for takeaway' takeaway.o: In function `~takeaway': project:151: undefined reference to `vtable for takeaway' pro...

How to run multiple .BAT files within a .BAT file

I'm trying to get my commit-build.bat to execute other .BAT files as part of our build process. Content of commit-build.bat: "msbuild.bat" "unit-tests.bat" "deploy.bat" This seems simple enough, but commit-build.bat only executes the first item i...

Simplest JQuery validation rules example

The following HTML form successfully utilizes jQuery's form validation, displaying "This field is required" to the right of the form field if left blank, and "Please enter at least 2 characters" if fewer than 2 characters were entered. However, inst...

Windows batch files: .bat vs .cmd?

As I understand it, .bat is the old 16-bit naming convention, and .cmd is for 32-bit Windows, i.e., starting with NT. But I continue to see .bat files everywhere, and they seem to work exactly the same using either suffix. Assuming that my code will ...

PHPExcel How to apply styles and set cell width and cell height to cell generated dynamically

I have form that I generate its content to Excel through PHPExcel, my problem is that how can I set width and height and also styles to the heading cells. the excel generated demo is here: the excel i want is here: here is my code: for ($col ...

Android Relative Layout Align Center

I am trying to create a List Activities Item Layout as follows <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_h...

How do you get a timestamp in JavaScript?

How can I get a timestamp in JavaScript? Something similar to Unix timestamp, that is, a single number that represents the current time and date. Either as a number or a string....

How to use multiple LEFT JOINs in SQL?

Is it possible to use multiple left joins in sql query? LEFT JOIN ab ON ab.sht = cd.sht i want to add to attach one more query like this to it? will it work? LEFT JOIN ab AND aa ON ab.sht = cd.sht ...

Something like 'contains any' for Java set?

I have two sets, A and B, of the same type. I have to find if A contains any element from the set B. What would be the best way to do that without iterating over the sets? The Set library has contains(object) and containsAll(collection), but not co...

Algorithm to find Largest prime factor of a number

What is the best approach to calculating the largest prime factor of a number? I'm thinking the most efficient would be the following: Find lowest prime number that divides cleanly Check if result of division is prime If not, find next lowest Go t...

How can I enable MySQL's slow query log without restarting MySQL?

I followed the instructions here: http://crazytoon.com/2007/07/23/mysql-changing-runtime-variables-with-out-restarting-mysql-server/ but that seems to only set the threshold. Do I need to do anything else like set the filepath? According to MySQL's...

How do I check if a SQL Server text column is empty?

I am using SQL Server 2005. I have a table with a text column and I have many rows in the table where the value of this column is not null, but it is empty. Trying to compare against '' yields this response: The data types text and varchar are ...

In HTML5, should the main navigation be inside or outside the <header> element?

In HTML5, I know that <nav> can be used either inside or outside the page's masthead <header> element. For websites having both secondary and main navigation, it seems common to include the secondary navigation as a <nav> element i...

Creating a JSON array in C#

Ok, so I am trying to send POST commands over an http connection, and using JSON formatting to do so. I am writing the program to do this in C#, and was wondering how I would format an array of values to be passed as JSON to the server. Currently...

Extract Month and Year From Date in R

I have tried a number of methods to no avail. I have data in terms of a date (YYYY-MM-DD) and am trying to get in terms of just the month and year, such as: MM-YYYY or YYYY-MM. Ultimately, I would like it to look like this: ID Date Month...

How to switch to another domain and get-aduser

I am on a server under the DomainA. I can use Get-ADUser and it's working fine. Now there is a trust built between DomainA and DomainB. I would like to switch to DomainB and get all the users that's in OU=New Users, DC=DomainB, DC=com. I tried thes...

Efficient thresholding filter of an array with numpy

I need to filter an array to remove the elements that are lower than a certain threshold. My current code is like this: threshold = 5 a = numpy.array(range(10)) # testing data b = numpy.array(filter(lambda x: x >= threshold, a)) The problem is ...

What JSON library to use in Scala?

I need to build a JSON string, something like this: [ { 'id': 1, 'name': 'John'}, { 'id': 2, 'name': 'Dani'} ] val jArray = JsArray(); jArray += (("id", "1"), ("name", "John")) jArray += (("id", "2"), ("name", "Dani")) println(jArray.dump) I ...

Singleton design pattern vs Singleton beans in Spring container

As we all know we have beans as singleton by default in Spring container and if we have a web application based on Spring framework then in that case do we really need to implement Singleton design pattern to hold global data rather than just creatin...

How do I prevent DIV tag starting a new line?

I want to output a single line of text to the browser that contains a tag. When this is rendered it appears that the DIV causes a new line. How can I include the content in the div tag on the same line - here is my code. <?php echo("<a hre...

Full examples of using pySerial package

Can someone please show me a full python sample code that uses pyserial, i have the package and am wondering how to send the AT commands and read them back!...

Get a worksheet name using Excel VBA

I would like to create an user-defined function in Excel that can return the current worksheet. I could use the sheetname = ActiveSheet.Name But the problem with this is, it works and suddenly it starts to get different sheet name. For example, ...

dyld: Library not loaded: /usr/local/lib/libpng16.16.dylib with anything php related

Using any php application results in: dyld: Library not loaded: /usr/local/lib/libpng15.15.dylib Referenced from: /usr/local/bin/php Reason: image not found [1] 4494 trace trap php Most of my php applications were installed using homebrew with...

Copying from one text file to another using Python

I would like to copy certain lines of text from one text file to another. In my current script when I search for a string it copies everything afterwards, how can I copy just a certain part of the text? E.g. only copy lines when it has "tests/file/my...

sendmail: how to configure sendmail on ubuntu?

When I searched for configuring sendmail on ubuntu I din't get any clear answer, each of them assume I know what they are talking about, I just want basic configuration to enable email sending, basically I will use it with google app engine to enabl...

How to enable CORS in apache tomcat

I am trying to consume some web services which are cross domain. When I disable chrome's web-security it is working fine. I want it to work without this so I have tried adding cross-domain.xml and still it didnt work. When i searched more, came to k...

Does Python support short-circuiting?

Does Python support short-circuiting in boolean expressions?...

How to stop/shut down an elasticsearch node?

I want to restart an elasticsearch node with a new configuration. What is the best way to gracefully shut down an node? Is killing the process the best way of shutting the server down, or is there some magic URL I can use to shut the node down?...

How to create an integer array in Python?

It should not be so hard. I mean in C, int a[10]; is all you need. How to create an array of all zeros for a random size. I know the zeros() function in NumPy but there must be an easy way built-in, not another module....

How can I make a button have a rounded border in Swift?

I'm building an app using swift in the latest version of Xcode 6, and would like to know how I can modify my button so that it can have a rounded border that I could adjust myself if needed. Once that's done, how can I change the color of the border ...

Maven: How to run a .java file from command line passing arguments

I have the following problem. I would like to run mvn from command line for a Main.java file. Main.java accepts a parameter. How do I do that from command line? I tried finding an example but I was not successful. Could someone help me by giving me ...

Using grep and sed to find and replace a string

I am using the following to search a directory recursively for specific string and replace it with another: grep -rl oldstr path | xargs sed -i 's/oldstr/newstr/g' This works okay. The only problem is that if the string doesn't exist then sed fail...

Best way to include CSS? Why use @import?

Basically I am wondering what is the advantage / purpose of using @import to import stylesheets into an existing stylesheet versus just adding another ... <link rel="stylesheet" type="text/css" href="" /> to the head of the document?...

How do I completely remove root password

I am running slitaz distro, and would like to completely remove the root password. I have tried giving a blank password to the passwd command, however that did not seem to do the trick. It gave me an error password was too short, ans it still asked m...

How to add reference to System.Web.Optimization for MVC-3-converted-to-4 app

I'm trying to use the new bundling feature in a project I recently converted from MVC 3 to MVC 4 beta. It requires a line of code in global.asax, BundleTable.Bundles.RegisterTemplateBundles();, which requires using System.Web.Optimization; at the top...

ActionBarActivity cannot resolve a symbol

In my android Studio, Compiler is not able to locate ActionBarActivity. Because of it, I am getting many errors. The compiler is not able to import the ActionBarActivity and ActionBar class. These are the lines where compiler is throwing error: imp...

How to check if a string contains a substring in Bash

I have a string in Bash: string="My string" How can I test if it contains another string? if [ $string ?? 'foo' ]; then echo "It's there!" fi Where ?? is my unknown operator. Do I use echo and grep? if echo "$string"...

How to detect window.print() finish

In my application, I tried to print out a voucher page for the user like this: var htm ="<div>Voucher Details</div>"; $('#divprint').html(htm); window.setTimeout('window.print()',2000); 'divprint' is a div in my page which store ...

Python: Is there an equivalent of mid, right, and left from BASIC?

I want to do something like this: >>> mystring = "foo" >>> print(mid(mystring)) Help!...

How to make an Android device vibrate? with different frequency?

I wrote an Android application. Now, I want to make the device vibrate when a certain action occurs. How can I do this?...

Cast Double to Integer in Java

Any way to cast java.lang.Double to java.lang.Integer? It throws an exception "java.lang.ClassCastException: java.lang.Double incompatible with java.lang.Integer" ...

what is the use of "response.setContentType("text/html")" in servlet

public class HelloWorld extends HttpServlet{ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException{ **response.setContentType("text/html");** PrintWriter pw = r...

How to update data in one table from corresponding data in another table in SQL Server 2005

I have two tables in different databases on the same database server. Both the databases have the same structure, but different data. Database1 (Test1) is the latest, and database2 (Test2) is an old copy of the database. Test1 has a table called E...

javascript: using a condition in switch case

Sorry for that dumb question. How can I use a condition for a case in the javascript switch-case language element? Like in the example below, a case should match when the variable liCount is <=5 and >0; however, my code does not work: switch (liC...

Failed to decode downloaded font

This is an error I am getting in Chrome and unfortunately searching for it hasn't given me much results. The font itself is appearing correctly. However I still get this error/warning. More specifically, this is the full warning: "Failed to decod...

How to disable the resize grabber of <textarea>?

How to disable the grabber in the <textarea>? I mean that triangle thing which appears in the right-bottom corner of the <textarea>....

Why I get 'list' object has no attribute 'items'?

Using Python 2.7, I have this list: qs = [{u'a': 15L, u'b': 9L, u'a': 16L}] I'd like to extract values out of it. i.e. [15, 9, 16] So I tried: result_list = [int(v) for k,v in qs.items()] But instead, I get this error: Traceback (most recen...

Matching an optional substring in a regex

I'm developing an algorithm to parse a number out of a series of short-ish strings. These strings are somewhat regular, but there's a few different general forms and several exceptions. I'm trying to build a set of regexes that will handle the variou...

collapse cell in jupyter notebook

I am using ipython Jupyter notebook. Let's say I defined a function that occupies a lot of space on my screen. Is there a way to collapse the cell? I want the function to remain executed and callable, yet I want to hide / collapse the cell in order...

Jquery Ajax Posting json to webservice

I am trying to post a JSON object to a asp.net webservice. My json looks like this: var markers = { "markers": [ { "position": "128.3657142857143", "markerPosition": "7" }, { "position": "235.1944023323615", "markerPosition": "19" }, { "posit...

SQL Inner-join with 3 tables?

I'm trying to join 3 tables in a view; here is the situation: I have a table that contains information of students who are applying to live on this College Campus. I have another table that lists the Hall Preferences (3 of them) for each Student. Bu...

php search array key and get value

I was wondering what is the best way to search keys in an array and return it's value. Something like array_search but for keys. Would a loop be the best way? Array: Array([20120425] => 409 [20120426] => 610 [20120427] => 277 [2012...

How to read a value from the Windows registry

Given the key for some registry value (e.g. HKEY_LOCAL_MACHINE\blah\blah\blah\foo) how can I: Safely determine that such a key exists. Programmatically (i.e. with code) get its value. I have absolutely no intention of writing anything back to the...

Remove All Event Listeners of Specific Type

I want to remove all event listeners of a specific type that were added using addEventListener(). All the resources I'm seeing are saying you need to do this: elem.addEventListener('mousedown',specific_function); elem.removeEventListener('mousedown'...

Read each line of txt file to new array element

I am trying to read every line of a text file into an array and have each line in a new element. My code so far. <?php $file = fopen("members.txt", "r"); while (!feof($file)) { $line_of_text = fgets($file); $members = explode(...

Cannot open local file - Chrome: Not allowed to load local resource

Test browser: Version of Chrome: 52.0.2743.116 It is a simple javascript that is to open an image file from local like 'C:\002.jpg' function run(){ var URL = "file:///C:\002.jpg"; window.open(URL, null); } run(); Here is my sample code....

Variable declaration in a header file

In case I have a variable that may be used in several sources - is it a good practice to declare it in a header? or is it better to declare it in a .c file and use extern in other files?...

NGINX to reverse proxy websockets AND enable SSL (wss://)?

I'm so lost and new to building NGINX on my own but I want to be able to enable secure websockets without having an additional layer. I don't want to enable SSL on the websocket server itself but instead I want to use NGINX to add an SSL layer to th...

iPhone Debugging: How to resolve 'failed to get the task for process'?

I have just added a provisioning profile to XCode (needed to support notifications and in app purchase), setup as needed the build configuration for ad hoc distribution, and tried to run the app on the device (I have done this several times in the pa...

How to negate 'isblank' function

I want to do "is not blank" in a custom formula. There is a isblank() function but I can find neither an isnotblank() function nor a way to say not, such as ! or ==False. How can I say is not blank?...

How to get the number of days of difference between two dates on mysql?

I need to get the number of days contained within a couple of dates on MySQL. For example: Check in date is 12-04-2010 Check out date 15-04-2010 The day difference would be 3 ...

How to create an Array with AngularJS's ng-model

I'm trying to create an array holding telephones, i have this code <input type="text" ng-model="telephone[0]" /> <input type="text" ng-model="telephone[1]" /> But i can't access $scope.telephone...

Creating and throwing new exception

How I can create and throw a new exception in PowerShell? I want to do different things for a specific error....

How to cast from List<Double> to double[] in Java?

I have a variable like that: List<Double> frameList = new ArrayList<Double>(); /* Double elements has added to frameList */ How can I have a new variable has a type of double[] from that variable in Java with high performance?...

Rendering HTML inside textarea

I need to be able to render some HTML tags inside a textarea (namely <strong>, <i>, <u>, <a>) but textareas only interpret their content as text. Is there an easy way of doing it without relying on external libraries/plugins (...

Android ADB commands to get the device properties

I am trying to get the device properties from ADB commands. I can how ever get those values by running sample android application. How ever I wish to get using adb shell command itself to make my life easier. Here is the way I will get through sample...

Can´t run .bat file under windows 10

I have few .bat files that I used under Windows XP. Now I want to use them under Windows 10, but when I run one of the files (even as administrator) it shows the command prompt screen for 1 second and nothing happens. Can someone help me please?...

Custom Cell Row Height setting in storyboard is not responding

I am trying to adjust the cell height for one of the cells on my table view. I am adjusting the size from the "row height" setting inside the "size inspector" of the cell in question. When I run the app on my iPhone the cell has the default size set ...

Django Multiple Choice Field / Checkbox Select Multiple

I have a Django application and want to display multiple choice checkboxes in a user's profile. They will then be able to select multiple items. This is a simplified version of my models.py: from profiles.choices import SAMPLE_CHOICES class Profi...

How should I print types like off_t and size_t?

I'm trying to print types like off_t and size_t. What is the correct placeholder for printf() that is portable? Or is there a completely different way to print those variables?...

Getting last month's date in php

I want to get last month's date. I wrote this out: $prevmonth = date('M Y'); Which gives me the current month/year. I can't tell if I should use strtotime, mktime. Something to the timestamp? Do I need to add something afterwards to reset so that...

TypeError: window.initMap is not a function

I am following this tutorial, basically copy all the code https://developers.google.com/maps/documentation/javascript/tutorial but got an error saying that the initMap function is not a function. I am using angularjs in my project, could that be ca...

Could not resolve this reference. Could not locate the assembly

Everytime I build my solution, I get this error message: Warning 3 Could not resolve this reference. Could not locate the assembly "StandardClassLibrary, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL". Check to make s...

How to make unicode string with python3

I used this : u = unicode(text, 'utf-8') But getting error with Python 3 (or... maybe I just forgot to include something) : NameError: global name 'unicode' is not defined Thank you....

Splitting a string into chunks of a certain size

Suppose I had a string: string str = "1111222233334444"; How can I break this string into chunks of some size? e.g., breaking this into sizes of 4 would return strings: "1111" "2222" "3333" "4444" ...

When would you use the Builder Pattern?

What are some common, real world examples of using the Builder Pattern? What does it buy you? Why not just use a Factory Pattern?...

Using ZXing to create an Android barcode scanning app

I've been searching for how to add a barcode scanner to my app. Are there any examples or how can I do this easily?...

Absolute positioning ignoring padding of parent

How do you make an absolute positioned element honor the padding of its parent? I want an inner div to stretch across the width of its parent and to be positioned at the bottom of that parent, basically a footer. But the child has to honor the paddin...

How to find the last field using 'cut'

Without using sed or awk, only cut, how do I get the last field when the number of fields are unknown or change with every line?...

How to sign an android apk file

I am trying to sign my apk file. I can't figure out how to do it. I can't find good in-depth directions. I have very little programing experience, so any help would be appreciated....

Call an overridden method from super class in typescript

When I'm calling an overridden method from the super class constructor, I cannot get a value of a sub class property correctly. example class A { constructor() { this.MyvirtualMethod(); } protected MyvirtualMethod(): void ...

Pair/tuple data type in Go

While doing the final exercise of the Tour of Go, I decided I needed a queue of (string, int) pairs. That's easy enough: type job struct { url string depth int } queue := make(chan job) queue <- job{url, depth} But this got me thinking...

Disable LESS-CSS Overwriting calc()

Right Now I'm trying to do this in CSS3 in my LESS code: width: calc(100% - 200px); However, when LESS compiles it is outputting this: width: calc(-100%); Is there a way to tell LESS not to compile it in that manner and to output it normally?...

Prevent form submission on Enter key press

I have a form with two text boxes, one select drop down and one radio button. When the enter key is pressed, I want to call my JavaScript function, but when I press it, the form is submitted. How do I prevent the form from being submitted when the en...

Setting unique Constraint with fluent API?

I'm trying to build an EF Entity with Code First, and an EntityTypeConfiguration using fluent API. creating primary keys is easy but not so with a Unique Constraint. I was seeing old posts that suggested executing native SQL commands for this, but th...

UITableView load more when scrolling to bottom like Facebook application

I am developing an application that uses SQLite. I want to show a list of users (UITableView) using a paginating mechanism. Could any one please tell me how to load more data in my list when the user scrolls to the end of the list (like on home page ...

Python Database connection Close

Using the code below leaves me with an open connection, how do I close? import pyodbc conn = pyodbc.connect('DRIVER=MySQL ODBC 5.1 driver;SERVER=localhost;DATABASE=spt;UID=who;PWD=testest') csr = conn.cursor() csr.close() del csr ...

Retrieve list of tasks in a queue in Celery

How can I retrieve a list of tasks in a queue that are yet to be processed?...

How do I resolve "Please make sure that the file is accessible and that it is a valid assembly or COM component"?

I am building a project with OpenCV in C#. It requires a dll file called cvextern.dll. but, when adding this file as a reference, this message appears :- a reference "cvextern.dll" can't be added, Please make sure that the file is accessible and tha...

In the shell, what does " 2>&1 " mean?

In a Unix shell, if I want to combine stderr and stdout into the stdout stream for further manipulation, I can append the following on the end of my command: 2>&1 So, if I want to use head on the output from g++, I can do something like thi...

Ignore python multiple return value

Say I have a Python function that returns multiple values in a tuple: def func(): return 1, 2 Is there a nice way to ignore one of the results rather than just assigning to a temporary variable? Say if I was only interested in the first value,...

How to filter keys of an object with lodash?

I have an object with some keys, and I want to only keep some of the keys with their value? I tried with filter: _x000D_ _x000D_ const data = {_x000D_ aaa: 111,_x000D_ abb: 222,_x000D_ bbb: 333_x000D_ };_x000D_ _x000D_ const result = _.filter...

Windows Batch: How to add Host-Entries?

I want to use this batch script to add new entries into my host file automatically by using windows batch. Unfortunately, the script just adds one single line to the hosts file, also when i run the script as a administrator, so what's wrong? @echo ...

Meaning of "487 Request Terminated"

Please tell me when a SIP call return 487 Request Terminated? Is it a termination issue?...

How do I check if a variable exists?

I want to check if a variable exists. Now I'm doing something like this: try: myVar except NameError: # Do something. Are there other ways without exceptions?...

Python get current time in right timezone

Right now I use import datetime print(datetime.datetime.now().strftime("%X")) to display the current time as a string. Problem is, my computer is running in Europe/Berlin time zone, and the offset of +2 to UTC is not accounted here. Instead of 19:...

SQL SERVER: Check if variable is null and then assign statement for Where Clause

I am trying to achieve something like the below in WHERE clause in sql. if (@zipCode ==null) begin ([Portal].[dbo].[Address].Position.Filter(@radiusBuff) = 1) end else if(@zipCode !=null) begin ([Portal].[dbo].[Address].PostalCode=@zipCode ) end...

How to find all occurrences of an element in a list

index() will give the first occurrence of an item in a list. Is there a neat trick which returns all indices in a list for an element?...

Best practice for storing and protecting private API keys in applications

Most app developers will integrate some third party libraries into their apps. If it's to access a service, such as Dropbox or YouTube, or for logging crashes. The number of third party libraries and services is staggering. Most of those libraries an...

How do I build JSON dynamically in javascript?

var myJSON = { "list1" : [ "1", "2" ], "list2" : [ "a", "b" ], "list3" : [ { "key1" : "value1" }, { "key2" : "value2" } ], "not_a_list" : "11" }; How do I dynamically build this...

Deleting rows with MySQL LEFT JOIN

I have two tables, one for job deadlines, one for describe a job. Each job can take a status and some statuses means the jobs' deadlines must be deleted from the other table. I can easily SELECT the jobs/deadlines that meets my criteria with a LEFT ...

How to get the current time in milliseconds in C Programming

Possible Duplicate: How to measure time in milliseconds using ANSI C? How can I get the Windows system time with millisecond resolution? We want to calculate the time which a player have taken to finish the game. But with time.h we could...

npm install -g less does not work: EACCES: permission denied

I'm trying to set up less on phpstorm so I can compile .less files to .css on save. I have installed node.js and the next step (according to this https://www.jetbrains.com/webstorm/help/transpiling-sass-less-and-scss-to-css.html) is running this comm...

Retrieve only the queried element in an object array in MongoDB collection

Suppose you have the following documents in my collection: { "_id":ObjectId("562e7c594c12942f08fe4192"), "shapes":[ { "shape":"square", "color":"blue" }, { "shape":"circle", "color"...

Have nginx access_log and error_log log to STDOUT and STDERR of master process

Is there a way to have the master process log to STDOUT STDERR instead of to a file? It seems that you can only pass a filepath to the access_log directive: access_log /var/log/nginx/access.log And the same goes for error_log: error_log /var/l...

MySQL stored procedure vs function, which would I use when?

I'm looking at MySQL stored procedures and function. What is the real difference? They seem to be similar, but a function has more limitations. I'm likely wrong, but it seems a stored procedure can do everything and more a stored function can. Why...

asp.net mvc @Html.CheckBoxFor

I have checkboxes in my form I added at my model using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace CorePartners_Site2.Models { public class CareerForm { //.... public List<CheckB...

How do you extract IP addresses from files using a regex in a linux shell?

How to extract a text part by regexp in linux shell? Lets say, I have a file where in every line is an IP address, but on a different position. What is the simplest way to extract those IP addresses using common unix command-line tools?...

In STL maps, is it better to use map::insert than []?

A while ago, I had a discussion with a colleague about how to insert values in STL maps. I preferred map[key] = value; because it feels natural and is clear to read whereas he preferred map.insert(std::make_pair(key, value)). I just asked him and nei...

Convert data file to blob

How to get a blob? HTML: <input type="file" onchange="previewFile()"> JavaScript: function previewFile() { var file = document.querySelector('input[type=file]').files[0]; var reader = new FileReader(); // Get blob? console.log...

Can't escape the backslash with regex?

I'm using the following regex ^[a-zA-Z0-9\',!;\?\$\^:\\\/`\|~&\" @#%\*\{}\(\)_\+\.\s=-]{1,1000}$ I know it's ugly, but so far it serves its purpose other than the backslash not being allowed as I think it should because it's escaped, I also tr...

What is the `data-target` attribute in Bootstrap 3?

Can you tell me what is the system or behavior behind the data-target attribute used by Bootstrap 3? I know that data-toggle used to aim API JavaScript of Bootstrap of graphical functionality....

How to create an installer for a .net Windows Service using Visual Studio

How do I create an installer for a Windows Service that I have created using Visual Studio?...

How to add empty spaces into MD markdown readme on GitHub?

I'm struggling to add empty spaces before the string starts to make my GitHub README.md looks something like this: Right now it looks like this: I tried adding <br /> tag to fix the new string start, now it works, but I don't understand h...

When do items in HTML5 local storage expire?

For how long is data stored in localStorage (as part of DOM Storage in HTML5) available? Can I set an expiration time for the data which I put into local storage?...

Graphviz: How to go from .dot to a graph?

I can't seem to figure this out. I have a .dot file, which is valid according to the syntax. How do I use graphviz to convert this into an image? (note that I'm on Windows, not linux)...

log4j configuration via JVM argument(s)?

What variables do I have to set/pass as arguments to the JVM to get log4j to run properly? And by properly I mean not complain and print to the console. Can I see a typical example? Note: I need to avoid creating a log4j.properties file in the appl...

How to check undefined in Typescript

I am using this code to check undefined variable but it's not working. _x000D_ _x000D_ var uemail = localStorage.getItem("useremail");_x000D_ _x000D_ if (typeof uemail === "undefined")_x000D_ {_x000D_ alert('undefined');_x000D_ }_x000D_ else_x0...

onclick event function in JavaScript

I have some JavaScript code in an HTML page with a button. I have a function called click() that handles the onClick event of the button. The code for the button is as follows: <input type="button" onClick="click()">button t...

jQuery Selector: Id Ends With?

Is there a selector that I can query for elements with an ID that ends with a given string? Say I have a element with an id of ctl00$ContentBody$txtTitle. How can I get this by passing just txtTitle?...

How to validate phone number using PHP?

How to validate phone number using php...

What is the proper way to display the full InnerException?

What is the proper way to show my full InnerException. I found that some of my InnerExceptions has another InnerException and that go's on pretty deep. Will InnerException.ToString() do the job for me or do i need to loop through the InnerException...

How do I check if a type is a subtype OR the type of an object?

To check if a type is a subclass of another type in C#, it's easy: typeof (SubClass).IsSubclassOf(typeof (BaseClass)); // returns true However, this will fail: typeof (BaseClass).IsSubclassOf(typeof (BaseClass)); // returns false Is there any w...

How to center a window on the screen in Tkinter?

I'm trying to center a tkinter window. I know I can programatically get the size of the window and the size of the screen and use that to set the geometry, but I'm wondering if there's a simpler way to center the window on the screen....

C++: constructor initializer for arrays

I'm having a brain cramp... how do I initialize an array of objects properly in C++? non-array example: struct Foo { Foo(int x) { /* ... */ } }; struct Bar { Foo foo; Bar() : foo(4) {} }; array example: struct Foo { Foo(int x) { /*...

How do I remove lines between ListViews on Android?

I'm using two ListViews like this: <ListView android:id="@+id/ListView" android:text="@string/Website" android:layout_height="30px" android:layout_width="150px" android:scrollbars="none" android:transcriptMode="normal"/> <...

How to convert a string to integer in C?

I am trying to find out if there is an alternative way of converting string to integer in C. I regularly pattern the following in my code. char s[] = "45"; int num = atoi(s); So, is there a better way or another way?...

Creating a node class in Java

So I'm fairly new to Java and programming and I was wondering how to create a node class? So far I have: public class ItemInfoNode{ private ItemInfoNode next; private ItemInfoNode prev; private ItemInfo info; public ItemInfoNode(I...

Why doesn't Mockito mock static methods?

I read a few threads here about static methods, and I think I understand the problems misuse/excessive use of static methods can cause. But I didn't really get to the bottom of why it is hard to mock static methods. I know other mocking frameworks, ...

Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (38)

I am having a big problem trying to connect to mysql. When I run: /usr/local/mysql/bin/mysql start I have the following error : Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (38) I do have mysql.sock under the /var/...

How do you delete all text above a certain line

How do you delete all text above a certain line. For deletion below a line I use "d shift g"...

how to File.listFiles in alphabetical order?

I've got code as below: class ListPageXMLFiles implements FileFilter { @Override public boolean accept(File pathname) { DebugLog.i("ListPageXMLFiles", "pathname is " + pathname); String regex = ".*pa...

Select columns based on string match - dplyr::select

I have a data frame ("data") with lots and lots of columns. Some of the columns contain a certain string ("search_string"). How can I use dplyr::select() to give me a subset including only the columns that contain the string? I tried: # columns as...

Can't access Tomcat using IP address

I'm running a Tomcat 5.5 instance (port: 8089) on Windows 7. The server runs correctly if I open http://localhost:8089/ but it gives me an error (Connection refused) on http://192.168.1.100:8089/ I thought it was a firewall issue...so I disabled it...

How to Reload ReCaptcha using JavaScript?

I have a signup form with AJAX so that I want to refresh Recaptcha image anytime an error is occured (i.e. username already in use). I am looking for a code compatible with ReCaptcha to reload it using JavaScript....

Coerce multiple columns to factors at once

I have a sample data frame like below: data <- data.frame(matrix(sample(1:40), 4, 10, dimnames = list(1:4, LETTERS[1:10]))) I want to know how can I select multiple columns and convert them together to factors. I usually do it in the way like d...

add/remove active class for ul list with jquery?

I'm trying to remove and set an active class for a list item every time it's clicked. It's currently removing the selected active class but isn't setting it. Any idea what I'm missing? HTML <ul class="nav nav-list"> <li class='nav-heade...

Copy text from nano editor to shell

Is it possible to copy text from a file, opened with nano, to the shell? I have a text file, and I want to copy several lines to the console, but I cannot find a keyboard shortcut to copy the text....

Install Visual Studio 2013 on Windows 7

I would like to install Visual Studio 2013 on Windows 7 64-bit. For some reason, the installer says "Setup Blocked" with an error "This version of Visual Studio requires a computer with a newer version of Windows". This error is not exactly descr...

Makefile: How to correctly include header file and its directory?

I have the following makefile: CC=g++ INC_DIR = ../StdCUtil CFLAGS=-c -Wall -I$(INC_DIR) DEPS = split.h all: Lock.o DBC.o Trace.o %.o: %.cpp $(DEPS) $(CC) -o $@ $< $(CFLAGS) clean: rm -rf *o all This makefile and all three source fil...

Git Extensions: Win32 error 487: Couldn't reserve space for cygwin's heap, Win32 error 0

Git Extensions: Everything was working fine until yesterday. But suddenly I am get this error when I try to pull some repositories using git extensions C:\Program Files\Git\bin\git.exe pull --progress "origin" Done 0 [main] us 0 init_cheap: V...

How does PHP 'foreach' actually work?

Let me prefix this by saying that I know what foreach is, does and how to use it. This question concerns how it works under the bonnet, and I don't want any answers along the lines of "this is how you loop an array with foreach". For a long time I...

Better way to check variable for null or empty string?

Since PHP is a dynamic language what's the best way of checking to see if a provided field is empty? I want to ensure that: null is considered an empty string a white space only string is considered empty that "0" is not considered empty This ...

ReactJs: What should the PropTypes be for this.props.children?

Given a simple component that renders its children: class ContainerComponent extends Component { static propTypes = { children: PropTypes.object.isRequired, } render() { return ( <div> {this.props.children} &...

How to write an inline IF statement in JavaScript?

How can I use an inline if statement in JavaScript? Is there an inline else statement too? Something like this: var a = 2; var b = 3; if(a < b) { // do something } ...

Bash script plugin for Eclipse?

Are there any decent bash plug-ins for Eclipse? My only requirement is syntax highlighting. I've googled about but did not see anything that looked like "the" bash plug-in. ...

Recommended website resolution (width and height)?

Is there any standard on common website resolution? We are targeting newer monitors, perhaps at least 1280px wide, but the height may varies, and each browser may have different toolbar heights too. Is there any sort of standard to this?...

Access maven properties defined in the pom

How do I access maven properties defined in the pom in a normal maven project, and in a maven plugin project?...

What does the KEY keyword mean?

In this MySQL table definition: CREATE TABLE groups ( ug_main_grp_id smallint NOT NULL default '0', ug_uid smallint default NULL, ug_grp_id smallint default NULL, KEY (ug_main_grp_id) ); What does the KEY keyword mean? It's not a primary...

time.sleep -- sleeps thread or process?

In Python for *nix, does time.sleep() block the thread or the process?...

Using FileSystemWatcher to monitor a directory

I am using a Windows Forms Application to monitor a directory and move the files dropped in it to another directory. At the moment it will copy the file to another directory, but when another file is added it will just end with no error message. Som...

Changing every value in a hash in Ruby

I want to change every value in a hash so as to add '%' before and after the value so { :a=>'a' , :b=>'b' } must be changed to { :a=>'%a%' , :b=>'%b%' } What's the best way to do this?...

How do I compare two variables containing strings in JavaScript?

I want compare two variables, that are strings, but I am getting an error. <script> var to_check=$(this).val(); var cur_string=$("#0").text(); var to_chk = "that"; var cur_str= "that"; if(to_chk==cur_str){ alert("b...

Creating a data frame from two vectors using cbind

Consider the following R code. > x = cbind(c(10, 20), c("[]", "[]"), c("[[1,2]]","[[1,3]]")) > x [,1] [,2] [,3] [1,] "10" "[]" "[[1,2]]" [2,] "20" "[]" "[[1,3]]" Similarly > x = rbind(c(10, "[]", "[[1,2]]"), c(20, "[]", "[[1,3]...

nginx: connect() failed (111: Connection refused) while connecting to upstream

Trying to deploy my first portal . I am getting 502 gateway timeout error in browser when i was sending the request through browser when i checked the logs , i got this error 2014/02/03 09:00:32 [error] 16607#0: *1 connect() failed (111: Connec...

How to use Object.values with typescript?

I am trying to form a comma separated string from an object, const data = {"Ticket-1.pdf":"8e6e8255-a6e9-4626-9606-4cd255055f71.pdf","Ticket-2.pdf":"106c3613-d976-4331-ab0c-d581576e7ca1.pdf"}; const values = Object.values(data).map(x => x.subst...

Including all the jars in a directory within the Java classpath

Is there a way to include all the jar files within a directory in the classpath? I'm trying java -classpath lib/*.jar:. my.package.Program and it is not able to find class files that are certainly in those jars. Do I need to add each jar file to th...

c++ exception : throwing std::string

I would like to throw an exception when my C++ methods encounter something weird and can't recover. Is it OK to throw a std::string pointer? Here's what I was looking forward to doing: void Foo::Bar() { if(!QueryPerformanceTimer(&m_baz)) { ...

Protecting cells in Excel but allow these to be modified by VBA script

I am using Excel where certain fields are allowed for user input and other cells are to be protected. I have used Tools Protect sheet, however after doing this I am not able to change the values in the VBA script. I need to restrict the sheet to stop...

How to convert string date to Timestamp in java?

I want to convert string Date into Timestamp in java. The following coding i have written.I have declare the date for date1 is: 7-11-11 12:13:14. SimpleDateFormat datetimeFormatter1 = new SimpleDateFormat( "yyyy-MM-dd hh:mm:ss"); Dat...

force client disconnect from server with socket.io and nodejs

Is there any way to disconnect a client with SocketIO, and literally close the connection? So if someone is connected to my server, and I want to close the connection between them and my server, how would I go about doing that?...

Capture key press (or keydown) event on DIV element

How do you trap the keypress or key down event on a DIV element (using jQuery)? What is required to give the DIV element focus?...

Best practice for REST token-based authentication with JAX-RS and Jersey

I'm looking for a way to enable token-based authentication in Jersey. I am trying not to use any particular framework. Is that possible? My plan is: A user signs up for my web service, my web service generates a token, sends it to the client, and th...

php convert datetime to UTC

I am in need of an easy way to convert a date time stamp to UTC (from whatever timezone the server is in) HOPEFULLY without using any libraries....

pull access denied repository does not exist or may require docker login

I am using Laravel 4.2 with docker. I setup it on local. It worked without any problem but when I am trying to setup online using same procedure then I am getting error pull access denied for <projectname>/php, repository does not exist or may...

REST API - Use the "Accept: application/json" HTTP Header

When I make a request, I get a response in XML, but what I need is JSON. In the doc it is stated in order to get a JSON in return: Use the Accept: application/json HTTP Header. Where do I find the HTTP Header to put Accept: application/json inside? ...

ERROR 1064 (42000): You have an error in your SQL syntax;

I have a MySQL commands: CREATE DATABASE IF NOT EXISTS courses; USE courses CREATE TABLE IF NOT EXISTS teachers( id INT(10) UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT, name VAR_CHAR(50) NOT NULL, addr VAR_CHAR(255) NOT NULL, phon...

What are Aggregates and PODs and how/why are they special?

This FAQ is about Aggregates and PODs and covers the following material: What are Aggregates? What are PODs (Plain Old Data)? How are they related? How and why are they special? What changes for C++11? ...

Moving from one activity to another Activity in Android

I want to move from one activity to another (using virtual device). When I click on button to move, My emulator ones a dialog box showing unfortunately SMS1 has stopped working (SMS1 is my app name). Can anybody help me in correcting my code? Main...

How to show android checkbox at right side?

By default android checkbox shows text at right side and checkbox at left I want to show checkbox at right side with text at left how do I achieve this?...

Algorithm to randomly generate an aesthetically-pleasing color palette

I'm looking for a simple algorithm to generate a large number of random, aesthetically pleasing colors. So no crazy neon colors, colors reminiscent of feces, etc. I've found solutions to this problem but they rely on alternative color palettes than...

Proper indentation for Python multiline strings

What is the proper indentation for Python multiline strings within a function? def method(): string = """line one line two line three""" or def method(): string = """line one line two line three""" or som...

How to convert array values to lowercase in PHP?

How can I convert all values in an array to lowercase in PHP? Something like array_change_key_case?...

Getting the source of a specific image element with jQuery

I have many image elements and want to get a specific image's source where the alternative text is "example". I tried this: var src = $('.conversation_img').attr('src'); but I can't get the one I need with that. How do I select a specific image ...

How to get jQuery to wait until an effect is finished?

I am sure I read about this the other day but I can't seem to find it anywhere. I have a fadeOut() event after which I remove the element, but jQuery is removing the element before it has the chance to finish fading out. How do I get jQuery to wait u...

Code for best fit straight line of a scatter plot in python

Below is my code for scatter plotting the data in my text file. The file I am opening contains two columns. The left column is x coordinates and the right column is y coordinates. the code creates a scatter plot of x vs. y. I need a code to overplot ...

How to JSON decode array elements in JavaScript?

I have a JavaScript array that, among others, contains a URL. If I try to simply put the URL in the page (the array is in a project involving the Yahoo! Maps API) it shows the URL as it should be. But if I try to do a redirect or simply do an 'alert...

Change the color of glyphicons to blue in some- but not at all places using Bootstrap 2

I am using the Bootstrap framework for my UI. I want to change the color of my glyphicons to blue, but not in all places. In some places it should use the default color. I have referred to these two links, but I am not finding anything helpful. Ca...

Homebrew install specific version of formula?

How do I install a specific version of a formula in homebrew? For example, postgresql-8.4.4 instead of the latest 9.0....

"Fade" borders in CSS

I'm using border-left: groove on an element but I want the border to "fade" into the background as it's about to end at the bottom. I hope I'm making sense. How would I achieve something to that effect? ...

'IF' in 'SELECT' statement - choose output value based on column values

SELECT id, amount FROM report I need amount to be amount if report.type='P' and -amount if report.type='N'. How do I add this to the above query?...

jQuery: select an element's class and id at the same time?

I've got some links that I want to select class and id at the same time. This is because I've got 2 different behaviours. When a class of links got one class name they behave in one way, when the same clas of links got another class name they behave...

How can jQuery deferred be used?

jQuery 1.5 brings the new Deferred object and the attached methods .when, .Deferred and ._Deferred. For those who haven't used .Deferred before, I've annotated the source for it. What are the possible usages of these new methods, how do we go about...

How do I parse a HTML page with Node.js

I need to parse (server side) big amounts of HTML pages. We all agree that regexp is not the way to go here. It seems to me that javascript is the native way of parsing a HTML page, but that assumption relies on the server side code having all the DO...

Remote Procedure call failed with sql server 2008 R2

I am working with SQL Server 2008 R2. I am unable to connect to my database remotely. I got the following error. A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or w...

How to split long commands over multiple lines in PowerShell

How do you take a command like the following in PowerShell and split it across multiple lines? &"C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe" -verb:sync -source:contentPath="c:\workspace\xxx\master\Build\_PublishedWebsites\xxx.Web" -d...

Flutter: how to make a TextField with HintText but no Underline?

This is what I'm trying to make: In the Flutter docs for Text Fields (https://flutter.io/text-input/) it says you can remove the underline by passing null to the decoration. However, that also gets rid of the hint text. I do not want any underli...

XMLHttpRequest (Ajax) Error

I'm using XMLHttpRequest in JavaScript. However, it gives me an error, and I don't know what my problem is. I have to parse an XML file and assign its contents to the webpage - here's my code: <script = "text/javascript"> window.onload = ...

Can I define a class name on paragraph using Markdown?

Can I define a class name on paragraph using Markdown? If so, how?...

find filenames NOT ending in specific extensions on Unix?

Is there a simple way to recursively find all files in a directory hierarchy, that do not end in a list of extensions? E.g. all files that are not *.dll or *.exe UNIX/GNU find, powerful as it is, doesn't seem to have an exclude mode (or I'm missing ...

CSS media queries: max-width OR max-height

When writing a CSS media query, is there any way you can specify multiple conditions with "OR" logic? I'm attempting to do something like this: /* This doesn't work */ @media screen and (max-width: 995px OR max-height: 700px) { ... } ...

In c, in bool, true == 1 and false == 0?

Just to clarify I found similar answer but for C++, I'm kinda new to coding so I'm not sure whether it applies to C as well....

Converting strings to floats in a DataFrame

How to covert a DataFrame column containing strings and NaN values to floats. And there is another column whose values are strings and floats; how to convert this entire column to floats. ...

How to convert a std::string to const char* or char*?

How can I convert an std::string to a char* or a const char*?...

What does the SQL Server Error "String Data, Right Truncation" mean and how do I fix it?

We are doing some performance tests on our website and we are getting the following error a lot: *** 'C:\inetpub\foo.plex' log message at: 2008/10/07 13:19:58 DBD::ODBC::st execute failed: [Microsoft][SQL Native Client]String data, right truncation ...

How to initialize log4j properly?

After adding log4j to my application I get the following output every time I execute my application: log4j:WARN No appenders could be found for logger (slideselector.facedata.FaceDataParser). log4j:WARN Please initialize the log4j system properly. ...

long long in C/C++

I am trying this code on GNU's C++ compiler and am unable to understand its behaviour: #include <stdio.h>; int main() { int num1 = 1000000000; long num2 = 1000000000; long long num3; //num3 = 100000000000; long long num4 ...

How to format strings in Java

Primitive question, but how do I format strings like this: "Step {1} of {2}" by substituting variables using Java? In C# it's easy....

UnsatisfiedDependencyException: Error creating bean with name

For several days I'm trying to create Spring CRUD application. I'm confused. I can't solve this errors. org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'clientController': Unsatisfied dependency exp...

Update MySQL version from 5.1 to 5.5 in CentOS 6.2

I tried to update MySQL from 5.1 to 5.5 in CentOS 6.2. The following is the process I did: 1. rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm 2. yum install libmysqlclient15 --enablerepo=webtatic 3. yum remove mysql mysql-* 4. yum install ...

Unable to connect to any of the specified mysql hosts. C# MySQL

I am getting the above error when I execute the code - MySqlConnection mysqlConn=new MySqlConnection("server=127.0.0.1;uid=pankaj;port=3306;pwd=master;database=patholabs;"); mysqlConn.Open(); I have tried setting server to localhost, user ...

'tsc command not found' in compiling typescript

I want to install typescript, so I used the following command: npm install -g typescript and test tsc --version, but it just show 'tsc command not found'. I have tried many ways as suggested in stackoverflow, github and other sites. but it doesn'...

How does createOrReplaceTempView work in Spark?

I am new to Spark and Spark SQL. How does createOrReplaceTempView work in Spark? If we register an RDD of objects as a table will spark keep all the data in memory? ...

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2:java (default-cli)

Im working on Smooks - Camel Integration.Im stuck with an error.The Build Fails when I try to Run it using mvn exec:java [ERROR]: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2:java (default-cli) on project camel-example...

What are some examples of commonly used practices for naming git branches?

I've been using a local git repository interacting with my group's CVS repository for several months, now. I've made an almost neurotic number of branches, most of which have thankfully merged back into my trunk. But naming is starting to become an...

Reason to Pass a Pointer by Reference in C++?

Under which circumstances would you want to use code of this nature in c++? void foo(type *&in) {...} void fii() { type *choochoo; ... foo(choochoo); } ...

How can I add an item to a ListBox in C# and WinForms?

I'm having trouble figuring out how to add items to a ListBox in WinForms. I have tried: list.DisplayMember = "clan"; list.ValueMember = sifOsoba; How can I add ValueMember to the list with an int value and some text for the DisplayMember? list....

HTML/CSS: Making two floating divs the same height

I have a little peculiar problem that I currently solve using a table, see below. Basically, I want to have two divs take up 100% of the available width, but only take up as much vertical space as needed (which isn't really that obvious from the pic...

How to redirect output of an already running process

Normally I would start a command like longcommand &; I know you can redirect it by doing something like longcommand > /dev/null; for instance to get rid of the output or longcommand 2>&1 > output.log to capture output. But...