Examples On Programing Languages

How to display a Windows Form in full screen on top of the taskbar?

I have a .net windows application that needs to run in full screen. When the application starts however the taskbar is shown on top of the main form and it only disappears when activating the form by clicking on it or using ALT-TAB. The form's curren...

Can typescript export a function?

Is it possible to export a simple function from a typescript module? This isn't compiling for me. module SayHi { export function() { console.log("Hi"); } } new SayHi(); This workitem seems to imply that you cannot but doesn't flat out s...

maximum value of int

Is there any code to find the maximum value of integer (accordingly to the compiler) in C/C++ like Integer.MaxValue function in java?...

How to encode Doctrine entities to JSON in Symfony 2.0 AJAX application?

I'm developing game app and using Symfony 2.0. I have many AJAX requests to the backend. And more responses is converting entity to JSON. For example: class DefaultController extends Controller { public function launchAction() { ...

ImportError: No module named pandas

I am trying to write a code in python to fetch twitter data i am not getting error for twython. But i am getting error for pandas. I have installed pandas using pip install pandas. But i still get this error . Please help F:\>pip install pandas...

CRC32 C or C++ implementation

I'm looking for an implementation of CRC32 in C or C++ that is explicitly licensed as being no cost or public domain. The implementation here seems nice, but the only thing it says about the license is "source code", which isn't good enough. I'd pr...

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

excel - if cell is not blank, then do IF statement

