Examples On Programing Languages

Finding a substring within a list in Python

Background: Example list: mylist = ['abc123', 'def456', 'ghi789'] I want to retrieve an element if there's a match for a substring, like abc Code: sub = 'abc' print any(sub in mystring for mystring in mylist) above prints True if any of the elements...

File upload along with other object in Jersey restful web service

I want to create an employee information in the system by uploading an image along with employee data. I am able to do it with different rest calls using jersey. But I want to achieve in one rest call. I provide below the structure. Please help me ho...

Django ChoiceField

I'm trying to solve following issue: I have a web page that can see only moderators. Fields displayed on this page (after user have registered): Username, First name+Last name, Email, Status, Relevance, etc. I need to display table with information o...

Could not open a connection to your authentication agent

I am running into this error of: $ git push heroku master Warning: Permanently added the RSA host key for IP address '50.19.85.132' to the list of known hosts. ! Your key with fingerprint b7:fd:15:25:02:8e:5f:06:4f:1c:af:f3:f0:c3:c2:65 is not auth...

forEach() in React JSX does not output any HTML

I have a object that I want to output via React: question = { text: "Is this a good question?", answers: [ "Yes", "No", "I don't know" ] } and my react component (cut down), ...

How to access Anaconda command prompt in Windows 10 (64-bit)

I had to install the 64-bit version of Anaconda with python 3.5 in Windows 10. I followed the default settings (AppData/Continuum/Anaconda3). However, after installation, I am unsure how to access the Anaconda command prompt so that I can use conda t...

Why do we usually use || over |? What is the difference?

I'm just wondering why we usually use logical OR || between two booleans not bitwise OR |, though they are both working well. I mean, look at the following: if(true | true) // pass if(true | false) // pass if(false | true) // pass if(false | fa...

SQL - How to find the highest number in a column?

Let's say I have the following data in the Customers table: (nothing more) ID FirstName LastName ------------------------------- 20 John Mackenzie 21 Ted Green 22 Marcy Nate What sort of SELECT statement can get me t...

How do I dynamically change the content in an iframe using jquery?

I was wondering if it is possible to have a site with an iframe and some jquery code that changes the iframe content every 30 seconds. The content is in different webpages. Something like this: <html> <head> <script type="text/...

MySQL VARCHAR size?

I'm wondering, if I have a VARCHAR of 200 characters and that I put a string of 100 characters, will it use 200 bytes or it will just use the actual size of the string?...

Find specific string in a text file with VBS script

I need to find the string "Test Case " & index in a txt file. I give you an example of the lines you can find in this file: <tr><td><a href="../../Login/Log_ in_U1A1">Log_ in_U1A1</a></td></tr> <tr><...

Git: How to check if a local repo is up to date?

I would like to know if my local repo is up to date (and if not, ideally, I would like to see the changes). How could I check this without doing git fetch or git pull ?...

kill a process in bash

How do I kill a process which is running in bash - for example, suppose I open a file: $ gedit file.txt is there any way within the command prompt to close it? This example is fairly trivial, since I could just close the window, but it seems to...

Convert UTF-8 encoded NSData to NSString

I have UTF-8 encoded NSData from windows server and I want to convert it to NSString for iPhone. Since data contains characters (like a degree symbol) which have different values on both platforms, how do I convert data to string?...

Window.open and pass parameters by post method