I have this simple statement in excel. I compare two dates. If the date 2 is greater than or equal to date 1, then I show 1. If not, then I show 0. However, I would like to apply this function only when the cells contains text: IF(NOT(ISBLANK((Q2&l...

SQL Server 2012 can't start because of a login failure

I recently installed Microsoft SQL Server 2012 on a fresh Windows 7 installation, but whenever I want to run the server, I get the following error: Error 1069: The service did not start due to a logon failure. The following user is configured t...

Spring 3 MVC resources and tag <mvc:resources />

I'm having some problems with the tag (Spring 3.0.5). I want to add images to my web application, but it doesnt work. Here is part of my beans config: <mvc:annotation-driven/> <mvc:default-servlet-handler default-servlet-name="ideafactory...

Why do I have ORA-00904 even when the column is present?

I see an error while executing hibernate sql query. java.sql.SQLException: ORA-00904: "table_name"."column_name": invalid identifier When I open up the table in sqldeveloper, the column is present. The error is only happening in PROD, not i...

How to override the path of PHP to use the MAMP path?

After screwing up entirely my PHP configuration on MAC trying to get the SOAP module working (-bash: /usr/bin/php: No such file or directory ....) I now have to use MAMP but each time I have to type the path Applications/MAMP/bin/php5.3/bin/php to ...

check if a file is open in Python

In my app, I write to an excel file. After writing, the user is able to view the file by opening it. But if the user forgets to close the file before any further writing, a warning message should appear. So I need a way to check this file is open bef...

fatal: 'origin' does not appear to be a git repository

I've a repository moodle on my Github account which I forked from the official repository. I then cloned it on my local machine. It worked fine. I created several branches (under the master branch). I made several commits and it worked fine. I don...

Limit number of characters allowed in form input text field

How do I limit or restrict the user to only enter a maximum of five characters in the textbox? Below is the input field as part of my form: <input type="text" id="sessionNo" name="sessionNum" /> Is it using something like maxSize or somethi...

Using os.walk() to recursively traverse directories in Python

I want to navigate from the root directory to all other directories within and print the same. Here's my code: #!/usr/bin/python import os import fnmatch for root, dir, files in os.walk("."): print root print "" for items ...

Git Bash: Could not open a connection to your authentication agent

I'm new to Github and Generating SSH Keys look a neccessity. And was informed by my boss about this, so I need to comply. I successfully created SSH Key but when I'm going to add it to the ssh-agent this is what happens What seems to be the proble...

Submitting the value of a disabled input field

I want to disable an input field, but when I submit the form it should still pass the value. Use case: I am trying to get latitude and longitude from Google Maps and wanna display it, but I don't want the user to edit it. Is this possible?...

How to git commit a single file/directory

Tried the following command: git commit path/to/my/file.ext -m 'my notes' Receive an error in git version 1.5.2.1: error: pathspec '-m' did not match any file(s) known to git. error: pathspec 'MY MESSAGE' did not match any file(s) known to git. ...

Is it possible to insert multiple rows at a time in an SQLite database?

In MySQL you can insert multiple rows like this: INSERT INTO 'tablename' ('column1', 'column2') VALUES ('data1', 'data2'), ('data1', 'data2'), ('data1', 'data2'), ('data1', 'data2'); However, I am getting an error when I try to do ...

Rails server says port already used, how to kill that process?

I'm on a mac, doing: rails server I get: 2010-12-17 12:35:15] INFO WEBrick 1.3.1 [2010-12-17 12:35:15] INFO ruby 1.8.7 (2010-08-16) [i686-darwin10.4.0] [2010-12-17 12:35:15] WARN TCPServer Error: Address already in use - bind(2) Exiting I kn...

Div not expanding even with content inside

I have a stack of divs inside of each other, all of which have an ID which specifies CSS only. But for some reason the surrounding DIV tag only expands to it's anointed height value, and not it's default auto, meaning that although the content is in...

How to replace multiple strings in a file using PowerShell

I am writing a script for customising a configuration file. I want to replace multiple instances of strings within this file, and I tried using PowerShell to do the job. It works fine for a single replace, but doing multiple replaces is very slow be...

Accessing a value in a tuple that is in a list

[(1,2), (2,3), (4,5), (3,4), (6,7), (6,7), (3,8)] How do I return the 2nd value from each tuple inside this list? Desired output: [2, 3, 5, 4, 7, 7, 8] ...

Escape regex special characters in a Python string

Does Python have a function that I can use to escape special characters in a regular expression? For example, I'm "stuck" :\ should become I\'m \"stuck\" :\\....

How to extract a substring using regex

I have a string that has two single quotes in it, the ' character. In between the single quotes is the data I want. How can I write a regex to extract "the data i want" from the following text? mydata = "some string with 'the data i want' inside"; ...

Difference between datetime and timestamp in sqlserver?

What is the difference between Timestamp and Datetime SQL Server? I thought Both formats are capable of storing date + time. Then, Where the difference is lying between them? But Timestamp is not capable of storing date, time information. Still Wh...

Call javascript from MVC controller action

Can I call javascript function from MVC controller action (not from view page) and get return value? How? I need to make request to server from code (.cs) using javascript like here (but this is aspx page) function getInitData() { var code; code...

Numbering rows within groups in a data frame

Working with a data frame similar to this: set.seed(100) df <- data.frame(cat = c(rep("aaa", 5), rep("bbb", 5), rep("ccc", 5)), val = runif(15)) df <- df[order(df$cat, df$val), ] df cat val 1 aaa 0.05638315 ...

element with the max height from a set of elements

I have a set of div elements. In jQuery, I would like to be able to find out the div with the maximum height and also the height of that div. For instance: <div> <div class="panel"> Line 1 Line 2 </div> <div class...

Correct way to handle conditional styling in React

I'm doing some React right now and I was wondering if there is a "correct" way to do conditional styling. In the tutorial they use style={{ textDecoration: completed ? 'line-through' : 'none' }} I prefer not to use inline styling so I want to in...

Chrome Dev Tools - Modify javascript and reload

Is it possible to modify the JavaScript of a page and then reload the page without reloading the modified JavaScript file (and thus losing modifications)?...

Value does not fall within the expected range

I am using the following code to update a listbox, this recieving a list from a Web service: client.userKeywordsCompleted += new EventHandler<userKeywordsCompletedEventArgs>(client_userKeywordsCompleted); client.userKeywordsAsync(); Using: ...

Initial size for the ArrayList

You can set the initial size for an ArrayList by doing ArrayList<Integer> arr=new ArrayList<Integer>(10); However, you can't do arr.add(5, 10); because it causes an out of bounds exception. What is the use of setting an initial siz...

Bash scripting missing ']'

I am getting an error ./test.sh: line 13: [: missing `]' in the file test.sh I tried using brackets and other options such as -a or by checking the size of the file p1 but the error is always there and the else statement is always executed irrespecti...

How to install python-dateutil on Windows?

I'm trying to convert some date/times to UTC, which I thought would be dead simple in Python - batteries included, right? Well, it would be simple except that Python (2.6) doesn't include any tzinfo classes. No problem, a quick search turns up python...

Cannot run the macro... the macro may not be available in this workbook

I am trying to call a sub on a different worksheet but I got a run time error message. Specifically, I have two worksheets and multiple VBA sub s in those worksheets. In one of the VBA Project (say workbook1.xlsm), I have the following code: Sub A...

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

Change onClick attribute with javascript

This is my function and it should change the onClick attribute of the HTML input, but if I use document.getElementById('buttonLED'+id).onclick = "writeLED(1,1)"; it does not work at all, but if I use document.getElementById('buttonLED'+id).oncli...

Detecting when the 'back' button is pressed on a navbar

I need to perform some actions when the back button(return to previous screen, return to parent-view) button is pressed on a Navbar. Is there some method I can implement to catch the event and fire off some actions to pause and save data before the ...

Specifying content of an iframe instead of the src attribute to a page

I'm currently working on a form which includes some file inputs to upload pictures. There is an onchange() event for those inputs that submits the pictures to an iframe, then dynamically loads the uploaded pictures into the form, with fields to be mo...

Java Synchronized list

I have a pre-populated array list. And I have multiple threads which will remove elements from the array list. Each thread calls the remove method below and removes one item from the list. Does the following code give me consistent behavior ? ArrayL...

Use a.empty, a.bool(), a.item(), a.any() or a.all()

import random import pandas as pd heart_rate = [random.randrange(45,125) for _ in range(500)] blood_pressure_systolic = [random.randrange(140,230) for _ in range(500)] blood_pressure_dyastolic = [random.randrange(90,140) for _ in range(500)] tempera...

how to console.log result of this ajax call?

I have the following function in jQuery code: btnLogin.on('click', function(e,errorMessage){ console.log('my message' + errorMessage); e.preventDefault(); return $.ajax({ type: 'POST', url: 'loginCheck', data: $(...

Can I add color to bootstrap icons only using CSS?

Twitter's bootstrap uses Icons by Glyphicons. They are "available in dark gray and white" by default: Is it possible to use some CSS trickery to change the colors of the icons? I was hoping for some other css3 brilliance that would prevent having ...

Comparing arrays in JUnit assertions, concise built-in way?

Is there a concise, built-in way to do equals assertions on two like-typed arrays in JUnit? By default (at least in JUnit 4) it seems to do an instance compare on the array object itself. EG, doesn't work: int[] expectedResult = new int[] { 116800...

How to access List elements

I have a list list = [['vegas','London'],['US','UK']] How to access each element of this list?...

How to store date/time and timestamps in UTC time zone with JPA and Hibernate

How can I configure JPA/Hibernate to store a date/time in the database as UTC (GMT) time zone? Consider this annotated JPA entity: public class Event { @Id public int id; @Temporal(TemporalType.TIMESTAMP) public java.util.Date date;...

How to set the max size of upload file

I'm developing application based on Spring Boot and AngularJS using JHipster. My question is how to set max size of uploading files? If I'm trying to upload to big file I'm getting this information in console: DEBUG 11768 --- [io-8080-exec-10] c....

java : convert float to String and String to float

How could I convert from float to string or string to float? In my case I need to make the assertion between 2 values string (value that I have got from table) and float value that I have calculated. String valueFromTable = "25"; Float valueCalcula...

What's the difference between HTML 'hidden' and 'aria-hidden' attributes?

I have been seeing the aria attribute all over while working with Angular Material. Can someone explain to me, what the aria prefix means? but most importantly what I'm trying to understand is the difference between aria-hidden and hidden attribute....

MultipartException: Current request is not a multipart request

I am trying to make a restful controller to upload files. I have seen this and made this controller: @RestController public class MaterialController { @RequestMapping(value="/upload", method= RequestMethod.POST) public String handleFileUpl...

Opening a SQL Server .bak file (Not restoring!)

I have been reading a LOT of google posts and StackOverflow questions about how to restore a database in SQL Server from a .bak file. But none of them states how to just READ the tables in the database-backup. (None that I could find anyway?) I jus...

How to trim a string after a specific character in java

I have a string variable in java having value: String result="34.1 -118.33\n<!--ABCDEFG-->"; I want my final string to contain the value: String result="34.1 -118.33"; How can I do this? I'm new to java programming language. Thanks,...

How can I remove an element from a list?

I have a list and I want to remove a single element from it. How can I do this? I've tried looking up what I think the obvious names for this function would be in the reference manual and I haven't found anything appropriate....

How to increase request timeout in IIS?

How to increase request timeout in IIS 7.0? The same is done under application tab in ASP configuration settngs in IIS 6.0. I am not able to find the asp.net configuration section in IIS 7.0...

cast a List to a Collection

i have some pb. I want to cast a List to Collection in java Collection<T> collection = new Collection<T>(mylList); but i have this error Can not instantiate the type Collection ...

How an 'if (A && B)' statement is evaluated?

if( (A) && (B) ) { //do something } else //do something else The question is, would the statement immediately break to else if A was FALSE. Would B even get evaluated? I ask this in the case that B checking the validity of an array ...

C# windows application Event: CLR20r3 on application start

I created a C# application and installed it on my test box. My app works perfect on my dev box, but when I install in on a different machine it crashes in the Main(). I get the EventType: CLR20r3 here is the Event Message Problem signature: ...

Android studio Error "Unsupported Modules Detected: Compilation is not supported for following modules"

I am using Android studio 1.0.1. I have a java module referred by other modules in my project. I have checked it out from SVN But now every Unsupported Modules Detected: Compilation is not supported for following modules: . Unfortunately you can't ...

How to disable all div content

I was under the assumption that if I disabled a div, all content got disabled too. However, the content is grayed but I can still interact with it. Is there a way to do that? (disable a div and get all content disabled also)...

Getting the exception value in Python

If I have that code: try: some_method() except Exception, e: How can I get this Exception value (string representation I mean)?...

The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'Negotiate,NTLM'

I've looked through a ton of SO articles, and even other sites, but can't seem to get this service working. I have a SOAP service I'm trying to hit and it's configured like this: <system.serviceModel> <bindings> <basicHttp...

Java Multiple Inheritance

In an attempt to fully understand how to solve Java's multiple inheritance problems I have a classic question that I need clarified. Lets say I have class Animal this has sub classes Bird and Horse and I need to make a class Pegasus that extends fro...

Convert integer to binary in C#

How to convert an integer number into its binary representation? I'm using this code: String input = "8"; String output = Convert.ToInt32(input, 2).ToString(); But it throws an exception: Could not find any parsable digits ...

How to check a radio button with jQuery?

I try to check a radio button with jQuery. Here's my code: <form> <div id='type'> <input type='radio' id='radio_1' name='type' value='1' /> <input type='radio' id='radio_2' name='type' value='2' /> ...

How to get a path to the desktop for current user in C#?

How do I get a path to the desktop for current user in C#? The only thing I could find was the VB.NET-only class SpecialDirectories, which has this property: My.Computer.FileSystem.SpecialDirectories.Desktop How can I do this in C#?...

builder for HashMap

Guava provides us with great factory methods for Java types, such as Maps.newHashMap(). But are there also builders for java Maps? HashMap<String,Integer> m = Maps.BuildHashMap. put("a",1). put("b",2). build(); ...

Unable to execute dex: method ID not in [0, 0xffff]: 65536

I have seen various versions of the dex erros before, but this one is new. clean/restart etc won't help. Library projects seems intact and dependency seems to be linked correctly. Unable to execute dex: method ID not in [0, 0xffff]: 65536 Conversio...

Convert a negative number to a positive one in JavaScript

Is there a math function in JavaScript that converts numbers to positive value?...

How does DHT in torrents work?

I'm coding a p2p implementation that I would like to make decentralized however I'm having some trouble grasping how DHT in protocols like bittorrent work. How does the client know where the peers are if there is no tracker? Are peers stored in the a...

How would I check a string for a certain letter in Python?

How would I tell Python to check the below for the letter x and then print "Yes"? The below is what I have so far... dog = "xdasds" if "x" is in dog: print "Yes!" ...

postgres: upgrade a user to be a superuser?

In postgres, how do I change an existing user to be a superuser? I don't want to delete the existing user, for various reasons. # alter user myuser ...? ...

Get property value from C# dynamic object by string (reflection?)

Imagine that I have a dynamic variable: dynamic d = *something* Now, I create properties for d which I have on the other hand from a string array: string[] strarray = { 'property1','property2',..... } I don't know the property names in advance....

Which is fastest? SELECT SQL_CALC_FOUND_ROWS FROM `table`, or SELECT COUNT(*)

When you limit the number of rows to be returned by a SQL query, usually used in paging, there are two methods to determine the total number of records: Method 1 Include the SQL_CALC_FOUND_ROWS option in the original SELECT, and then get the total ...

Amazon S3 exception: "The specified key does not exist"

I am using the AmazonS3Client in an Android app using a getObject request to download an image from my Amazon S3 bucket. Currently, I am getting this exception: com.amazonaws.services.s3.model.AmazonS3Exception: The specified key does not exist. ...

What method in the String class returns only the first N characters?

I'd like to write an extension method to the String class so that if the input string to is longer than the provided length N, only the first N characters are to be displayed. Here's how it looks like: public static string TruncateLongString(this s...

What is LDAP used for?

I know that LDAP is used to provide some information and to help facilitate authorization. But what are the other usages of LDAP? ...

OpenCV TypeError: Expected cv::UMat for argument 'src' - What is this?

Disclaimer: huge openCV noob Traceback (most recent call last): File "lanes2.py", line 22, in canny = canny(lane_image) File "lanes2.py", line 5, in canny gray = cv2.cvtColor(imgUMat, cv2.COLOR_RGB2GRAY) TypeError: Expected cv...

Where does Jenkins store configuration files for the jobs it runs?

I'm adding continuous integration to an EC2 project at work using Jenkins. The Jenkins machine itself is kept on an EC2 machine - one that might need to be taken offline and brought back on an entirely different EC2 instance at any point. We have a b...

How to exit from the application and show the home screen?

I have an application where on the home page I have buttons for navigation through the application. On that page I have a button "EXIT" which when clicked should take the user to the home screen on the phone where the application icon is. How can I...

Leader Not Available Kafka in Console Producer

I am trying to use Kafka. All configurations are done properly but when I try to produce message from console I keep getting the following error WARN Error while fetching metadata with correlation id 39 : {4-3-16-topic1=LEADER_NOT_AVAILABLE} (...

How to call external JavaScript function in HTML

I have a small chunk of code I can't seem to get working. I am building a website and using JavaScript for the first time. I have my JavaScript code in an external file 'Marq_Msg.js' which looks like this: var Messages = new Array(); Messages[0] = "...

Send response to all clients except sender

To send something to all clients, you use: io.sockets.emit('response', data); To receive from clients, you use: socket.on('cursor', function(data) { ... }); How can I combine the two so that when recieving a message on the server from a clien...

Static Vs. Dynamic Binding in Java

I'm currently doing an assignment for one of my classes, and in it, I have to give examples, using Java syntax, of static and dynamic binding. I understand the basic concept, that static binding happens at compile time and dynamic binding happens at...

PUT vs. POST in REST

According to the HTTP/1.1 Spec: The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line In other words, POST is ...

ASP.NET document.getElementById('<%=Control.ClientID%>'); returns null

I'm trying to retrieve a server control in JavaScript. For testing purposes I am calling the JavaScript function from the page load event. protected void Page_Load(object sender, EventArgs e){ ClientScript.RegisterClientScriptBlock(GetType(), "j...

.htaccess or .htpasswd equivalent on IIS?

Does anyone know if there is an equivalent to .htaccess and .htpassword for IIS ? I am being asked to migrate an app to IIS that uses .htaccess to control access to sets of files in various URLs based on the contents of .htaccess files. I did a goo...

Bin size in Matplotlib (Histogram)

I'm using matplotlib to make a histogram. Is there any way to manually set the size of the bins as opposed to the number of bins?...

Error: "dictionary update sequence element #0 has length 1; 2 is required" on Django 1.4

I have an error message on django 1.4: dictionary update sequence element #0 has length 1; 2 is required [EDIT] It happened when I tried using a template tag like: `{% for v in values %}: dictionary update sequence element #0 has length 1; 2 ...

Posting a File and Associated Data to a RESTful WebService preferably as JSON

This is probably going to be a stupid question but I'm having one of those nights. In an application I am developing RESTful API and we want the client to send data as JSON. Part of this application requires the client to upload a file (usually an im...

perform an action on checkbox checked or unchecked event on html form

I have a checkbox on a form which is unchecked by default as usual. now I want to perform two separated actions on checked and unchecked state of this checkbox. this is my checkbox: <form> syn<input type="checkbox" name="checkfield" id...

How can I open an Excel file in Python?

How do I open a file that is an Excel file for reading in Python? I've opened text files, for example, sometextfile.txt with the reading command. How do I do that for an Excel file?...

Maximum number of threads in a .NET app?

What is the maximum number of threads you can create in a C# application? And what happens when you reach this limit? Is an exception of some kind thrown?...

Convert a Python int into a big-endian string of bytes

I have a non-negative int and I would like to efficiently convert it to a big-endian string containing the same data. For example, the int 1245427 (which is 0x1300F3) should result in a string of length 3 containing three characters whose byte value...

How can one display images side by side in a GitHub README.md?

I'm trying to show a comparison between two photos in my README.md which is why I want to display them side-by-side. Here is how the two images are placed currently. I want to show the two Solarized color schemes side by side instead of top and botto...

jQuery function to open link in new window

I'm trying to find a plugin or simple script to open a file in a popup window by clicking on a button. This used to work, but with all the jQuery updates (even with the migration file), this no longer works. I found this, but this opens the popup an...

git returns http error 407 from proxy after CONNECT

I have a problem while connecting to github from my PC, using git. System Win 7. I have connection through proxy, so i specified it in git config files (both in general git folder, and in git repo folder). To do this i entered next line to my git bu...

Adb install failure: INSTALL_CANCELED_BY_USER

I try to install app via adb and get a error: $ ./adb -d install /Users/dimon/Projects/one-place/myprogram/platforms/android/build/outputs/apk/android-debug.apk -r -g 3704 KB/s (4595985 bytes in 1.211s) pkg: /data/local/tmp/android-debug.apk Fai...

How to ignore SSL certificate errors in Apache HttpClient 4.0

How do I bypass invalid SSL certificate errors with Apache HttpClient 4.0?...

Debugging Stored Procedure in SQL Server 2008

Is there any way to debug a stored procedure on SQL Server 2008? I have access to use SQL Server Management Studio 2008 and Visual Studio 2008 (not sure whether either provides this functionality). Generally I use the SQL profiler to find the para...

Convert cells(1,1) into "A1" and vice versa

I am working on an worksheet generator in Excel 2007. I have a certain layout I have to follow and I often have to format cells based on input. Since the generator is dynamic I have to calculate all kinds of ranges, merge cells, etc. How can I conve...

Could not find tools.jar. Please check that C:\Program Files\Java\jre1.8.0_151 contains a valid JDK installation

Even though I manually configured JDK project structure file/Project structure it still shows this error FAILURE: Build failed with an exception. `What went wrong: Execution failed for task ':sample:compileReleaseJavaWithJavac'. Could not find ...

Jquery Ajax beforeSend and success,error & complete

I have a problem with multiple ajax functions where the beforeSend of the second ajax post is executed before the complete function of the first ajax. The loading class I am adding to the placeholder before sending is working for the first ajax call...

Format of the initialization string does not conform to specification starting at index 0

I have an ASP.NET application which runs fine on my local development machine. When I run this application online, it shows the following error: Format of the initialization string does not conform to specification starting at index 0 Why is this a...

Change R default library path using .libPaths in Rprofile.site fails to work

I am running R on Windows, not as an administrator. When I install a package, the following command doesn't work: > install.packages("zoo") Installing package(s) into ‘C:/Program Files/R/R-2.15.2/library’ (as ‘lib’ is unspecified) Warning...

How to write both h1 and h2 in the same line?

I have a page and I want simply to make a header. This header is an <h1> text aligned to the left, and an <h2> aligned to the right, in the same line, and after them, an <hr>. My code so far look as follows (if you test it, you'll s...

How to get device make and model on iOS?

I was wondering if it's possible to determine what kind of iPhone (for example) the currentdevice is? I know it's possible to get the model through NSString *deviceType = [[UIDevice currentDevice] model]; which will just return whether I have an ...

How to use ng-if to test if a variable is defined

Is there a way to use ng-if to test if a variable is defined, not just if it's truthy? In the example below (live demo), the HTML displays a shipping cost for the red item only, because item.shipping is both defined and nonzero. I'd like to also dis...

Creating lowpass filter in SciPy - understanding methods and units

I am trying to filter a noisy heart rate signal with python. Because heart rates should never be above about 220 beats per minute, I want to filter out all noise above 220 bpm. I converted 220/minute into 3.66666666 Hertz and then converted that Hert...

List comprehension with if statement

I want to compare 2 iterables and print the items which appear in both iterables. >>> a = ('q', 'r') >>> b = ('q') # Iterate over a. If y not in b, print y. # I want to see ['r'] printed. >>> print([ y if y not in b for ...

Number of lines in a file in Java

I use huge data files, sometimes I only need to know the number of lines in these files, usually I open them up and read them line by line until I reach the end of the file I was wondering if there is a smarter way to do that...

How to fix .pch file missing on build?

When I build my c++ solution in Visual Studio it complains that the xxxxx.pch file is missing. Is there a setting I am missing to get the pre-compiled headers back? here is the exact error for completeness: Error 1 fatal error C1083: Cannot ope...


How to refresh Gridview after pressed a button in asp.net

I am trying to make a simple library database. I list the search results in a gridview, then i have a textbox and a button, user enters the isbn and clicks loan button. Then, if there is enough number of items (itemNumber>0) it is loaned by user. Her...

Consistency of hashCode() on a Java string

The hashCode value of a Java String is computed as (String.hashCode()): s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] Are there any circumstances (say JVM version, vendor, etc.) under which the following expression will evaluate to false? boolean ...

How can I return the current action in an ASP.NET MVC view?

I wanted to set a CSS class in my master page, which depends on the current controller and action. I can get to the current controller via ViewContext.Controller.GetType().Name, but how do I get the current action (e.g. Index, Show etc.)?...

Converting int to string in C

I am using the itoa() function to convert an int into string, but it is giving an error: undefined reference to `itoa' collect2: ld returned 1 exit status What is the reason? Is there some other way to perform this conversion?...

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

Check if a file exists in jenkins pipeline

I am trying to run a block if a directory exists in my jenkins workspace and the pipeline step "fileExists: Verify file exists" in workspace doesn't seem to work correctly. I'm using Jenkins v 1.642 and Pipeline v 2.1. and trying to have a condition...

Ubuntu apt-get unable to fetch packages

Just installed Ubuntu 13.10 (Saucy) and anything I try to install via sudo apt-get install is failing and throwing a series of 404 erros. Example - installing tmux [jeeves@HAL] hadoop > sudo apt-get install tmux [sudo] password for jeeves: Read...

Display HTML form values in same page after submit using Ajax

I have a HTML form and I need to display the form field values below the form after user clicks the submit button. How can I do this using HTML and JavaScript Ajax?...

How can I make a .NET Windows Forms application that only runs in the System Tray?

What do I need to do to make a Windows Forms application to be able to run in the System Tray? Not an application that can be minimized to the tray, but an application that will be only exist in the tray, with nothing more than an icon a tool tip, a...

Cut Java String at a number of character

I would like to cut a Java String when this String length is > 50, and add "..." at the end of the string. Example : I have the following Java String : String str = "abcdefghijklmnopqrtuvwxyz"; I would like to cut the String at length = 8 : Res...

How to set the default value of an attribute on a Laravel model

How to set the default value of an attribute on a Laravel model? Should I set the default when creating a migration or should I set it in the model class?...

Gradle Sync failed could not find constraint-layout:1.0.0-alpha2

Problem : Error:Could not find com.android.support.constraint:constraint-layout:1.0.0-alpha2. Required by: myapp:app:unspecified Background : Android Studio 2.2 P 1...

How to assign execute permission to a .sh file in windows to be executed in linux

Here is my problem, In Windows I am making a zip file in which there is a text .sh file which is supposed to be executed in Linux. The user on the other end opens the zip file in Linux and tries to execute the .sh file but the execute permission is ...

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

Keep-alive header clarification

I was asked to build a site , and one of the co-developer told me That I would need to include the keep-alive header. Well I read alot about it and still I have questions. msdn -> The open connection improves performance when a client makes mult...

What does "hard coded" mean?

My assignment asks me to access a test.txt document, so the file name has to be hard coded to my C drive. I have no idea what hardcoding means. Can somebody please help me with this?...

Color text in terminal applications in UNIX

I started to write a terminal text editor, something like the first text editors for UNIX, such as vi. My only goal is to have a good time, but I want to be able to show text in color, so I can have syntax highlighting for editing source code. How ...

How do I read a response from Python Requests?

I have two Python scripts. One uses the Urllib2 library and one uses the Requests library. I have found Requests easier to implement, but I can't find an equivalent for urlib2's read() function. For example: ... response = url.urlopen(req) print re...

How to adjust gutter in Bootstrap 3 grid system?

The new Bootstrap 3 grid system is great. It's more powerful for responsive design at all screen sizes, and much easier for nested. But I have one issue I could not figure out. How do I add precise gap between the columns? Say I have container 960px...

How to handle authentication popup with Selenium WebDriver using Java

I'm trying to handle authentication popup using the code below: FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("network.http.phishy-userpass-length", 255); profile.setPreference("network.automatic-ntlm-auth.trusted-uris", "x.x....

Path of assets in CSS files in Symfony 2

Problem I have a CSS file with some paths in it (for images, fonts, etc.. url(..)). My path structure is like this: ... +-src/ | +-MyCompany/ | +-MyBundle/ | +-Resources/ | +-assets/ | +-css/ | +-stylesheets... +-web/ | ...

Convert date field into text in Excel

I have an Excel file which has a column formatted as date in the format dd-mm-YYYY. I need to convert that field to text. If I change the field type excel converts it to a strange value (like 40603). I tried the text function but it gives me Error ...

How is using OnClickListener interface different via XML and Java code?

Possible Duplicate: Difference between OnClick() event and OnClickListener? I'm semi-new to Android development and when I first started I tried to avoid using the xml layout by any means necessary so some of my earlier projects involve bu...

HttpContext.Current.User.Identity.Name is Empty

I have a Silverlight application (using MVC) and when i'm building in visual studio, using Visual Studio Development center, there's no problem, the HttpContext.Current.User.Identity.Name has a Value But when i'm using the same project with IIS 7.5 ...

What is the regex for "Any positive integer, excluding 0"

How can ^\d+$ be improved to disallow 0? EDIT (Make it more concrete): Examples to allow: 1 30 111 Examples to disallow: 0 00 -22 It doesn't matter if positive numbers with a leading zero are allowed or not (e.g. 022). This is for Java JDK Rege...

Set mouse focus and move cursor to end of input using jQuery

This question has been asked in a few different formats but I can't get any of the answers to work in my scenario. I am using jQuery to implement command history when user hits up/down arrows. When up arrow is hit, I replace the input value with pre...

Excel VBA Password via Hex Editor

I have used the "Hex Editor to modify DPB to DPx" many times in the past to bypass VBA project security on my old Excel VBA projects (.xls), so I definitely know how to do it and know that I can do it. However I have just tried to do it yesterday an...

android.content.Context.getPackageName()' on a null object reference

I am working with Fragments which implements an interface. public class SigninFragment extends Fragment implements SigninInterface The interface's method implementation in the fragment class is as follows. @Override public void afterSubmitClicked(S...

jQuery onclick event for <li> tags

I have the following menu items generated by a template generator, artisteer: <ul class="art-vmenu"> <li><a href="#" ><span class="l"></span><span class="r"></span> <span class="t">Home</sp...

What is the easiest way to push an element to the beginning of the array?

I can't think of a one line way to do this. Is there a way?...

Twitter Bootstrap carousel different height images cause bouncing arrows

I've been using Bootstrap's carousel class and it has been straightforward so far, however one problem I've had is that images of different heights cause the arrows to bounce up and down to adjust to the new height.. This is the code I'm using for m...

How to load URL in UIWebView in Swift?

I have the following code: UIWebView.loadRequest(NSURLRequest(URL: NSURL(string: "google.ca"))) I am getting the following error: 'NSURLRequest' is not convertible to UIWebView. Any idea what the problem is? ...

How to locate the git config file in Mac

As title reads, how to locate the git config file in Mac? Not sure how to find it. Need to set git config --global http.postBuffer 524288000 Need some guidance on finding it.....

R numbers from 1 to 100

Possible Duplicate: How to generate a vector containing a numeric sequence? In R, how can I get the list of numbers from 1 to 100? Other languages have a function 'range' to do this. R's range does something else entirely. > range(1,10...

Turn off iPhone/Safari input element rounding

My website renders well on the iPhone/Safari browser, with one exception: My text input fields have a weird rounded style which doesn't look good at all with the rest of my website. Is there a way to instruct Safari (via CSS or metadata) not to roun...

CodeIgniter: "Unable to load the requested class"

On my WAMP box, I did the following: Added a file called /application/libraries/Foo.php Foo.php is a class, and it's name is Foo In /application/config/autoload.php, I added $autoload['libraries'] = array('foo'); Everything works fine. When I upl...

Cannot find vcvarsall.bat when running a Python script

I am working on Vista, and using Python 2.6.4. I am using a software that utilizes a Python script, but bumped into the message: cannot find vcvarsall.bat So, I installed visual c++ 2010. Still the file is not found - though, it is there. My guess...

Search a whole table in mySQL for a string

I'm trying to search a whole table in mySQL for a string. I want to search all fields and all entrees of a table, returning each full entry that contains the specified text. I can't figure out how to search multiple fields easily; here are the det...

How to protect Excel workbook using VBA?

With a trigger like a check box I want to protect my work book. I tried Excel 2003: thisworkbook.protect("password",true,true) thisworkbook.unprotect("password") It's not working. Any suggestions?...

How to increase image size of pandas.DataFrame.plot in jupyter notebook?

How can I modify the size of the output image of the function pandas.DataFrame.plot? I tried: plt.figure (figsize=(10,5)) and %matplotlib notebook but none of them work....

Can I scale a div's height proportionally to its width using CSS?

Can I set any variable in CSS like I want my div height to always be half of width my div scales with the screen size width for div is in percent <div class="ss"></div> CSS: .ss { width:30%; height: half of the width; } This...

How can I change the color of my prompt in zsh (different from normal text)?

To recognize better the start and the end of output on a commandline, I want to change the color of my prompt, so that it is visibly different from the programs output. As I use zsh, can anyone give me a hint?...

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 do you tell if a checkbox is selected in Selenium for Java?

I am using Selenium in Java to test the checking of a checkbox in a webapp. Here's the code: private boolean isChecked; private WebElement e; I declare e and assign it to the area where the checkbox is. isChecked = e.findElement(By.tagName("inp...

How to display Woocommerce product price by ID number on a custom page?

I'm trying to display a price of a product in Woocommerce, on a custom page. There is a short code for that, but it gives product price and also adds an "Add to cart button", I don't want the button, i just want to get the price of a specific product...

convert iso date to milliseconds in javascript

Can I convert iso date to milliseconds? for example I want to convert this iso 2012-02-10T13:19:11+0000 to milliseconds. Because I want to compare current date from the created date. And created date is an iso date....

program cant start because php5.dll is missing

I installed XAMPP , phpinfo: PHP Version 5.3.5 Downloaded PHPPDT, installed downloaded webserver debug extension, copied dummy.php added zend_extension="c:\edward\xampp\php\ext\5_3_x_nts_comp\ZendDebugger.dll" stop, restart apache, get: "the prog...

Use images instead of radio buttons

If I have a radio group with buttons: ... how can I show only images in the select option instead of the buttons, e.g. ...

How do I get client IP address in ASP.NET CORE?

Can you please let me know how to get client IP address in ASP.NET when using MVC 6. Request.ServerVariables["REMOTE_ADDR"] does not work....

intellij incorrectly saying no beans of type found for autowired repository

I have created a simple unit test but IntelliJ is incorrectly highlighting it red. marking it as an error No beans? As you can see below it passes the test? So it must be Autowired? ...

Cannot open backup device. Operating System error 5

Below is the query that I am using to backup (create a .bak) my database. However, whenever I run it, I always get this error message: Msg 3201, Level 16, State 1, Line 1 Cannot open backup device 'C:\Users\Me\Desktop\Backup\MyDB.Bak'. Operat...

Mailto links do nothing in Chrome but work in Firefox?

It seems like the mailto links we're embedding in our website fail to do anything in Chrome, though they work in Firefox. Simple example here: http://jsfiddle.net/wAPNH/ <a href='mailto:[email protected]'>hi this is a test</a> Do we need ...

Mysql: Select rows from a table that are not in another

How to select all rows in one table that do not appear on another? Table1: +-----------+----------+------------+ | FirstName | LastName | BirthDate | +-----------+----------+------------+ | Tia | Carrera | 1975-09-18 | | Nikki | Taylor ...

sql primary key and index

Say I have an ID row (int) in a database set as the primary key. If I query off the ID often do I also need to index it? Or does it being a primary key mean it's already indexed? Reason I ask is because in MS SQL Server I can create an index on this...

How do you hide the Address bar in Google Chrome for Chrome Apps?

I want to increase the screen real estate for my Chrome app. The Address Bar is useless in a Chrome App and I was wondering if there was a way to disable it....

Python 3.6 install win32api?

Is there a way to install the win32api module for python 3.6 or do I have to change my version of python? Everytime I try to install it using pip I get the following error: Could not find a version that satisfies the requirement win32api (from vers...

ERROR 2003 (HY000): Can't connect to MySQL server (111)

This question is related to the following questions: Can't connect to MySQL server error 111 Trying to connect to remote MySQL host (error 2003) I am configuring a new MySQL (5.1) server on my local machine. I need to provide remote access to...

Pandas read_csv from url

I'm trying to read a csv-file from given URL, using Python 3.x: import pandas as pd import requests url = "https://github.com/cs109/2014_data/blob/master/countries.csv" s = requests.get(url).content c = pd.read_csv(s) I have the following...

How to get domain URL and application name?

Here's the scenario. My Java web application has following path https://www.mywebsite.com:9443/MyWebApp Let's say there is a JSP file https://www.mywebsite.com:9443/MyWebApp/protected/index.jsp and I need to retrieve https://www.mywebsite.co...

How to create hyperlink to call phone number on mobile devices?

What is the proper, universal format for creating a clickable hyperlink for users on mobile devices to call a phone number? Area code with dashes <a href="tel:555-555-1212">555-555-1212</a> Area code with no dashes <a href="tel:55...

JAVA_HOME should point to a JDK not a JRE

I am trying to set up maven for my project and I am getting this error "JAVA_HOME should point to a JDK not a JRE" I know there are already similar question but it did not work. How can I point JAVA_HOME to JDK in windows. I am using IntelliJ ID...

how to check confirm password field in form without reloading page

I have a project in which I have to add a registration form and I want to to validate that the password and confirm fields are equal without clicking the register button. If password and confirm password field will not match, then I also want to put...

TypeError: unsupported operand type(s) for -: 'str' and 'int'

How come I'm getting this error? My code: def cat_n_times(s, n): while s != 0: print(n) s = s - 1 text = input("What would you like the computer to repeat back to you: ") num = input("How many times: ") cat_n...

Can I replace groups in Java regex?

I have this code, and I want to know, if I can replace only groups (not all pattern) in Java regex. Code: //... Pattern p = Pattern.compile("(\\d).*(\\d)"); String input = "6 example input 4"; Matcher m = p.matcher(input); if (m.find()...

Converting json results to a date

Possible Duplicate: How to format a JSON date? I have the following result from a $getJSON call from JavaScript. How do I convert the start property to a proper date in JavaScript? [ {"id":1,"start":"/Date(1238540400000)/"}, {"id"...

Difference between natural join and inner join

What is the difference between a natural join and an inner join?...

Incrementing in C++ - When to use x++ or ++x?

I'm currently learning C++ and I've learned about the incrementation a while ago. I know that you can use "++x" to make the incrementation before and "x++" to do it after. Still, I really don't know when to use either of the two... I've never really...

How to disable text selection using jQuery?

Does jQuery or jQuery-UI have any functionality to disable text selection for given document elements?...

Make DateTimePicker work as TimePicker only in WinForms

How to restrict DateTimePicker to select the time only? I don't know how to disable calendar control which drops when you press the button at the right of DateTimePicker....

CSS table layout: why does table-row not accept a margin?

_x000D_ _x000D_ .container {_x000D_ width: 850px;_x000D_ padding: 0;_x000D_ display: table;_x000D_ margin-left: auto;_x000D_ margin-right: auto;_x000D_ }_x000D_ .row {_x000D_ display: table-row;_x000D_ margin-bottom: 30px;_x000D_ /* H...

Simulate limited bandwidth from within Chrome?

Is there a way I can simulate various connection speeds from within Chrome? I need to be able to check http://localhost with varying speeds. I know there are standalone applications that can do this, but I'd rather do this inside Chrome....

CSS : center form in page horizontally and vertically

How can i center the form called form_login horizontally and vertically in my page ? Here is the HTML I'm using right now: <body> <form id="form_login"> <p> <input type="text" id="username" placeholder="...

Get data from fs.readFile

var content; fs.readFile('./Index.html', function read(err, data) { if (err) { throw err; } content = data; }); console.log(content); Logs undefined, why?...

EXC_BAD_ACCESS signal received

When deploying the application to the device, the program will quit after a few cycles with the following error: Program received signal: "EXC_BAD_ACCESS". The program runs without any issue on the iPhone simulator, it will also debug and run as l...

MySQL search and replace some text in a field

What MySQL query will do a text search and replace in one particular field in a table? I.e. search for foo and replace with bar so a record with a field with the value hello foo becomes hello bar....

How to select and change value of table cell with jQuery?

How do I change the content of the cell containing the 'c' letter in the HTML sample using jQuery? <table id="table_header"> <tr> <td>a</td> <td>b</td> <td>c</td> </tr> </table> ...

Reshaping data.frame from wide to long format

I have some trouble to convert my data.frame from a wide table to a long table. At the moment it looks like this: Code Country 1950 1951 1952 1953 1954 AFG Afghanistan 20,249 21,352 22,532 23,557 24,555 ALB Albania ...

How to compare two files in Notepad++ v6.6.8

I want to compare values from two different files. In Notepad++ version 5.0.3 we had shortcut button Alt+d but in version 6.6.8 I cannot find any option to compare. Also let me know which version is most stable....

Hunk #1 FAILED at 1. What's that mean?

I get the following error when running make, and I have no idea what it means or what to do about it. Can anyone illuminate me or point me in the right direction? (cd libdvdnav-git && patch -p1) < ../../contrib/src/dvdnav/dvdnav.patch pat...

What does "collect2: error: ld returned 1 exit status" mean?

I see the error collect2: error: ld returned 1 exit status very often. For example, I was executing the following snippet of code: void main() { char i; printf("ENTER i"); scanf("%c",&i); clrscr(); switch(i) { default: pri...

Create or write/append in text file

I have a website that every time a user logs in or logs out I save it to a text file. My code doesn't work in appending data or creating a text file if it does not exist.. Here is the sample code $myfile = fopen("logs.txt", "wr") or die("Unable to ...

Bootstrap 3: pull-right for col-lg only

New to bootstrap 3.... In my layout I have: <div class="row"> <div class="col-lg-6 col-md-6">elements 1</div> <div class="col-lg-6 col-md-6"> <div class="pull-right"> elements 2 <...

Using JsonConvert.DeserializeObject to deserialize Json to a C# POCO class

Here is my simple User POCO class: /// <summary> /// The User class represents a Coderwall User. /// </summary> public class User { /// <summary> /// A User's username. eg: "sergiotapia, mrkibbles, matumbo" /// </sum...

How to select multiple rows filled with constants?

Selecting constants without referring to a table is perfectly legal in an SQL statement: SELECT 1, 2, 3 The result set that the latter returns is a single row containing the values. I was wondering if there is a way to select multiple rows at once...

Slicing of a NumPy 2d array, or how do I extract an mxm submatrix from an nxn array (n>m)?

I want to slice a NumPy nxn array. I want to extract an arbitrary selection of m rows and columns of that array (i.e. without any pattern in the numbers of rows/columns), making it a new, mxm array. For this example let us say the array is 4x4 and I ...

Wait for Angular 2 to load/resolve model before rendering view/template

In Angular 1.x, UI-Router was my primary tool for this. By returning a promise for "resolve" values, the router would simply wait for the promise to complete before rendering directives. Alternately, in Angular 1.x, a null object will not crash a te...

geom_smooth() what are the methods available?

I'm using geom_smooth() from ggplot2. In Hadley Wickham's book ("ggplot2 - Elegant Graphics for Data Analysis") there is an example (page 51), where method="lm" is used. In the online manual there is no talk of the method argument. I see other Googl...

npm notice created a lockfile as package-lock.json. You should commit this file

I have been trying to load the skeleton of express with npm install express. It outputs the following line: npm notice created a lockfile as package-lock.json. You should commit this file. What should I do in order to load the template ejs an...

Getting the index of a particular item in array

I want to retrieve the index of an array but I know only a part of the actual value in the array. For example, I am storing an author name in the array dynamically say "author = 'xyz'". Now I want to find the index of the array item contai...

AddRange to a Collection

A coworker asked me today how to add a range to a collection. He has a class that inherits from Collection<T>. There's a get-only property of that type that already contains some items. He wants to add the items in another collection to the pro...

Create a new line in Java's FileWriter

I have coded the following FileWriter: try { FileWriter writer = new FileWriter(new File("file.txt"), false); String sizeX = jTextField1.getText(); String sizeY = jTextField2.getText(); writer.write(sizeX); writer.write(sizeY); ...

What is special about /dev/tty?

ls -la /dev/tty shows the output: crw-rw-rw- 1 root tty 5, 0 Dec 14 22:21 /dev/tty What does c at the beginning mean? When I do something like pwd > /dev/tty it prints to the stdout. What does the file /dev/tty contain?...

How to create nested directories using Mkdir in Golang?

I am trying to create a set of nested directories from a Go executable such as 'dir1/dir2/dir3'. I have succeeded in creating a single directory with this line: os.Mkdir("." + string(filepath.Separator) + c.Args().First(),0777); However, I have no...

How to insert new row to database with AUTO_INCREMENT column without specifying column names?

I have a table with the following columns: id - INT UNSIGNED AUTO_INCREMENT name - VARCHAR(20) group - VARCHAR(20) I know that I can add a row like this: INSERT INTO table_name (name, group) VALUES ('my name', 'my group') I wonder if there is ...

stop all instances of node.js server

This is my first time working with Node.js and I ran into this problem: I have started a Node server through the plugin of an IDE. Unfortunately, I cannot use the IDE's terminal. So I tried to run the script from the command line. This is the probl...

Python Pandas merge only certain columns

Is it possible to only merge some columns? I have a DataFrame df1 with columns x, y, z, and df2 with columns x, a ,b, c, d, e, f, etc. I want to merge the two DataFrames on x, but I only want to merge columns df2.a, df2.b - not the entire DataFrame....

In React Native, how do I put a view on top of another view, with part of it lying outside the bounds of the view behind?

I'm trying to make a layout as per below with React Native. How do I specify the position of B relative to A? With iOS Interface Builder and autoconstraints, this can very explicitly be done and is a breeze. It's not so obvious how one might achi...

How do I convert strings in a Pandas data frame to a 'date' data type?

I have a Pandas data frame, one of the column contains date strings in the format YYYY-MM-DD For e.g. '2013-10-28' At the moment the dtype of the column is object. How do I convert the column values to Pandas date format?...

Maintain image aspect ratio when changing height

Using the CSS flex box model, how can I force an image to maintain its aspect ratio? JS Fiddle: http://jsfiddle.net/xLc2Le0k/2/ Notice that the images stretch or shrink in order to fill the width of the container. That's fine, but can we also have ...

Composer could not find a composer.json

I tried to install composer via brew per: In usr/local/bin (which was not on Mavricks and I had to make personally) I did. brew tap josegonzalez/homebrew-php brew install josegonzalez/php/composer I can run php composer.phar, but when I do php c...

What does the construct x = x || y mean?

I am debugging some JavaScript, and can't explain what this || does? function (title, msg) { var title = title || 'Error'; var msg = msg || 'Error on Request'; } Can someone give me an hint, why this guy is using var title = title || 'ERROR'...

Angular window resize event

I would like to perform some tasks based on the window re-size event (on load and dynamically). Currently I have my DOM as follows: <div id="Harbour"> <div id="Port" (window:resize)="onResize($event)" > <router-outlet>...

Editing an item in a list<T>

How do I edit an item in the list in the code below: List<Class1> list = new List<Class1>(); int count = 0 , index = -1; foreach (Class1 s in list) { if (s.Number == textBox6.Text) index = count; // I found a match and I wan...

Nginx not running with no error message

I am trying to start my nginx server. When I type "$> /etc/init.d/nginx start", I have a message appearing "Starting nginx:", and then nothing happens. There is no error message, and when I check the status of nginx I see that it is not running. Her...

How do you connect localhost in the Android emulator?

I have made a php script inside localhost and I am connecting that with httpClient but I am getting a problem. Please tell me how can I connect to a php file at localhost from the emulator?...

What is the difference between HAVING and WHERE in SQL?

What is the difference between HAVING and WHERE in an SQL SELECT statement? EDIT: I have marked Steven's answer as the correct one as it contained the key bit of information on the link: When GROUP BY is not used, HAVING behaves like a WHERE clause ...

How to create range in Swift?

In Objective-c we create range by using NSRange NSRange range; So how to create range in Swift?...

SVG Positioning

I'm having a play with SVG and am having a few problems with positioning. I have a series of shapes which are contained in the g group tag. I was hoping to use it like a container, so I could set its x position and then all the elements in that group...

Android Studio Gradle Configuration with name 'default' not found

I am having problems compiling my app with Android Studio (0.1.5). The app uses 2 libraries which I have included as follows: settings.gradle include ':myapp',':library',':android-ColorPickerPreference' build.gradle buildscript { reposito...

Android getText from EditText field

I have a problem with getting text from EditText field to insert it in Email composer with intent. I've declared EditText field in layout file (@+id/vnosEmaila): <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http...

jQuery show for 5 seconds then hide

I'm using .show to display a hidden message after a successful form submit. How to display the message for 5 seconds then hide?...

How can I make a div not larger than its contents?

I have a layout similar to: <div> <table> </table> </div> I would like for the div to only expand to as wide as my table becomes....

How can I select all rows with sqlalchemy?

I am trying to get all rows from a table. In controller I have: meta.Session.query(User).all() The result is [, ], but I have 2 rows in this table. I use this model for the table: import hashlib import sqlalchemy as sa from sqlalchemy import o...

How to add a custom right-click menu to a webpage?

I want to add a custom right-click menu to my web application. Can this be done without using any pre-built libraries? If so, how to display a simple custom right-click menu which does not use a 3rd party JavaScript library? I'm aiming for something...

Android 6.0 Marshmallow. Cannot write to SD Card

I have an app that uses external storage to store photographs. As required, in its manifest, the following permissions are requested <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permiss...

Why does Boolean.ToString output "True" and not "true"

true.ToString() false.toString(); Output: True False Is there a valid reason for it being "True" and not "true"? It breaks when writing XML as XML's boolean type is lower case, and also isn't compatible with C#'s true/false (not sure about CLS th...

mysqli_connect(): (HY000/2002): No connection could be made because the target machine actively refused it

I know there are many questions like this, but i didn't find any solution in it. Things i tried:- checked firewall restarted my PC and Apache server restarted MYSQL checked my code Tried everything i know and found on internet here's my code:- ...

Sending email with attachments from C#, attachments arrive as Part 1.2 in Thunderbird

I have a C# application which emails out Excel spreadsheet reports via an Exchange 2007 server using SMTP. These arrive fine for Outlook users, but for Thunderbird and Blackberry users the attachments have been renamed as "Part 1.2". I found this ar...

Defining custom attrs

I need to implement my own attributes like in com.android.R.attr Found nothing in official documentation so I need information about how to define these attrs and how to use them from my code....

How to clear the entire array?

I have an array like this: Dim aFirstArray() As Variant How do I clear the entire array? What about a collection?...

@RequestBody and @ResponseBody annotations in Spring

Can someone explain the @RequestBody and @ResponseBody annotations in Spring 3? What are they for? Any examples would be great....

How to change the pop-up position of the jQuery DatePicker control

Any idea how to get the DatePicker to appear at the end of the associated text box instead of directly below it? What tends to happen is that the text box is towards the bottom of the page and the DatePicker shifts up to account for it and totally co...

Database Structure for Tree Data Structure

What would be the best way to implement a customizable tree data structure (meaning, a tree structure with an unknown number of level) in a database? I've done this once before using a table with a foreign key to itself. What other implementations c...

Error creating bean with name 'entityManagerFactory

I am trying to run a dbtest but I get the following error : "Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [root-context.xml]: Invocatio...

Difference between two lists

I Have two generic list filled with CustomsObjects. I need to retrieve the difference between those two lists(Items who are in the first without the items in the second one) in a third one. I was thinking using .Except() was a good idea but I don'...

What's wrong with using == to compare floats in Java?

According to this java.sun page == is the equality comparison operator for floating point numbers in Java. However, when I type this code: if(sectionID == currentSectionID) into my editor and run static analysis, I get: "JAVA0078 Floating point v...

Open mvc view in new window from controller

Is there any way to open a view from a controller action in a new window? public ActionResult NewWindow() { // some code return View(); } How would I get the NewWindow.cshtml view to open in a new browser tab? I know how to do it from a l...

Java : Cannot format given Object as a Date

I have Date in this format (2012-11-17T00:00:00.000-05:00). I need to convert the date into this format mm/yyyy. I tried this way, but I am getting this Exception. Exception in thread "main" java.lang.IllegalArgumentException: Cannot format given ...

Best way to load module/class from lib folder in Rails 3?

Since the latest Rails 3 release is not auto-loading modules and classes from lib anymore, what would be the best way to load them? From github: A few changes were done in this commit: Do not autoload code in *lib* for applications (now you need ...

Conversion failed when converting from a character string to uniqueidentifier

Created a stored procedure in SQL 9 (2005) and have since upgraded to SQL 10 (2008). Since then, the following stored procedure has stopped working and thrown up the above error: ALTER PROCEDURE [dbo].[GetModifiedPages] @vPortalUID nvar...

How to know if a DateTime is between a DateRange in C#

I need to know if a Date is between a DateRange. I have three dates: // The date range DateTime startDate; DateTime endDate; DateTime dateToCheck; The easy solution is doing a comparison, but is there a smarter way to do this?...

How to normalize a 2-dimensional numpy array in python less verbose?

Given a 3 times 3 numpy array a = numpy.arange(0,27,3).reshape(3,3) # array([[ 0, 3, 6], # [ 9, 12, 15], # [18, 21, 24]]) To normalize the rows of the 2-dimensional array I thought of row_sums = a.sum(axis=1) # array([ 9, 36, 63]...

Can you write nested functions in JavaScript?

I am wondering if JavaScript supports writing a function within another function, or nested functions (I read it in a blog). Is this really possible?. In fact, I have used these but am unsure of this concept. I am really unclear on this -- please hel...

PostgreSQL query to list all table names?

Is there any query available to list all tables in my Postgres DB. I tried out one query like: SELECT table_name FROM information_schema.tables WHERE table_schema='public' But this query returns views also. How can i get o...

Why does CSS not support negative padding?

I have seen this many a times that the prospect of a negative padding might help the development of CSS of certain page elements become better and easier. Yet, there is no provision for a negative padding in the W3C CSS. What is the reason behind thi...

Creating a selector from a method name with parameters

I have a code sample that gets a SEL from the current object, SEL callback = @selector(mymethod:parameter2); And I have a method like -(void)mymethod:(id)v1 parameter2;(NSString*)v2 { } Now I need to move mymethod to another object, say myDe...

Excel: How to check if a cell is empty with VBA?

Via VBA how can I check if a cell is empty from another with specific information? For example: If A:A = "product special" And B:B is null Then C1 = "product special" Additionally, how can I use a For Each loop on theRange and ...

How can you print a variable name in python?

Say I have a variable named choice it is equal to 2. How would I access the name of the variable? Something equivalent to In [53]: namestr(choice) Out[53]: 'choice' for use in making a dictionary. There's a good way to do this and I'm just missing...

Make body have 100% of the browser height

I want to make body have 100% of the browser height. Can I do that using CSS? I tried setting height: 100%, but it doesn't work. I want to set a background color for a page to fill the entire browser window, but if the page has little content I get...

Application Error - The connection to the server was unsuccessful. (file:///android_asset/www/index.html)

App Dies On Startup (connection to the server was unsuccessful) I have an Android application that I'm writing using PhoneGap BUILD. The app was working fine earlier, but now it seems I am getting this error after refining my app (some UI changes o...

Oracle row count of table by count(*) vs NUM_ROWS from DBA_TABLES

Looks like count(*) is slower than NUM_ROWS. Can experts in this area throw some light on this....

How do I upgrade PHP in Mac OS X?

I feel this is an awfully obtuse question to ask, but strangely, this problem is poorly documented. I would like to upgrade PHP, but there are several problems: There is no built-in package manager. MacPorts doesn't recognize php as an installed...

How to change resolution (DPI) of an image?

I have a JPEG picture with a DPI of 72. I want to change 72 dpi to 300 dpi. How could I change resolution of JPEG pictures using C#?...

How to use WinForms progress bar?

I want to show progress of calculations, which are performing in external library. For example if I have some calculate method, and I want to use it for 100000 values in my Form class I can write: public partial class Form1 : Form { public Fo...

Creating a UIImage from a UIColor to use as a background image for UIButton

I'm creating a colored image like this: CGRect rect = CGRectMake(0, 0, 1, 1); UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [[...

Can anyone confirm that phpMyAdmin AllowNoPassword works with MySQL databases?

I have a version of phpMyAdmin located on my local Apache server. I am trying to login without a password however phpMyAdmin keeps throwing the warning: Login without a password is forbidden by configuration (see AllowNoPassword) However in my...

document.getElementById("remember").visibility = "hidden"; not working on a checkbox

I cannot get the visibility or display properties to work. Here is the HTML footer: <div id="footer"> &copy; <strong id="foot" onmouseover="showData();" onmouseout = "hideData()"> Exquisite Taste 2012 </strong> &l...

Excel: Use a cell value as a parameter for a SQL query

I'm using MS Excel to get data from a MySQL database through ODBC. I successfully get data using an SQL query. But now I want that query to be parameterized. So I wonder If it is possible to use a cell value (a spreadsheet cell) as a parameter for su...

How to sort List<Integer>?

I have code and I have used list to store data. I want to sort data of it, then is there any way to sort data or shall I have to sort it manually by comparing all data? import java.util.ArrayList; import java.util.List; public class tes { publ...

Test if object implements interface

This has probably been asked before, but a quick search only brought up the same question asked for C#. See here. What I basically want to do is to check wether a given object implements a given interface. I kind of figured out a solution but this ...

Troubleshooting "Illegal mix of collations" error in mysql

Am getting the below error when trying to do a select through a stored procedure in MySQL. Illegal mix of collations (latin1_general_cs,IMPLICIT) and (latin1_general_ci,IMPLICIT) for operation '=' Any idea on what might be going wrong here? Th...

Pure JavaScript equivalent of jQuery's $.ready() - how to call a function when the page/DOM is ready for it

With jQuery, we all know the wonderful .ready() function: $('document').ready(function(){}); However, let's say I want to run a function that is written in standard JavaScript with no library backing it, and that I want to launch a function as soo...

Swift: print() vs println() vs NSLog()

What's the difference between print, NSLog and println and when should I use each? For example, in Python if I wanted to print a dictionary, I'd just print myDict, but now I have 2 other options. How and when should I use each?...

How can a divider line be added in an Android RecyclerView?

I am developing an android application where I am using RecyclerView. I need to add a divider in RecyclerView. I tried to add - recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST)...

HTML input file selection event not firing upon selecting the same file

Is there any chance to detect every file selection the user made for an HTML input of type file element? This was asked many times before, but the usually proposed onchange event doesn't fire if the user select the same file again. ...

How to get a certain element in a list, given the position?

So I've got a list: list<Object> myList; myList.push_back(Object myObject); I'm not sure but I'm confident that this would be the "0th" element in the array. Is there any function I can use that will return "myObject"? Object copy = myList....

How to build a DataTable from a DataGridView?

I may well be looking at this problem backwards but I am curious none the less. Is there a way to build a DataTable from what is currently displayed in the DataGridView? To be clear, I know you can do this DataTable data = (DataTable)(dgvMyMembers...

Typescript : Property does not exist on type 'object'

I have the follow setup and when I loop through using for...of and get an error of : Property "country" doesn't exist on type "object". Is this a correct way to loop through each object in array and compare the object property v...

How do I update the GUI from another thread?

Which is the simplest way to update a Label from another Thread? I have a Form running on thread1, and from that I'm starting another thread (thread2). While thread2 is processing some files I would like to update a Label on the Form with the curr...

How can I switch to another branch in git?

Which one of these lines is correct? git checkout 'another_branch' Or git checkout origin 'another_branch' Or git checkout origin/'another_branch' And what is the difference between them? ...

get next sequence value from database using hibernate

I have an entity that has an NON-ID field that must be set from a sequence. Currently, I fetch for the first value of the sequence, store it on the client's side, and compute from that value. However, I'm looking for a "better" way of doing this. I...

string to string array conversion in java

I have a string = "name"; I want to convert into a string array. How do I do it? Is there any java built in function? Manually I can do it but I'm searching for a java built in function. I want an array where each character of the string will be a s...

Extract a subset of a dataframe based on a condition involving a field

I have a large CSV with the results of a medical survey from different locations (the location is a factor present in the data). As some analyses are specific to a location and for convenience, I'd like to extract subframes with the rows only from th...

Recursively find all files newer than a given time

Given a time_t: ? date -ur 1312603983 Sat 6 Aug 2011 04:13:03 UTC I'm looking for a bash one-liner that lists all files newer. The comparison should take the timezone into account. Something like find . --newer 1312603983 But with a time_t in...

Error in Eclipse: "The project cannot be built until build path errors are resolved"

I am a computer science student learning Java, so I do some work at home and at college on a mixture of Linux and Windows. I have a problem after copying a new project into the Eclipse workspace. The project shows up, but with a red exclamation mark ...

How do I make HttpURLConnection use a proxy?

If I do this... conn = new URL(urlString).openConnection(); System.out.println("Proxy? " + conn.usingProxy()); it prints Proxy? false The problem is, I am behind a proxy. Where does the JVM get its proxy information from on Windows? How do I se...

Strange "java.lang.NoClassDefFoundError" in Eclipse

I have a Java project in Eclipse perfectly running smoothly until this afternoon, when I updated some files (including a ant build.xml file). When I build the project, the following error appears: java.lang.NoClassDefFoundError: proj/absa/FrontEnd/A...

How do I escape only single quotes?

I am writing some JavaScript code that uses a string rendered with PHP. How can I escape single quotes (and only single quotes) in my PHP string? <script type="text/javascript"> $('#myElement').html('say hello to <?php echo $mystringWit...

Testing pointers for validity (C/C++)

Is there any way to determine (programatically, of course) if a given pointer is "valid"? Checking for NULL is easy, but what about things like 0x00001234? When trying to dereference this kind of pointer an exception/crash occurs. A cross-platform m...

What are the different types of keys in RDBMS?

What are the different types of keys in RDBMS? Please include examples with your answer....

Create a batch file to run an .exe with an additional parameter

I need a batch file which will do the following: 1. Open CMD and navigate to a location C:/Users/...../program.exe 2. Run the program.exe with an additional command to point it to a config file: e.g. "program.exe C:/Users/..../configFile.bgi" How ...

Parsing jQuery AJAX response

I use the following function to post a form to via jQuery AJAX: $('form#add_systemgoal .error').remove(); var formdata = $('form#add_systemgoal').serialize(); $.ajaxSetup({async: false}); $.ajax({ type: "POST", url: '/admin...

How to find the type of an object in Go?

How do I find the type of an object in Go? In Python, I just use typeof to fetch the type of object. Similarly in Go, is there a way to implement the same ? Here is the container from which I am iterating: for e := dlist.Front(); e != nil; e = e.Ne...

How to set up java logging using a properties file? (java.util.logging)

I have a stupid java logging problem: I'm loading the logging configuration from my app configuration file - but it just doesn't log anything after reading the file (which looks pretty much like the examples you will find on the net except for the ad...

How To Execute SSH Commands Via PHP

I am looking to SSH out via PHP. What is the best/most secure way to go about this? I know I can do: shell_exec("SSH [email protected] mkdir /testing"); Anything better? That feels so 'naughty' :)....

Password must have at least one non-alpha character

I need a regular expression for a password. The password has to contain at least 8 characters. At least one character must be a number or a special character (not a letter). [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters ...

How to show all shared libraries used by executables in Linux?

I'd like to know which libraries are used by executables on my system. More specifically, I'd like to rank which libraries are used the most, along with the binaries that use them. How can I do this?...

Trying to add adb to PATH variable OSX

I am trying to develop for android and I want to add the adb to my PATH so that I can launch it really easily. I have added directories before by for some reason adb does not want to be found. This is very frustrating. Has anyone else had this proble...

What is a software framework?

Can someone please explain me what a software framework is? Why do we need a framework? What does a framework do to make programming easier?...

React fetch data in server before render

I'm new to reactjs, I want to fetch data in server, so that it will send page with data to client. It is OK when the function getDefaultProps return dummy data like this {data: {books: [{..}, {..}]}}. However not work with code below. The code exec...

Node.js console.log() not logging anything

Trying out node.js for the first time. Set up node, set up the example app from the nodejs.org site. Can start the server fine, but console.log() isn't actually logging anything. Tried the Javascript console in Chrome, Firefox, and Safari - nothing a...

How to increase time in web.config for executing sql query

When I am running a query in web application, I'm getting a null value. Same query directly in SQL Management Studio returns results. I think that the problem is a timeout. How can I increase the time for execution of query in web application? In m...

Changing the space between each item in Bootstrap navbar

How can I create a larger space between each link on my navbar, so they are further apart? Is it something I change the CSS or HTML? Here's how I've implemented my navbar in the html: <div class="navbar-wrapper"> <div class="container"> ...

Is it possible to install Xcode 10.2 on High Sierra (10.13.6)?

I recently upgraded iOS in my iPhone device to 12.2 (to provide support of latest versions for my app "Match4app"), and this does not appear to be compatible with Xcode 10.1. Should I update Xcode to 10.2 ? In my Mac with High Sierra, when I click "...

Storing Images in DB - Yea or Nay?

So I'm using an app that stores images heavily in the DB. What's your outlook on this? I'm more of a type to store the location in the filesystem, than store it directly in the DB. What do you think are the pros/cons? ...

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

In a nutshell the exception is thrown during POSTing wrapper model and changing the state of one entry to 'Modified'. Before changing the state, the state is set to 'Detached' but calling Attach() does throw the same error. I'm using EF6. Please fin...

How to process POST data in Node.js?

How do you extract form data (form[method="post"]) and file uploads sent from the HTTP POST method in Node.js? I've read the documentation, googled and found nothing. function (request, response) { //request.post???? } Is there a library or a...

MySQL and PHP - insert NULL rather than empty string

I have a MySQL statement that inserts some variables into the database. I recently added 2 fields which are optional ($intLat, $intLng). Right now, if these values are not entered I pass along an empty string as a value. How do I pass an explicit N...

R command for setting working directory to source file location in Rstudio

I am working out some tutorials in R. Each R code is contained in a specific folder. There are data files and other files in there. I want to open the .r file and source it such that I do not have to change the working directory in Rstudio as shown b...

Get top 1 row of each group

I have a table which I want to get the latest entry for each group. Here's the table: DocumentStatusLogs Table |ID| DocumentID | Status | DateCreated | | 2| 1 | S1 | 7/29/2011 | | 3| 1 | S2 | 7/30/2011 | | 6| 1 ...

XAMPP keeps showing Dashboard/Welcome Page instead of the Configuration Page

I've just downloaded and installed XAMPP 5.6.11 and started all the tools from the control panel. I've seen that one of it's new features is that it has a Welcome/Dashboard page. Previously, going to 127.0.0.1 would take me to a language selection p...

Get model's fields in Django

Given a Django model, I'm trying to list all of its fields. I've seen some examples of doing this using the _meta model attribute, but doesn't the underscore in front of meta indicate that the _meta attribute is a private attribute and shouldn't be ...

What is the purpose of the vshost.exe file?

When I create and compile a "Hello, World!" application in C#, I get three files in the Debug folder apart from the main exe (e.g. HelloWorld.exe) HelloWorld.vshost.exe HelloWorld.pdb HelloWorld.vshost.exe.manifest What purpose do these files ser...

Storing images in SQL Server?

I have made a small demo site and on it I am storing images within a image column on the sql server. A few questions I have are... Is this a bad idea? Will it affect performance on my site when it grows? The alternative would be to store the ima...

How to git-cherry-pick only changes to certain files?

If I want to merge into a Git branch the changes made only to some of the files changed in a particular commit which includes changes to multiple files, how can this be achieved? Suppose the Git commit called stuff has changes to files A, B, C, and ...

Flexbox: how to get divs to fill up 100% of the container width without wrapping?

I'm in the process of updating an old inline-block-based grid model I have to a newer Flexbox one I created. Everything has worked fine, apart from one little snag, which has become a bit of a dealbreaker: I have a bunch of CSS-controlled sliders; s...

jQuery onclick toggle class name

Using jQuery, how do I toggle classA to classB on click going from: <a class="switch" href="#">Switch</a> <div class="classA"></div> $('.switch').on('click', function(e){ $('.classA').removeClass('classA').addClass('cla...

High Quality Image Scaling Library

I want to scale an image in C# with quality level as good as Photoshop does. Is there any C# image processing library available to do this thing?...

How to tag an older commit in Git?

We are new to git, and I want to set a tag at the beginning of our repository. Our production code is the same as the beginning repository, but we've made commits since then. A tag at the beginning would allow us to "roll back" production to a known...

How do you move a file?

I'm using TortoiseSVN against the SourceForge SVN repository. I'd like to move a file from one folder to another in order to maintain its revision history. Is this possible? If so, how do you do it? (My current strategy has been to copy the file int...

Why are my PowerShell scripts not running?

I wrote a simple batch file as a PowerShell script, and I am getting errors when they run. It's in a scripts directory in my path. This is the error I get: Cannot be loaded because the execution of scripts is disabled on this system. Please ...

Could not load file or assembly ... An attempt was made to load a program with an incorrect format (System.BadImageFormatException)

I have two projects, ProjectA and ProjectB. ProjectB is a console application, which depends on ProjectA. Yesterday, everything was working fine, but suddenly today when I run ProjectB I get this: BadImageFormatException was unhandled: Could ...

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(); ...

How can I send the "&" (ampersand) character via AJAX?

I want to send a few variables and a string with the POST method from JavaScript. I get the string from the database, and then send it to a PHP page. I am using an XMLHttpRequest object. The problem is that the string contains the character & ...

How to enable NSZombie in Xcode?

I have an app that is crashing with no error tracing. I can see part of what is going on if I debug, but can't figure out which object is "zombie-ing". Does anybody know how to enable NSZombie in Xcode 4?...

Java string replace and the NUL (NULL, ASCII 0) character?

Testing out someone elses code, I noticed a few JSP pages printing funky non-ASCII characters. Taking a dip into the source I found this tidbit: // remove any periods from first name e.g. Mr. John --> Mr John firstName = firstName.trim().replace(...

git checkout tag, git pull fails in branch

I have cloned a git repository and then checked out a tag: # git checkout 2.4.33 -b my_branch This is OK, but when I try to run git pull in my branch, git spits out this error: There is no tracking information for the current branch. Please ...

Slide up/down effect with ng-show and ng-animate

I'm trying to use ng-animate to get a behavior similar to JQuery's slideUp() and slideDown(). Only I'd rather use ng-show I'm looking at the ng-animate tutorial here - http://www.yearofmoo.com/2013/04/animation-in-angularjs.html, and I can reproduc...

How can I perform a short delay in C# without using sleep?

I'm incredibly new to programming, and I've been learning well enough so far, I think, but I still can't get a grasp around the idea of making a delay the way I want. What I'm working on is a sort of test "game" thingy using a Windows forms applicati...

Python list of dictionaries search

Assume I have this: [ {"name": "Tom", "age": 10}, {"name": "Mark", "age": 5}, {"name": "Pam", "age": 7} ] and by searching "Pam" as name, I want to retrieve the related dictionary: {name: "Pam", age: 7} How to achieve this ?...

npm install Error: rollbackFailedOptional

When I try npm install new packages it shows me this error: rollbackFailedOptional: verb npm-session 585aaecfe5f9a82 node --version 8.4.0 npm --version 5.3.0 ...

How can I send a Firebase Cloud Messaging notification without use the Firebase Console?

I'm starting with the new Google service for the notifications, Firebase Cloud Messaging. Thanks to this code https://github.com/firebase/quickstart-android/tree/master/messaging I was able to send notifications from my Firebase User Console to my ...

Which command do I use to generate the build of a Vue app?

What should I do after developing a Vue app with vue-cli? In Angular there was some command that bundle all the scripts into one single script. Is there something the same in Vue?...

Mockito: Inject real objects into private @Autowired fields

I'm using Mockito's @Mock and @InjectMocks annotations to inject dependencies into private fields which are annotated with Spring's @Autowired: @RunWith(MockitoJUnitRunner.class) public class DemoTest { @Mock private SomeService service; ...

Trigger change() event when setting <select>'s value with val() function

What is the easiest and best way to trigger change event when setting the value of select element. I've expected that executing the following code $('select#some').val(10); or $('select#some').attr('value', 10); would result in triggering the...

How do I set headers using python's urllib?

I am pretty new to python's urllib. What I need to do is set a custom header for the request being sent to the server. Specifically, I need to set the Content-type and Authorizations headers. I have looked into the python documentation, but I have...

What is the best way to get the minimum or maximum value from an Array of numbers?

Let's say I have an Array of numbers: [2,3,3,4,2,2,5,6,7,2] What is the best way to find the minimum or maximum value in that Array? Right now, to get the maximum, I am looping through the Array, and resetting a variable to the value if it is great...

Why is the jquery script not working?

Why is the jQuery script working in my jsfiddle but not in my page? What I've done: Tried different versions of JQuery...made the script So I have this test page: Head Part <!-- Scripts --> <script src="//ajax.googleapis.com/...

How to retrieve data from sqlite database in android and display it in TextView

I am learning Android. I have a problem and I can't solve it. I want to retrieve data from an existing database and display it in a TextView after click button. My code DataBaseHelper looks like this: public class DataBaseHelper extends SQLiteOpen...

Non-numeric Argument to Binary Operator Error in R

The issue I believe is how CurrentDay is entered. It was previously created as: Transaction <- function(PnL, Day) results <- list(a = PnL, b = Day) return(results) Both PnL and Day are numeric values. Day <- Transaction(PnL, Day)["b"...

Android camera android.hardware.Camera deprecated

if android.hardware.Camera is deprecated and you cannot use the variable Camera, then what would be the alternative to this?...

How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar"

The following code is inspired from PrimeFaces DataGrid + DataTable Tutorials and put into a <p:tab> of a <p:tabView> residing in a <p:layoutUnit> of a <p:layout>. Here is the inner part of the code (starting from p:tab compon...

How to read a file in other directory in python

I have a file named 5_1.txt in a directory named direct, how can I read that file using read? I verified the path using : import os os.getcwd() os.path.exists(direct) the result was True x_file=open(direct,'r') and I got this error : ...

Define make variable at rule execution time

In my GNUmakefile, I would like to have a rule that uses a temporary directory. For example: out.tar: TMP := $(shell mktemp -d) echo hi $(TMP)/hi.txt tar -C $(TMP) cf $@ . rm -rf $(TMP) As written, the above rule creates t...

Is there a way to programmatically scroll a scroll view to a specific edit text?

I have a very long activity with a scrollview. It is a form with various fields that the user must fill in. I have a checkbox half way down my form, and when the user checks it I want to scroll to a specific part of the view. Is there any way to scro...

Solve error javax.mail.AuthenticationFailedException

I'm not familiar with this function to send mail in java. I'm getting an error while sending email to reset a password. Hope you can give me a solution. Below is my code: public synchronized static boolean sendMailAdvance(String emailTo, String sub...

Java Comparator class to sort arrays

Say, we have the following 2-dimensional array: int camels[][] = new int[n][2]; How should Java Comparator class be declared to sort the arrays by their first elements in decreasing order using Arrays.sort(camels, comparator)? The compare function...

C# string replace

I want to replace "," with a ; in my string. For example: Change "Text","Text","Text", to this: "Text;Text;Text", I've been trying the line.replace( ... , ... ), but can't get anything working pro...

Subset and ggplot2

I have a problem to plot a subset of a data frame with ggplot2. My df is like: df = data.frame(ID = c('P1', 'P1', 'P2', 'P2', 'P3', 'P3'), Value1 = c(100, 120, 300, 400, 130, 140), Value2 = c(12, 13, 11, 16, 15, 12)) ...

Add multiple items to already initialized arraylist in java

I'm googling it and can't seem to find the syntax. My arraylist might be populated differently based on a user setting, so I've initialized it ArrayList<Integer> arList = new ArrayList<Integer>(); And now I'd like to add hundred of int...

TextView Marquee not working

I have tried to use marquee and its not working here is my code, please let me know where im going wrong <TextView android:text="lunch 20.00 | Dinner 60.00 | Travel 60.00 | Doctor 5000.00 | lunch 20.00 | Dinner 60.00 | Travel 60.00 | Doctor 50...

How to set custom ActionBar color / style?

I am using Android Navigation bar in my project, I want to change the top color in action bar to something red, How can i do that? I have something like this, and i want something like this, how can i achieve that?...

Please initialize the log4j system properly warning

Here is the error message - log4j:WARN No appenders could be found for logger (SerialPortUtil). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. Here is the...

How to use multiprocessing queue in Python?

I'm having much trouble trying to understand just how the multiprocessing queue works on python and how to implement it. Lets say I have two python modules that access data from a shared file, let's call these two modules a writer and a reader. My pl...

How to create a self-signed certificate for a domain name for development?

I have subdomain.example.com that I use for development purposes. My web application solution contains a web API etc, that I need to call from external systems, hence I am not using localhost. I now need to test for SSL and need a certificate for my...

How to pass parameter to function using in addEventListener?

In the traditional way to add event listener: function getComboA(sel) { var value = sel.options[sel.selectedIndex].value; } <select id="comboA" onchange="getComboA(this)"> <option value="">Select combo</option> <option va...

How can I make the Android emulator show the soft keyboard?

I'm debugging an issue with the soft keyboard display not displaying when it should. However, I don't have a device handy for testing. The problem is that the emulator never shows the soft keyboard. Some skins have a keyboard constantly displayed ...

Android studio logcat nothing to show

I installed Android Studio yesterday, and I tried to use the LogCat to see the logs. But there is nothing to show in the logcat. I used the terminal to run ./adb logcat and it works. Is there someone who can explain to me how to use logcat in Andr...

Converting string to date in mongodb

Is there a way to convert string to date using custom format using mongodb shell I am trying to convert "21/May/2012:16:35:33 -0400" to date, Is there a way to pass DateFormatter or something to Date.parse(...) or ISODate(....) method?...

Why are you not able to declare a class as static in Java?

Why are you not able to declare a class as static in Java?...

Set initial value in datepicker with jquery?

I'm trying to set an initial value in my jquery ui datepicker. I've tried several different ways, but nothing seems to display the date, it's empty. var idag = new Date(); $("#txtFrom").datepicker("setDate", idag - 2); $("#txtTom").datepicker("setDa...

what's the easiest way to put space between 2 side-by-side buttons in asp.net

I have 2 buttons side by side, and I would like to have some inbetween them. Following code will have 2 buttons right next to each other. I have tried margin for the div, and just couldn't get some nice space between the two. <div style="text-a...

How to empty a list?

It seems so "dirty" emptying a list in this way: while len(alist) > 0 : alist.pop() Does a clear way exist to do that?...

Where does npm install packages?

Can someone tell me where can I find the Node.js modules, which I installed using npm?...

How to Exit a Method without Exiting the Program?

I am still pretty new to C# and am having a difficult time getting used to it compared to C/CPP. How do you exit a function on C# without exiting the program like this function would? if (textBox1.Text == "" || textBox1.Text == String.Empty || tex...

How to hide "Showing 1 of N Entries" with the dataTables.js library

How do you remove the "Showing 1 of N entries" line of text on a dataTable (that is when using the javascript library dataTables? I think I was looking for something along these lines... $('#example').dataTable({ "showNEntries" : false ...

Replace single quotes in SQL Server

I have this function in SQL Server to replace single quotes. But when I insert a single quote it throws an error on Replace(@strip,''','')): Create Function [dbo].[fn_stripsingleQuote] (@strStrip varchar(Max)) returns varchar as begin d...

Is there a way to represent a directory tree in a Github README.md?

In my Githubs repos documentation I want to represent a directory tree structure like this: Is there a way to do that with Github flavoured markdown, besides just creating it with ascii art? So basically like this question, but I'm wondering if t...

What is the incentive for curl to release the library for free?

I recently started using libCurl for my VC++ project. I've been wondering: what is the incentive for the curl creators to release the entire library for free? Is it purely to help their fellow developers? This is one of the best open source librarie...

Change x axes scale in matplotlib

I created this plot using Matlab Using matplotlib, the x-axies draws large numbers such as 100000, 200000, 300000. I would like to have something like 1, 2, 3 and a 10^5 to indicate that it's actually 100000, 200000, 300000. Is there a simple wa...

Using an IF Statement in a MySQL SELECT query

I am trying to use an IF statement in a MySQL select query. I am getting an error after the AND statement where the first IF. SELECT J.JOB_ID,E.COMPANY_NAME,J.JOB_DESC,JT.JOBTYPE_NAME,J.COMPENSATION,ST.STATE_NAME,MC.METRO_CITY_NAME,I.INDUSTRY_NAM...

Use LIKE %..% with field values in MySQL

I stumbled into a delicate SQL problem when I needed to use a value from a field inside a LIKE %..% statement. Example: SELECT t1.Notes, t2.Name FROM Table1 t1, Table2 t2 WHERE t1.Notes LIKE '%t2.Name%' This is only an example from the top of my ...

Double quotes within php script echo

I have a line of php code that looks like this: echo "<script>$('#edit_errors').html('<h3><em>Please Correct Errors Before Proceeding</em></h3>')</script>"; I would like to know how to add a font color to the te...

Detecting value change of input[type=text] in jQuery

I want to execute a function every time the value of a specific input box changes. It almost works with $('input').keyup(function), but nothing happens when pasting text into the box, for example. $input.change(function) only triggers when the input ...

How to match "anything up until this sequence of characters" in a regular expression?

Take this regular expression: /^[^abc]/. This will match any single character at the beginning of a string, except a, b, or c. If you add a * after it – /^[^abc]*/ – the regular expression will continue to add each subsequent character to the re...

jquery $(window).height() is returning the document height

I'm sure there is a simple error I'm making, but I am simply alerting $(window).height() and it returns the same value as $(document).height(). I am on a 13" MBA and my window height of my browsers when maximised between 780px - 820px (roughly) but ...

Can I get Unix's pthread.h to compile in Windows?

If I try to compile a program with #include <pthread.h> in it, I get the error: pthread.h: No such file or directory Is it possible to get this to compile in a Windows environment? I am using Vista with the latest MinGW. I do not want t...

Convert file path to a file URI?

Does the .NET Framework have any methods for converting a path (e.g. "C:\whatever.txt") into a file URI (e.g. "file:///C:/whatever.txt")? The System.Uri class has the reverse (from a file URI to absolute path), but nothing as far as I can find for c...

Split string into array

In JS if you would like to split user entry into an array what is the best way of going about it? For example: entry = prompt("Enter your name") for (i=0; i<entry.length; i++) { entryArray[i] = entry.charAt([i]); } // entryArray=['j', 'e', 'a...

Why do we assign a parent reference to the child object in Java?

I am asking a quite simple question, but I am bit confused in this. Suppose I have a class Parent: public class Parent { int name; } And have another class Child: public class Child extends Parent{ int salary; } And finally my Main.java c...

ASP.NET MVC 3 Razor: Include JavaScript file in the head tag

I'm trying to figure out the proper Razor syntax to get a JavaScript file for a particular *.cshtml to be in the head tag along with all the other include files that are defined in _Layout.cshtml....

Select row and element in awk

I learned that in awk, $2 is the 2nd column. How to specify the ith line and the element at the ith row and jth column?...

How can I clear the NuGet package cache using the command line?

I can clear my development computer's NuGet package cache using Visual Studio menu Tools → Options → NuGet Package Manager → General: Clear Package Cache button. I would like to do this on the command line. Unfortunately, I can n...

How to limit the maximum value of a numeric field in a Django model?

Django has various numeric fields available for use in models, e.g. DecimalField and PositiveIntegerField. Although the former can be restricted to the number of decimal places stored and the overall number of characters stored, is there any way to r...

Git, How to reset origin/master to a commit?

I reset my local master to a commit by this command: git reset --hard e3f1e37 when I enter $ git status command, terminal says: # On branch master # Your branch is behind 'origin/master' by 7 commits, and can be fast-forwarded. # (use "git pul...

Preferred method to store PHP arrays (json_encode vs serialize)

I need to store a multi-dimensional associative array of data in a flat file for caching purposes. I might occasionally come across the need to convert it to JSON for use in my web app but the vast majority of the time I will be using the array direc...

Importing a long list of constants to a Python file

In Python, is there an analogue of the C preprocessor statement such as?: #define MY_CONSTANT 50 Also, I have a large list of constants I'd like to import to several classes. Is there an analogue of declaring the constants as a long sequence of sta...

PHP output showing little black diamonds with a question mark

I'm writing a php program that pulls from a database source. Some of the varchars have quotes that are displaying as black diamonds with a question mark in them (?, REPLACEMENT CHARACTER, I assume from Microsoft Word text). How can I use php to stri...

Mean Squared Error in Numpy?

Is there a method in numpy for calculating the Mean Squared Error between two matrices? I've tried searching but found none. Is it under a different name? If there isn't, how do you overcome this? Do you write it yourself or use a different lib?...

How does the getView() method work when creating your own custom adapter?

My questions are: What is exactly the function of the LayoutInflater? Why do all the articles that I've read check if convertview is null or not first? What does it mean when it is null and what does it mean when it isn't? What is the parent parame...

How to display hexadecimal numbers in C?

I have a list of numbers as below: 0, 16, 32, 48 ... I need to output those numbers in hexadecimal as: 0000,0010,0020,0030,0040 ... I have tried solution such as: printf("%.4x",a); // where a is an integer but the result that I got is:...

Event detect when css property changed using Jquery

Is there a way to detect if the "display" css property of an element is changed (to whether none or block or inline-block...)? if not, any plugin? Thanks...

VBA macro that search for file in multiple subfolders

I have macro, if I put in cell E1 name of the file, macro search trough C:\Users\Marek\Desktop\Makro\ directory, find it and put the needed values in specific cells of my original file with macro. Is it possible to make this work without specific ...

What's the Use of '\r' escape sequence?

I have C code like this: #include<stdio.h> int main() { printf("Hey this is my first hello world \r"); return 0; } I have used the \r escape sequence as an experiment. When I run the code I get the output as: o world Why is that, ...

How to center a Window in Java?

What's the easiest way to centre a java.awt.Window, such as a JFrame or a JDialog?...

How does spring.jpa.hibernate.ddl-auto property exactly work in Spring?

I was working on my Spring boot app project and noticed that, sometimes there is a connection time out error to my Database on another server(SQL Server). This happens specially when I try to do some script migration with FlyWay but it works after s...

Hide scroll bar, but while still being able to scroll

I want to be able to scroll through the whole page, but without the scrollbar being shown. In Google Chrome it's: ::-webkit-scrollbar { display: none; } But Mozilla Firefox and Internet Explorer don't seem to work like that. I also tried thi...

JUnit 4 compare Sets

How would you succinctly assert the equality of Collection elements, specifically a Set in JUnit 4?...

Transparent ARGB hex value

The colors in this table is all not transparent. I guess the value for the A is set to FF. What is the code for transparency? For example this color FFF0F8FF (AliceBlue), to a transparent code such as ??F0F8FF ?...

How do I write to the console from a Laravel Controller?

So I have a Laravel controller: class YeahMyController extends BaseController { public function getSomething() { Console::info('mymessage'); // <-- what do I put here? return 'yeahoutputthistotheresponse'; } } Currently,...

Fastest way(s) to move the cursor on a terminal command line?

What is the best way to move around on a given very long command line in the terminal? Say I used the arrow key or Ctrl-R to get this long command line: ./cmd --option1 --option2 --option3 --option4 --option5 --option6 --option7 --option8 --option9...

Can a table have two foreign keys?

I have the following tables (Primary key in bold. Foreign key in Italic) Customer table ID---Name---Balance---Account_Name---Account_Type Account Category table Account_Type----Balance Customer Detail table Account_Name---First_Name----Las...

How to obtain Certificate Signing Request

How do I obtain a Certificate Signing Request? All I'm trying to do is get my app running on my ipod touch. This was easy as I could just go to the IOS development portal and just download one, no muss no fuss. But now they want me to create a CSR to...

What is the quickest way to HTTP GET in Python?

What is the quickest way to HTTP GET in Python if I know the content will be a string? I am searching the documentation for a quick one-liner like: contents = url.get("http://example.com/foo/bar") But all I can find using Google are httplib and ur...

angular2 manually firing click event on particular element

I am trying to fire click event (or any other event) on element programatically , In other word I want to know the similar features as offered by jQuery .trigger() method in angular2. Is there any built in method to do this? ..... if not please su...

Excel - extracting data based on another list

I have an Excel worksheet with two columns (name/ID) and then another list that is a subset of the names only from the larger aforementioned list. I want to go through the subset list and then pull the data from the larger list (name/ID) and put it s...

Dialog to pick image from gallery or from camera

Is there a standard way to call dialog box with choose either to pick an image from the camera or to get from gallery (like in build-in phone book or Skype)? I've taken a look at this but the code opens gallery without suggesting to pick it from cam...

Grid of responsive squares

I'm wondering how I would go about creating a layout with responsive squares. Each square would have vertically and horizontally aligned content. The specific example is displayed below... ...

pthread_join() and pthread_exit()

I have a question about C concurrency programming. In the pthread library, the prototype of pthread_join is int pthread_join(pthread_t tid, void **ret); and the prototype of pthread_exit is: void pthread_exit(void *ret); So I am confused that,...

What is the difference between compileSdkVersion and targetSdkVersion?

I have looked at the documentation for building with Gradle, but I'm still not sure what the difference between compileSdkVersion and targetSdkVersion is. All it says is: The compileSdkVersion property specifies the compilation target. Well, w...

ETag vs Header Expires

I've looked around but haven't been able to figure out if I should use both an ETag and an Expires Header or one or the other. What I'm trying to do is make sure that my flash files (and other images and what not only get updated when there is a cha...

Moving average or running mean

Is there a SciPy function or NumPy function or module for Python that calculates the running mean of a 1D array given a specific window?...

How do I select a span containing a specific text value, using jquery?

How do I find the span containing the text "FIND ME" <div> <span>FIND ME</span> <span>dont find me</span> </div> ...

What is the question mark for in a Typescript parameter name

export class Thread { id: string; lastMessage: Message; name: string; avatarSrc: string; constructor(id?: string, name?: string, avatarSrc?: string) { this.id = id || uuid(); this.name = name; this.a...

Show all current locks from get_lock

Is there any way to select / show all current locks that have been taken out using the GET_LOCK function? Note that GET_LOCK locks are different from table locks, like those acquired with LOCK TABLES - readers who want to know how to see those locks...

How to get all columns' names for all the tables in MySQL?

Is there a fast way of getting all column names from all tables in MySQL, without having to list all the tables?...

Fatal error: Namespace declaration statement has to be the very first statement in the script in

I'm trying to use this to create a image form upload for my website, the reason I'm using this is because it's more secure than doing everything myself (but if someone could point another working script I would be appreciated) simon-eQ / ImageUpload...

Class vs. static method in JavaScript

I know this will work: function Foo() {}; Foo.prototype.talk = function () { alert('hello~\n'); }; var a = new Foo; a.talk(); // 'hello~\n' But if I want to call Foo.talk() // this will not work Foo.prototype.talk() // this works correctly ...

Disabling contextual LOB creation as createClob() method threw error

I am using Hibernate 3.5.6 with Oracle 10g. I am seeing the below exception during initialization but the application itself is working fine. What is the cause for this exception? and how it can be corrected? Exception Disabling contextual LOB creat...

How to show matplotlib plots in python

I am sure the configuration of matplotlib for python is correct since I have used it to plot some figures. But today it just stop working for some reason. I tested it with really simple code like: import matplotlib.pyplot as plt import numpy as np ...

How to make promises work in IE11

I have a simple code that runs perfectly on every browser except for the Internet Explorer 11. How can I make it work on all browsers? Codepen Thanks in advance. 'use strict'; let promise = new Promise((resolve, reject) => { setTimeout(() =...

How to add footnotes to GitHub-flavoured Markdown?

I am just trying to add footnotes in my GitHub Gist, but it doesn't work: Some long sentence. [^footnote] [^footnote]: Test, [Link](https://google.com). I am following this guide and I don't think I'm doing anything wrong. Can someone point out m...

How to use SQL Select statement with IF EXISTS sub query?

How to select Boolean value from sub query with IF EXISTS statement (SQL Server)? It should be something like : SELECT TABEL1.Id, NewFiled = (IF EXISTS(SELECT Id FROM TABLE2 WHERE TABLE2.ID = TABEL1.ID) SELECT 'TRUE' ...

How to find out which processes are using swap space in Linux?

Under Linux, how do I find out which process is using the swap space more?...

What is the difference between exit(0) and exit(1) in C?

Can anyone tell me? What is the difference between exit(0) and exit(1) in C language?...

Angular 2 Dropdown Options Default Value

In Angular 1 I could select the default option for a drop down box using the following: <select data-ng-model="carSelection" data-ng-options = "x.make for x in cars" data-ng-selected="$first"> </select> In Angular 2 I have: ...

Select first 4 rows of a data.frame in R

How can I select the first 4 rows of a data.frame: Weight Response 1 Control 59 0.0 2 Treatment 90 0.8 3 Treatment 47 0.1 4 Treamment 106 0.1 5 Control 85 0.7 6 Treatment 73 0.6 ...

how to convert JSONArray to List of Object using camel-jackson

Am having the String of json array as follow {"Compemployes":[ { "id":1001, "name":"jhon" }, { "id":1002, "name":"jhon" } ]} i want to convert this this jsonarray to List<Empol...

Filter output in logcat by tagname

I'm trying to filter logcat output from a real device (not an emulator) by tag name but I get all the messages which is quite a spam. I just want to read messages from browser which should be something like "browser:" or "webkit:" , but it doesn't wo...

What is the difference between #import and #include in Objective-C?

What are the differences between #import and #include in Objective-C and are there times where you should use one over the other? Is one deprecated? I was reading the following tutorial: http://www.otierney.net/objective-c.html#preamble and its para...

How do I install the yaml package for Python?

I have a Python program that uses YAML. I attempted to install it on a new server using pip install yaml and it returns the following: $ sudo pip install yaml Downloading/unpacking yaml Could not find any downloads that satisfy the requirement ya...

How do I start an activity from within a Fragment?

I have a set of tabs inside of a FragmentActivity that each hold their own fragment. When I tried to start a new activity from within that fragment via an onClickListener, and using the startActivity(myIntent) method, my application force closes. Af...

SQL Server - find nth occurrence in a string

I have a table column that contains values such as abc_1_2_3_4.gif or zzz_12_3_3_45.gif etc. I want to find the index of each underscore _ in the above values. There will only ever be four underscores but given that they can be in any position in th...

C++ - Hold the console window open?

My question is super simple, but I'm transitioning from C# to C++, and I was wondering what command holds the console window open in C++? I know in C#, the most basic way is: Console.ReadLine(); Or if you want to let the user press any key, its: ...

Enabling the OpenSSL in XAMPP

I spent three hours but I did not find anything; I'm unable to connect to a SSL enabled server. I want to list what i did: First checked my PHP extensions directory was in order; extension wasn't there, php_openssl.dll Then I opened my php.ini file...

How to pass an array into a SQL Server stored procedure

How to pass an array into a SQL Server stored procedure? For example, I have a list of employees. I want to use this list as a table and join it with another table. But the list of employees should be passed as parameter from C#....

Get The Current Domain Name With Javascript (Not the path, etc.)

I plan on buying two domain names for the same site. Depending on which domain is used I plan on providing slightly different data on the page. Is there a way for me to detect the actual domain name that the page is loading from so that I know what...

Initializing IEnumerable<string> In C#

I have this object : IEnumerable<string> m_oEnum = null; and I'd like to initialize it. Tried with IEnumerable<string> m_oEnum = new IEnumerable<string>() { "1", "2", "3"}; but it say "IEnumerable doesnt contain a method for ...

convert string to number node.js

I'm trying to convert req.params to Number because that is what I defined in my schema for year param. I have tried req.params.year = parseInt( req.params.year, 10 ); and Number( req.params.year); and 1*req.params.year; but non of them wo...

Jquery: how to trigger click event on pressing enter key

I need to execute a button click event upon pressing key enter. As it is at the moment the event is not firing. Please Help me with the syntax if possible. $(document).on("click", "input[name='butAssignProd']", function () { //all the action }...

pgadmin4 : postgresql application server could not be contacted.

I have installed PostgreSQL 9.6.2 on my Windows 8.1. But the pgadmin4 is not able to contact the local server. I have tried several solutions suggested here in stackoverflow, tried to uninstall and reinstall PostgreSQL 9.6.2 , tried to modify the con...

How can I check if a checkbox is checked?

I am building a mobile web app with jQuery Mobile and I want to check if a checkbox is checked. Here is my code. <script type=text/javascript> function validate(){ if (remember.checked == 1){ alert("checked") ; } else { a...

Launch Failed. Binary not found. CDT on Eclipse Helios

I'm using Eclipse Helios on Ubuntu 10.04, and I'm trying to install CDT plugin on it. I download it from here here. And then I go to Install New Software and select the zip file (I don't extract it, just select the zip file). And its ok, it install...

How can I let a user download multiple files when a button is clicked?

So I have a httpd server running which has links to a bunch of files. Lets say the user selects three files from a file list to download and they're located at: mysite.com/file1 mysite.com/file2 mysite.com/file3 When they click the download butt...

How to check if one DateTime is greater than the other in C#

I have two DateTime objects: StartDate and EndDate. I want to make sure StartDate is before EndDate. How is this done in C#?...

Uncaught SyntaxError: Unexpected token < On Chrome

I know this question has been asked many times but I can't find similarity with my issue. I'm getting this error only in Chrome, in every other browser everything is ok. I return data with JSON in several places but since my code works in other brows...

How to calculate a mod b in Python?

Is there a modulo function in the Python math library? Isn't 15 % 4, 3? But 15 mod 4 is 1, right?...

link_to method and click event in Rails

How do I create a link of this type: <a href="#" onclick="document.getElementById('search').value=this.value"> using method link_to in Rails? I couldn't figure it out from Rails docs....

Python style - line continuation with strings?

In trying to obey the python style rules, I've set my editors to a max of 79 cols. In the PEP, it recommends using python's implied continuation within brackets, parentheses and braces. However, when dealing with strings when I hit the col limit, i...

Print in one line dynamically

I would like to make several statements that give standard output without seeing newlines in between statements. Specifically, suppose I have: for item in range(1,100): print item The result is: 1 2 3 4 . . . How get this to instead look l...

angularjs - ng-repeat: access key and value from JSON array object

I have JSON Array object as shown below. $scope.items = [ {Name: "Soap", Price: "25", Quantity: "10"}, {Name: "Bag", Price: "100", Quantity: "15"}, {Name: "Pen", Price: "15", Quantity: "13"} ]; I want to get the keys and va...

Using Environment Variables with Vue.js

I've been reading the official docs and I'm unable to find anything on environment variables. Apparently there are some community projects that support environment variables but this might be overkill for me. So I was wondering if there's something s...

Link a photo with the cell in excel

Is there anyone who knows how to connect a picture with the cell that it is in at microsoft excel? For example in the first column I put some brands of mobile phones and in the second one some pictures of them. Now when I sort the values of the firs...

NSPhotoLibraryUsageDescription key must be present in Info.plist to use camera roll

Recently I started to get this error: NSPhotoLibraryUsageDescription key must be present in Info.plist to use camera roll. I am using React Native to build my app (I am not familiar with ios native development) and I don't know how to add th...

Replacing instances of a character in a string

This simple code that simply tries to replace semicolons (at i-specified postions) by colons does not work: for i in range(0,len(line)): if (line[i]==";" and i in rightindexarray): line[i]=":" It gives the error line[i]=":" TypeErr...

Compare one String with multiple values in one expression

I have one String variable, str with possible values, val1, val2 and val3. I want to compare (with equal case) str to all of these values using an if statement, for example: if("val1".equalsIgnoreCase(str)||"val2".equalsIgnoreCase(str)||"val3.equal...

Filtering a data frame by values in a column

I am working with the dataset LearnBayes. For those that want to see the actual data: install.packages('LearnBayes') I am trying to filter out rows based on the value in the columns. For example, if the column value is "water", then I want that r...

Arduino COM port doesn't work

I bought an Arduino Uno recently. After getting the necessary cables, I decided to upload an example to the chip. Instead of seeing that Blink, I received an error like processing.app.SerialException: Serial port 'COM1' not found. Did you select th...

String's Maximum length in Java - calling length() method

In Java, what is the maximum size a String object may have, referring to the length() method call? I know that length() return the size of a String as a char [];...

How to import an existing X.509 certificate and private key in Java keystore to use in SSL?

I have this in an ActiveMQ config: <sslContext> <sslContext keyStore="file:/home/alex/work/amq/broker.ks" keyStorePassword="password" trustStore="file:${activemq.base}/conf/broker.ts" trustStorePassword="password"/> </ssl...

Difference between == and ===

In swift there seem to be two equality operators: the double equals (==) and the triple equals (===), what is the difference between the two?...

PHP compare time

How to compare times in PHP? I want to say this: $ThatTime ="14:08:10"; $todaydate = date('Y-m-d'); $time_now=mktime(date('G'),date('i'),date('s')); $NowisTime=date('G:i:s',$time_now); if($NowisTime >= $ThatTime) { echo "ok"; } The above c...

Multiple "style" attributes in a "span" tag: what's supposed to happen?

Consider the following HTML fragment with two style attributes: <span style="color:blue" style="font-style:italic">Test</span> In Opera 12.16 and Chrome 40, it shows up as blue non-italic text, while Internet Explorer 9 shows blue ital...

Read response headers from API response - Angular 5 + TypeScript

I'm triggering a HTTP request and I'm getting a valid response from it. The response also has a header X-Token that I wish to read. I'm trying the below code to read the headers, however, I get null as a result this.currentlyExecuting.request = this...

How to capitalize the first letter of word in a string using Java?

Example strings one thousand only two hundred twenty seven How do I change the first character of a string in capital letter and not change the case of any of the other letters? After the change it should be: One thousand only Two hundred Twenty...

alert() not working in Chrome

'nuff said. I have absolutely no clue why using alert() there wouldn't work. It works perfectly in Firefox, but gives that error in Chrome....

Converting serial port data to TCP/IP in a Linux environment

I need to get data from the serial port of a Linux system and convert it to TCP/IP to send to a server. Is this difficult to do? I have some basic programming experience, but not much experience with Linux. Is there an open source application that do...

How to add Drop-Down list (<select>) programmatically?

I want to create a function in order to programmatically add some elements on a page. Lets say I want to add a drop-down list with four options: <select name="drop1" id="Select1"> <option value="volvo">Volvo</option> <opti...

What does LPCWSTR stand for and how should it be handled with?

First of all, what is it exactly? I guess it is a pointer (LPC means long pointer constant), but what does "W" mean? Is it a specific pointer to a string or a pointer to a specific string? For example I want to close a Window named "TestWindow". H...

Adding a stylesheet to asp.net (using Visual Studio 2010)

I am trying to add a stylesheet to a master page in an asp.net web form. Basically trying to create an inline nav menu for the top of the page. I'm having issues with it. I've created the stylesheet (the same way I would create if this were an html s...

C# HttpWebRequest of type "application/x-www-form-urlencoded" - how to send '&' character in content body?

I'm writing a small API-connected application in C#. I connect to a API which has a method that takes a long string, the contents of a calendar(ics) file. I'm doing it like this: HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(URL);...

What goes into your .gitignore if you're using CocoaPods?

I've been doing iOS development for a couple of months now and just learned of the promising CocoaPods library for dependency management. I tried it out on a personal project: added a dependency to Kiwi to my Podfile, ran pod install CocoaPodsTest.x...

Getting all request parameters in Symfony 2

In symfony 2 controllers, every time I want to get a value from post I need to run: $this->getRequest()->get('value1'); $this->getRequest()->get('value2'); Is there any way to consolidate these into one statement that would return an a...

Converting a char to ASCII?

I have tried lots of solutions to convert a char to Ascii. And all of them have got a problem. One solution was: char A; int ValeurASCII = static_cast<int>(A); But VS mentions that static_cast is an invalid type conversion!!! PS: my A is a...

How do we check if a pointer is NULL pointer?

I always think simply if(p != NULL){..} will do the job. But after reading this Stack Overflow question, it seems not. So what's the canonical way to check for NULL pointers after absorbing all discussion in that question which says NULL pointers ca...

Dynamic height for DIV

I have the following DIV <div id="products"> </div> #products { height: 102px; width: 84%; padding:5px; margin-bottom:8px; border: 1px solid #EFEFEF; } Now inside the DIV, I am dynamically generating 4 links. But sometime...

ipython notebook clear cell output in code

In a iPython notebook, I have a while loop that listens to a Serial port and print the received data in real time. What I want to achieve to only show the latest received data (i.e only one line showing the most recent data. no scrolling in the cell...

How to remove unused imports from Eclipse

Is there any way to automatically remove all unused imports (signaled with a warning) of a project with Eclipse IDE?...

How do you append rows to a table using jQuery?

Hi I was trying to add a row to a table using jQuery, but it is not working. What might be the reason? And, can I put in some value to the newly added row..? Here is the code: <html> <head> <script type="text/javascript" src="jq...

Why is there no Constant feature in Java?

I was trying to identify the reason behind constants in Java I have learned that Java allows us to declare constants by using final keyword. My question is why didn't Java introduce a Constant (const) feature. Since many people say it has come from ...

Oracle 'Partition By' and 'Row_Number' keyword

I have a SQL query written by someone else and I'm trying to figure out what it does. Can someone please explain what the Partition By and Row_Number keywords does here and give a simple example of it in action, as well as why one would want to use i...

How to draw a standard normal distribution in R

Possible Duplicate: Making a standard normal distribution in R Using R, draw a standard normal distribution. Label the mean and 3 standard deviations above and below the (10) mean. Include an informative title and labels on the x and y ...

displayname attribute vs display attribute

What is difference between DisplayName attribute and Display attribute in ASP.NET MVC?...

What is the difference between <jsp:include page = ... > and <%@ include file = ... >?

Both tags include the content from one page in another. So what is the exact difference between these two tags?...

RecyclerView onClick

Has anyone using RecyclerView found a way to set an onClickListener to items in the RecyclerView? I thought of setting a listener to each of the layouts for each item but that seems a little too much hassle I'm sure there is a way for the RecyclerVie...

Right click to select a row in a Datagridview and show a menu to delete it

I have few columns in my DataGridView, and there is data in my rows. I saw few solutions in here, but I can not combine them! Simply a way to right-click on a row, it will select the whole row and show a menu with an option to delete the row and whe...

How to refresh or show immediately in datagridview after inserting?

After entering data into all the textbox, and after clicking the submit button, it won't immediately show in the datagridview, I need to reopen the form in order to see the new inserted row. What code to put in for refresh? Followed @user3222297 cod...

Python requests library how to pass Authorization header with single token

I have a request URI and a token. If I use: curl -s "<MY_URI>" -H "Authorization: TOK:<MY_TOKEN>" etc., I get a 200 and view the corresponding JSON data. So, I installed requests and when I attempt to access this resource I get a 403 p...

How to convert datetime to timestamp using C#/.NET (ignoring current timezone)

How do I convert datetime to timestamp using C# .NET (ignoring the current timezone)? I am using the below code: private long ConvertToTimestamp(DateTime value) { long epoch = (value.ToUniversalTime().Ticks - 621355968000000000) / 10000000; ...

How to set selected value of jquery select2?

This belong to codes prior to select2 version 4 I have a simple code of select2 that get data from ajax $("#programid").select2({ placeholder: "Select a Program", allowClear: true, minimumInputLength: 3, ajax: { url: "ajax.php", dat...

Java: Most efficient method to iterate over all elements in a org.w3c.dom.Document?

What is the most efficient way to iterate through all DOM elements in Java? Something like this but for every single DOM elements on current org.w3c.dom.Document? for(Node childNode = node.getFirstChild(); childNode!=null;){ Node nextChild = ch...

How to Select Columns in Editors (Atom,Notepad++, Kate, VIM, Sublime, Textpad,etc) and IDEs (NetBeans, IntelliJ IDEA, Eclipse, Visual Studio, etc)

How to select columns in Editors and IDEs to columnar delete, insert or replace some characters ? Editors: Atom Notepad++ Kate VIM Sublime Emacs Textpad Emerald Editor UltraEdit MCEdit jEdit Nedit IDEs: NetBeans Eclipse Visual Studio IntelliJ ...

Is it possible to auto-format your code in Dreamweaver?

Is it possible to auto-format your code in Dreamweaver like in Visual Studio (ctrl+k+d)...

How to get HTTP response code for a URL in Java?

Please tell me the steps or code to get the response code of a particlular URL....

How to subtract days from a plain Date?

Is there an easy way of taking a olain JavaScript Date (e.g. today) and going back X days? So, for example, if I want to calculate the date 5 days before today....

I get Access Forbidden (Error 403) when setting up new alias

I'm running windows 7 and recently installed XAMPP to build a dev environment. I'm not great with the server side of things so I'm having some problems setting up an alias for a project. So far XAMPP is running and if I go to localhost I get the XAM...

What is the most elegant way to check if all values in a boolean array are true?

I have a boolean array in java: boolean[] myArray = new boolean[10]; What's the most elegant way to check if all the values are true?...

Is there a better way to refresh WebView?

Ok. I have looked EVERYWHERE and my little brain just can't understand a better way to refresh an activity. Any suggestions that I can understand would be great. :) Here is the java code: package com.dge.dges; import android.app.Activity; import ...

Oracle client and networking components were not found

I created SSIS will do task like get data from oracle to sql server.i run ssis package run in my local system.it is working fine but i deployed ssis package in remote system and trying access from sql procedure. I'm getting error like below. Orac...

Change a column type from Date to DateTime during ROR migration

I need to change my column type from date to datetime for an app I am making. I don't care about the data as its still being developed. How can I do this? ...

Include in SELECT a column that isn't actually in the database

I'm trying to execute a SELECT statement that includes a column of a static string value. I've done this in Access, but never with raw SQL. Is this possible? Example: Name | Status ------+-------- John | Unpaid Terry | Unpaid Joe | Unpai...

How to animate button in android?

I am making an android app, and I have a button which leads to a messaging place. On the activity with the button, I check if there is any unread messages, and if so I want to do something to the button to let the user know that there is something un...

How to redirect output to a file and stdout

In bash, calling foo would display any output from that command on the stdout. Calling foo > output would redirect any output from that command to the file specified (in this case 'output'). Is there a way to redirect output to a file and have i...

How to perform OR condition in django queryset?

I want to write a Django query equivalent to this SQL query: SELECT * from user where income >= 5000 or income is NULL. How to construct the Django queryset filter? User.objects.filter(income__gte=5000, income=0) This doesn't work, because i...

Show only two digit after decimal

How to get the double value that is only two digit after decimal point. for example if i=348842. double i2=i/60000; tv.setText(String.valueOf(i2)); this code generating 5.81403333. But I want only 5.81. So what shoud I do?...

oracle plsql: how to parse XML and insert into table

How to load a nested xml file into database table ? <?xml version="1.0" ?> <person> <row> <name>Tom</name> <Address> <State>California</State> <City>Los an...