With window.open method I open new site with parameters, which I have to pass by post method.I've found solution, but unfortunately it doesn't work. This is my code: <script type="text/javascript"> function openWindowWithPost(url,name,k...

Is it possible that one domain name has multiple corresponding IP addresses?

For example, when we connect to www.example.com, at first we try to connect to 192.0.2.1. And if first try fails, then we try 192.0.2.222. Is it possible? Can we register multiple backup IP addresses for one domain name?...

ReferenceError: describe is not defined NodeJs

I am trying to define some endpoints and do a test using nodejs. In server.js I have: var express = require('express'); var func1 = require('./func1.js'); var port = 8080; var server = express(); server.configure(function(){ server.use(express.bo...

Coloring Buttons in Android with Material Design and AppCompat

Before the AppCompat update came out today I was able to change the color of buttons in Android L but not on older versions. After including the new AppCompat update I am unable to change the color for either version, when I do try the button just di...

PHP class: Global variable as property in class

I have a global variable outside my class = $MyNumber; How do I declare this as a property in myClass? For every method in my class, this is what I do: class myClass() { private function foo() { $privateNumber = $GLOBALS['MyNumber'];...

Bootstrap 3 collapsed menu doesn't close on click

I have a more or less standard navigation from bootstrap 3 <body data-spy="scroll" data-target=".navbar-collapse"> <!-- ---------- Navigation ---------- --> <div class="navbar navbar-fixed-top" role="navigation"> &l...

How to sort in mongoose?

I find no doc for the sort modifier. The only insight is in the unit tests: spec.lib.query.js#L12 writer.limit(5).sort(['test', 1]).group('name') But it doesn't work for me: Post.find().sort(['updatedAt', 1]); ...

psql: server closed the connection unexepectedly

I've been trying to run this batch file that goes through the Postgre DB Server and run two different sql files, as shown below: set PGPASSWORD=blah cls @echo on "C:\Progra~1\pgAdmin III\1.16\psql" -d [db name] -h [server name] -p 5432 -U postgres -...

How to acces external json file objects in vue.js app

How to access JSON objects in the vue.js app I am new in this import json from './json/data.json' the JSON file is loaded and now I have to access the objects within it ...

Python: avoid new line with print command

I've started programming today and have this issue with Python. It's pretty dumb but I can't figure out how to do it. When I use the print command, it prints whatever I want and then goes to a different line. For example: print "this should be"; pr...

How to determine the version of the C++ standard used by the compiler?

How do you determine what version of the C++ standard is implemented by your compiler? As far as I know, below are the standards I've known: C++03 C++98 ...

dereferencing pointer to incomplete type

I've seen a lot of questions on this but I'm going to ask the question differently without specific code. Is there a way of EASILY determining what is causing the type to be incomplete? In my case I'm using someone elses code and I'm completely sur...

How do I check if a Sql server string is null or empty

I want to check for data, but ignore it if it's null or empty. Currently the query is as follows... Select Coalesce(listing.OfferText, company.OfferText, '') As Offer_Text, from tbl_directorylisting listing Inner Join tbl_c...

How to get a path to a resource in a Java JAR file

I am trying to get a path to a Resource but I have had no luck. This works (both in IDE and with the JAR) but this way I can't get a path to a file, only the file contents: ClassLoader classLoader = getClass().getClassLoader(); PrintInputStream(c...

Regular Expression: Allow letters, numbers, and spaces (with at least one letter or number)

I'm currently using this regex ^[A-Z0-9 _]*$ to accept letters, numbers, spaces and underscores. I need to modify it to require at least one number or letter somewhere in the string. Any help would be appreciated! This would be for validating userna...

How to remove Firefox's dotted outline on BUTTONS as well as links?

I can make Firefox not display the ugly dotted focus outlines on links with this: a:focus { outline: none; } But how can I do this for <button> tags as well? When I do this: button:focus { outline: none; } the buttons still ha...

Import multiple csv files into pandas and concatenate into one DataFrame

I would like to read several csv files from a directory into pandas and concatenate them into one big DataFrame. I have not been able to figure it out though. Here is what I have so far: import glob import pandas as pd # get data file names path =r...

jQuery UI Dialog individual CSS styling

I'm looking to style a modal dialog (using UI Dialog) with unique CSS that is separate from the traditional dialog, so in essence to have two jQuery dialogs that each look different. I've styled one, for example, <div id="dialog_style1" class="d...

How to find the size of an int[]?

I have int list[] = {1, 2, 3}; How to I get the size of list? I know that for a char array, we can use strlen(array) to find the size, or check with '\0' at the end of the array. I tried sizeof(array) / sizeof(array[0]) as some answers said, ...

How to plot a 2D FFT in Matlab?

I am using fft2 to compute the Fourier Transform of a grayscale image in MATLAB. What is the common way to plot the magnitude of the result?...

How can I read the contents of an URL with Python?

The following works when I paste it on the browser: http://www.somesite.com/details.pl?urn=2344 But when I try reading the URL with Python nothing happens: link = 'http://www.somesite.com/details.pl?urn=2344' f = urllib.urlopen(link) ...

How to convert integer to char in C?

How to convert integer to char in C?...

How can I add additional PHP versions to MAMP

The current version of MAMP that I have only has php 5.2.17 and 5.4.4. I need 5.3.X. Is there a way to add additional versions that can be selected in the MAMP interfaces php preferences? This is for the free version of MAMP, not MAMP PRO. Thanks...

How do I handle a click anywhere in the page, even when a certain element stops the propagation?

We are working on a JavaScript tool that has older code in it, so we cannot re-write the whole tool. Now, a menu was added position fixed to the bottom and the client would very much like it to have a toggle button to open and close the menu, except...

How to upgrade R in ubuntu?

I have R 2.12.1 installed in my ubuntu, and I'd like upgrade to lastest version 2.15, how can achieve that ? Thanks ...

How do I find the caller of a method using stacktrace or reflection?

I need to find the caller of a method. Is it possible using stacktrace or reflection?...

Compare DATETIME and DATE ignoring time portion

I have two tables where column [date] is type of DATETIME2(0). I have to compare two records only by theirs Date parts (day+month+year), discarding Time parts (hours+minutes+seconds). How can I do that?...

Iterate over model instance field names and values in template

I'm trying to create a basic template to display the selected instance's field values, along with their names. Think of it as just a standard output of the values of that instance in table format, with the field name (verbose_name specifically if sp...

How to insert text into the textarea at the current cursor position?

I would like to create a simple function that adds text into a text area at the user's cursor position. It needs to be a clean function. Just the basics. I can figure out the rest. ...

Use of "instanceof" in Java

What is the 'instanceof' operator used for? I learned that Java has the instanceof operator. Can you elaborate where it is used and what are its advantages?...

How to convert array values to lowercase in PHP?

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

Bash array with spaces in elements

I'm trying to construct an array in bash of the filenames from my camera: FILES=(2011-09-04 21.43.02.jpg 2011-09-05 10.23.14.jpg 2011-09-09 12.31.16.jpg 2011-09-11 08.43.12.jpg) As you can see, there is a space in the middle of each filename. I'v...

Getting the first and last day of a month, using a given DateTime object

I want to get the first day and last day of the month where a given date lies in. The date comes from a value in a UI field. If I'm using a time picker I could say var maxDay = dtpAttendance.MaxDate.Day; But I'm trying to get it from a DateTime o...

No module named serial

and I got a question when I run my Python code. I installed Python 2.7 on Windows 7, bit 64. I got an error "No module named serial" when I compiled my code: import serial ser = serial.Serial("COM5", 9600) ser.write("Hello world") x = ser.readli...

.gitignore after commit

I have a git repository hosted on Github. After committing many files, I am realizing that I need to create .gitignore and exclude .exe, .obj files. However, will it automatically remove these committed files from the repository? Is there any way to...

Rails: How does the respond_to block work?

I'm going through the Getting Started with Rails guide and got confused with section 6.7. After generating a scaffold I find the following auto-generated block in my controller: def index @posts = Post.all respond_to do |format| format.html...

Generate an integer sequence in MySQL

I need to do a join with a table/result-set/whatever that has the integers n to m inclusive. Is there a trivial way to get that without just building the table? (BTW what would that type of construct be called, a "Meta query"?) m-n is bounded to so...

Conditional Replace Pandas

I have a DataFrame, and I want to replace the values in a particular column that exceed a value with zero. I had thought this was a way of achieving this: df[df.my_channel > 20000].my_channel = 0 If I copy the channel into a new data frame it's s...

Change project name on Android Studio

I want to change the name of my project and module. But if I try to rename them Android Studio notify me some errors... e.g. I want to change the name from "MyApplication" to "AndroidApp" as shown in the image below. In the first rectangle I want to...

Handling identity columns in an "Insert Into TABLE Values()" statement?

In SQL Server 2000 or above is there anyway to handle an auto generated primary key (identity) column when using a statement like the following? Insert Into TableName Values(?, ?, ?) My goal is to NOT use the column names at all....

How to get the current plugin directory in WordPress?

I need to get the current plugin directory like [wordpress_install_dir]/wp-content/plugins/plugin_name (if getcwd() called from the plugin, it returns [wordpress_install_dir], the root of installation) thanks for help...

Extracting text from a PDF file using PDFMiner in python?

I am looking for documentation or examples on how to extract text from a PDF file using PDFMiner with Python. It looks like PDFMiner updated their API and all the relevant examples I have found contain outdated code(classes and methods have changed)...

Removing all unused references from a project in Visual Studio projects

I just wondered if it possible within various Visual Studio versions to automatically remove all references from a project that were never been used? In your answer, please specify which version of VS the solution applies to....

How to change the port of Tomcat from 8080 to 80?

I want to execute my web app as http://localhost....

Correctly determine if date string is a valid date in that format

I'm receiving a date string from an API, and it is formatted as yyyy-mm-dd. I am currently using a regex to validate the string format, which works ok, but I can see some cases where it could be a correct format according to the string but actually ...

Unresolved Import Issues with PyDev and Eclipse

I am very new to PyDev and Python, though I have used Eclipse for Java plenty. I am trying to work through some of the Dive Into Python examples and this feels like an extremely trivial problem that's just becoming exceedingly annoying. I am using Ub...

base_url() function not working in codeigniter

In my web application using codeigniter. I am trying to use base_url() function but it shows empty results. I have also used autoload helper through autoload file, but then too it doesn't seem to work. Also I had defined base constants but all in vai...

Finding modified date of a file/folder

I am very new to PowerShell, and I was hoping I could get some help creating a script that tells me the modified date of a file. I wish I knew more about PowerShell, as I feel like I am asking a lot (all my free-time this week will be dedicated to l...

Make the console wait for a user input to close

I have a console application that after performing its tasks, must give feedback to the user, such as "operation completed" or "operation failed" and the detailed error. The thing is, if I just "let it run", the output message will be printed but th...

Change border color on <select> HTML form

Is it possible to change the border color on a <select/> element in an HTML form? The border-color style works in Firefox but not IE. I could find no real answers on Google....

Android Google Maps API V2 Zoom to Current Location

I'm trying to mess around with the Maps API V2 to get more familiar with it, and I'm trying to start the map centered at the user's current location. Using the map.setMyLocationEnabled(true); statement, I am able to show my current location on the ma...

change html input type by JS?

How to do this through the tag itself change type from text to password <input type='text' name='pass' /> Is it possible to insert JS inside the input tag itself to change type='text' to type='password'?...

Searching for Text within Oracle Stored Procedures

I need to search through all of the stored procedures in an Oracle database using TOAD. I am looking for anywhere that the developers used MAX + 1 instead of the NEXTVAL on the sequence to get the next ID number. I've been doing SQL Server for years...

Change keystore password from no password to a non blank password

I have a jks keystore with no password. When I run the command keytool -list -keystore mykeystore.jks And it prompts me for the keystore password, I simply hit 'enter'. Please note that the keystore password IS NOT the default java password of '...

Apache VirtualHost 403 Forbidden

I recently tried to set a test server up with Apache. The site must run under domain www.mytest.com. I always get a 403 Forbidden error. I am on Ubuntu 10.10 server edition. The doc root is under dir /var/www. The following are my settings: Content ...

Calling Scalar-valued Functions in SQL

I have migrated a database from oracle, and now have a few Scalar-valued Functions. However, when I call them, I get an error saying: Cannot find either column "dbo" or the user-defined function or aggregate "dbo.chk_mgr", or the name is ambiguo...

Linux: where are environment variables stored?

If I type into a terminal, export DISPLAY=:0.0 ... where is the shell storing that environment variable? I'm using Ubuntu 8.10. I've looked in the files ~/.profile and /etc/profile and can find no trace of DISPLAY....

Python dict how to create key or append an element to key?

I have an empty dictionary. Name: dict_x It is to have keys of which values are lists. From a separate iteration, I obtain a key (ex: key_123), and an item (a tuple) to place in the list of dict_x's value key_123. If this key already exists, I want t...

How do you merge two Git repositories?

Consider the following scenario: I have developed a small experimental project A in its own Git repo. It has now matured, and I'd like A to be part of larger project B, which has its own big repository. I'd now like to add A as a subdirectory of B. ...

Clear and refresh jQuery Chosen dropdown list

I'm trying to clear jQuery Chosen dropdown list and refresh it. HTML: <select data-placeholder="Select Picture..." class="chosen-select" style="width:250px;" id="picturegallery" tabindex="2"> <option value="" selected="selected"><...

Handling 'Sequence has no elements' Exception

I am updating a quantity in my cart, but it is throwing a Sequence has no elements' exception. And I don't know what that even means. At first I thought that maybe there was a null value being passed somewhere, but that isn't the case, as I've check...

Are "while(true)" loops so bad?

I've been programming in Java for several years now, but I just recently returned to school to get a formal degree. I was quite surprised to learn that, on my last assignment, I lost points for using a loop like the one below. do{ //get some in...

Date object to Calendar [Java]

I have a class Movie in it i have a start Date, a duration and a stop Date. Start and stop Date are Date Objects (private Date startDate ...) (It's an assignment so i cant change that) now I want to automatically calculate the stopDate by adding the ...

Import error No module named skimage

I am building code on python using skimage. But I am getting import errors while using skimage.segmentation. Traceback (most recent call last): File "superpixel.py", line 5, in from skimage.segmentation import slic ImportError: No module ...

Set a default parameter value for a JavaScript function

I would like a JavaScript function to have optional arguments which I set a default on, which get used if the value isn't defined (and ignored if the value is passed). In Ruby you can do it like this: def read_file(file, delete_after = false) # co...

How to disable action bar permanently

I can hide the action bar in honeycomb using this code: getActionBar().hide(); But when the keyboard opens, and user copy-pastes anything, the action bar shows again. How can I disable the action bar permanently?...

Bootstrap 3 Slide in Menu / Navbar on Mobile

I am building a browser-based mobile app and I've decided to use Bootstrap 3 as the css framework for the design. Bootstrap 3 comes with a great "responsive" feature in the navigation bar where it collapses automatically if it detects a specific "bre...

iOS 10: "[App] if we're in the real pre-commit handler we can't actually add any new fences due to CA restriction"

I sometimes get this message in the logs of Xcode 8b3 when running my app, everything seems to work, but I'd like to know where this comes from. Google did not help at all....

How to remove white space characters from a string in SQL Server

I'm trying to remove white spaces from a string in SQL but LTRIM and RTRIM functions don't seem to work? Column: [ProductAlternateKey] [nvarchar](25) COLLATE Latin1_General_CS_AS NULL Query: select REPLACE(ProductAlternateKey, ' ', '@'), ...

Using an Alias in a WHERE clause

I have a query which is meant to show me any rows in table A which have not been updated recently enough. (Each row should be updated within 2 months after "month_no".): SELECT A.identifier , A.name , TO_NUMBER(DECODE( A.month_no ...

How to use patterns in a case statement?

The man page says that case statements use "filename expansion pattern matching". I usually want to have short names for some parameters, so I go: case $1 in req|reqs|requirements) TASK="Functional Requirements";; met|meet|meetings) TASK="Me...

How do I use Wget to download all images into a single folder, from a URL?

I am using wget to download all images from a website and it works fine but it stores the original hierarchy of the site with all the subfolders and so the images are dotted around. Is there a way so that it will just download all the images into a s...

Why does the Google Play store say my Android app is incompatible with my own device?

I am hesitant to ask this question, because it appears as though many people have a similar problem and yet I have found no solution that solves my particular instance. I have developed an Android app (link to the actual app) and have uploaded it to...

Change Title of Javascript Alert

How can i change the title of javascript alert popup ?...

Which language uses .pde extension?

While searching for an implementation of the Barnsley's Fern fractal I came across a implementation that has .pde extension. Which programming language uses this extension? Implementation Page...

calculating execution time in c++

I have written a c++ program , I want to know how to calculate the time taken for execution so I won't exceed the time limit. #include<iostream> using namespace std; int main () { int st[10000],d[10000],p[10000],n,k,km,r,t,ym[10000]; ...

Getting char from string at specified index

As stated how to get char from string at specified index in the visual basic? I look through google and these do not work: s(index) , s.Chars(index),s,Characters(index) So how to get char at specified index?...

"[notice] child pid XXXX exit signal Segmentation fault (11)" in apache error.log

I am using Apache/PHP/MySQL stack. Using as framework CakePHP. Every now and then I get a blank white page. I can't debug it through Cake, so I peek in the apache error.log and here's what I get: [Wed Oct 12 15:27:23 2011] [notice] child pid 3580 ...

Delete cookie by name?

How can I delete a specific cookie with the name roundcube_sessauth? Shouldn't the following: function del_cookie(name) { document.cookie = 'roundcube_sessauth' + '=; expires=Thu, 01-Jan-70 00:00:01 GMT;'; } And then: <a href="javas...

Flask Python Buttons

I'm trying to create two buttons on a page. Each one I would like to carry out a different Python script on the server. So far I have only managed to get/collect one button using. def contact(): form = ContactForm() if request.method == 'POST': ...

JPA eager fetch does not join

What exactly does JPA's fetch strategy control? I can't detect any difference between eager and lazy. In both cases JPA/Hibernate does not automatically join many-to-one relationships. Example: Person has a single address. An address can belong to m...

How do I correct the character encoding of a file?

I have an ANSI encoded text file that should not have been encoded as ANSI as there were accented characters that ANSI does not support. I would rather work with UTF-8. Can the data be decoded correctly or is it lost in transcoding? What tools coul...

Query to search all packages for table and/or column

Is there a query I can run to search all packages to see if a particular table and/or column is used in the package? There are too many packages to open each one and do a find on the value(s) I'm looking for....

Factorial in numpy and scipy

How can I import factorial function from numpy and scipy separately in order to see which one is faster? I already imported factorial from python itself by import math. But, it does not work for numpy and scipy....

Visual Studio: Relative Assembly References Paths

When adding a reference to an assembly located within the solution directory, is there any way to add it relatively, so that when checked in and out of a repository it is referenced in projects correctly?...

check if array is empty (vba excel)

These if ... then statements are getting the wrong results in my opinion. The first is returning the value 'false' when it should be 'true'. The fourth returns the right value. The second and third return an error. Sub empty_array() Dim arr1(...

How can you export the Visual Studio Code extension list?

I need to send all my installed extensions to my colleagues. How can I export them? The extension manager seems to do nothing... It won't install any extension....

Sublime Text 2 - Show file navigation in sidebar

I just switched to Sublime Text as my new editor. If I open the sidebar it shows the opening file, but what I want is a file navigation sidebar, is it possible to change that without downloading plugins? ...

How to best display in Terminal a MySQL SELECT returning too many fields?

I'm using PuTTY to run: mysql> SELECT * FROM sometable; sometable has many fields and this results in many columns trying to be displayed in the terminal. The fields wrap onto the next line so it is very hard to line up column titles with field...

jQuery animate margin top

I have a script on jsfiddle: http://jsfiddle.net/kX7b6/ Nothing happens on hover On hover I want the green box to overlap the red box with a negative margin -50px. Nothing happens. The animation works, but not margin Just to show that the animati...

How do you remove a specific revision in the git history?

Suppose your git history looks like this: 1 2 3 4 5 1–5 are separate revisions. You need to remove 3 while still keeping 1, 2, 4 and 5. How can this be done? Is there an efficient method when there are hundreds of revisions after the one to be d...

A variable modified inside a while loop is not remembered

In the following program, if I set the variable $foo to the value 1 inside the first if statement, it works in the sense that its value is remembered after the if statement. However, when I set the same variable to the value 2 inside an if which is i...

Javascript - validation, numbers only

I'm trying to get my login form to only validate if only numbers were inputted. I can it to work if the input is only digits, but when i type any characters after a number, it will still validate etc. 12akf will work. 1am will work. How can i get pas...

How do I execute a PowerShell script automatically using Windows task scheduler?

I have one PowerShell script which sends emails. I want to execute that script automatically, every 1 minute. How can I do it, using task scheduler? Currently I have created a task and provided the path of my script. But that scheduler opens my scri...

SQL Greater than, Equal to AND Less Than

I want to create a query like the following, But im unsure of how to code it correctly, I want it to return all bookings within 1 hour of a StartTime, Here is what i came up with: SELECT BookingId, StartTime FROM Booking WHERE StartTime <=> 1...

How can I remove the extension of a filename in a shell script?

What's wrong with the following code? name='$filename | cut -f1 -d'.'' As is, I get the literal string $filename | cut -f1 -d'.', but if I remove the quotes I don't get anything. Meanwhile, typing "test.exe" | cut -f1 -d'.' in a shell gives me ...

SVN repository backup strategies

I'm new to SVN and I'd like to know what methods are available for backing up repositories in a Windows environment?...

How to convert byte[] to InputStream?

Possible Duplicate: Can we convert a byte array into an InputStream in Java? There is a way to convert an array of bytes (byte[]) to InputStream in Java? I looked at some methods in Apache Commons IO, but found nothing....

Adding a color background and border radius to a Layout

I want to create a layout with rounded corners and a filled color background. This is my layout: <LinearLayout android:layout_width="match_parent" android:layout_height="210dp" android:orientation="vertical" android:layout_margin...

Recyclerview and handling different type of row inflation

I'm trying to work with the new RecyclerView, but I could not find an example of a RecyclerView with different types of rows/cardviews getting inflated. With ListView I override the getViewTypeCount and getItemViewType, for handling different types ...

Creating a procedure in mySql with parameters

I am trying to make a stored procedure using mySQL. This procedure will validate a username and a password. I'm currently running mySQL 5.0.32 so it should be possible to create procedures. Heres the code I've used. All I get is an SQL syntax error...

jQuery AJAX file upload PHP

I want to implement a simple file upload in my intranet-page, with the smallest setup possible. This is my HTML part: <input id="sortpicture" type="file" name="sortpic" /> <button id="upload">Upload</button> and this is my JS jq...

C++ create string of text and variables

I'm trying to do something very simple and yet, after an hour of so of searching a I can't find a suitable answer so I must be missing something fairly obvious. I'm trying to dynamically create filenames for use with ifstream. Whilst I understand va...

How to use ArgumentCaptor for stubbing?

In Mockito documentation and javadocs it says It is recommended to use ArgumentCaptor with verification but not with stubbing. but I don't understand how ArgumentCaptor can be used for stubbing. Can someone explain the above statement and show...

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

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

how to show calendar on text box click in html

In html i want to show calendar to select date while clicking a text box. then we select a date from that calendar then the selected date will be display in that text box....

importing pyspark in python shell

This is a copy of someone else's question on another forum that was never answered, so I thought I'd re-ask it here, as I have the same issue. (See http://geekple.com/blogs/feeds/Xgzu7/posts/351703064084736) I have Spark installed properly on my ma...

How to find the day, month and year with moment.js

2014-07-28 How do I find the month, year and day with moment.js given the date format above? var check = moment(n.entry.date_entered).format("YYYY/MM/DD"); var month = check.getUTCMonth(); var day = check.entry.date_entered.getUTCDate(); var year ...

Can't bind to 'ngModel' since it isn't a known property of 'input'

I've got the following error when launching my Angular app, even if the component is not displayed. I have to comment out the <input> so that my app works. zone.js:461 Unhandled Promise rejection: Template parse errors: Can't bind to 'ngModel...

How to retrieve Jenkins build parameters using the Groovy API?

I have a parameterized job that uses the Perforce plugin and would like to retrieve the build parameters/properties as well as the p4.change property that's set by the Perforce plugin. How do I retrieve these properties with the Jenkins Groovy API?...

How do I pass data to Angular routed components?

In one of my Angular 2 routes's templates (FirstComponent) I have a button first.component.html <div class="button" click="routeWithData()">Pass data and route</div> My goal is to achieve: Button click -> route to another componen...

How to launch a Google Chrome Tab with specific URL using C#

Is there a way I can launch a tab (not a new Window) in Google Chrome with a specific URL loaded into it from a custom app? My application is coded in C# (.NET 4 Full). I'm performing some actions via SOAP from C# and once successfully completed, I...

Convert time.Time to string

I'm trying to add some values from my database to a []string in Go. Some of these are timestamps. I get the error: cannot use U.Created_date (type time.Time) as type string in array element Can I convert time.Time to string? type UsersSession...

Express.js req.body undefined

I have this as configuration of my Express server app.use(app.router); app.use(express.cookieParser()); app.use(express.session({ secret: "keyboard cat" })); app.set('view engine', 'ejs'); app.set("view options", { layout: true }); //Handles post r...

Why em instead of px?

I heard you should define sizes and distances in your stylesheet with em instead of in pixels. So the question is why should I use em instead of px when defining styles in css? Is there a good example that illustrates this?...

How do I get the last word in each line with bash

For example i have a file: $ cat file i am the first example. i am the second line. i do a question about a file. and i need: example, line, file i intent with "awk" but the problem is that the words are in different space ...

Could not extract response: no suitable HttpMessageConverter found for response type

I am new with spring integration and working in spring integration http module for my project requirement. I am sending request from outbound gateway as a http client. I am trying to initiate a request to the server and server should return me ...

React Native: Possible unhandled promise rejection

I'm getting the following error: Possible unhandled promise rejection (id:0: Network request failed Here's the promise code, I don't see what's wrong here, any ideas? return fetch(url) .then(function(response){ return response.json()...

How to read request body in an asp.net core webapi controller?

I'm trying to read the request body in the OnActionExecuting method, but I always get null for the body. var request = context.HttpContext.Request; var stream = new StreamReader(request.Body); var body = stream.ReadToEnd(); I have tried to explicitl...

How to install Maven 3 on Ubuntu 18.04/17.04/16.10/16.04 LTS/15.10/15.04/14.10/14.04 LTS/13.10/13.04 by using apt-get?

Try: sudo apt-get install maven If it works for you ignore the rest of this post. Intro I started setting up my Ubuntu 12.10 on April 2013 and the normal sudo apt-get install maven was not working for maven 3 back then. The manual installatio...

Removing an item from a select box

How do I remove items from, or add items to, a select box? I'm running jQuery, should that make the task easier. Below is an example select box. <select name="selectBox" id="selectBox"> <option value="option1">option1</option> ...

How to get rid of the "No bootable medium found!" error in Virtual Box?

I am working withing Oracle VM Virtual box on Solaris 11. When the battery of my laptop became 0% and I wasn't beside my laptop, the system halted. So when I started the session I got the following: Fatal: No bootable medium found! System halted. ...

Instantiating a generic class in Java

I know Java's generics are somewhat inferior to .Net's. I have a generic class Foo<T>, and I really need to instantiate a T in Foo using a parameter-less constructor. How can one work around Java's limitation?...

How do I get a list of locked users in an Oracle database?

I want to be able to list all of the users in a given database along with an icon that determines whether they are locked or not. The problem I'm having is querying the "locked" status for a given user, I though it might have been on all_users but it...

Does static constexpr variable inside a function make sense?

If I have a variable inside a function (say, a large array), does it make sense to declare it both static and constexpr? constexpr guarantees that the array is created at compile time, so would the static be useless? void f() { static constexpr ...

Simple 'if' or logic statement in Python

How would you write the following in Python? if key < 1 or key > 34: I've tried every way I can think of and am finding it very frustrating....

Difference between mkdir() and mkdirs() in java for java.io.File

Can anyone tell me the difference between these two methods: file.mkdir() file.mkdirs() ...

How do I add a Fragment to an Activity with a programmatically created content view

I want to add a Fragment to an Activity that implements its layout programmatically. I looked over the Fragment documentation but there aren't many examples describing what I need. Here is the type of code I tried to write: public class DebugExample...

How to find length of digits in an integer?

In Python, how do you find the number of digits in an integer?...

How to loop and render elements in React.js without an array of objects to map?

I'm trying to convert a jQuery component to React.js and one of the things I'm having difficulty with is rendering n number of elements based on a for loop. I understand this is not possible, or recommended and that where an array exists in the mo...

Returning a file to View/Download in ASP.NET MVC

I'm encountering a problem sending files stored in a database back to the user in ASP.NET MVC. What I want is a view listing two links, one to view the file and let the mimetype sent to the browser determine how it should be handled, and the other to...

Rubymine: How to make Git ignore .idea files created by Rubymine

I use Rubymine for Rails projects. Very often, Rubymine makes changes in .idea/* files that I don't care about. But it keeps preventing me from checking out new branches, and makes my version of .idea/ different from my coworkers. We already added ....

Checking if a variable is initialized

Seems like this would be a duplicate, but maybe it is just so obvious it hasn't been asked... Is this the proper way of checking if a variable (not pointer) is initialized in a C++ class? class MyClass { void SomeMethod(); char mCharacter;...

Proper way to renew distribution certificate for iOS

My distribution certificate is expiring on June 7th, along with all of my provisioning files. How do I properly renew it? Should I revoke it now and request a new one? If I do that than will all my live apps be taken down?...

git command to move a folder inside another

I have created a folder common with a bunch of source files and folders. Now I want to move the common folder into the include folder so it looks like include/common I tried these: git add include git mv common/ include/ but it fails with this erro...

youtube: link to display HD video by default

Is there a way to link a youtube video so that it plays automatically in HD? I've tried several things (adding &hd=1, &vq=hd720) but none of them works For example: https://www.youtube.com/v/BH_lZSTYFHs&hd=1 It starts always as 480p, ...

find_spec_for_exe': can't find gem bundler (>= 0.a) (Gem::GemNotFoundException)

I used sudo bundle install and that might be the cause of the issue? Now I have: gem -v 2.6.14 ruby -v ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-darwin15] jekyll -v jekyll 3.6.2 bundle -vBundler version 1.16.0.pre.3 I'm getting the fol...

getting integer values from textfield

I am trying to get Integer values from my jtextfield but not able to it is showing incompatible datatypes required int found string. Is there some other way of writing my code is as follows and i want to get only integer values private void jTextFie...

How do I make Git ignore file mode (chmod) changes?

I have a project in which I have to change the mode of files with chmod to 777 while developing, but which should not change in the main repo. Git picks up on chmod -R 777 . and marks all files as changed. Is there a way to make Git ignore mode cha...

Check if string matches pattern

How do I check if a string matches this pattern? Uppercase letter, number(s), uppercase letter, number(s)... Example, These would match: A1B2 B10L1 C1N200J1 These wouldn't ('^' points to problem) a1B2 ^ A10B ^ AB400 ^ ...

Is it really impossible to make a div fit its size to its content?

I'd like to clarify whether it's possible or not to make a div fit its size based on the content's size without having to make elements float or having to make their position absolute. Is it possible?...

how to check the version of jar file?

I am currently working on a J2ME polish application, just enhancing it. I am finding difficulties to get the exact version of the jar file. Is there any way to find the version of the jar file for the imports done in the class? I mean if you have som...

How do I use FileSystemObject in VBA?

Is there something that I need to reference? How do I use this: Dim fso As New FileSystemObject Dim fld As Folder Dim ts As TextStream I am getting an error because it does not recognize these objects....

Java, how to compare Strings with String Arrays

I have been searching here for some time but haven't been able to find the answer to it. I am basically required to use an array for this assignment from college. And then I am supposed to check that the input (which is also a String) matches whatev...

C++ string to double conversion

Usually when I write anything in C++ and I need to convert a char into an int I simply make a new int equal to the char. I used the code(snippet) string word; openfile >> word; double lol=word; I receive the error that Code1.cpp ca...

Column name or number of supplied values does not match table definition

In SQL server, I am trying to insert values from one table to another by using the below query: delete from tblTable1 insert into tblTable1 select * from tblTable1_Link I am getting the following error: Column name or number of supplied value...

Django return redirect() with parameters

In my view function I want to call another view and pass data to it : return redirect('some-view-name', backend, form.cleaned_data) , where backend is of registration.backends object, and form.cleaned_data is a dict of form data (but both must be ...

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

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

Remove Array Value By index in jquery

Array: var arr = {'abc','def','ghi'}; I want to remove above array value 'def' by using index....

How to get full REST request body using Jersey?

How can one get the full HTTP REST request body for a POST request using Jersey? In our case the data will be XML. Size would vary from 1K to 1MB. The docs seem to indicate you should use MessageBodyReader but I can't see any examples....

How to delete multiple pandas (python) dataframes from memory to save RAM?

I have lot of dataframes created as part of preprocessing. Since I have limited 6GB ram, I want to delete all the unnecessary dataframes from RAM to avoid running out of memory when running GRIDSEARCHCV in scikit-learn. 1) Is there a function to lis...

Why my $.ajax showing "preflight is invalid redirect error"?

I tried the following code in Postman and it was working. Is there something wrong with the code? $.ajax({ url: 'http://api.example.com/users/get', type: 'POST', headers: { 'name-api-key':'ewf45r4435trge', }, data: { 'uid'...

Curl : connection refused

I got the following error while running curl: curl: (7) Failed to connect to 127.0.0.1 port 8080: Connection refused. It seems that it is easy to debug, but, I didnt find how to solve it. The adress 127.0.0.1 is mentioned in the file etc/host...

Can't import database through phpmyadmin file size too large

I have been trying to import Database through phpMyAdmin. My database file is a.sql and it's size is 1.2 GB I am trying to import this on local and phpMyAdmin is saying: You probably tried to upload too large file. Please refer to documentation ...

Disable vertical sync for glxgears

Sometimes you need to check whether you Linux 3D acceleration is really working (besides the glxinfo output). This can be quickly done by the glxgears tool. However, the FPS are often limited to the displays vertical refresh rate (i.e. 60 fps). So th...

How to add a TextView to a LinearLayout dynamically in Android?

I try to add a TextView to a LinearLayout dynamically such as in the following code, but it doesn't appear when I run the application? setContentView(R.layout.advanced); m_vwJokeLayout=(LinearLayout) this.findViewById(R.id.m_vwJokeLayout); m_vwJoke...

MVC If statement in View

I have problem with IF statement inside MVC View. I am trying to use it for creating row for every three items. <div class="content"> <div class="container"> @if (ViewBag.Articles != null) { int nmb = 0; foreach (va...

The transaction log for database is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases

I am getting following error while I am trying to delete 355447 records in single delete query. The transaction log for database is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases I tried...

Converting Select results into Insert script - SQL Server

I have SQL Server 2008, SQL Server Management Studio. I need to select data from Table1 in database1. Then I have to edit some values in the results and insert values into Table1 in database2. Or let me put it other way. How can I convert the da...

make image( not background img) in div repeat?

I'm trying to repeat-y an image that's in a div and no background image but haven't figured how. Could you please point me to a solution? My code looks like this: <div id="rightflower"> <img src="/image/layout/lotus-dreapta.png" style="rep...

Create a jTDS connection string

my sql server instance name is MYPC\SQLEXPRESS and I'm trying to create a jTDS connection string to connect to the database 'Blog'. Can anyone please help me accomplish that? I'm trying to do like this: DriverManager.getConnection("jdbc:jtds:sqlser...

"Eliminate render-blocking CSS in above-the-fold content"

I've been using Google PageSpeed insights to try and improve my site's performance, and so far it's proven extremely successful. Things like deferring scripts worked beautifully, since I already had an in-house version of jQuery's .ready() to defer s...

How to export MySQL database with triggers and procedures?

How to create a MySQL database dump (.sql file) with all its triggers and procedures?...

Build a basic Python iterator

How would one create an iterative function (or iterator object) in python?...

When does System.gc() do something?

I know that garbage collection is automated in Java. But I understood that if you call System.gc() in your code that the JVM may or may not decide to perform garbage collection at that point. How does this work precisely? On what basis/parameters exa...

Installing Oracle Instant Client

I can't seem to figure out how to install the Oracle client on Windows Server 2008. I downloaded x64 version (the first file on the list) here. There are installation instructions on the bottom of that page: Step 2 ("instantclient") Which executa...

TypeScript and field initializers

How to init a new class in TS in such a way (example in C# to show what I want): // ... some code before return new MyClass { Field1 = "ASD", Field2 = "QWE" }; // ... some code after [edit] When I was writing this question I was pure .NET develop...

How does OkHttp get Json string?

Solution: It was a mistake on my side. The right way is response.body().string() other than response.body.toString() Im using Jetty servlet, the URL ishttp://172.16.10.126:8789/test/path/jsonpage, every time request this URL it will return {"empl...

Double precision floating values in Python?

Are there data types with better precision than float?...

Array to Hash Ruby

Okay so here's the deal, I've been googling for ages to find a solution to this and while there are many out there, they don't seem to do the job I'm looking for. Basically I have an array structured like this ["item 1", "item 2", "item 3", "item ...

Refresh a page using JavaScript or HTML

How can I refresh a page using JavaScript or HTML?...

How to execute an oracle stored procedure?

I am using oracle 10g express edition. It has a nice ui for db developers. But i am facing some problems executing stored procedures. Procedure: create or replace procedure temp_proc is begin DBMS_OUTPUT.PUT_LINE('Test'); end it is created suc...

Mixing C# & VB In The Same Project

Can you mix vb and c# files in the same project for a class library? Is there some setting that makes it possible? I tried and none of the intellisense works quite right, although the background compiler seems to handle it well enough (aside from th...

Why would Oracle.ManagedDataAccess not work when Oracle.DataAccess does?

I'm developing a very simple application which I intend to use to troubleshoot an issue I am having on a few machines but before I even got that far I ran into a few issues, including cpu architecture differences and Oracle database libraries. I hav...

CSS Flex Box Layout: full-width row and columns

Hello fellow programmers! I've got a simple box-layout which I would love to achieve using flexbox, but I simply can't figure it out. It should look like this image. So basically a row and two columns, with the row being fixed at lets say 100px i...

Playing sound notifications using Javascript?

How can I do that, so whenever a user clicks a link we play a sound? Using javascript and jquery here....

npm install doesn't create node_modules directory

I am trying to do a homework for a mongodb uni course. They gave us some files, instructions are: run npm install mongodb then node app.js for some reason npm install does not create a node_modules directory but I don't see any build errors: mongo...

What is the correct syntax for 'else if'?

I'm a new Python programmer who is making the leap from 2.6.4 to 3.1.1. Everything has gone fine until I tried to use the 'else if' statement. The interpreter gives me a syntax error after the 'if' in 'else if' for a reason I can't seem to figure out...

How do I get indices of N maximum values in a NumPy array?

NumPy proposes a way to get the index of the maximum value of an array via np.argmax. I would like a similar thing, but returning the indexes of the N maximum values. For instance, if I have an array, [1, 3, 2, 4, 5], function(array, n=3) would ret...

How to create a JSON object

I am trying to create an JSON object out of a PHP array. The array looks like this: $post_data = array('item_type_id' => $item_type, 'string_key' => $string_key, 'string_value' => $string_value, 'string_extra' => $string_extr...

How to change the default encoding to UTF-8 for Apache?

I am using a hosting company and it will list the files in a directory if the file index.html is not there, it uses iso-8859-1 as the default encoding. If the server is Apache, is there a way to set UTF-8 as the default instead? Update: Additionall...

How to import Maven dependency in Android Studio/IntelliJ?

I've created a new Android project using the default wizard in Android Studio. Compiled, and deployed the app to my device. All is well. Now I want to import an external library that is available on Maven. (http://square.github.io/picasso/). I went ...

Programmatically register a broadcast receiver

I'd like to know what is the best practice/way of programmatically register a broadcast receiver. I want to register specific receivers according to user choice. As the registration is done through the manifest file, I'm wondering if there's a prope...

Find out whether radio button is checked with JQuery?

I can set a radio button to checked fine, but what I want to do is setup a sort of 'listener' that activates when a certain radio button is checked. Take, for example the following code: $("#element").click(function() { $('#radio_button').at...

How do write IF ELSE statement in a MySQL query

How do I write an IF ELSE statement in a MySQL query? Something like this: mysql_query("...(irrelevant code).. IF(action==2&&state==0){state=1}"); Then down in my array I should be able to do this: $row['state'] //this should equal 1,...

How to do a JUnit assert on a message in a logger

I have some code-under-test that calls on a Java logger to report its status. In the JUnit test code, I would like to verify that the correct log entry was made in this logger. Something along the following lines: methodUnderTest(bool x){ if(x) ...

Most efficient way to increment a Map value in Java

I hope this question is not considered too basic for this forum, but we'll see. I'm wondering how to refactor some code for better performance that is getting run a bunch of times. Say I'm creating a word frequency list, using a Map (probably a Hash...

How to fix "containing working copy admin area is missing" in SVN?

I deleted manually a directory I just added, offline, in my repository. I can't restore the directory. Any attempt to do an update or a commit will fail with: "blabla/.svn" containing working copy admin area is missing. I understand why, but is ...

Iterating through struct fieldnames in MATLAB

My question is easily summarized as: "Why does the following not work?" teststruct = struct('a',3,'b',5,'c',9) fields = fieldnames(teststruct) for i=1:numel(fields) fields(i) teststruct.(fields(i)) end output: ans = 'a' ??? Argument to dyn...

How to find out the username and password for mysql database

I've forgotten what I set as username and password for mysql database. How could I be able to find it out? I am using wamp server. I am a newbie in mysql....

Why do I get the "Unhandled exception type IOException"?

I have the following simple code: import java.io.*; class IO { public static void main(String[] args) { BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in)); String userInput; while ((userI...

How to mock void methods with Mockito

How to mock methods with void return type? I implemented an observer pattern but I can't mock it with Mockito because I don't know how. And I tried to find an example on the Internet but didn't succeed. My class looks like this: public class Wor...

how to configure hibernate config file for sql server

Here is the config file for MySQL: <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property> <property name="hibernate.connection.url">jd...

Fundamental difference between Hashing and Encryption algorithms

I see a lot of confusion between hashes and encryption algorithms and I would like to hear some more expert advice about: When to use hashes vs encryptions What makes a hash or encryption algorithm different (from a theoretical/mathematical level) ...

Faster way to zero memory than with memset?

I learned that memset(ptr, 0, nbytes) is really fast, but is there a faster way (at least on x86)? I assume that memset uses mov, however when zeroing memory most compilers use xor as it's faster, correct? edit1: Wrong, as GregS pointed out that onl...

How to have an auto incrementing version number (Visual Studio)?

I want to store a set of integers that get auto incremented at build time: int MajorVersion = 0; int MinorVersion = 1; int Revision = 92; When I compile, it would auto-increment Revision. When I build the setup project, it would increment MinorVer...

How to get to a particular element in a List in java?

I have a CSV file. It has many lines. In each line there are multiple values separated by commas. I am using OPENCSV to extract data from the file. I want to have the ability to directly go to any particular line which is in List data structure. CS...

Easiest way to use SVG in Android?

I have found a myriad of libraries in order to use svg in Android and avoid the frustrating creation of different resolutions and dropping files for each resolution, this becomes very annoying when the app has many icons or images. Can anyone be as ...

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

How do I create a right click context menu in Java Swing?

I'm currently creating a right-click context menu by instantiating a new JMenu on right click and setting its location to that of the mouse's position... Is there a better way?...

Is there any way to set environment variables in Visual Studio Code?

Could you please help me, how to setup environment variables in visual studio code?...

Where is Python's sys.path initialized from?

Where is Python's sys.path initialized from? UPD: Python is adding some paths before refering to PYTHONPATH: >>> import sys >>> from pprint import pprint as p >>> p(sys.path) ['', 'C:\\Python25\\lib\\...

How to specify a local file within html using the file: scheme?

I'm loading a html file hosted on the OS X built in Apache server, within that file I am linking to another html file in the same directory as follows: <a href="2ndFile.html"><button type="submit">Local file</button> This works. ...

Unioning two tables with different number of columns

I have two tables (Table A and Table B). These have different number of columns - Say Table A has more columns. How can I union these two table and get null for the columns that Table B does not have?...

Is it possible to hide/encode/encrypt php source code and let others have the system?

Is it possible to hide/encode/encrypt the php file/source code, and let others have the system installed and run on their machine?...

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

Getting multiple values with scanf()

I am using scanf() to get a set of ints from the user. But I would like the user to supply all 4 ints at once instead of 4 different promps. I know I can get one value by doing: scanf( "%i", &minx); But I would like the user to be able to do s...

What is REST call and how to send a REST call?

I want to ask some questions about the REST call. I am the green for the REST call and I would like to like what is REST call and how to use the URL to send a REST call to the server. Can anyone give me some basic tutorial or link for my to reference...

How can I read a text file in Android?

I want to read the text from a text file. In the code below, an exception occurs (that means it goes to the catch block). I put the text file in the application folder. Where should I put this text file (mani.txt) in order to read it correctly? ...

Install Chrome extension form outside the Chrome Web Store

I have developed a Chrome extension and I have packed it. I sent my extension to some people to try it, but Chrome started to block extensions that it does not find in the store. Is there any way to install my extension without getting blocked by Ch...

Resetting remote to a certain commit

I want to discard all changes done after commit <commit-hash> . So I did: git reset --hard <commit-hash> Now I want to do the same with my remote. How can I do this? I have done some commits (and pushes) after <commit-hash> and I...

What are enums and why are they useful?

Today I was browsing through some questions on this site and I found a mention of an enum being used in singleton pattern about purported thread safety benefits to such solution. I have never used enums and I have been programing in Java for more tha...

Javascript window.open pass values using POST

I have a javascript function that uses window.open to call another page and returning the result. Here is the section of my code: var windowFeatures = "status=0, toolbar=0, location=0, menubar=0, directories=0, resizable=1, scrollbars=1"; window.op...

Order by multiple columns with Doctrine

I need to order data by two columns (when the rows have different values for column number 1, order by it; otherwise, order by column number 2) I'm using a QueryBuilder to create the query. If I call the orderBy method a second time, it replaces an...

Can I use GDB to debug a running process?

Under linux, can I use GDB to debug a process that is currently running?...

An App ID with Identifier '' is not available. Please enter a different string

I am trying to add a new APP ID to prepare for App Store submission and got the following error under the bundle ID I provided. An App ID with Identifier 'com.domainName.AppName' is not available. Please enter a different string. What does this mea...

How do you create a toggle button?

I want to create a toggle button in html using css. I want it so that when you click on it , it stays pushed in and than when you click it on it again it pops out. If theres no way of doing it just using css. Is there a way to do it using jQuery?...

Have a fixed position div that needs to scroll if content overflows

I have actually two issues, but lets resolve the primary issue first as I believe the other is easier to address. I have a fixed position div on the left side of the scroll for a menu. Right side is a standard div that scrolls properly. The issue is...

Please initialize the log4j system properly. While running web service

Maybe it looks silly to ask this but I am confused. I referred to Configuring Log4j property but it doesn't seem to help. I have written a simple web service HelloWorld. And while running it I am getting the error something like this : log4j:WA...

Git add all files modified, deleted, and untracked?

Is there a way to add all files no matter what you do to them whether it be deleted, untracked, etc? like for a commit. I just don't want to have to git add or git rm all my files every time I commit, especially when I'm working on a large product....

JQuery select2 set default value from an option in list?

I want to be able to set the default/selected value of a select element using the JQuery Select2 plugin....

Property '...' has no initializer and is not definitely assigned in the constructor

in my Angular app i have a component: import { MakeService } from './../../services/make.service'; import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-vehicle-form', templateUrl: './vehicle-form.component.html', sty...

Remove multiple objects with rm()

My memory is getting clogged by a bunch of intermediate files (call them temp1, temp2, etc.). and I would like to know if it is possible to remove them from memory without doing repeated rm calls (i.e. rm(temp1), rm(temp2))? I tried rm(list(temp1, te...

pandas read_csv index_col=None not working with delimiters at the end of each line

I am going through the 'Python for Data Analysis' book and having trouble in the 'Example: 2012 Federal Election Commision Database' section reading the data to a DataFrame. The trouble is that one of the columns of data is always being set as the in...

What does bundle exec rake mean?

What does bundle exec rake db:migrate mean? Or just bundle exec rake <command> in general? I understand that bundle takes care of maintaining things in the Gemfile. I know what the word "exec" means. I understand that rake maintains all the ...

Parse time of format hh:mm:ss

How can I parse a time of format hh:mm:ss , inputted as a string to obtain only the integer values (ignoring the colons) in java?...

SQL - HAVING vs. WHERE

I have the following two tables: 1. Lecturers (LectID, Fname, Lname, degree). 2. Lecturers_Specialization (LectID, Expertise). I want to find the lecturer with the most Specialization. When I try this, it is not working: SELECT L.LectID, Fna...

Centering elements in jQuery Mobile

Does the jQuery Mobile framework have a way of centering elements, specifically buttons? It looks like it defaults to left-aligning everything and I can't find a way (within the framework) to do this....

How to convert string to date to string in Swift iOS?

Am learning swift and am struck in converting the date String to NSDate to string. Am getting the date string in this format "Thu, 22 Oct 2015 07:45:17 +0000". I need to show the date in the MM-dd-yyyy format. I tried the following code but, it retur...

How to print colored text to the terminal?

How can I output colored text to the terminal in Python?...

How to write a unit test for a Spring Boot Controller endpoint

I have a sample Spring Boot app with the following Boot main class @SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } Controller ...

How do I remove a file from the FileList

I'm building a drag-and-drop-to-upload web application using HTML5, and I'm dropping the files onto a div and of course fetching the dataTransfer object, which gives me the FileList. Now I want to remove some of the files, but I don't know how, or i...

How should I copy Strings in Java?

String s = "hello"; String backup_of_s = s; s = "bye"; At this point, the backup variable still contains the original value "hello" (this is because of String's immutability right?). But is it really safe to copy Strings with this meth...

Getting command-line password input in Python

You know how in Linux when you try some Sudo stuff it tells you to enter the password and, as you type, nothing is shown in the terminal window (the password is not shown)? Is there a way to do that in Python? I'm working on a script that requires s...

Can't start Tomcat as Windows Service

I am using Tomcat6 on Windows 8. I am able to start Tomcat via startup.bat without error. I've copied Tomcat6.exe, Tomcat6w.exe and service.bat under tomcat/bin directory and set the .exe files to run as administrator. I open command line with admi...

Check if list contains element that contains a string and get that element

While searching for an answer to this question, I've run into similar ones utilizing LINQ but I haven't been able to fully understand them (and thus, implement them), as I'm not familiarized with it. What I would like to, basically, is this: Check ...

How do I find out what version of Sybase is running

I would like to know the exact version of Sybase currently running on my machine. Please let me know how to get this info?...

How to use HTTP_X_FORWARDED_FOR properly?

Alright, I have an small authentication issue. My web service allows to connect to my API over HTTP with a username and password, but this connection can also be restricted to a specific IP address. This means that the $_SERVER['REMOTE_ADDR'] can be...

test attribute in JSTL <c:if> tag

I saw some code like the following in a JSP <c:if test="<%=request.isUserInRole(RoleEnum.USER.getCode())%>"> <li>user</li> </c:if> My confusion is over the "=" that appears in the value of the test attribute. My u...

Select all occurrences of selected word in VSCode

Are there any trick or extension to select all instances of selected word in visual studio code, to facilitate editing or deleting those instances without search and replace, like ?Alt+F3 in sublime text...

Nexus 7 (2013) and Win 7 64 - cannot install USB driver despite checking many forums and online resources

I'm trying to set up my Nexus 7 (2013) for debugging, but I am getting stuck at the step where you install the USB driver. Here's what I've tried so far: Steps taken: Turned on debugging mode on Nexus 7 (2013) Connected device to PC Downloaded Go...

How to display a pdf in a modal window?

I have a modal window, which contains an anchor text. When i click on this link, it must call a pdf housed somewhere else and display it in a pop up . How can I do that ? Kindly help ....

String concatenation in MySQL

I am using MySQL and MySQL Workbench 5.2 CE. When I try to concatenate 2 columns, last_name and first_name, it doesn't work : select first_name + last_name as "Name" from test.student ...

How to set Spinner Default by its Value instead of Position?

I have 1-50 records in the database. I am fetching those data using cursor and set those values to Spinner using Simple Cursor Adapter. Now what i need is i want to set one value say 39th value as default. But not by its position i want to set by its...

What is Options +FollowSymLinks?

I am using a Lamp server on my computer. I started to use Laravel php framework. In my .htaccess , If I use Options +FollowSymLinks , I get 500 error. And If I comment out , I have to use index.php in my all addresses ..example: /~ytsejam/blog/pu...

Fastest way to tell if two files have the same contents in Unix/Linux?

I have a shell script in which I need to check whether two files contain the same data or not. I do this a for a lot of files, and in my script the diff command seems to be the performance bottleneck. Here's the line: diff -q $dst $new > /dev/null...

Make selected block of text uppercase

Can I make a multi-line selection of text all capitals in Visual Studio Code? In full Visual Studio it's CTRL+SHIFT+U to do this. The extension that exists that I have seen only do non-multi-line blocks....

How can I loop through a C++ map of maps?

How can I loop through a std::map in C++? My map is defined as: std::map< std::string, std::map<std::string, std::string> > For example, the above container holds data like this: m["name1"]["value1"] = "data1"; m["name1"]["value2"] = ...

In a simple to understand explanation, what is Runnable in Java?

What is "runnable" in Java, in layman's terms? I am an AP programming student in high school, whose assignment is to do research, or seek out from others what "runnable" is (we are just getting into OOP, and haven't touched threads yet)....

How do I count unique values inside a list

So I'm trying to make this program that will ask the user for input and store the values in an array / list. Then when a blank line is entered it will tell the user how many of those values are unique. I'm building this for real life reasons and not ...

Postgresql Windows, is there a default password?

Just installed Postgresql on Windows 7. I was not asked to set a password during installation. When i run psql, I'm asked for a password. Googled some and the only possible default password was "postgre". But that didn't work. Also tried a blank pass...

How can I listen for keypress event on the whole page?

I'm looking for a way to bind a function to my whole page (when a user presses a key, I want it to trigger a function in my component.ts) It was easy in AngularJS with a ng-keypress but it does not work with (keypress)="handleInput($event)". I tri...

MySQL Data - Best way to implement paging?

My iPhone app connects to my PHP web service to retrieve data from a MySQL database. A request can return 500 results. What is the best way to implement paging and retrieve 20 items at a time? Let's say I receive the first 20 ads from my database. ...

Get JavaScript object from array of objects by value of property

Let's say I have an array of four objects: var jsObjects = [ {a: 1, b: 2}, {a: 3, b: 4}, {a: 5, b: 6}, {a: 7, b: 8} ]; Is there a way that I can get the third object ({a: 5, b: 6}) by the value of the property b for example without ...

Make an existing Git branch track a remote branch?

I know how to make a new branch that tracks remote branches, but how do I make an existing branch track a remote branch? I know I can just edit the .git/config file, but it seems there should be an easier way....

How do I make calls to a REST API using C#?

This is the code I have so far: public class Class1 { private const string URL = "https://sub.domain.com/objects.json?api_key=123"; private const string DATA = @"{""object"":{""name...

Change the mouse pointer using JavaScript

I wanted to use a script to change the mouse pointer on my website using JavaScript. It's better done by CSS but my requirement is of a script that can be distributed to many people to embed in the head section of their websites. Through CSS, this ca...

"int cannot be dereferenced" in Java

I'm fairly new to Java and I'm using BlueJ. I keep getting this "Int cannot be dereferenced" error when trying to compile and I'm not sure what the problem is. The error is specifically happening in my if statement at the bottom, where it says "equa...

How do I assert my exception message with JUnit Test annotation?

I have written a few JUnit tests with @Test annotation. If my test method throws a checked exception and if I want to assert the message along with the exception, is there a way to do so with JUnit @Test annotation? AFAIK, JUnit 4.7 doesn't provide t...

Having services in React application

I'm coming from the angular world where I could extract logic to a service/factory and consume them in my controllers. I'm trying to understand how can I achieve the same in a React application. Let's say that I have a component that validates user...

Task not serializable: java.io.NotSerializableException when calling function outside closure only on classes not objects

Getting strange behavior when calling function outside of a closure: when function is in a object everything is working when function is in a class get : Task not serializable: java.io.NotSerializableException: testing The problem is I need...

Interpreting segfault messages

What is the correct interpretation of the following segfault messages? segfault at 10 ip 00007f9bebcca90d sp 00007fffb62705f0 error 4 in libQtWebKit.so.4.5.2[7f9beb83a000+f6f000] segfault at 10 ip 00007fa44d78890d sp 00007fff43f6b720 error 4 in libQ...

Visual Studio displaying errors even if projects build

I have a problem with Visual Studio on a C# solution. It displays totally random errors, but the projects build. Right now, I have 33 files with errors, and I can see red squiggly lines in all of them. I tried cleaning / rebuilding the solution, clos...

Where are logs located?

I'm debugging a JSON endpoint and need to view internal server errors. However, my app/storage/logs dir is empty and it seems there are no other directories dedicated to logs in the project. I've tried googling the subject to no avail. How can I ena...

gpg: no valid OpenPGP data found

I am trying to install Jenkins on Ubuntu 13.10 and I am getting the above mentioned error when i try to run the following command: wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add - ...

How do I copy SQL Azure database to my local development server?

Does anyone know how I can copy a SQL Azure database to my development machine? I'd like to stop paying to have a development database in the cloud, but it's the best way to get production data. I copy my production database to a new development data...

How do I get the Git commit count?

I'd like to get the number of commits of my Git repository, a bit like SVN revision numbers. The goal is to use it as a unique, incrementing build number. I currently do like that, on Unix/Cygwin/msysGit: git log --pretty=format:'' | wc -l But I...

Comparing strings in C# with OR in an if statement

I'm a newbie to C#, but can't seem to find anything about this problem. Here's what I'm trying to do: string testString = txtBox1.Text; string testString2 = txtBox2.Text; if ((testString == "") || (testString2 == "")) { MessageBox.Show("You mu...

jQuery.css() - marginLeft vs. margin-left?

With jQuery.css() I've been told I can use the following two functions for the same results: $(".element").css("marginLeft") = "200px"; $(".element").css("margin-left") = "200px"; I've always used marginLeft as this is what is used in the documen...

Comparison of DES, Triple DES, AES, blowfish encryption for data

Does anyone have pros and cons together for comparing these encryption algorithms ?...

HTML input textbox with a width of 100% overflows table cells

Does anyone know why the input elements with a width of 100% go over the table's cells border. In the simple example below input box go over the table's cells border, the result is horrible. This was tested and it happens in the same way on: Firefox...

How to check if there exists a process with a given pid in Python?

Is there a way to check to see if a pid corresponds to a valid process? I'm getting a pid from a different source other than from os.getpid() and I need to check to see if a process with that pid doesn't exist on the machine. I need it to be availa...

HTML input field hint

I want to provide the user with a hint on what he needs to enter into my text field. However, when I set the value, it does not disappear once a user clicks on the text field. How can you make it disappear? <form action="input_password.htm"> ...

Wait until all jQuery Ajax requests are done?

How do I make a function wait until all jQuery Ajax requests are done inside another function? In short, I need to wait for all Ajax requests to be done before I execute the next. But how?...

How can I fix assembly version conflicts with JSON.NET after updating NuGet package references in a new ASP.NET MVC 5 project?

I created a new ASP.NET MVC 5 web project in VS 2013 (Update 1) then updated all NuGet packages. When I build the project, I get the following warning: warning MSB3243: No way to resolve conflict between "Newtonsoft.Json, Version=6.0.0.0, Cultur...

Running Selenium Webdriver with a proxy in Python

I am trying to run a Selenium Webdriver script in Python to do some basic tasks. I can get the robot to function perfectly when running it through the Selenium IDE inteface (ie: when simply getting the GUI to repeat my actions). However when I export...

How do I turn off Unicode in a VC++ project?

I have a VC++ project in Visual Studio 2008. It is defining the symbols for unicode on the compiler command line (/D "_UNICODE" /D "UNICODE"), even though I do not have this symbol turned on in the preprocessor section for the project. As a r...

SQL Query to find missing rows between two related tables

I have two tables: Table A ID ABC_ID VAL Table B ID ABC_ID VAL These two tables are directly related to each other through the ABC_ID column. I want to find all the VAL column values in table A which are not present in table B for the same ...

How do I check whether a checkbox is checked in jQuery?

I need to check the checked property of a checkbox and perform an action based on the checked property using jQuery. For example, if the age checkbox is checked, then I need to show a textbox to enter age, else hide the textbox. But the following cod...

Is the practice of returning a C++ reference variable evil?

This is a little subjective I think; I'm not sure if the opinion will be unanimous (I've seen a lot of code snippets where references are returned). According to a comment toward this question I just asked, regarding initializing references, returni...

How to check if an element exists in the xml using xpath?

Below is my element hierarchy. How to check (using xpath) that AttachedXml element is present under CreditReport of Primary Consumer <Consumers xmlns="http://xml.mycompany.com/XMLSchema"> <Consumer subjectIdentifier="Primary"> ...

How to display svg icons(.svg files) in UI using React Component?

I have seen lot libraries for svg on react but none gave me how to import a .svg in the react component , I have seen code which talk about bring the svg code in to react rather than using the .svg icon as image and show it in the UI . Please let me...

How to check if a Java 8 Stream is empty?

How can I check if a Stream is empty and throw an exception if it's not, as a non-terminal operation? Basically, I'm looking for something equivalent to the code below, but without materializing the stream in-between. In particular, the check should...

char *array and char array[]

if I write this char *array = "One good thing about music"; I actually create an array? I mean it's the same like this? char array[] = {"One", "good", "thing", "about", "music"}; ...

Python vs Bash - In which kind of tasks each one outruns the other performance-wise?

Obviously Python is more user friendly, a quick search on google shows many results that say that, as Python is byte-compiled is usually faster. I even found this that claims that you can see an improvement of over 2000% on dictionary-based operation...

Description Box using "onmouseover"

I am playing with the onmouseover event in javascript I would like a little box to pop up and remain up until there is no onmouseover anymore I think it's called a description box, but I am not sure. How do I get a little box to pop up with custom...

How to escape "&" in XML?

I write <string name="magazine">Newspaper & Magazines</string> in strings.xml But the Compiler says: The entity name must immediately follow the '&' in the entity reference. strings.xml /OOReaderWidget/res/values li...

did you register the component correctly? For recursive components, make sure to provide the "name" option

I configured 'i-tab-pane': Tabpane but report error,the code is bellow: <template> <div class="page-common"> <i-tabs> <i-tab-pane label="wx"> content </i-tab-pane> </i-tabs> </di...

Why doesn't adding CORS headers to an OPTIONS route allow browsers to access my API?

I am trying to support CORS in my Node.js application that uses the Express.js web framework. I have read a Google group discussion about how to handle this, and read a few articles about how CORS works. First, I did this (code is written in CoffeeSc...

Filtering Pandas DataFrames on dates

I have a Pandas DataFrame with a 'date' column. Now I need to filter out all rows in the DataFrame that have dates outside of the next two months. Essentially, I only need to retain the rows that are within the next two months. What is the best way...

My eclipse won't open, i download the bundle pack it keeps saying error log

Its say this huge message. Showing the last part , and I am on windows !ENTRY org.eclipse.osgi 4 0 2013-12-31 18:02:27.633 !MESSAGE Application error !STACK 1 java.lang.RuntimeException: Application "org.eclipse.ui.ide.workbench" could not be found...

How can I simulate an array variable in MySQL?

It appears that MySQL doesn't have array variables. What should I use instead? There seem to be two alternatives suggested: A set-type scalar and temporary tables. The question I linked to suggests the former. But is it good practice to use these...

App.settings - the Angular way?

I want to add an App Settings section into my App where It will contain some consts and pre defined values. I've already read this answer which uses OpaqueToken But it is deprecated in Angular. This article explains the differences but it didn't pro...

What is the simplest way to get indented XML with line breaks from XmlDocument?

When I build XML up from scratch with XmlDocument, the OuterXml property already has everything nicely indented with line breaks. However, if I call LoadXml on some very "compressed" XML (no line breaks or indention) then the output of OuterXml stay...

How to take backup of a single table in a MySQL database?

By default, mysqldump takes the backup of an entire database. I need to backup a single table in MySQL. Is it possible? How do I restore it?...

Difference between $.ajax() and $.get() and $.load()

What is the difference between $.ajax() and $.get() and $.load()? Which is better to use and in what conditions?...

Pass an array of integers to ASP.NET Web API?

I have an ASP.NET Web API (version 4) REST service where I need to pass an array of integers. Here is my action method: public IEnumerable<Category> GetCategories(int[] categoryIds){ // code to retrieve categories from database } And this i...

In angular $http service, How can I catch the "status" of error?

I'm reading a book called, "Pro Angular JS". However, I have a question about how to catch a status of error. What I coded is : $http.get(dataUrl) .success(function (data){ $scope.data.products = data; }) .error(function (error)...

Input Type image submit form value?

I am using this code to try and submit a value via form but it doesn't seem to submit anything... I would normally use a checkbox or Radio buttons for multiple options but I want to use an image to do this. Is this code wrong? <input id="test1"...

How do I clear a search box with an 'x' in bootstrap 3?

Having some trouble with bootstrap, so some help would be awesome. Thanks What I would like:(top part) My current code: <div class="form-group"> <input type="text" class="form-control" id="findJobTitle" ...

how to draw smooth curve through N points using javascript HTML5 canvas?

For a drawing application, I'm saving the mouse movement coordinates to an array then drawing them with lineTo. The resulting line is not smooth. How can I produce a single curve between all the gathered points? I've googled but I have only fo...

HttpWebRequest-The remote server returned an error: (400) Bad Request

I am getting The remote server returned an error: (400) Bad Request error while running the following code. I am trying to upload xml file on the http server. My xml file contains tag for the username,password and domain and when i am trying to conne...

Linear Layout and weight in Android

I always read about this funny weight value in the Android documentations. Now I want to try it for the first time but it isn't working at all. As I understand it from the documentations this layout: <LinearLayout android:layout_width=...

jQuery UI Accordion Expand/Collapse All

I'm using the jQuery UI Accordion (which does not allow more than one item open at a time) on a project. Using accordion is appropriate since I usually do only want one panel open at a time. However, I need to offer an "Expand All" link which switch...

Display images in asp.net mvc

I am trying to create a website to upload/display images (using MVC4). I have written the below code to fetch the images which are locally stored on the server under a folder App_Data\Images. The path for the image is stored in the ImageFile property...

How to convert webpage into PDF by using Python

I was finding solution to print webpage into local file PDF, using Python. one of the good solution is to use Qt, found here, https://bharatikunal.wordpress.com/2010/01/. It didn't work at the beginning as I had problem with the installation of PyQt...

How to run VBScript from command line without Cscript/Wscript

I am a beginner in VBScript. I googled it & got to know that we can run VBScript from command line by executing below command: For Example my vbscript name is Converter.vbs & it's present in folder D:\VBS. I can run it through following met...

When to use virtual destructors?

I have a solid understanding of most OOP theory but the one thing that confuses me a lot is virtual destructors. I thought that the destructor always gets called no matter what and for every object in the chain. When are you meant to make them virtua...

Conversion between UTF-8 ArrayBuffer and String

I have an ArrayBuffer which contains a string encoded using UTF-8 and I can't find a standard way of converting such ArrayBuffer into a JS String (which I understand is encoded using UTF-16). I've seen this code in numerous places, but I fail to see...

Insert entire DataTable into database at once instead of row by row?

I have a DataTable and need the entire thing pushed to a Database table. I can get it all in there with a foreach and inserting each row at a time. This goes very slow though since there are a few thousand rows. Is there any way to do the entire da...

What is the difference between Collection and List in Java?

What is the difference between Collection and List in Java? When should I use which?...

How do I convert struct System.Byte byte[] to a System.IO.Stream object in C#?

How do I convert struct System.Byte byte[] to a System.IO.Stream object in C#?...

What does MVW stand for?

Here's the content description for AngularJS page: AngularJS is what HTML would have been, had it been designed for building web-apps. Declarative templates with data-binding, MVW, MVVM, MVC, dependency injection and great testability story all i...

Emulate ggplot2 default color palette

What function can I use to emulate ggplot2's default color palette for a desired number of colors. For example, an input of 3 would produce a character vector of HEX colors with these colors: ...

Laravel Mail::send() sending to multiple to or bcc addresses

I can't seem to successfully send to multiple addresses when using Laravel's Mail::send() callback, the code does however work when I only specify one recipient. I've tried chaining: // for example $emails = array("[email protected]", "myemail2@em...

How can I override Bootstrap CSS styles?

I need to modify bootstrap.css to fit my website. I feel it's better to create a separate custom.css file instead of modifying bootstrap.css directly, one reason being that should bootstrap.css get an update, I'll suffer trying to re-include all my m...

How to prevent column break within an element?

Consider the following HTML: <div class='x'> <ul> <li>Number one</li> <li>Number two</li> <li>Number three</li> <li>Number four is a bit longer</li> ...

How do I find the duplicates in a list and create another list with them?

How can I find the duplicates in a Python list and create another list of the duplicates? The list only contains integers....

Working with time DURATION, not time of day

I'm doing some benchmarking, and I want to use Excel to produce graphs of the results. I've got a simple but annoying problem which is baking my noodle. The problem is that Excel insists that "time" means a time of day. It refuses to let me work wit...

How can you debug a CORS request with cURL?

How can you debug CORS requests using cURL? So far I couldn't find any way to "simulate" the preflight request ....

Sleep Command in T-SQL?

Is there to way write a T-SQL command to just make it sleep for a period of time? I am writing a web service asynchronously and I want to be able to run some tests to see if the asynchronous pattern is really going to make it more scalable. In orde...

What happened to Lodash _.pluck?

I once used Lodash _.pluck...I loved pluck... Realizing Lodash no longer supports pluck (as of Lodash 4.x), I'm struggling to remember what to use instead... I went to the docs, hit cmd-f, typed 'pluck', but my poor abandoned friend is not even giv...

C++ alignment when printing cout <<

Is there a way to align text when printing using std::cout? I'm using tabs, but when the words are too big they won't be aligned anymore. Sales Report for September 15, 2010 Artist Title Price Genre Disc Sale Tax Cash Merle Blue 12...

How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?

I have a .diff file created by a coworker, and would like to apply the changes listed in that diff file to my local branch of the exact same repository. I do not have access to that worker's pc or branch that was used to generate this diff file. Ob...

Where can I read the Console output in Visual Studio 2015

I am new to C# and downloaded the free version of Microsoft Visual Studio 2015. To write a first program, I created a Windows Forms Application. Now I use Console.Out.WriteLine() to print some test data. But where can I read the console?...

Combine Multiple child rows into one row MYSQL

Thanks in advance, I just can't seem to get it! I have two tables Ordered_Item ID | Item_Name 1 | Pizza 2 | Stromboli Ordered_Options Ordered_Item_ID | Option_Number | Value 1 43 Pepperoni 1 ...

Get skin path in Magento?

I have a few custom PHP functions for my Magento store that I stored in myfunc.php and I need to require it from in a few different .phtml files. How do I do that? I mean I can use an absolute path but that would be dirty and probably problematic wh...

html/css buttons that scroll down to different div sections on a webpage

Can someone help me I'm searching for css/html code example: I have a webpage with 3 buttons(top, middle, bottom) each specified to 1 div section on my page, lets say my first div section is in the middle of that page div id='middle'. If I click th...

Javascript split regex question

hello I am trying what I thought would be a rather easy regex in Javascript but is giving me lots of trouble. I want the ability to split a date via javascript splitting either by a '-','.','/' and ' '. var date = "02-25-2010"; var myregexp2 = new ...

How to run .APK file on emulator

Possible Duplicate: How do you install an APK file in the Android emulator? I download an APK file and I want to run it on an Android emulator but I don't know how. Please help me. Thanks!...

Call An Asynchronous Javascript Function Synchronously

First, this is a very specific case of doing it the wrong way on-purpose to retrofit an asynchronous call into a very synchronous codebase that is many thousands of lines long and time doesn't currently afford the ability to make the changes to "do i...

Hide element by class in pure Javascript

I have tried the following code, but it doesn't work. Any idea where I have gone wrong? _x000D_ _x000D_ document.getElementsByClassName('appBanner').style.visibility='hidden';_x000D_ <div class="appBanner">appbanner</div>_x000D_ _x000D_ ...

Converting a string to a date in a cell

I have 100.000 rows of data in Excel. Some of the fields are dates, but the fields in Excel are as text. I need these fields in number format including both dates AND time (e.g. 21.10.2011 13:10:50). Formatting the cells doesn't work because that doe...

How to apply Hovering on html area tag?

I am trying to hover the area tag of HTML. I tried this in CSS: area:hover { border:1px solid black; } This is the HTML on which it should be applied. <!-- This imagemap inserted by Gwyn's Imagemap Selector http://gwynethllewelyn.net/gwyns...

SQL - Rounding off to 2 decimal places

I need to convert minutes to hours, rounded off to 2 decimal places.I also need to display only up to 2 numbers after the decimal point. So if I have minutes as 650.Then hours should be 10.83 Here's what I have so far: Select round(Minutes/60.0,2) ...

Using ResourceManager

I'm trying to use the ResourceManager in a C# class, but don't know what to substitute for the basename when creating a new instance of the ResourceManager class. I have a separate project that contains the resource files which is referenced by my p...

EF Core add-migration Build Failed

I have a developer that is getting "Build failed." when running add-migration in a .NET Core EF project, with no explanation of why the build failed. How do you troubleshoot this error? This is what he gets in the Package Manager Console: Additiona...

cannot call member function without object

This program has the user input name/age pairs and then outputs them, using a class. Here is the code. #include "std_lib_facilities.h" class Name_pairs { public: bool test(); void read_names(); void read_ages(); void pri...

jQuery: select all elements of a given class, except for a particular Id

This is probably pretty simple. I want to select all elements of a given class thisClass, except where the id is thisId. i.e. something equivalent to (where -/minus implies remove): $(".thisClass"-"#thisId").doAction(); ...

How to retrieve value from elements in array using jQuery?

I have multiple input fields like so: <input type="text" name="card[]"> <input type="text" name="card[]"> <input type="text" name="card[]"> Users can add or remove these fields as required, therefore the name of the fields is an ...

how to loop through each row of dataFrame in pyspark

E.g sqlContext = SQLContext(sc) sample=sqlContext.sql("select Name ,age ,city from user") sample.show() The above statement print entire table on terminal but i want to access each row in that table using for or while to perform further calculati...

Getting fb.me URL

How do I go about either making, or retrieving facebook short url's (fb.me) from a page, profile, event etc? I want to update my url shortener site - but if the user links to a facebook page I want to just return a fb.me link instead. Does facebook m...

comparing two strings in ruby

I've just started to learn ruby and this is probably very easy to solve. How do I compare two strings in Ruby? I've tried the following : puts var1 == var2 //false, should be true (I think) puts var1.eql?(var2) //false, should be true (I think) W...

HTML text-overflow ellipsis detection

I have a collection of block elements on a page. They all have the CSS rules white-space, overflow, text-overflow set so that overflowing text is trimmed and an ellipsis is used. However, not all the elements overflow. Is there anyway I can use jav...

Count unique values with pandas per groups

I need to count unique ID values in every domain I have data ID, domain 123, 'vk.com' 123, 'vk.com' 123, 'twitter.com' 456, 'vk.com' 456, 'facebook.com' 456, 'vk.com' 456, 'google.com' 789, 'twitter.com' 789, 'vk.com' I try df.groupby(['domain', '...

Overwriting txt file in java

The code I've written is supposed to overwrite over the contents of the selected text file, but it's appending it. What am I doing wrong exactly? File fnew=new File("../playlist/"+existingPlaylist.getText()+".txt"); String source = textArea.getText(...

Angular 4 checkbox change value

how could you achieve in Angular 4 that when you register in a checkbox save an "A" or "B" value. As much as I try, he is only sending me true or false, I hope someone can help me. registry.component.ts this.userForm = new FormG...

How to create standard Borderless buttons (like in the design guideline mentioned)?

I was just checking the design guidelines and wondering about the borderless buttons. I goggled and tried to find in the source but can't bring it together by myself. Is this the normal Button widget but you add a custom (Android default) style? How ...

How do I create an Excel chart that pulls data from multiple sheets?

I have monthly sales figures stored in separate sheets. I would like to create a plot of sales for multiple products per month. Each product would be represented in a different colored line on the same chart with each month running along the x axis...

How to convert a time string to seconds?

I need to convert time value strings given in the following format to seconds, for example: 1.'00:00:00,000' -> 0 seconds 2.'00:00:10,000' -> 10 seconds 3.'00:01:04,000' -> 64 seconds 4.'01:01:09,000' -> 3669 seconds Do I need to us...

The following classes could not be instantiated: - android.support.v7.widget.Toolbar

I am creating an app with the new Material Design used in Android Lollipop (5.0). I am using the following guides: http://android-developers.blogspot.it/2014/10/appcompat-v21-material-design-for-pre.html http://antonioleiva.com/material-design-eve...

How can I create an utility class?

I want to create a class with utility methods, for example public class Util { public static void f (int i) {...} public static int g (int i, int j) {...} } Which is the best method to create an utility class? Should I use a private cons...

How can I detect when the mouse leaves the window?

I want to be able to detect when the mouse leaves the window so I can stop events from firing while the user's mouse is elsewhere. Any ideas of how to do this?...

Assigning variables with dynamic names in Java

I'd like to assign a set of variables in java as follows: int n1,n2,n3; for(int i=1;i<4;i++) { n<i> = 5; } How can I achieve this in Java?...

how to get the one entry from hashmap without iterating

Is there a elegant way of obtaining only one Entry<K,V> from HashMap, without iterating, if key is not known. As order of entry of entry is not important, can we say something like hashMapObject.get(zeroth_index); Although I am aware that t...

ImproperlyConfigured: You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings

I was trying to configure my django project to deploy to heroku. I am getting the following error and I don't really know how to fix it. Here is the full traceback and error: 22:46:15 web.1 | Traceback (most recent call last): 22:46:15 web.1 | ...

Missing .map resource?

I've recently started having this problem with all my projects. When my index page loads which contains a reference to the jquery source file, my console logs this error: GET http://localhost:3000/js/lib/jquery-1.10.2.min.map 500 (Internal Server Er...

Generate random colors (RGB)

I just picked up image processing in python this past week at the suggestion of a friend to generate patterns of random colors. I found this piece of script online that generates a wide array of different colors across the RGB spectrum. def random_c...

How to parse the Manifest.mbdb file in an iOS 4.0 iTunes Backup

In iOS 4.0 Apple has redesigned the backup process. iTunes used to store a list of filenames associated with backup files in the Manifest.plist file, but in iOS 4.0 it has moved this information to a Manifest.mbdb You can see an example of this f...

How to Scroll Down - JQuery

I'm not a programmer, but I use the code below to scroll the page to the top. How can I adapt it to make a scroll down? <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> <a class="btnMedio" href...

Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

I am trying to configure hibernate orm mapping tool to my java class and using PostgreSQL as my database and configured the password as "password". When I tried to run the application, I have encountered error on my console logs as Unable t...

How to iterate a loop with index and element in Swift

Is there a function that I can use to iterate over an array and have both index and element, like Python's enumerate? for index, element in enumerate(list): ... ...

How to convert a string of bytes into an int?

How can I convert a string of bytes into an int in python? Say like this: 'y\xcc\xa6\xbb' I came up with a clever/stupid way of doing it: sum(ord(c) << (i * 8) for i, c in enumerate('y\xcc\xa6\xbb'[::-1])) I know there has to be something...

matplotlib error - no module named tkinter

I tried to use the matplotlib package via Pycharm IDE on windows 10. when I run this code: from matplotlib import pyplot I get the following error: ImportError: No module named 'tkinter' I know that in python 2.x it was called Tkinter, but that...

overlay two images in android to set an imageview

I am trying to overlay two images in my app, but they seem to crash at my canvas.setBitmap() line. What am I doing wrong? private void test() { Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.t); Bitmap mBitmap2 = Bi...

What is %2C in a URL?

I'm trying to understand the structure of a URL, and I'm seeing a lot of %2C. I'm guessing this is a result of some encoding. What does that stand for?...

Get single row result with Doctrine NativeQuery

I'm trying to get a single row returned from a native query with Doctrine. Here's my code: $rsm = new ResultSetMapping; $rsm->addEntityResult('VNNCoreBundle:Player', 'p'); $rsm->addFieldResult('p', 'player_id', 'id'); $sql = " SELECT pla...

Parse date string and change format

I have a date string with the format 'Mon Feb 15 2010'. I want to change the format to '15/02/2010'. How can I do this?...

Safari 3rd party cookie iframe trick no longer working?

So this is the umteenth revenge of the "how do I get 3rd party cookies to work in Safari" question but I'm asking again because I think the playing field has changed, perhaps after February 2012. One of the standard tricks to get 3rd party cookies in...

How to make JavaScript execute after page load?

I'm executing an external script, using a <script> inside <head>. Now since the script executes before the page has loaded, I can't access the <body>, among other things. I'd like to execute some JavaScript after the document has b...

How do I display a MySQL error in PHP for a long query that depends on the user input?

In PHP, I am trying to execute a long MySQL query that depends on the user input. However, my query fails with the following message, "Query Failed". Actually I have printed this message whenever the query fails, but I am having hard time looking ...

Extract month and year from a zoo::yearmon object

I have a yearmon object: require(zoo) date1 <- as.yearmon("Mar 2012", "%b %Y") class(date1) # [1] "yearmon" How can I extract the month and year from this? month1 <- fn(date1) year1 <- fn(date1) What function should I use in place of f...

How to show the text on a ImageButton?

I have an ImageButton and I want to show a text and an image on it. But when I try on emulator: <ImageButton android:text="OK" android:id="@+id/buttonok" android:src="@drawable/buttonok" android:layout_width="match_parent" ...

How to get URI from an asset File?

I have been trying to get the URI path for an asset file. uri = Uri.fromFile(new File("//assets/mydemo.txt")); When I check if the file exists I see that file doesn't exist File f = new File(filepath); if (f.exists() == true) { Log.e(TAG, "V...

How to run Rake tasks from within Rake tasks?

I have a Rakefile that compiles the project in two ways, according to the global variable $build_type, which can be :debug or :release (the results go in separate directories): task :build => [:some_other_tasks] do end I wish to create a task t...

How to serialize/deserialize to `Dictionary<int, string>` from custom XML not using XElement?

Having empty Dictionary<int, string> how to fill it with keys and values from XML like <items> <item id='int_goes_here' value='string_goes_here'/> </items> and serialize it back into XML not using XElement?...

python: how to send mail with TO, CC and BCC?

I need for testing purposes to populate few hundred email boxes with various messages, and was going to use smtplib for that. But among other things I need to be able to send messages not only TO specific mailboxes, but CC and BCC them as well. It do...

syntax error when using command line in python

I am a beginner to python and am at the moment having trouble using the command line. I have a script test.py (which only contains print("Hello.")), and it is located in the map C:\Python27. In my system variables, I have specified python to be C:\Py...

Array.Add vs +=

I've found some interesting behaviour in PowerShell Arrays, namely, if I declare an array as: $array = @() And then try to add items to it using the $array.Add("item") method, I receive the following error: Exception calling "Add" with "1" arg...

Node.js - Maximum call stack size exceeded

When I run my code, Node.js throws a "RangeError: Maximum call stack size exceeded" exception caused by too many recursive calls. I tried to increase Node.js stack size by sudo node --stack-size=16000 app, but Node.js crashes without any error messag...

What is the purpose of Order By 1 in SQL select statement?

I'm reading through some old code at work, and have noticed that there are several views with an order by 1 clause. What does this accomplish? Example: Create view v_payment_summary AS SELECT A.PAYMENT_DATE, (SELECT SUM(paymentamount) ...

How can I render repeating React elements?

I've written some code to render repeating elements in ReactJS, but I hate how ugly it is. render: function(){ var titles = this.props.titles.map(function(title) { return <th>{title}</th>; }); var rows = this.props.rows.map(fun...

How to open a workbook specifying its path

Sub openwb() ChDir "E:\sarath\PTMetrics\20131004\D8 L538-L550 16MY" Workbooks("D8 L538-L550_16MY_Powertrain Metrics_20131002.xlsm").Open End sub Here, I am getting an error saying Subscript out of range on 3rd line. What should I do t...

What is AndroidX?

I am reading about a room library of Android. I see they changed package android to androidx. I did not understand that. Can someone explain, please? implementation "androidx.room:room-runtime:$room_version" annotationProcessor "androidx.room:room-c...

How to use XPath contains() here?

I'm trying to learn XPath. I looked at the other contains() examples around here, but nothing that uses an AND operator. I can't get this to work: //ul[@class='featureList' and contains(li, 'Model')] On: ... <ul class="featureList"> <li...

Twitter Bootstrap Form File Element Upload Button

Why isn't there a fancy file element upload button for twitter bootstrap? It would be sweet if the blue primary button was implemented for the upload button. Is it even possible to finesse the upload button using CSS? (seems like a native browser ele...

How to get all the AD groups for a particular user?

I checked this post already. But it doesn't answer my question. I want to get all the active directory groups in which a particular user is a member. I've written the following code. But I'm not able to proceed further as I don't know how to give th...

Android ListView with onClick items

I'm a new programmer and new in Android. I'm using this example http://www.androidhive.info/2012/09/android-adding-search-functionality-to-listview/ and it works great. Now I want to make the items (Dell, Samsung Galaxy S3, etc) to call a function ...

Rename package in Android Studio

How do you rename packages in the new IDE Android Studio, based on IntelliJ IDEA? Is there an automatic refactoring included? I want to make bulk refactoring, but I don't know how. I worked two years with Eclipse and in Eclipse it's a one-click op...

Exporting to .xlsx using Microsoft.Office.Interop.Excel SaveAs Error

I am in the process of writing a module to export a DataTable to Excel using Microsoft.Office.Interop.Excel but before starting in earnest I want to get the very basics working: open file, save as, and close. I have succeeded in opening and saving a...

How can I check if a key exists in a dictionary?

Let's say I have an associative array like so: {'key1': 22, 'key2': 42}. How can I check if key1 exists in the dictionary?...

Use latest version of Internet Explorer in the webbrowser control

The default version of the webbrowser control in a C# Windows Forms application is 7. I have changed to 9 by the article Browser Emulation, but how is it possible to use the latest version of the installed Internet Explorer in a webbrowser control?...

Javascript Uncaught Reference error Function is not defined

Check the Fiddle to see the failure occurring. When I add Data (Even if I leave it empty) to the text box and try to click "Add" it doesn't do anything. Opening the Chrome and Firefox console both give me the same error, it says "changeText2()" is ...

Passing multiple values for same variable in stored procedure

I have a variable that passes multiple values to stored procedure. When I see through fidler I see values being passed correctly like arg1=331 arg1=222 arg1=876 arg1=932 In my stored procedure I am reading as procedure main...

When should I use File.separator and when File.pathSeparator?

In the File class there are two strings, separator and pathSeparator. What's the difference? When should I use one over the other?...

How do I access command line arguments in Python?

I use python to create my project settings setup, but I need help getting the command line arguments. I tried this on the terminal: $python myfile.py var1 var2 var3 In my Python file, I want to use all variables that are input....

Check If array is null or not in php

I have an array like below which is generated by parsing a xml url. The array is Array ( [Tags] => SimpleXMLElement Object ( [0] => ) ) The array name is $result. Now I want to check that if the array received like a...

How can I use grep to find a word inside a folder?

In Windows, I would have done a search for finding a word inside a folder. Similarly, I want to know if a specific word occurs inside a directory containing many sub-directories and files. My searches for grep syntax shows I must specify the filename...

How do you read scanf until EOF in C?

I have this but once it reaches the supposed EOF it just repeats the loop and scanf again. int main(void) { char words[16]; while(scanf("%15s", words) == 1) printf("%s\n", words); return 0; } ...

Limit to 2 decimal places with a simple pipe

I have found an example which limits a number to 2 decimal places AND turns the figure into a currency amount- eg £2.55. {{ number | currency : 'GBP' : true : '1.2-2'}} Is there a simple pipe which does the same without applying a currency?...

Dynamically Add Images React Webpack

I've been trying to figure out how to dynamically add images via React and Webpack. I have an image folder under src/images and a component under src/components/index. I'm using url-loader with the following config for webpack { test: /...

VB6 IDE cannot load MSCOMCTL.OCX after update KB 2687323

After windows update installed security update KB2687323, my VB6 project fails to load. Displayed error message is "'[project_vbp_path]/MSCOMCTL.OCX' could not be loaded--Continue Loading Project?". Note that the path in the messeage is the vbp file ...

Parse HTML in Android

I am trying to parse HTML in android from a webpage, and since the webpage it not well formed, I get SAXException. Is there a way to parse HTML in Android?...

SQL Server Management Studio alternatives to browse/edit tables and run queries

I was wondering if there are any alternatives to Microsoft's SQL Server Management Studio? Not there's anything wrong with SSMS, but sometimes it just seem too big an application where all I want todo is browse/edit tables and run queries....

Is it possible to stop JavaScript execution?

Is it possible in some way to stop or terminate JavaScript in a way that it prevents any further JavaScript-based execution from occuring, without reloading the browser? I am thinking of a JavaScript equivalent of exit() in PHP....

Launch Android application without main Activity and start Service on launching application

I have the following scenario in my application. There is no UI in my application; instead there is a Service which starts on boot up and will continuously run. How can I configure my manifest file without a main Activity? Can I launch my app witho...

How to encode URL to avoid special characters in Java?

i need java code to encode URL to avoid special characters such as spaces and % and & ...etc...

Is there a C# case insensitive equals operator?

I know that the following is case sensitive: if (StringA == StringB) { So is there an operator which will compare two strings in an insensitive manner?...

How to find schema name in Oracle ? when you are connected in sql session using read only user

I am connected to a oracle database with a read only user and i used service name while Setting up connection in sql developer hence i dont know SID ( schema ). How can i find out schema name which i am connected to ? I am looking for this because ...

T-SQL and the WHERE LIKE %Parameter% clause

I was trying to write a statement which uses the WHERE LIKE '%text%' clause, but I am not receiving results when I try to use a parameter for the text. For example, this works: SELECT Employee WHERE LastName LIKE '%ning%' This would return users ...

Basic http file downloading and saving to disk in python?

I'm new to Python and I've been going through the Q&A on this site, for an answer to my question. However, I'm a beginner and I find it difficult to understand some of the solutions. I need a very basic solution. Could someone please explain a s...

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

how to change default python version?

I have installed python 3.2 in my mac. After I run /Applications/Python 3.2/Update Shell Profile.command, it's confusing that when I type python -V in Terminal it says that Python 2.6.1, how can I change the default python version?...

Is key-value observation (KVO) available in Swift?

If so, are there any key differences that weren't otherwise present when using key-value observation in Objective-C?...

Preg_match backtrack error

When I use the regex (.*)*[0] everything works well: preg_match('/(.*)*[0]/', 'this is a test string'); var_dump(preg_last_error()); // no code's returned But when I add another character to char class, it will throw out error: preg_match('/(.*)*...

Git Cherry-pick vs Merge Workflow

Assuming I am the maintainer of a repo, and I want to pull in changes from a contributor, there are a few possible workflows: I cherry-pick each commit from the remote (in order). In this case git records the commit as unrelated to the remote branc...

What does Include() do in LINQ?

I tried to do a lot of research but I'm more of a db guy - so even the explanation in the MSDN doesn't make any sense to me. Can anyone please explain, and provide some examples on what Include() statement does in the term of SQL query?...

How to send a pdf file directly to the printer using JavaScript?

How to send a PDF file directly to the printer using JavaScript? I found two answers in a forum: <embed src="vehinvc.pdf" id = "Pdf1" name="Pdf1" hidden> <a onClick="document.getElementById('Pdf1').printWithDialog()" style="cursor:hand;"&g...

highlight the navigation menu for the current page

In a page with some navigation links,I want the link of the current page are hightlighted,just like this: The link "HTML Attributes" is highlighted(bolded) since this link will take one to the current page. I know this can be implemented m...

Can I pass parameters by reference in Java?

I'd like semantics similar to C#'s ref keyword....

How do I calculate percentiles with python/numpy?

Is there a convenient way to calculate percentiles for a sequence or single-dimensional numpy array? I am looking for something similar to Excel's percentile function. I looked in NumPy's statistics reference, and couldn't find this. All I could fi...

How do I best silence a warning about unused variables?

I have a cross platform application and in a few of my functions not all the values passed to functions are utilised. Hence I get a warning from GCC telling me that there are unused variables. What would be the best way of coding around the warning...

MySQL "CREATE TABLE IF NOT EXISTS" -> Error 1050

Using the command: CREATE TABLE IF NOT EXISTS `test`.`t1` ( `col` VARCHAR(16) NOT NULL ) ENGINE=MEMORY; Running this twice in the MySQL Query Browser results in: Table 't1' already exists Error 1050 I would have thought that creating the...

jQuery Validation using the class instead of the name value

I'd like to validate a form using the jquery validate plugin, but I'm unable to use the 'name' value within the html - as this is a field also used by the server app. Specifically, I need to limit the number of checkboxes checked from a group. (Maxim...

Making a PowerShell POST request if a body param starts with '@'

I want to make a POST request in PowerShell. Following is the body details in Postman. { "@type":"login", "username":"[email protected]", "password":"yyy" } How do I pass this in PowerShell?...

Overlapping Views in Android

Is it possible to have overlapping views in Android? I would like to have an ImageView with a transparent png in the front and another view in the background. edit: This is what I have at the moment, the problem is that the image in the imageView i...

PHP Array to JSON Array using json_encode();

I've encoded an Array I've made using the inbuilt json_encode(); function. I need it in the format of an Array of Arrays like so: [["Afghanistan",32,12],["Albania",32,12]] However, it is returning as: ["2":["Afghanistan",32,12],"4":["Albania",32,...

JavaFX How to set scene background image

How can I set the background image of a scene?...

CSS: auto height on containing div, 100% height on background div inside containing div

The problem, is that I have a content div which stretches its container height-wise (container and content div have auto height). I want the background container, which is a sibling div of the content div to stretch to fill the container. The bac...

The executable was signed with invalid entitlements

I am having a problem with ad-hoc distribution on my iPhone. I have developed an application with SDK 3.0. I have a developer's license. I have added certificates and provisioning profiles in my project. So, no problem with that. But, when I try to ...

jQuery append() vs appendChild()

Here's some sample code: function addTextNode(){ var newtext = document.createTextNode(" Some text added dynamically. "); var para = document.getElementById("p1"); para.appendChild(newtext); $("#p1").append("HI"); } <div style="...

docker build with --build-arg with multiple arguments

According to the documentation, it's possible to define multiple args for the flag --build-arg, but I can't find out how. I tried the following: docker build -t essearch/ess-elasticsearch:1.7.6 --build-arg number_of_shards=5 number_of_replicas=2 --n...

Triggering change detection manually in Angular

I'm writing an Angular component that has a property Mode(): string. I would like to be able to set this property programmatically not in response to any event. The problem is that in the absence of a browser event, a template binding {{Mode}} does...

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

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

Uses of content-disposition in an HTTP response header

I have found the following asp.net code to be very useful when serving files from a database: Response.AppendHeader("content-disposition", "attachment; filename=" + fileName); This lets the user save the file to their computer and then decide how ...

iPad WebApp Full Screen in Safari

Apple says in the Safari HTML reference that the below code is supposed to make the the web-app full screen on iPhone OS 2.1 and later. <meta name="apple-mobile-web-app-capable" content="yes"> But it doesn't seem to work. Is there a way of ...

Is there a foreach loop in Go?

Is there a foreach construct in the Go language? Can I iterate over a slice or array using a for?...

Use a.any() or a.all()

x = np.arange(0,2,0.5) valeur = 2*x if valeur <= 0.6: print ("this works") else: print ("valeur is too high") here is the error I get: if valeur <= 0.6: ValueError: The truth value of an array with more than one element is ambigu...

Check if all values of array are equal

I need to find arrays where all values are equal. What's the fastest way to do this? Should I loop through it and just compare values? ['a', 'a', 'a', 'a'] // true ['a', 'a', 'b', 'a'] // false ...

Error: Could not find or load main class in intelliJ IDE

I'm a beginner in Java and am trying to run my code using IntelliJ that I just installed as my IDE with JDK 1.7. The following piece of code keeps does not even compile and keeps giving me the error: Error: Could not find or load main class libTest...

How do I protect javascript files?

I know it's impossible to hide source code but, for example, if I have to link a JavaScript file from my CDN to a web page and I don't want the people to know the location and/or content of this script, is this possible? For example, to link a scrip...

Scanner is never closed

I'm working on a game and I came across a little problem with my scanner. I'm getting a resource leak scanner never closed. But I thought my scanner was working before without closing it. But now it ain't. Anyone can help me out here? import java.u...

What to return if Spring MVC controller method doesn't return value?

I am using jQuery's $.getJSON() to make asynchronous calls to my simple Spring MVC backend. Most of the Spring controller methods look like this: @RequestMapping(value = "/someURL", method = RequestMethod.POST) public @ResponseBody SomePOJO...

Difference between left join and right join in SQL Server

I know about joins in SQL Server. For example. There are two tables Table1, Table2. Their table structures are the following. create table Table1 (id int, Name varchar (10)) create table Table2 (id int, Name varchar (10)) Table1 data as follow...

How to npm install to a specified directory?

Is it possible to specify a target directory when running npm install <package>?...

Using intents to pass data between activities

I am trying to pass the data between Activities I use intents to pass data between regular activities consider the code below:: AndroidTabRestaurantDescSearchListView.java public class AndroidTabRestaurantDescSearchListView extends TabActivity { ...

In SQL, how can you "group by" in ranges?

Suppose I have a table with a numeric column (lets call it "score"). I'd like to generate a table of counts, that shows how many times scores appeared in each range. For example: score range | number of occurrences ------------------------------...

Elasticsearch : Root mapping definition has unsupported parameters index : not_analyzed

Hi all I am trying to create schema Test. PUT /test { "mappings": { "field1": { "type": "integer" }, "field2": { "type": "integer" }, "field3": { "type": "string", ...

Is the Scala 2.8 collections library a case of "the longest suicide note in history"?

I have just started to look at the Scala collections library re-implementation which is coming in the imminent 2.8 release. Those familiar with the library from 2.7 will notice that the library, from a usage perspective, has changed little. For examp...

Convert multidimensional array into single array

I have an array which is multidimensional for no reason /* This is how my array is currently */ Array ( [0] => Array ( [0] => Array ( [plan] => basic ) [1] => Array ...

Understanding dict.copy() - shallow or deep?

While reading up the documentation for dict.copy(), it says that it makes a shallow copy of the dictionary. Same goes for the book I am following (Beazley's Python Reference), which says: The m.copy() method makes a shallow copy of the items c...

gcc error: wrong ELF class: ELFCLASS64

I was trying to compile a program using an external compiled object coreset.o. I wrote the public01.c test file and my functions are in computation.c, both of which compiles. However its failing on linking it together. What might be the problem? ...

How to find pg_config path

Complete newbie here, trying to set up Django to work with PostgreSQL. I'm using mac osx 10.6.8. I have also installed PostgreSQL 9.3 When I run pip install psycopg2 in terminal I get the following error Downloading/unpacking psycopg2 Downloadi...

List of all special characters that need to be escaped in a regex

I am trying to create an application that matches a message template with a message that a user is trying to send. I am using Java regex for matching the message. The template/message may contain special characters. How would I get the complete list...

How to use ArrayList's get() method

I'm new to java (& to OOP too) and I'm trying to understand about the class ArrayList but I don't understand how to use the get(). I tried searching in net, but couldn't find anything helpful....

Can Powershell Run Commands in Parallel?

I have a powershell script to do some batch processing on a bunch of images and I'd like to do some parallel processing. Powershell seems to have some background processing options such as start-job, wait-job, etc, but the only good resource I found...

Printing long int value in C

I have two variables of long int type as shown below: long int a=-2147483648, b=-2147483648; a=a+b; printf("%d",a); I am getting zero. I tried changing the type to long long int, but I'm still not getting the correct answer. ...

What's the difference between KeyDown and KeyPress in .NET?

What is the difference between the KeyDown and KeyPress events in .NET?...

Run-time error '3061'. Too few parameters. Expected 1. (Access 2007)

I have the following 'set recordset' line that I cannot get working. The parameters seem correct according to all available help I can find on the subject. The error displays : "Run-time error '3061'. Too few parameters. Expected 1." Here is t...

$(document).ready(function(){ Uncaught ReferenceError: $ is not defined

Hi I am having a "Uncaught ReferenceError: $ is not defined" while using bellow codes I am currently getting the following error in my log. I have been looking at the samples in the framework and I just can't seem to find where the error is. It's be...

How to open Emacs inside Bash

I'm using Ubuntu 11.10 (Oneiric Ocelot). When I type the command "emacs" in the terminal, it opens Emacs as a separate window. How can I open it inside the terminal, like the nano editor?...

What is the best way to remove a table row with jQuery?

What is the best method for removing a table row with jQuery?...

How to create a DataFrame from a text file in Spark

I have a text file on HDFS and I want to convert it to a Data Frame in Spark. I am using the Spark Context to load the file and then try to generate individual columns from that file. val myFile = sc.textFile("file.txt") val myFile1 = myFile.map(x...

Date Difference in php on days?

Is there a quick way to calculate date difference in php? For example: $date1 = '2009-11-12 12:09:08'; $date2 = '2009-12-01 08:20:11'; And then do a calculation, $date2 minus $date1 I read php.net documentation, but no luck. Is there a quick way ...

Java socket API: How to tell if a connection has been closed?

I am running into some issues with the Java socket API. I am trying to display the number of players currently connected to my game. It is easy to determine when a player has connected. However, it seems unnecessarily difficult to determine when a ...

HTML-parser on Node.js

Is there something like Ruby's nokogiri on nodejs? I mean a user-friendly HTML-parser. I'd seen on Node.js modules page some parsers, but I can't find something pretty and fresh....

How to put table in the center of the page using CSS?

I am using the following code. How to put this table in the center of the page using CSS? <html> <head> <link rel="stylesheet" type="text/css" href="styles.css" /> <meta http-equi...

Most Pythonic way to provide global configuration variables in config.py?

In my endless quest in over-complicating simple stuff, I am researching the most 'Pythonic' way to provide global configuration variables inside the typical 'config.py' found in Python egg packages. The traditional way (aah, good ol' #define!) is a...

Find the least number of coins required that can make any change from 1 to 99 cents

Recently I challenged my co-worker to write an algorithm to solve this problem: Find the least number of coins required that can make any change from 1 to 99 cents. The coins can only be pennies (1), nickels (5), dimes (10), and quarters (25), an...

Send password when using scp to copy files from one server to another

using scp to copy files from 1 unix server to another regularly and performing certain actions. to do this quickly I wish to use a unix script which does the scp and inputs the password required to complete the scp. I have tried the expect command t...

ToggleButton in C# WinForms

Is it possible to create a toggle button in C# WinForms? I know that you can use a CheckBox control and set it's Appearance property to "Button", but it doesn't look right. I want it to appear sunken, not flat, when pressed. Any thoughts?...

What does principal end of an association means in 1:1 relationship in Entity framework

public class Foo { public string FooId{get;set;} public Boo Boo{get;set;} } public class Boo { public string BooId{get;set;} public Foo Foo{get;set;} } I was trying to do this in Entity Framework when I got the error: Unable t...

Passing multiple argument through CommandArgument of Button in Asp.net

I have a gridview with multiple rows, each has a Update button and I need to pass 2 values when someone clicks on Update button. Aside from packing the arguments inside CommandArgument separated by commas (archaic and not elegant), how would I pass ...

MySQL: Insert datetime into other datetime field

I have a table with a DATETIME column. I would like to SELECT this datetime value and INSERT it into another column. I did this (note: '2011-12-18 13:17:17' is the value the former SELECT gave me from the DATETIME field): UPDATE products SET former...

How to hide a div element depending on Model value? MVC

Here is what I have at the moment hidden="@(Model.IsOwnedByUser||!Model.CanEdit)" This works fine on Chrome but doesnt hide on Internet Explorer I tried also visibility set false but no luck. then I found out another style as below style="@(...

How to set a Timer in Java?

How to set a Timer, say for 2 minutes, to try to connect to a Database then throw exception if there is any issue in connection?...

Using any() and all() to check if a list contains one set of values or another

My code is for a Tic Tac Toe game and checking for a draw state but I think this question could be more useful in a general sense. I have a list that represents the board, it looks like this: board = [1,2,3,4,5,6,7,8,9] When a player makes a move...

How do I use T-SQL's Case/When?

I have a huge query which uses case/when often. Now I have this SQL here, which does not work. (select case when xyz.something = 1 then 'SOMETEXT' else (select case when xyz.somethingelse = 1) then 'SOMEOTHERTEXT' ...

How to downgrade php from 5.5 to 5.3

Is there a way to downgrade php 5.5 to 5.3 in xampp? I searched on google but every one just tell me to uninstall xampp and install an older version. Could I have php 5.5 downgrade to 5.3 without reinstall xampp?...

Regex any ASCII character

What is the regex to match xxx[any ASCII character here, spaces included]+xxx? I am trying xxx[(\w)(\W)(\s)]+xxx, but it doesn't seem to work....

Check if value exists in Postgres array

Using Postgres 9.0, I need a way to test if a value exists in a given array. So far I came up with something like this: select '{1,2,3}'::int[] @> (ARRAY[]::int[] || value_variable::int) But I keep thinking there should be a simpler way to this...

Why is the Visual Studio 2015/2017/2019 Test Runner not discovering my xUnit v2 tests

UPDATE: Adding a 2019; the discovery/runner integration mechanism is same as per 2017 & 2015, so the key things that can go wrong are the same. I've read Why is the xUnit runner not finding my tests, which covers reasons xUnit would never be a...

What ports does RabbitMQ use?

What ports does RabbitMQ Server use or need to have open on the firewall for a cluster of nodes? My /usr/lib/rabbitmq/bin/rabbitmq-env is set below which I'm assuming are needed (35197). SERVER_ERL_ARGS="+K true +A30 +P 1048576 \ -kernel inet_de...

Retrieving the last record in each group - MySQL

There is a table messages that contains data as shown below: Id Name Other_Columns ------------------------- 1 A A_data_1 2 A A_data_2 3 A A_data_3 4 B B_data_1 5 B B_data_2 6 C C_data_1 If...

IPython/Jupyter Problems saving notebook as PDF

So, i've been trying to save a jupyter notebook as PDF but i just can't figure out how to do this. The first thing i try is from the file menu just download as PDF, but doing that results in: nbconvert failed: PDF creating failed the next thing i ...