Examples On Programing Languages

In LaTeX, how can one add a header/footer in the document class Letter?

In LaTeX, how can one create a document using the Letter documentclass, but with customized headers and footers? Typically I would use: \usepackage{fancyhdr} \pagestyle{fancy} \lhead{\footnotesize \parbox{11cm}{Custom left-head-note} } \lfoot{\foo...

Can the jQuery UI Datepicker be made to disable Saturdays and Sundays (and holidays)?

I use a datepicker for choosing an appointment day. I already set the date range to be only for the next month. That works fine. I want to exclude Saturdays and Sundays from the available choices. Can this be done? If so, how?...

How can I safely create a nested directory?

What is the most elegant way to check if the directory a file is going to be written to exists, and if not, create the directory using Python? Here is what I tried: import os file_path = "/my/directory/filename.txt" directory = os.path.dirname(file...

How to install wget in macOS?

I try to install wget in MAC OS 10.11.1 but when I run ./configure --with-ssl=openssl I get this error: configure: error: --with-ssl=openssl was given, but SSL is not available. How to resolve this problem in OSX 10.11.1?...

iOS app with framework crashed on device, dyld: Library not loaded, Xcode 6 Beta

This crash has been a blocking issue I used the following steps to reproduce the issue: Create a Cocoa Touch Framework project Add a swift file and a class Dog Build a framework for device Create a Single View application in Swift Import framework ...

Can I avoid the native fullscreen video player with HTML5 on iPhone or android?

I've built a web app that uses the HTML5 tag and JavaScript code that renders other content synchronized with the running video. It works great in desktop browsers: Firefox, Chrome, and Safari. On an iPhone or a DroidX, the native video player pops ...

Debugging the error "gcc: error: x86_64-linux-gnu-gcc: No such file or directory"

I'm trying to build: https://github.com/kanzure/nanoengineer But it looks like it errors out on: gcc -DHAVE_CONFIG_H -I. -I../.. -I/usr/include/python2.7 -std=c99 x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -W...

how can get index & count in vuejs

I have code like this (JSFiddle) <li v-for="(itemObjKey, catalog) in catalogs">this index : {{itemObjKey}}</li> Output: this index: 0 this index: 1 My question is: How can I get value index first begin: 1 for example I want output...

Rails: How to reference images in CSS within Rails 4

There's a strange issue with Rails 4 on Heroku. When images are compiled they have hashes added to them, yet the reference to those files from within CSS don't have the proper name adjusted. Here's what I mean. I have a file called logo.png. Yet w...

How to make a promise from setTimeout

This is not a realworld problem, I'm just trying to understand how promises are created. I need to understand how to make a promise for a function that returns nothing, like setTimeout. Suppose I have: function async(callback){ setTimeout(fun...

HTML Form: Select-Option vs Datalist-Option

I was wondering what the differences are between Select-Option and Datalist-Option. Is there any situation in which it would be better to use one or the other? An example of each follows: Select-Option <select name="browser"> <option val...

SQL Server® 2016, 2017 and 2019 Express full download

All previous version of SQL Server Express were available in both web and full downloads. But I cannot find full download of SQL Server® 2016 Express. Does it exist? Asked the same question on MSDN forums, not much luck: https://social.msdn.microso...

How to measure elapsed time in Python?

What I want is to start counting time somewhere in my code and then get the passed time, to measure the time it took to execute few function. I think I'm using the timeit module wrong, but the docs are just confusing for me. import timeit start = t...

org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 15

I'm porting a webapp from Tomcat 7 to another server with Tomcat 7 but with Java 8. Tomcat starts successfully but in log catalina.out I get: org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 15 at o...

Angularjs simple file download causes router to redirect

HTML: <a href="mysite.com/uploads/asd4a4d5a.pdf" download="foo.pdf"> Uploads get a unique file name while there real name is kept in database. I want to realize a simple file download. But the code above redirects to / because of: $routePro...

When to use cla(), clf() or close() for clearing a plot in matplotlib?

Matplotlib offers these functions: cla() # Clear axis clf() # Clear figure close() # Close a figure window The documentation doesn't offer a lot of insight into what the difference between these functions is. When should I use each function and ...

How to include CSS file in Symfony 2 and Twig?

I'm playing around with Symfony2, and I have problems including CSS and JS files in Twig template. I have a bundle named Webs/HomeBundle inside which I have HomeController with indexAction that renders a twig template file: public function indexActio...

What is the default lifetime of a session?

If I hit a page which calls session_start(), how long would I have to wait before I get a new session ID when I refresh the page?...

Using $_POST to get select option value from HTML

I use select as below: <select name="taskOption"> <option>First</option> <option>Second</option> <option>Third</option> </select> How do I get the value from the select option and store i...

Getting the first character of a string with $str[0]

I want to get the first letter of a string and I've noticed that $str[0] works great. I am just not sure whether this is 'good practice', as that notation is generally used with arrays. This feature doesn't seem to be very well documented so I'm turn...

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

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

How do I perform an IF...THEN in an SQL SELECT?

How do I perform an IF...THEN in an SQL SELECT statement? For example: SELECT IF(Obsolete = 'N' OR InStock = 'Y' ? 1 : 0) AS Saleable, * FROM Product ...

Styling text input caret

I want to style the caret of a focused <input type='text'/>. Specifically, the color and thickness....

SQL not a single-group group function

When I run the following SQL statement: SELECT MAX(SUM(TIME)) FROM downloads GROUP BY SSN It returns the maximum sum value of downloads by a customer, however if I try to find the social security number that that max value belongs to by adding it ...

Firestore Getting documents id from collection

I'm trying to retrieve my documents with id but can't figure it out. Currently I retrieve my documents like this : const racesCollection: AngularFirestoreCollection<Races> = this.afs.collection('races'); return racesCollection.valueChanges();...

How to revert to origin's master branch's version of file

I'm in my local computer's master branch of a cloned master-branch of a repo from a remote server. I updated a file, and I want to revert back to the original version from the remote master branch. How can I do this?...

How to set shape's opacity?

I already know how to set the opacity of the background image but I need to set the opacity of my shape object. In my Android app, I have it like this: and I want to make this black area a bit transparent, like here, for example I can see circles ...

How to find lines containing a string in linux

I have a file in Linux, I would like to diplay lines which contain a specific string in that file, how to do this?...

Yii2 data provider default sorting

In Yii 1.1 this code works for default sorting: $dataProvider = new CActiveDataProvider('article',array( 'sort'=>array( 'defaultOrder'=>'id DESC', ), )); How default sorting can be set in Yii2? Tried below code, but no resul...

How can I use grep to show just filenames on Linux?

How can I use grep to show just file-names (no in-line matches) on Linux? I am usually using something like: find . -iname "*php" -exec grep -H myString {} \; How can I just get the file-names (with paths), but without the matches? Do I have to u...

Angular.js: set element height on page load

I'm AngularJS newbie. I want to create grid (using ng-grid) which height depends on window height ie. $('.gridStyle').height($(window).height() - 100); I have written directive: app.directive('resize', function($window) { return function(scope...

Reset all the items in a form

I was wondering, is there a way I can reset all the checkboxes, textboxes, numerics and other controls back to the default values without writing code for every control individually? This is the code I've tried, but doesn't seem to work: for (int ...

NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

I'm trying to run the sample tiles example given here. Below is my POM.xml: <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <vers...

How to pick a new color for each plotted line within a figure in matplotlib?

I'd like to NOT specify a color for each plotted line, and have each line get a distinct color. But if I run: from matplotlib import pyplot as plt for i in range(20): plt.plot([0, 1], [i, i]) plt.show() then I get this output: If you look ...

How to drop columns by name in a data frame

I have a large data set and I would like to read specific columns or drop all the others. data <- read.dta("file.dta") I select the columns that I'm not interested in: var.out <- names(data)[!names(data) %in% c("iden", "name", "x_serv", "m_...

Load HTML page dynamically into div with jQuery

I'm trying to make it so when I click on a link in a HTML page, it dynamically loads the requested page into a div with jQuery. How can I do that? <html> <head> <script type="text/javascript"> // what can I do for load any url...

Conversion failed when converting date and/or time from character string in SQL SERVER 2008

I have below SQL. UPDATE student_queues SET Deleted=0, last_accessed_by='raja', last_accessed_on=CONVERT(VARCHAR(24),'23-07-2014 09:37:00',113) WHERE std_id IN ('2144-384-11564') AND reject_details='REJECT' when I ran the a...

What is the functionality of setSoTimeout and how it works?

I'm trying to learn Socket by myself. I'm little bit confused by following text from Oracle website. I have some questions regarding that. Thanks in advance for any clear explanation. setSoTimeout public void setSoTimeout(int timeout) throw...

jQuery - checkbox enable/disable

I have a bunch of checkboxes like this. If the "Check Me" checkbox is checked, all the other 3 checkboxes should be enabled, else they should be disabled. How can I do this using jQuery? <form name="frmChkForm" id="frmChkForm"> <input type=...

How do I force git pull to overwrite everything on every pull?

I have a CENTRAL bare repository that has three developer repositories pulling and pushing to it normally. I also have two other repositories that pull from the CENTRAL bare repo: one is the live server, and the other is a test/stage server—each p...

Create a global variable in TypeScript

In JavaScript I can just do this: something = 'testing'; And then in another file: if (something === 'testing') and it will have something be defined (as long as they were called in the correct order). I can't seem to figure out how to do th...

Check if an array contains duplicate values

I wanted to write a javascript function which checks if array contains duplicate values or not. I have written the following code but its giving answer as "true" always. Can anybody please tell me what am I missing. function checkIfArrayIsUnique(m...

Fatal error: Class 'Illuminate\Foundation\Application' not found

I am getting following error when I open my site which is made using laravel 5 Fatal error: Class 'Illuminate\Foundation\Application' not found in C:\cms\bootstrap\app.php on line 14 I have tried removing vendor folder and composer.lock file an...

What is the .idea folder?

When I create a project in JetBrains WebStorm, a folder called .idea gets created. Is it okay if I delete it? Will it affect my project?...

save a pandas.Series histogram plot to file

In ipython Notebook, first create a pandas Series object, then by calling the instance method .hist(), the browser displays the figure. I am wondering how to save this figure to a file (I mean not by right click and save as, but the commands needed...

Select Tag Helper in ASP.NET Core MVC

I need some help with the select tag helper in ASP.NET Core. I have a list of employees that I'm trying to bind to a select tag helper. My employees are in a List<Employee> EmployeesList and selected value will go into EmployeeId property. My ...

How to check a radio button with jQuery?

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

HTML table with horizontal scrolling (first column fixed)

I have been trying to think of a way to make a table with a fixed first column (and the rest of the table with a horizontal overflow) I saw a post which had a similar question. but the fixed column bit did not seem to be resolved. Help?...

Send Email Intent

Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/html"); intent.putExtra(Intent.EXTRA_EMAIL, "[email protected]"); intent.putExtra(Intent.EXTRA_SUBJECT, "Subject"); intent.putExtra(Intent.EXTRA_TEXT, "I'm email body.")...

How can I plot a confusion matrix?

I am using scikit-learn for classification of text documents(22000) to 100 classes. I use scikit-learn's confusion matrix method for computing the confusion matrix. model1 = LogisticRegression() model1 = model1.fit(matrix, labels) pred = model1.pred...

Create Excel files from C# without office

I am writing a program that generates excel reports, currently using the Microsoft.Interop.Excel reference. My dev computer has Excel on it, but the end user may or may not have Office installed. Will this tool fail if Office isn't installed on the...

Understanding Popen.communicate

I have a script named 1st.py which creates a REPL (read-eval-print-loop): print "Something to print" while True: r = raw_input() if r == 'n': print "exiting" break else: print "continuing" I then launched 1st.py...

Definitive way to trigger keypress events with jQuery

I've read all the answers on to this questions and none of the solutions seem to work. Also, I am getting the vibe that triggering keypress with special characters does not work at all. Can someone verify who has done this? ...

How to log PostgreSQL queries?

How to enable logging of all SQL executed by PostgreSQL 8.3? Edited (more info) I changed these lines : log_directory = 'pg_log' log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' log_statement = 'all' And restart PostgreSQL serv...

Spark - SELECT WHERE or filtering?

What's the difference between selecting with a where clause and filtering in Spark? Are there any use cases in which one is more appropriate than the other one? When do I use DataFrame newdf = df.select(df.col("*")).where(df.col("somecol").leq(10...

Javascript ajax call on page onload

I wish a page to fully load before issuing an ajax call to update database. I can call a javascript function in the body onload event so the page is fully loaded, but I'm not sure how to trigger the Ajax call from there.Is there any better way of ach...

How to push a docker image to a private repository

I have a docker image tagged as me/my-image, and I have a private repo on the dockerhub named me-private. When I push my me/my-image, I end up always hitting the public repo. What is the exact syntax to specifically push my image to my private repo?...

What is the difference between a candidate key and a primary key?

Is it that a primary key is the selected candidate key chosen for a given table?...

Case Function Equivalent in Excel

I have an interesting challenge - I need to run a check on the following data in Excel: | A - B - C - D | |------|------|------|------| | 36 | 0 | 0 | x | | 0 | 600 | 700 | x | |___________________________| You'll ha...

pandas dataframe create new columns and fill with calculated values from same df

Here is a simplified example of my df: ds = pd.DataFrame(np.abs(randn(3, 4)), index=[1,2,3], columns=['A','B','C','D']) ds A B C D 1 1.099679 0.042043 0.083903 0.410128 2 0.268205 0.718933 1.459374 0.758887 3 0...

alternatives to REPLACE on a text or ntext datatype

I need to update/replace the data in datatable.column. The table has a field named Content. I'm using the REPLACE function. Since the column datatype is NTEXT, SQL Server doesn't allow me to use the REPLACE function. I can't change the datatype beca...

Express.js - app.listen vs server.listen

This may be a very basic question but I simply don't get it. What is the difference between creating an app using Express.js and starting the app listening on port 1234, for example: var express = require('express'); var app = express(); //app.conf...

Tainted canvases may not be exported

I want to save my canvas to a img. I have this function: function save() { document.getElementById("canvasimg").style.border = "2px solid"; var dataURL = canvas.toDataURL(); document.getElementById("canvasimg").src = dataURL; documen...

How to process SIGTERM signal gracefully?

Let's assume we have such a trivial daemon written in python: def mainloop(): while True: # 1. do # 2. some # 3. important # 4. job # 5. sleep mainloop() and we daemonize it using start-stop-daemon whic...

Android ADB devices unauthorized

Configuration: Windows 8.1 ADB version: 1.0.32 Smartphone: Oneplus One Problem I installed the Samsung drivers as it is said to do. When I run the ADB devices command, it said unauthorized. Already tried: I've done everything that'd been said...

VirtualBox Cannot register the hard disk already exists

I created a virtual disk file VM_1_Ubuntu.vdi. Then I moved it into another folder. I tried to update VM settings (right click on virtual machine -> settings -> Storage -> Controller SATA tab, VM_1_Ubuntu.vdi path). I wanted to set a new path. It sa...

Regex to match only letters

How can I write a regex that matches only letters?...

Replace comma with newline in sed on MacOS?

I have a file of id's that are comma separated. I'm trying to replace the commas with a new line. I've tried: sed 's/,/\n/g' file but it is not working. What am I missing?...

Drawing rotated text on a HTML5 canvas

Part of a web application I'm developing requires me to create bar graphs to display various information. I figured, if the user's browser is capable, I would draw them using the HTML5 canvas element. I have no problem drawing lines and bars for my g...

Combine two or more columns in a dataframe into a new column with a new name

For example if I have this: n = c(2, 3, 5) s = c("aa", "bb", "cc") b = c(TRUE, FALSE, TRUE) df = data.frame(n, s, b) n s b 1 2 aa TRUE 2 3 bb FALSE 3 5 cc TRUE Then how do I combine the two columns n and s into a new column named x su...

Redirect all output to file in Bash

I know that in Linux, to redirect output from the screen to a file, I can either use the > or tee. However, I'm not sure why part of the output is still output to the screen and not written to the file. Is there a way to redirect all output to f...

Environment variable in Jenkins Pipeline

Is there any environment variable available for getting the Jenkins Pipeline Title? I know we can use $JOB_NAME to get title for a freestyle job, but is there anything that can be used for getting Pipeline name?...

How to add an extra column to a NumPy array

Let’s say I have a NumPy array, a: a = np.array([ [1, 2, 3], [2, 3, 4] ]) And I would like to add a column of zeros to get an array, b: b = np.array([ [1, 2, 3, 0], [2, 3, 4, 0] ]) How can I do this easily in NumPy...

Cmake doesn't find Boost

I'm trying to configure a project using CMake, but it fails to find Boost libraries even though they are in the specified folder. I have specified Boost_INCLUDE_DIR, Boost_LIBRARYDIR and BOOST_ROOT , but I still get an error saying that CMake is not ...

How to make an anchor tag refer to nothing?

I use jQuery, I need to make some anchor tags perform no action. I usually write it like this: <a href="#">link</a> However this refers to the top of the page!...

How to call a Web Service Method?

I have a web service that contains this method: [WebMethod] public static List<string> GetFileListOnWebServer() { DirectoryInfo dInfo = new DirectoryInfo(HostingEnvironment.MapPath("~/UploadedFiles/")); FileInfo[] fInfo = dInfo.GetFiles(...

jQuery send HTML data through POST

I am using jQuery to make a POST to a PHP file with the HTML content of a div. The HTML content contain tables, inputs, smaller divs and I would like to grab the content of the main DIV and send it to the database. The only option I could think of is...

How to add image in a TextView text?

I've searched around on Google and came across this site where I found a question similar to mine in which how to include a image in a TextView text, for example "hello my name is [image]", and the answer was this: ImageSpan is = new ImageSpan(conte...

ImageView - have height match width?

I have an imageview. I want its width to be fill_parent. I want its height to be whatever the width ends up being. For example: <ImageView android:layout_width="fill_parent" android:layout_height="whatever the width ends up being" /> Is ...

How can INSERT INTO a table 300 times within a loop in SQL?

I would like to insert a value retrieved from a counter in SQL and repeat it 300 times. Something like: DECLARE @Counter = 0; -- BEGIN Loop SET @Counter = @Counter + 1 INSERT INTO tblFoo VALUES(@Counter) -- REPEAT 300 times How can I a...

Show Hide div if, if statement is true

My code works to a point. What I want is that when this if statement is false, the <div> doesn't show <?php $query3 = mysql_query($query3); $numrows = mysql_num_rows($query3); if ($numrows > 0) { $fvisit = mysql_fetch...

Kubernetes service external ip pending

I am trying to deploy nginx on kubernetes, kubernetes version is v1.5.2, I have deployed nginx with 3 replica, YAML file is below, apiVersion: extensions/v1beta1 kind: Deployment metadata: name: deployment-example spec: replicas: 3 revisionHist...

Android: I am unable to have ViewPager WRAP_CONTENT

I have setup a simple ViewPager that has an ImageView with a height of 200dp on each page. Here is my pager: pager = new ViewPager(this); pager.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); pager.setBackgro...

Bi-directional Map in Java?

I have a simple integer-to-string mapping in Java, but I need to be able to easily retrieve string from integer, and also integer from string. I've tried Map, but it can retrieve only string from integer, it's one way: private static final Map<In...

Link to a section of a webpage

I want to make a link that when clicked, sends you to a certain line on the page (or another page). I know this is possible, but how do I do it?...

Make absolute positioned div expand parent div height

As you can see in the CSS below, I want child2 to position itself before child1. This is because the site I'm currently developing should also work on mobile devices, on which the child2 should be at the bottom, as it contains the navigation which I ...

Node.js heap out of memory

Today I ran my script for filesystem indexing to refresh RAID files index and after 4h it crashed with following error: [md5:] 241613/241627 97.5% [md5:] 241614/241627 97.5% [md5:] 241625/241627 98.1% Creating missing list... (79570 files mis...

Why "net use * /delete" does not work but waits for confirmation in my PowerShell script?

I have a script where I want to disconnect from the mapped drives before I create a new PSDrive. Otherwise I get this error: New-PSDrive : Multiple connections to a server or shared resource by the same user , using more than one user name, a...

Convert a JSON Object to Buffer and Buffer to JSON Object back

I have a JSON object and I'm converting it to a Buffer and doing some process here. Later I want to convert the same buffer data to convert to valid JSON object. I'm working on Node V6.9.1 Below is the code I tried but I'm getting [object object] w...

Converting string into datetime

I've got a huge list of date-times like this as strings: Jun 1 2005 1:33PM Aug 28 1999 12:00AM I'm going to be shoving these back into proper datetime fields in a database so I need to magic them into real datetime objects. This is going throug...

No module named 'pymysql'

I'm trying to use PyMySQL on Ubuntu. I've installed pymysql using both pip and pip3 but every time I use import pymysql, it returns ImportError: No module named 'pymysql' I'm using Ubuntu 15.10 64-bit and Python 3.5. The same .py works on Windows ...

How to list all the files in a commit?

I am looking for a simple git command that provides a nicely formatted list of all files that were part of the commit given by a hash (SHA1), with no extraneous information. I have tried: git show a303aa90779efdd2f6b9d90693e2cbbbe4613c1d Although...

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

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

How to convert PDF files to images

I need to convert PDF files to images. If the PDF file is multi-page,I just need one image that contains all of the PDF pages. Is there an open source solution which is not charged like the Acrobat product?...

Finding height in Binary Search Tree

I was wondering if anybody could help me rework this method to find the height of a binary search tree. So far, my code looks like this. However, the answer I'm getting is larger than the actual height by 1. But when I remove the +1 from my return st...

What is the difference between dynamic and static polymorphism in Java?

Can anyone provide a simple example that explains the difference between Dynamic and Static polymorphism in Java?...

How to set the color of "placeholder" text?

Is that possible to set the color of placeholder text ? <textarea placeholder="Write your message here..."></textarea> ...

WPF Check box: Check changed handling

In WPF data binding, I can bind the IsChecked property to some data, e.g. user setting, but I need to handle "CheckChanged" event, I know I can seperately handle Checked, Unchecked event, but is there any way to get notified when this value is change...

PySpark 2.0 The size or shape of a DataFrame

I am trying to find out the size/shape of a DataFrame in PySpark. I do not see a single function that can do this. In Python I can do data.shape() Is there a similar function in PySpark. This is my current solution, but I am looking for an elemen...

What is the difference between Scrum and Agile Development?

What is the difference between Scrum and Agile Development? Are Sprint and Iterations the same?...

How to rename a directory/folder on GitHub website?

I was able to find a way on GitHub Website to rename a single file and did so with success. I was also able to find a way to rename a whole repository and did that with success. Does anyone know how to do this to a single directory without using c...

How to generate UL Li list from string array using jquery?

I have string array like 'United States', 'Canada', 'Argentina', 'Armenia', 'Aruba', 'Australia', 'Austria', 'Azerbaijan', 'Bahamas', 'Bangladesh', 'Belarus', 'Belgium'**, ... etc. I want create a dynamic list from string array like below:...

catch specific HTTP error in python

I want to catch a specific http error and not any one of the entire family.. what I was trying to do is -- import urllib2 try: urllib2.urlopen("some url") except urllib2.HTTPError: <whatever> but what I end up is catching any kind of h...

get all the images from a folder in php

I am using WordPress. I have an image folder like mytheme/images/myimages. I want to retrieve all the images name from the folder myimages Please advice me, how can I get images name....

JPanel setBackground(Color.BLACK) does nothing

I have the folowing custom JPanel and I have aded it to my frame using Netbeans GUI builder but the background won't change! I can see the circle, drawing with g.fillOval(). What's wrong? public class Board extends JPanel{ private Player player...

Access properties file programmatically with Spring?

We use the code below to inject Spring beans with properties from a properties file. <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations" value="classpath:/my.properties"/> ...

How to change font size in Eclipse for Java text editors?

I have just tried to change my font size in Eclipse 3.6.0 in the following way: General → Appearance → Colors and Fonts → Java Editor text font However, the font size only changed in the file I had open. How can I change the font...

Best timestamp format for CSV/Excel?

I'm writing a CSV file. I need to write timestamps that are accurate at least to the second, and preferably to the millisecond. What's the best format for timestamps in a CSV file such that they can be parsed accurately and unambiguously by Excel w...

Difference between readFile() and readFileSync()

The following code outputs the content of the index.html (it just contains the text hello world) to the browser. However, when I replace readFile() with readFileSync(), the request times out. What am I missing? Is a different kind of buffer required?...

TSQL Pivot without aggregate function

I have a table like this... CustomerID DBColumnName Data -------------------------------------- 1 FirstName Joe 1 MiddleName S 1 LastName Smith 1 Date 12/12/2009 2 F...

how to check redis instance version?

how to check Redis server version? I've found in Redis site this command: $ redis-server and that should give me (according to the site): [28550] 01 Aug 19:29:28 # Warning: no config file specified, using the default config. In order to specify a c...

Float a div above page content

I've implemented a popup box that dynamically displays search options. I want the box to "float" above all of the site content. Currently, when the box is displayed it displaces all of the content below it and looks bad. I believe I've already t...

@font-face src: local - How to use the local font if the user already has it?

What is the right way to use @font-face so that the browser will not download the font if the user already have it? I am using @font-face to define DejaVu, which is already installed on my system (linux). Firefox is not downloading the font, but Chr...

How to turn on line numbers in IDLE?

In the main shell of IDLE, errors always return a line number but the development environment doesn't even have line numbers. Is there anyway to turn on line numbers?...

"application blocked by security settings" prevent applets running using oracle SE 7 update 51 on firefox on Linux mint

Background Complete fresh installation of Oracle Java SDK (32-bit) on Linux. The installation is correct, the plugin is correctly installed. Problem The following error ("Application Blocked by Security Settings") appears when the applet runs insi...

URL encoding the space character: + or %20?

When is a space in a URL encoded to +, and when is it encoded to %20?...

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

How to word wrap text in HTML?

How can text like aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa which exceeds the width of a div (say 200px) be wrapped? I am open to any kind of solution such as CSS, jQuery, etc....

RS256 vs HS256: What's the difference?

I'm using Auth0 to handle authentication in my web app. I'm using ASP.NET Core v1.0.0 and Angular 2 rc5 and I don't know much about authentication/security in general. In the Auth0 docs for ASP.NET Core Web Api, there are two choices for the JWT algo...

String split on new line, tab and some number of spaces

I'm trying to perform a string split on a set of somewhat irregular data that looks something like: \n\tName: John Smith \n\t Home: Anytown USA \n\t Phone: 555-555-555 \n\t Other Home: Somewhere Else \n\t Notes: Other data \n\tName: Jane Smith ...

What is the easiest way to disable/enable buttons and links (jQuery + Bootstrap)

Sometimes I use anchors styled as buttons and sometimes I just use buttons. I want to disable specific clicky-things so that: They look disabled They stop being clicked How can I do this?...

Fixing the order of facets in ggplot

Data: df <- data.frame( type = c("T", "F", "P", "T", "F", "P", "T", "F", "P", "T", "F", "P"), size = c("50%&q...

Multi-statement Table Valued Function vs Inline Table Valued Function

A few examples to show, just incase: Inline Table Valued CREATE FUNCTION MyNS.GetUnshippedOrders() RETURNS TABLE AS RETURN SELECT a.SaleId, a.CustomerID, b.Qty FROM Sales.Sales a INNER JOIN Sales.SaleDetail b ON a.SaleId = b.SaleId ...

Write a file on iOS

How do I write a file on iOS? I'm trying to do it with the following code but I'm doing something wrong: char *saves = "abcd"; NSData *data = [[NSData alloc] initWithBytes:saves length:4]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocu...

How to add title to subplots in Matplotlib?

I have one figure which contains many subplots. fig = plt.figure(num=None, figsize=(26, 12), dpi=80, facecolor='w', edgecolor='k') fig.canvas.set_window_title('Window Title') # Returns the Axes instance ax = fig.add_subplot(311) ax2 = fig.add_subp...

How to escape comma and double quote at same time for CSV file?

I am writing a Java app to export data from Oracle to csv file Unfortunately the content of data may quite tricky. Still comma is the deliminator, but some data on a row could be like this: | ID | FN | LN | AGE | COMMENT ...

Rename file with Git

I'm new to Git/Github and I needs some help. I would like to rename file from README to README.md. I have only one repo called "change-z-index". 1) I open and login like that: ssh -T [email protected] And I enter my passphrase. 2) I try to rename t...

Is header('Content-Type:text/plain'); necessary at all?

I didn't see any difference with or without this head information yet....

How do I convert a Django QuerySet into list of dicts?

How can I convert a Django QuerySet into a list of dicts? I haven't found an answer to this so I'm wondering if I'm missing some sort of common helper function that everyone uses....

How to hide Soft Keyboard when activity starts

I have an Edittext with android:windowSoftInputMode="stateVisible" in Manifest. Now the keyboard will be shown when I start the activity. How to hide it? I cannot use android:windowSoftInputMode="stateHidden because when keyboard is visible then mini...

How can I parse a JSON file with PHP?

I tried to parse a JSON file using PHP. But I am stuck now. This is the content of my JSON file: { "John": { "status":"Wait" }, "Jennifer": { "status":"Active" }, "James": { "status":"Active", "ag...

Adding new column to existing DataFrame in Python pandas

I have the following indexed DataFrame with named columns and rows not- continuous numbers: a b c d 2 0.671399 0.101208 -0.181532 0.241273 3 0.446172 -0.243316 0.051767 1.577318 5 0.614758 0.075793 -0.451460...

Reading/Writing a MS Word file in PHP

Is it possible to read and write Word (2003 and 2007) files in PHP without using a COM object? I know that I can: $file = fopen('c:\file.doc', 'w+'); fwrite($file, $text); fclose(); but Word will read it as an HTML file not a native .doc file....

How to install a Mac application using Terminal

Apple suggests that prior to submitting to the Mac application store, the installation process for Macs be tested using the command sudo installer -store -pkg path-to-package -target / I saved the application package to the desktop and then in the...

Is it possible to open a Windows Explorer window from PowerShell?

I'm sure this must be possible, but I can't find out how to do it. Any clues?...

What is the default boolean value in C#?

A boolean (bool) can't be null. And: bool foo; if(foo){} // Use of unassigned local variable 'foo' Why the default value is not false? So what is the value if it is not null? What is the reason? Edit 1 - The default value is indeed false - but al...

How to retrieve the current version of a MySQL database management system (DBMS)?

What command returns the current version of a MySQL database?...

The instance of entity type cannot be tracked because another instance of this type with the same key is already being tracked

I have a Service Object Update public bool Update(object original, object modified) { var originalClient = (Client)original; var modifiedClient = (Client)modified; _context.Clients.Update(originalClient); //<-- throws the error _...

Remove Safari/Chrome textinput/textarea glow

I am wondering if its possible to remove the default blue and yellow glow when I click on a text input / text area using CSS?...

Checking during array iteration, if the current element is the last element

Please help me to translate this pseudo-code to real php code: foreach ($arr as $k => $v) if ( THIS IS NOT THE LAST ELEMENT IN THE ARRAY) doSomething(); Edit: the array may have numerical or string keys...

Gradle to execute Java class (without modifying build.gradle)

There is simple Eclipse plugin to run Gradle, that just uses command line way to launch gradle. What is gradle analog for maven compile and run mvn compile exec:java -Dexec.mainClass=example.Example This way any project with gradle.build could be r...

Java - Using Accessor and Mutator methods

I am working on a homework assignment. I am confused on how it should be done. The question is: Create a class called IDCard that contains a person's name, ID number, and the name of a file containing the person's photogrpah. Write accesso...

Android Studio doesn't see device

The AVD Manager in Android Studio doesn't show my device but adb devices does show it. Am I missing something obvious here?...

How to set .net Framework 4.5 version in IIS 7 application pool

I installed the Visual Studio 11 Beta and suddenly all the async action methods I had created under the VS 11 Developer preview started hanging (apparently this issue: http://blogs.msdn.com/b/pfxteam/archive/2012/03/03/10277166.aspx). My app is usin...

pass array to method Java

How can I pass an entire array to a method? private void PassArray() { String[] arrayw = new String[4]; //populate array PrintA(arrayw[]); } private void PrintA(String[] a) { //do whatever with array here } How do I do this correc...

Accessing items in an collections.OrderedDict by index

Lets say I have the following code: import collections d = collections.OrderedDict() d['foo'] = 'python' d['bar'] = 'spam' Is there a way I can access the items in a numbered manner, like: d(0) #foo's Output d(1) #bar's Output ...

How to remove items from a list while iterating?

I'm iterating over a list of tuples in Python, and am attempting to remove them if they meet certain criteria. for tup in somelist: if determine(tup): code_to_remove_tup What should I use in place of code_to_remove_tup? I can't figur...

Multiple Updates in MySQL

I know that you can insert multiple rows at once, is there a way to update multiple rows at once (as in, in one query) in MySQL? Edit: For example I have the following Name id Col1 Col2 Row1 1 6 1 Row2 2 2 3 Row3 3 9 ...

Get the first element of each tuple in a list in Python

An SQL query gives me a list of tuples, like this: [(elt1, elt2), (elt1, elt2), (elt1, elt2), (elt1, elt2), (elt1, elt2), ...] I'd like to have all the first elements of each tuple. Right now I use this: rows = cur.fetchall() res_list = [] for ro...

Move_uploaded_file() function is not working

I'm working on a website and I want the user to be able to upload files. So I'm trying to learn how to do that. I researched and it said that I had to use the function move_uploaded_file(). I wrote the code just like it was on the example (changing t...

How to do IF NOT EXISTS in SQLite

I am trying to port this line from MS SQL Server to SQLite IF NOT EXISTS(SELECT 1 FROM EVENTTYPE WHERE EventTypeName = 'ANI Received') INSERT INTO EVENTTYPE (EventTypeName) VALUES ('ANI Received'); It seems that SQLite does not support IF NOT...

Visual studio code CSS indentation and formatting

I'd like to know if there is any way to activate auto indent a CSS file in visual studio code with the shortcut ALT+SHIFT+F? It's working fine with JavaScript but strangely not with CSS....

What are C++ functors and their uses?

I keep hearing a lot about functors in C++. Can someone give me an overview as to what they are and in what cases they would be useful?...

Floating Point Exception C++ Why and what is it?

I'm building a program for the Euler projects question 3, and while that might not really matter as a result I'm current trying to make this code take a number and test if it is prime or not. Now then before I get to troubleshoot the function it give...

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

What is the difference between NULL, '\0' and 0?

In C, there appear to be differences between various values of zero -- NULL, NUL and 0. I know that the ASCII character '0' evaluates to 48 or 0x30. The NULL pointer is usually defined as: #define NULL 0 Or #define NULL (void *)0 In addition,...

Plugin org.apache.maven.plugins:maven-compiler-plugin or one of its dependencies could not be resolved

I'm having some issues to configure properly my eclipse to work with maven. I create a new project, this one is correctly build with maven in command line (mvn install), but in Eclipse I got this error: CoreException: Could not get the value for...

String compare in Perl with "eq" vs "=="

I am (a complete Perl newbie) doing string compare in an if statement: If I do following: if ($str1 == "taste" && $str2 == "waste") { } I see the correct result (i.e. if the condition matches, it evaluates the "then" block). But I see the...

Convert Xml to Table SQL Server

I wonder how can i read a xml data and transform it to a table in TSQL? For example: <row> <IdInvernadero>8</IdInvernadero> <IdProducto>3</IdProducto> <IdCaracteristica1>8</IdCaracteristica1> ...

How can I submit form on button click when using preventDefault()?

I'm using jQuery's .preventDefault() to prevent form submit when users clicks the [ENTER] key. The problem is that it also stops the form submitting when I click the submit button. I see there are many threads on Stackoverflow in regards of .prevent...

What's the difference between <mvc:annotation-driven /> and <context:annotation-config /> in servlet?

I am migrating from Spring 2.5 to Spring 3. They have introduced <mvc:annotation-driven /> which does some black magic. This is expected to be declared in servlet configuration file only. In Spring 2.5 I have just used <context:annotation...

What's the canonical way to check for type in Python?

What is the best way to check whether a given object is of a given type? How about checking whether the object inherits from a given type? Let's say I have an object o. How do I check whether it's a str?...

Prompt Dialog in Windows Forms

I am using System.Windows.Forms but strangely enough don't have the ability to create them. How can I get something like a javascript prompt dialog, without javascript? MessageBox is nice, but there is no way for the user to enter an input. I want...

trying to align html button at the center of the my page

I'm trying to align an HTML button exactly at the centre of the page irrespective of the browser used. It is either floating to the left while still being at the vertical centre or being somewhere on the page like at the top of the page etc.. I wan...

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

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

OpenCV - Saving images to a particular folder of choice

I'm learning OpenCV and Python. I captured some images from my webcam and saved them. But they are being saved by default into the local folder. I want to save them to another folder from direct path. How do I fix it? ...

How can I find whitespace in a String?

How can I check to see if a String contains a whitespace character, an empty space or " ". If possible, please provide a Java example. For example: String = "test word"; ...

select into in mysql

I am a MSSQL user and now I am converting my database to MySQL. I am writing the following query in MySQL: select * into new_tbl from tbl And I get the following error Error : Undeclared variable new_tbl How such a query should be properly writ...

Programmatically switching between tabs within Swift

I need write some code to switch the view to another tab when the iOS app starts (so, for example, the second tab is shown by default rather than the first). I'm new to Swift, and have worked out the following: The code should probably go in the o...

Android: how to create Switch case from this?

public void onItemClick(AdapterView<?> a, View v, int position, long id) { AlertDialog.Builder adb = new AlertDialog.Builder(CategoriesTab.this); adb.setTitle("Selected Category"); adb.setMessage("Selected Item is = "+lv1.getItemAt...

WebView link click open default browser

Right now I have an app that loads a webview and all the clicks are kept within the app. What I would like to do is when a certain link, for example, http://www.google.com is clicked within the app it opens the default browser. If anyone has some ide...

CSS Transition doesn't work with top, bottom, left, right

I have an element with style position: relative; transition: all 2s ease 0s; Then I want to change its position smoothly after clicking on it, but when I add the style change the transition doesn't take place, instead, the element moves instantly. $...

text box input height

I made the size of the box bigger. it look bigger int the dream weaver design view but does not seem to work in the browsers. <input type="text" **height="60%"** name=" item" align="left" /> ...

Drop all data in a pandas dataframe

I would like to drop all data in a pandas dataframe, but am getting TypeError: drop() takes at least 2 arguments (3 given). I essentially want a blank dataframe with just my columns headers. import pandas as pd web_stats = {'Day': [1, 2, 3, 4, 2, 6...

Number format in excel: Showing % value without multiplying with 100

When I set format of a cell as %, it automatically multiply the value with 100 & show the value. So 5.66 becomes 566 %. I want to apply % format on a column but want to keep the values same as before. I just want % sign to be shown along with th...

Does a `+` in a URL scheme/host/path represent a space?

I am aware that a + in the query string of a URL represents a space. Is this also the case outside of the query string region? That is to say, does the following URL: http://a.com/a+b/c actually represent: http://a.com/a b/c (and thus need to b...

How to get the correct range to set the value to a cell?

I want to set text or number in Google Sheet from script. I want to set Hello or number 9 in cell F2. I found this code so far: SpreadsheetApp.getActiveRange().setValue('hello'); but that doesn't specify which cell....

How to use icons and symbols from "Font Awesome" on Native Android Application

I'm trying to use Font Awesome on my application, I was able to integrate the font using Typeface.createFromAsset(), but I also want to use the icons provided by this font, but so far I haven't been able to do that. This particular font contains ic...

Runnable with a parameter?

I have a need for a "Runnable that accepts a parameter" although I know that such runnable doesn't really exist. This may point to fundamental flaw in the design of my app and/or a mental block in my tired brain, so I am hoping to find here some adv...

Purpose of a constructor in Java?

What is the purpose of a constructor? I've been learning Java in school and it seems to me like a constructor is largely redundant in things we've done thus far. It remains to be seen if a purpose comes about, but so far it seems meaningless to me. F...

How to upload and parse a CSV file in php

I want to upload a csv file with php. After the file is uploaded, I want to display the data of the CSV file. I would like an example how to accomplish this task....

How to update std::map after using the find method?

How to update the value of a key in std::map after using the find method? I have a map and iterator declaration like this: map <char, int> m1; map <char, int>::iterator m1_it; typedef pair <char, int> count_pair; I'm using the m...

Is it possible to change javascript variable values while debugging in Google Chrome?

I'm debugging a javascript app (using Chrome dev tools), and I would like to change some variable values while stepping through the code. Is that possible at all? I have tried and got something like: > modeline 1 > modeline=0 0 &...

How to urlencode a querystring in Python?

I am trying to urlencode this string before I submit. queryString = 'eventName=' + evt.fields["eventName"] + '&' + 'eventDescription=' + evt.fields["eventDescription"]; ...

How do I Set Background image in Flutter?

I am trying to set a background image for the home page. I am getting the image place from start of the screen and filling the width but not the height. Am I missing something in my code? Are there image standards for flutter? Do images scale based ...

Placing a textview on top of imageview in android

I have a listview, that has a single imageview which is scrollable vertically I am trying to place a textview on top of Imageview Both the views must be visible Is it possible ? If yes, How to do it programmatically ? What changes should i need...

How do I plot only a table in Matplotlib?

Is it possible to draw only a table with matplotlib? If I uncomment the line plt.bar(index, data[row], bar_width, bottom=y_offset, color=colors[row]) of this example code, the plot is still visible. I want to have a table on top of my (PyQt) wind...

node: command not found

I am in the process of setting up node.js in order to work with a framework like Meteor, Derby, or Ember, but am running into some problems early on. Following these instructions (http://www.nodebeginner.org), I installed node, created a simple hello...

Is there a decorator to simply cache function return values?

Consider the following: @property def name(self): if not hasattr(self, '_name'): # expensive calculation self._name = 1 + 1 return self._name I'm new, but I think the caching could be factored out into a decorator. Only ...

Android - border for button

How do I add a border to a button? Is it possible to do this without resorting to use of images?...

HttpContext.Current.Request.Url.Host what it returns?

I'm having a local application which has a path: http://localhost:950/m/pages/Searchresults.aspx?search=knife&filter=kitchen but when this goes to integration environment or perhaps the production, it will be something like http://www.somesho...

How to change value of ArrayList element in java

Please help me with below code , I get the same output even after changing the value import java.util.*; class Test { public static void main(String[] args) { ArrayList<Integer> a = new ArrayList<Integer>(); // added...

Python, TypeError: unhashable type: 'list'

i'm reciving the following error in my program: Traceback: Traceback (most recent call last): File "C:\Python33\Archive\PythonGrafos\Alpha.py", line 126, in <module> menugrafos() File "C:\Python33\Archive\PythonGrafos\Alpha.py", line 97, in me...

This view is not constrained

I get the following error and I am using Android studio 2.2 Preview 3. I searched Google but couldn't find any resources. Error: This view is not constrained, it only has design time positions, so it will jump to (0,0) unless you add constraints ...

In Typescript, what is the ! (exclamation mark / bang) operator when dereferencing a member?

When looking at the sourcecode for a tslint rule, I came across the following statement: if (node.parent!.kind === ts.SyntaxKind.ObjectLiteralExpression) { return; } Notice the ! operator after node.parent. Interesting! I first tried compilin...

problem with <select> and :after with CSS in WebKit

I would like to add some style on a select box with the pseudo :after (to style my select box with 2 parts and without images). Here's the HTML: <select name=""> <option value="">Test</option> </select> And it doesn't wor...

How to include header files in GCC search path?

I have the following code in a sample file: #include "SkCanvas.h" #include "SkDevice.h" #include "SkGLCanvas.h" #include "SkGraphics.h" #include "SkImageEncoder.h" #include "SkPaint.h" #include "SkPicture.h" #include "SkStream.h" #include "SkWindow....

How can I make my website's background transparent without making the content (images & text) transparent too?

I'm doing a website for a school project, and I'm currently having a small problem... I can't make the body's background transparent without it also affecting the content in it. Here's my HTML code: <html> <head> <meta http-equiv...

The program can’t start because MSVCR71.dll is missing from your computer. Try reinstalling the program to fix this program

Long ago, I installed 32-bit Oracle SQL Developer 2.1 on a Windows XP (32-bit) machine. I have since moved to Windows 7 (64-bit) and copied the SQL Developer 2.1 from the old machine onto the new one. When I try to run sqldeveloper.exe, I get the fo...

Intent.putExtra List

Possible Duplicate: How to put a List in intent I want to pass a List from one activity to another. So far I have not been successful. This is my code. //desserts.java private List<Item> data; @Override public void onCreate(...

SQL use CASE statement in WHERE IN clause

Is it posible to use case in where in clause? Something like this: DECLARE @Status VARCHAR(50); SET @Status='published'; SELECT * FROM Product P WHERE P.Status IN (CASE WHEN @Status='published' THEN (1,3) ...

How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version

I am trying to use Notepad++ as my all-in-one tool edit, run, compile, etc. I have JRE installed, and I have setup my path variable to the .../bin directory. When I run my "Hello world" in Notepad++, I get this message: java.lang.UnsupportedClassV...

Paste MS Excel data to SQL Server

I have a bunch of rows in Excel that I want to paste into a new table in MS SQL. Is there a simple way ?...

How to remove duplicate white spaces in string using Java?

How to remove duplicate white spaces (including tabs, newlines, spaces, etc...) in a string using Java?...

How to pass parameter to a promise function

this might seem a silly question but I am a newbie in this topic. I am working on promises on node js. And I want to pass parameter to a promise function. However I could not figure it out. someModule.someFunction.then(username, password,function(ui...

JWT (Json Web Token) Audience "aud" versus Client_Id - What's the difference?

I'm working on implementing OAuth 2.0 JWT access_token in my authentication server. But, I'm not clear on what the differences are between the JWT aud claim and the client_id HTTP header value. Are they the same? If not, can you explain the differenc...

AngularJS not detecting Access-Control-Allow-Origin header?

I am running an angular app on a local virtualhost (http://foo.app:8000). It is making a request to another local VirtualHost (http://bar.app:8000) using $http.post. $http.post('http://bar.app:8000/mobile/reply', reply, {withCredentials: true}); I...

Best practices for catching and re-throwing .NET exceptions

What are the best practices to consider when catching exceptions and re-throwing them? I want to make sure that the Exception object's InnerException and stack trace are preserved. Is there a difference between the following code blocks in the way th...

How to config Tomcat to serve images from an external folder outside webapps?

How can i use Tomcat to serve image files from a public folder outside webapps? I dont want to use a 2nd Apache fileserver on a different port since the image files are part of the same app. And i dont want to create a symlink to the public folder in...

Use jQuery to change value of a label

I have a label, costLabel. What I want to be able to do is change the value of this label depending on the selected value of a dropdownlist. This is my HTML: <table> <tr> <td width="343">Package*</td> <td col...

Quick way to clear all selections on a multiselect enabled <select> with jQuery?

Do I have to iterate through ALL the and set remove the 'selected' attribute or is there a better way?...

How to set page content to the middle of screen?

Possible Duplicate: How to align a <div> to the middle of the page I need is to show the content of a web page in the middle of the screen, no matter what screen size it is, big or small, resolution high or low, it always gets automa...

How to compare two JSON objects with the same elements in a different order equal?

How can I test whether two JSON objects are equal in python, disregarding the order of lists? For example ... JSON document a: { "errors": [ {"error": "invalid", "field": "email"}, {"error": "required", "field": "name"} ], ...

Connection Java-MySql : Public Key Retrieval is not allowed

I try to connect MySql database with Java using connector 8.0.11. Everything seems to be ok but I have this exception: Exception in thread "main" java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed Stack Trace: ...

What programming language does facebook use?

I don't know much about programming languages, but am interested in a career with facebook, so I was wondering if someone could tell me what programming language facebook uses. Also, do any other social networking sites use the same language?...

how to toggle (hide/show) a table onClick of <a> tag in java script

I want to show and hide (toggle) the <table> onClick event of the <a>. this is my <a> tag <a id="loginLink" onclick="toggleTable(true);" href="#">Login</a> here is my java script function toggleTable(hide) <sc...

Disable back button in react navigation

I'm using react native navigation (react-navigation) StackNavigator. it starts from the Login page throughout the whole lifecycle of the app. I don't want to have a back option, returning to the Login screen. Does anyone know how it can be hidden on...

Zoom in on a point (using scale and translate)

I want to be able to zoom in on the point under the mouse in an HTML 5 canvas, like zooming on Google Maps. How can I achieve that?...

Reading from memory stream to string

I am trying to write an object to an Xml string and take that string and save it to a DB. But first I need to get the string... private static readonly Encoding LocalEncoding = Encoding.UTF8; public static string SaveToString<T> (T se...

How to pass a value from one Activity to another in Android?

I have created an Activity with a AutuCompleteTextView[ACTV] and button. I enter some text in the ACTV then press the button. After I press the button I want the Activity to go to another Activity. In the second Activity I just want to display the te...

Can I extend a class using more than 1 class in PHP?

If I have several classes with functions that I need but want to store separately for organisation, can I extend a class to have both? i.e. class a extends b extends c edit: I know how to extend classes one at a time, but I'm looking for a method t...

How can I disable selected attribute from select2() dropdown Jquery?

I know how to enable the selected attribute from dropdown; I can use this code : $('select').select2(); but my problem is how to disable it ? thx ...

Maven: Command to update repository after adding dependency to POM

I've added a new dependency to my POM. Is there a simple command I can run to download this dependency to my repository?...

Quickest way to find missing number in an array of numbers

I have an array of numbers from 1 to 100 (both inclusive). The size of the array is 100. The numbers are randomly added to the array, but there is one random empty slot in the array. What is the quickest way to find that slot as well as the number t...

How to use && in EL boolean expressions in Facelets?

I am having a little trouble figuring out how to do and's on EL expressions in Facelets. So basically I have: <h:outputText id="Prompt" value="Fobar" rendered="#{beanA.prompt == true && beanB.currentBase !=null}" /> But I ke...

How to convert column with dtype as object to string in Pandas Dataframe

When I read a csv file to pandas dataframe, each column is cast to its own datatypes. I have a column that was converted to an object. I want to perform string operations for this column such as splitting the values and creating a list. But no such o...

How can I access a hover state in reactjs?

I have a sidenav with a bunch of basketball teams. So I would like to display something different for each team when one of them is being hovered over. Also, I am using Reactjs so if I could have a variable that I could pass to another component that...

How to refresh Android listview?

How to refresh an Android ListView after adding/deleting dynamic data?...

What's the best strategy for unit-testing database-driven applications?

I work with a lot of web applications that are driven by databases of varying complexity on the backend. Typically, there's an ORM layer separate from the business and presentation logic. This makes unit-testing the business logic fairly straightforw...

Git: How to return from 'detached HEAD' state

If one would checkout a branch: git checkout 760ac7e from e.g. b9ac70b, how can one go back to the last known head b9ac70b without knowing its SHA1?...

java.io.InvalidClassException: local class incompatible:

I created client and server and then added a class in client side for serializing purposes, then simply just went to the folder of the client in my hard drive and copy paste it to the server correponding location, both classname.class and classname.j...

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 71 bytes)

I'm getting an error when I try to open one of my dashboard pages in my wordpress script The error message is as follows: Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 71 bytes) in /home/admin/domains/files...

Write lines of text to a file in R

In the R scripting language, how do I write lines of text, e.g. the following two lines Hello World to a file named "output.txt"?...

How can I check the size of a file in a Windows batch script?

I want to have a batch file which checks what the filesize is of a file. If it is bigger than %somany% kbytes, it should redirect with GOTO to somewhere else. Example: [check for filesize] IF %file% [filesize thing Bigger than] GOTO No echo Great!...

How can I set the color of a selected row in DataGrid

The default background color of a selected row in DataGrid is so dark that I can't read it. Is there anyway of overriding it? Tried this <dg:DataGrid.RowStyle> <Style TargetType="{x:Type dg:DataGridRow}"> <Style.Triggers...

"Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo." when using GCC

While attempting to compile my C program, running the following command: gcc pthread.c -o pthread Returns: Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo. and my code does not compile. Why is th...

How to print bytes in hexadecimal using System.out.println?

I've declared a byte array (I'm using Java): byte test[] = new byte[3]; test[0] = 0x0A; test[1] = 0xFF; test[2] = 0x01; How could I print the different values stored in the array? If I use System.out.println(test[0]) it will print '10'. I'd like ...

Pip "Could not find a that satisfies the requirement"

When I try to install PyGame with:pip install pygame it says Collecting pygame Could not find a version that satisfies the requirement pygame (from versions: ) No matching distribution found I believe that I am using the most recent version, 8.1.1....

accessing a variable from another class

Very simple question but I can't do it. I have 3 classes: DrawCircle class import java.awt.*; import java.awt.event.*; import javax.swing.*; class DrawCircle extends JPanel { private int w, h, di, diBig, diSmall, maxRad, xSq, ySq, xPoint, yPoi...

System.loadLibrary(...) couldn't find native library in my case

I want to use a existing native library from another Android project, so I just copied the NDK built library (libcalculate.so) to my new Android project. In my new Android project I created a folder libs/armeabi/ and put libcalculate.so there. There ...

Difference between framework vs Library vs IDE vs API vs SDK vs Toolkits?

I want some examples. I always get confused, so with some examples I might be able to figure it out better. Also: Is Eclipse an API or IDE?...

How to call webmethod in Asp.net C#

I want to call a web method in asp.net c# application using the following code Jquery: jQuery.ajax({ url: 'AddToCart.aspx/AddTo_Cart', type: "POST", data: "{'quantity' : " + total_qty + ",'itemId':" + itemId + "}", contentType: "app...

Concatenating variables in Bash

stupid question no doubt, I'm trying to add a variable to the middle of a variable, so for instance in PHP i would do this: $mystring = $arg1 . '12' . $arg2 . 'endoffile'; so the output might be 20121201endoffile, how can I achieve the same in a l...

How to Call a Function inside a Render in React/Jsx

I want to call a function inside some embedded html. I tried the following but the function isn't called. Would this be the incorrect way of calling a function inside a render method? import React, { Component, PropTypes } from 'react'; export def...

Trouble using ROW_NUMBER() OVER (PARTITION BY ...)

I'm using SQL Server 2008 R2. I have table called EmployeeHistory with the following structure and sample data: EmployeeID Date DepartmentID SupervisorID 10001 20130101 001 10009 10001 20130909 001 10019 10001 ...

R cannot be resolved - Android error

I just downloaded and installed the new Android SDK. I wanted to create a simple application to test drive it. The wizard created this code: package eu.mauriziopz.gps; import android.app.Activity; import android.os.Bundle; public class ggps exten...

How to convert column with string type to int form in pyspark data frame?

I have dataframe in pyspark. Some of its numerical columns contain 'nan' so when I am reading the data and checking for the schema of dataframe, those columns will have 'string' type. How I can change them to int type.I replaced the 'nan' values with...

pip install access denied on Windows

I am trying to run pip install mitmproxy on Windows, but I keep getting access denied, even with cmd and PowerShell using the Run as Administrator option. WindowsError: [Error 5] Access is denied: 'c:\\users\\bruno\\appdata\\local\\temp\\easy_instal...

How to trigger checkbox click event even if it's checked through Javascript code?

I have many checkboxes in my page and there is a select all checkbox which checks all the checkboxes. Somehow I want to emulate that click event of checkbox even if it's checked/unchecked through select all button. How can I do it?...

use Lodash to sort array of object by value

I am trying to sort an array by 'name' value (using Lodash). I used the Lodash docs to create the solution below however .orderBy doesn't seem to be having any affect at all. Can anyone shed some light on the correct way to sort array? Chars Array ...

Merge two HTML table cells

I'm creating a table in HTML and I'd like to have my top cell be the width of two. Here's a rough drawing: __________________________________________ | HEADER | | | =============...

angular ng-repeat in reverse

How can i get a reversed array in angular? i'm trying to use orderBy filter, but it needs a predicate(e.g. 'name') to sort: <tr ng-repeat="friend in friends | orderBy:'name':true"> <td>{{friend.name}}</td> <td>{{f...

Jquery Open in new Tab (_blank)

I've setup some Jquery based off other StackOverflow questions/answers. The purpose of this script is that it makes an entire div a link based on any a href tag that is inside that div. This works fine however I need to set it to _blank to open in a...

XAMPP: Couldn't start Apache (Windows 10)

I'm using XAMPP, and I can start Apache, but, MySQL (phpMyAdmin) start! When I start, I get this error; 10:07:49 [Apache] Error: Apache shutdown unexpectedly. 10:07:49 [Apache] This may be due to a blocked port, missing dependencies, 10:07:49 [Apache...

Moment.js with Vuejs

I try to print out date time using like the following in vue-for {{ moment().format('MMMM Do YYYY, h:mm:ss a') }} but, it does not appear. It's just a blank. How I can try to use moment in vue?...

Static variables in JavaScript

How can I create static variables in Javascript?...

EditorFor() and html properties

Asp.Net MVC 2.0 preview builds provide helpers like Html.EditorFor(c => c.propertyname) If the property name is string, the above code renders a texbox. What if I want to pass in MaxLength and Size properties to the text box or my own css cla...

How to export a Hive table into a CSV file?

I used this Hive query to export a table into a CSV file. INSERT OVERWRITE DIRECTORY '/user/data/output/test' select column1, column2 from table1; The file generated '000000_0' does not have comma separator Is this the right way to generate CSV f...

How to format numbers as currency string?

I would like to format a price in JavaScript. I'd like a function which takes a float as an argument and returns a string formatted like this: "$ 2,500.00" What's the best way to do this?...

Convert web page to image

What are some utilities to obtain an image of a webpage? Basically equivalent to taking a "screenshot" of the page after opening it....

How to download image using requests

I'm trying to download and save an image from the web using python's requests module. Here is the (working) code I used: img = urllib2.urlopen(settings.STATICMAP_URL.format(**data)) with open(path, 'w') as f: f.write(img.read()) Here is the n...

Encoding Error in Panda read_csv

I'm attempting to read a CSV file into a Dataframe in Pandas. When I try to do that, I get the following error: UnicodeDecodeError: 'utf-8' codec can't decode byte 0x96 in position 55: invalid start byte This is from code: import pandas as pd ...

gdb: "No symbol table is loaded"

I keep getting this error mesage when trying to add a breakpoint in gdb. I've used these commands to compile: gcc -g main.c utmpib2.c -o main.o and: cc -g main.c utmpib2.c -o main.o and also: g++ -g main.c utmpib2.c -o main.o I also tried "-ggdb"...

How to align footer (div) to the bottom of the page?

Can anyone explain how to align a footer div to the bottom of the page. From the examples I've seen, they all show how to make the div stay visible at the bottom, no matter where you've scrolled the page. Although I don't want it like that. I want it...

How do you round a floating point number in Perl?

How can I round a decimal number (floating point) to the nearest integer? e.g. 1.2 = 1 1.7 = 2 ...

jQuery addClass onClick

The setting is easy; I want to be able to add a class to (in this case) a button when onClick-event is fired. My problem is that I haven't found a way to pass the button itself as the parameter to the function. I'd like to do something like: <asp...

Plotting time in Python with Matplotlib

I have an array of timestamps in the format (HH:MM:SS.mmmmmm) and another array of floating point numbers, each corresponding to a value in the timestamp array. Can I plot time on the x axis and the numbers on the y-axis using Matplotlib? I was try...

No templates in Visual Studio 2017

After a Visual Studio 2017 (RC) installation from scratch, I can't find a standard list of templates. I'm specifically interested in the Console Application (C#) template and the Windows Form (C#) template. I'm pretty sure I'm missing one of the Indi...

Make sure that the controller has a parameterless public constructor error

I have followed this tutorial which has worked great, until I modified my DbContext to have an additional constructor. I am now having issues with the resolution and not sure what to do to fix this. Is there an easy way to force it to grab the parame...

XPath to select multiple tags

Given this simplified data format: <a> <b> <c>C1</c> <d>D1</d> <e>E1</e> <f>don't select this one</f> </b> <b> <c>C2<...

JQuery datepicker language

I'm using the jQuery datepicker from jqueryui.com and I have a problem changing the calendar to Swedish, I have this code: <script type="text/javascript"> $(function() { $.datepicker.setDefaults($.datepicker.regional['sv']); ...

Multiple inputs with same name through POST in php

Is it possible to get multiple inputs of the same name to post and then access them from PHP? The idea is this: I have a form that allows the entry of an indefinite number of physical addresses along with other information. If I simply gave each of...

How to deal with persistent storage (e.g. databases) in Docker

How do people deal with persistent storage for your Docker containers? I am currently using this approach: build the image, e.g. for PostgreSQL, and then start the container with docker run --volumes-from c0dbc34fd631 -d app_name/postgres IMHO, t...

Excel VBA: AutoFill Multiple Cells with Formulas

I have big amount of data that I collected from different files. In this main workbook, I have different types of formulas for every cells. In range A to F is where the data from other files are collected. In range H to AC, I have the formula that I ...

Load local JSON file into variable

I'm trying to load a .json file into a variable in javascript, but I can't get it to work. It's probably just a minor error but I can't find it. Everything works just fine when I use static data like this: var json = { id: "whatever", name: "st...

Getting cursor position in Python

Is it possible to get the overall cursor position in Windows using the standard Python libraries?...

Error:Unknown host services.gradle.org. You may need to adjust the proxy settings in Gradle

i have tried it many times but its giving me same error.how to set the proxy so that this error is solved...

Hibernate Annotations - Which is better, field or property access?

This question is somewhat related to Hibernate Annotation Placement Question. But I want to know which is better? Access via properties or access via fields? What are the advantages and disadvantages of each?...

Permission denied (publickey) when SSH Access to Amazon EC2 instance

I want to use my Amazon ec2 instance but faced the following error: Permission denied (publickey). I have created my key pair and downloaded .pem file. Given: chmod 600 pem file. Then, this command ssh -i /home/kashif/serverk...

c# how to add byte to byte array

How to add a byte to the beginning of an existing byte array? My goal is to make array what's 3 bytes long to 4 bytes. So that's why I need to add 00 padding in the beginning of it....

how to store Image as blob in Sqlite & how to retrieve it?

I want to store an image(from url) into a sqlite database. For that I use: db = new DataBase(getApplicationContext()); URL url = new URL("http://sree.cc/wp-content/uploads/schogini_team.png"); URLConnection ucon = url.openConnection(); InputStream...

javascript unexpected identifier

I am trying to compress my JavaScript code to get less traffic on my site. It has been working fine, but now I came across an error I can't resolve. I turned my ajax function into one line: function(){if(xmlhttp.readyState==4&&xmlhttp.statu...

How to remove the arrow from a select element in Firefox

I'm trying to style a select element using CSS3. I'm getting the results I desire in WebKit (Chrome / Safari), but Firefox isn't playing nicely (I'm not even bothering with IE). I'm using the CSS3 appearance property, but for some reason I can't sha...

Validating a Textbox field for only numeric input.

I have created a form-based program that needs some input validation. I need to make sure the user can only enter numeric values within the distance Textbox. So far, I've checked that the Textbox has something in it, but if it has a value then it s...

Extract csv file specific columns to list in Python

What I'm trying to do is plot the latitude and longitude values of specific storms on a map using matplotlib,basemap,python, etc. My problem is that I'm trying to extract the latitude, longitude, and name of the storms on map but I keep getting error...

Node Version Manager install - nvm command not found

I am trying to install NVM as per these instructions I typed in this command in terminal: $ curl https://raw.github.com/creationix/nvm/master/install.sh | sh After running the install, I restart the terminal and attempt to install Node.js with t...

How do I create an empty array/matrix in NumPy?

I can't figure out how to use an array or matrix in the way that I would normally use a list. I want to create an empty array (or matrix) and then add one column (or row) to it at a time. At the moment the only way I can find to do this is like: ma...

Can't find SDK folder inside Android studio path, and SDK manager not opening

I have installed Android Studio for the millionth time but when i go to C:\Program Files\Android\Android Studio , i can't find any folder named "SDK" , can't find it any where on the computer either. Also, the SDK manager doesn't open, which i guess ...

How can I detect if a selector returns null?

What is the best way to detect if a jQuery-selector returns an empty object. If you do: alert($('#notAnElement')); you get [object Object], so the way I do it now is: alert($('#notAnElement').get(0)); which will write "undefined", and so you ca...

Error : getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443

I am working on a corporate network. Trying to install npm. But I'm getting this error again and again. $ npm install npm ERR! Windows_NT 6.1.7601 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\np...

How to put labels over geom_bar in R with ggplot2

I'd like to have some labels stacked on top of a geom_bar graph. Here's an example: df <- data.frame(x=factor(c(TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE))) ggplot(df) + geom_bar(aes(x,fill=x)) + opts(axis.text.x=theme_blank(),axis.ticks=theme_b...

How to convert HH:mm:ss.SSS to milliseconds?

I have a String 00:01:30.500 which is equivalent to 90500 milliseconds. I tried using SimpleDateFormat which give milliseconds including current date. I just need that String representation to milliseconds. Do I have to write custom method, which wil...

SVN 405 Method Not Allowed

I accidentally deleted a folder in SVN and added it back immediately. I ran into an issue with this and my solution ended up removing the folder completely from my local copy as well as the server copy. I can do updates and commits without problems o...

My prerelease app has been "processing" for over a week in iTunes Connect, what gives?

I used Xcode 6.1.1 to upload a new version of a prerelease app to iTunes Connect so I could distribute it to my external beta testers. I've done this with two versions of the same app previously and it worked fine. But this time, the upload was stuc...

In Subversion can I be a user other than my login name?

I'd like to know how to get Subversion to change the name that my changes appear under. I'm just starting to use Subversion. I'm currently using it to version control code on an XP laptop where I'm always logged in under my wife's name. I'd like the...

Count number of rows per group and add result to original data frame

Say I have a data.frame object: df <- data.frame(name=c('black','black','black','red','red'), type=c('chair','chair','sofa','sofa','plate'), num=c(4,5,12,4,3)) Now I want to count the number of rows (observatio...

How to recover stashed uncommitted changes

I had some uncommitted changes in my development branch and I stashed them using git stash, but there were some changes which were very important among those stashed ones. Is there any way to get back those changes? Also, I have made some changes on...

Query Mongodb on month, day, year... of a datetime

I'm using mongodb and I store datetime in my database in this way for a date "17-11-2011 18:00" I store: date = datetime.datetime(2011, 11, 17, 18, 0) db.mydatabase.mycollection.insert({"date" : date}) I would like to do a request like that mont...

remove url parameters with javascript or jquery

I am trying to use the youtube data api to generate a video playlist. However, the video urls require a format of: youtube.com/watch?v=3sZOD3xKL0Y but what the api generates is: youtube.com/watch?v=3sZOD3xKL0Y&amp;feature=youtube_gdata So...

Javascript geocoding from address to latitude and longitude numbers not working

I'm using the following geocoding function to convert a textual address into latitude and longitude numbers, but it's not working right. The alert writes "undefined". Can anyone say what's wrong? <script type="text/javascript" src="http://maps.g...

How do I start PowerShell from Windows Explorer?

Is there a way to start PowerShell in a specific folder from Windows Explorer, e.g. to right-click in a folder and have an option like "Open PowerShell in this Folder"? It's really annoying to have to change directories to my project folder the firs...

Creating/writing into a new file in Qt

I am trying to write into a file and if the file doesn't exist create it. I have searched on the internet and nothing worked for me. My code looks currently like this: QString filename="Data.txt"; QFile file( filename ); if ( file.open(QIODevice::R...

What is the Gradle artifact dependency graph command?

I read this comment in the Gradle docs: To deal with problems due to version conflicts, reports with dependency graphs are also very helpful. Such reports are another feature of dependency management. I have some kind of jar being brought in but I...

PostgreSQL create table if not exists

In a MySQL script you can write: CREATE TABLE IF NOT EXISTS foo ...; ... other stuff ... and then you can run the script many times without re-creating the table. How do you do this in PostgreSQL?...

SQL Select between dates

I am running sqlite to select data between two ranges for a sales report. To select the data from between two dates I use the following statement: SELECT * FROM test WHERE date BETWEEN "11/1/2011" AND "11/8/2011"; This statement grabs all the d...

How to run two jQuery animations simultaneously?

Is it possible to run two animations on two different elements simultaneously? I need the opposite of this question Jquery queueing animations. I need to do something like this... $('#first').animate({ width: 200 }, 200); $('#second').animate({ wid...

Formatting PowerShell Get-Date inside string

I can't get my head around how formatting a datetime variable inside a string works in PowerShell. $startTime = Get-Date Write-Host "The script was started $startTime" ...Do stuff... $endTime = Get-Date Write-Host "Done at $endTime. Time for the ...

How to hide soft keyboard on android after clicking outside EditText?

Ok everyone knows that to hide a keyboard you need to implement: InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); But the big deal here is how...

How to work with string fields in a C struct?

I'm having trouble making a database based on a singly-linked list in C, not because of the linked list concept but rather the string fields in the struct themselves. This is an assignment in C and as far as I know (I'm a newbie), C doesn't recogniz...

Adding double quote delimiters into csv file

I have a number of text files which contain radio programme titles where each item is on a separate line, e.g.: 15 by 15 15 Minute Drama Adrian Mole Afternoon Drama Afternoon Reading etc I would like to add double quotes as delimiters to each line...

Importing CSV File to Google Maps

I have an quite big CSv File I want to have in Google Maps or just on a map. These are just coordinates but I have 600.000 of them.. Do you have any Idea how I can do this? I've added an screenshot from XTabulator below: ...

See :hover state in Chrome Developer Tools

I want to see the :hover style for an anchor I'm hovering on in Chrome. In Firebug, there's a style dropdown that allows me to select different states for an element. I can't seem to find anything similar in Chrome. Am I missing something? ...

How to write data to a JSON file using Javascript

For example, I have a .JSON file that has the following: [{"honda": "accord", "color": "red"},{"ford": "focus", "color": "black"}] What would be the javascript code to push another object {"nissan": "sentra", "color": "green"} into this .json arra...

How to get < span > value?

There are a piece of code,but can not use <id> tag. So,how do I get to the <span> 1 2 3 4? <div id="test"> <span>1</span> <span>2</span> <span>3</span> <span>4</span>...

@RequestParam in Spring MVC handling optional parameters

Is it possible for a Spring controller to handle both kind of requests? 1) http://localhost:8080/submit/id/ID123432?logout=true 2) http://localhost:8080/submit/id/ID123432?name=sam&password=543432 If I define a single controller of the kind: ...

Printing Python version in output

How can I print the version number of the current Python installation from my script?...

Debugging in Maven?

Is it possible to launch a debugger such as jdb from Maven? I have a pom.xml file that compiles the project successfully. However, the program hangs somewhere and I would really like to launch jdb or an equivalent debugger to see what's happening. ...

Pandas aggregate count distinct

Let's say I have a log of user activity and I want to generate a report of total duration and the number of unique users per day. import numpy as np import pandas as pd df = pd.DataFrame({'date': ['2013-04-01','2013-04-01','2013-04-01','2013-04-02',...

Get list of all input objects using JavaScript, without accessing a form object

I need to get all the input objects and manipulate the onclick param. The following does the job for <a> links. Looking for something like this for input tags. for (var ls = document.links, numLinks = ls.length, i=0; i<numLinks; i++){ va...

What's the difference between a word and byte?

I've done some research. A byte is 8 bits and a word is the smallest unit that can be addressed on memory. The exact length of a word varies. What I don't understand is what's the point of having a byte? Why not say 8 bits? I asked a prof this quest...

How to get a string between two characters?

I have a string, String s = "test string (67)"; I want to get the no 67 which is the string between ( and ). Can anyone please tell me how to do this? ...

How to display tables on mobile using Bootstrap?

My tables display fine on desktop, but once I try to view the mobile version my table ends up being too wide for the mobile device screen. I am using a responsive layout. How can I set table widths for mobile view? What other alternatives are there ...

How to center a component in Material-UI and make it responsive?

I don't quite understand the React Material-UI grid system. If I want to use a form component for login, what is the easiest way to center it on the screen on all devices (mobile and desktop)?...

How to make a gui in python

I was wondering if any of you know where I could find a simple tutorial on the web maybe to make a very simplistic gui. I have no idea how to start out in code to make one so I need your help. What I want the gui to be used for is I have written a pr...

Distribution certificate / private key not installed

Using Xcode 9.1, after building an iOS app, I want to archive it and upload it to the appStore for beta-testing. But I get the following issue after clicking the button Upload to the App Store... and choosing Automatically manage signing: "My N...

Raise warning in Python without interrupting program

I am trying to raise a Warning in Python without making the program crash / stop / interrupt. I use the following simple function to check if the user passed a non-zero number to it. If so, the program should warn them, but continue as per normal. I...

C# Interfaces. Implicit implementation versus Explicit implementation

What are the differences in implementing interfaces implicitly and explicitly in C#? When should you use implicit and when should you use explicit? Are there any pros and/or cons to one or the other? Microsoft's official guidelines (from first e...

How to use addTarget method in swift 3

here is my button object let loginRegisterButton:UIButton = { let button = UIButton(type: .system) button.backgroundColor = UIColor(r: 50 , g: 80, b: 130) button.setTitle("Register", for: .normal) button.translatesAutoresizingMa...

Use placeholders in yaml

Is there a way to use placeholders in yaml like this: foo: &FOO <<propname>>: type: number default: <<default>> bar: - *FOO propname: "some_prop" default: "some default" ...

How to set True as default value for BooleanField on Django?

I am using BooleanField in Django. By default, the checkbox generated by it is unchecked state. I want the state to be checked by default. How do I do that?...

How do I install cURL on Windows?

I have followed all the instructions here: http://www.tonyspencer.com/2003/10/22/curl-with-php-and-apache-on-windows/ to install & config apache get the PHP5 packages and get the CURL packages. I run the apache and run a PHP script. no problem....

Save child objects automatically using JPA Hibernate

I have a one-to-many relation between Parent and Child table. In the parent object I have a List<Child> setChildren(List<Child> childs) I also have a foreign key in the Child table. This foreign key is an ID that references a Parent ...

What are .iml files in Android Studio?

What are .iml files in Android Studio project? I read that it is configuration file for modules. I do not understand how it works, and can't I just use gradle scripts to integrate with external modules that you add to your project. Also, most of the ...

Python "SyntaxError: Non-ASCII character '\xe2' in file"

I am writing some python code and I am receiving the error message as in the title, from searching this has to do with the character set. Here is the line that causes the error hc = HealthCheck("instance_health", interval=15, target808="HTTP:8080/...

Filter dict to contain only certain keys?

I've got a dict that has a whole bunch of entries. I'm only interested in a select few of them. Is there an easy way to prune all the other ones out?...

error C4996: 'scanf': This function or variable may be unsafe in c programming

I have created a small application to find max number by using user-defined function with parameter. When I run it, it shows this message Error 1 error C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead...

Javascript .querySelector find <div> by innerTEXT

How can I find DIV with certain text? For example: <div> SomeText, text continues. </div> Trying to use something like this: var text = document.querySelector('div[SomeText*]').innerTEXT; alert(text); But ofcourse it will not work. ...

How to export settings?

How is it possible to export all Visual Studio Code settings and plugins and import them to another machine?...

How to force a web browser NOT to cache images

Background I am writing and using a very simple CGI-based (Perl) content management tool for two pro-bono websites. It provides the website administrator with HTML forms for events where they fill the fields (date, place, title, description, links, ...

Run cron job only if it isn't already running

I'm trying to set up a cron job as a sort of watchdog for a daemon that I've created. If the daemon errors out and fails, I want the cron job to periodically restart it... I'm not sure how possible this is, but I read through a couple of cron tutoria...

Facebook OAuth "The domain of this URL isn't included in the app's domain"

Let me first start with saying I've searched for an answer to this question for quite some time... I'm trying to setup Facebook OAuth to work with my application that is being developed locally on my machine. Everything was working perfect with Fac...

Is it possible to get multiple values from a subquery?

Is there any way to have a subquery return multiple columns in oracle db? (I know this specific sql will result in an error, but it sums up what I want pretty well) select a.x, ( select b.y, b.z from b where b.v = a.v), from a I want a res...

How can I align all elements to the left in JPanel?

I would like to have all elements in my JPanel to be aligned to the left. I try to do it in the following way: JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.setAlignmentX(Component.LEFT_ALIGNMENT); As ...

Force IE compatibility mode off using tags

I am doing work for a client who forces compatibility mode on all intranet sites. I was wondering if there is a tag I can put into my HTML that forces compatibility mode off....

How can I search (case-insensitive) in a column using LIKE wildcard?

I looked around some and didn't find what I was after so here goes. SELECT * FROM trees WHERE trees.`title` LIKE '%elm%' This works fine, but not if the tree is named Elm or ELM etc... How do I make SQL case insensitive for this wild-card search...

Access iframe elements in JavaScript

I have a webpage where there is a textarea within an iframe. I need to read the value of this textarea from its child page using JavaScript. Presently by using window.parent.getelementbyID().value in the JavaScript, I am able to fetch values of all ...

How to import jquery using ES6 syntax?

I'm writing a new app using (JavaScript) ES6 syntax through babel transpiler and the preset-es2015 plugins, as well as semantic-ui for the style. index.js import * as stylesheet from '../assets/styles/app.scss'; import * as jquery2 from '../dist/s...

is it possible to evenly distribute buttons across the width of an android linearlayout

I have a linear layout (oriented horizontally) that contains 3 buttons. I want the 3 buttons to have a fixed width and be evenly distributed across the width of the linear layout. I can manage this by setting the gravity of the linearlayout to cent...

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

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

How to generate unique id in MySQL?

I'm programming a script using PHP and MySQL and I want to get a unique id (consisting of a string: capitals and small letters with numbers) like: gHYtUUi5b. I found many functions in PHP that can generate such numbers but I'm afraid about how to e...

Difference between acceptance test and functional test?

What is the real difference between acceptance tests and functional tests? What are the highlights or aims of each? Everywhere I read they are ambiguously similar....

MSIE and addEventListener Problem in Javascript?

document.getElementById('container').addEventListener('copy',beforecopy,false ); In Chrome / Safari, the above will run the "beforecopy" function when the content on the page is being copied. MSIE is supposed to support this functionality as well, ...

Get client IP address via third party web service

I would like to read my ip address from the following page(http://l2.io/ip or other) using javascript to save him in my variable "myIp". function getMyIP() { var myIp; ... return myIp; } How can you do?...

How do I create dynamic variable names inside a loop?

I'm working on an ajax google maps script and I need to create dynamic variable names in a for loop. for (var i = 0; i < coords.length; ++i) { var marker+i = "some stuff"; } What I want to get is: marker0, marker1, marker2 and so on. and I ...

Unable to connect to SQL Express "Error: 26-Error Locating Server/Instance Specified)

I am at an loose end with one particular box that is running SQL Server 2008 R2 Express. Windows Firewall is configured to allow inbound TCP & UDP 1433, 1434. Windows Firewall is configured to allow outbound TCP & UDP on any port. No other ...

Best way to encode Degree Celsius symbol into web page?

How should I encode special characters into web pages? For instance I need this symbol ?, which I used just by copying and pasting the character as I can see it now. This worked for the desktop browsers I checked with and also on iPad and iPhone but ...

Where can I find Android source code online?

Particularly, where can I browse the source code for any android source application(e.g.the contact application) ? Is the only way to go to download all there is?...

How to write error log or exception into file in java

Is there any way to write error log or exception into a file in java. i have gone through Log4j. I googled about it but diidnt find a good solution. I have written a simple code catch (Exception e) { PrintWriter pw = new PrintWriter(new FileOut...

Cannot get OpenCV to compile because of undefined references?

The code is simple and is essentially straight from this tutorial. I am running Arch Linux and have the OpenCV library stored at /usr/include/. I have also checked to ensure that /usr/include is in my PATH. #include <opencv/cv.h> #include <...

Is there a way to call a stored procedure with Dapper?

I am very impressed with the results of Dapper Micro ORM for stackoverflow.com. I am considering it for my new project and but I have one concern about that some times my project requires to have Stored Procedure and I have search a lot on web but no...

Why am I getting a "401 Unauthorized" error in Maven?

Why am I getting a "401 Unauthorized" error in Maven? Here's the error I'm getting when calling mvn deploy (full logs at the bottom): [INFO] BUILD FAILURE [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (defau...

Git, fatal: The remote end hung up unexpectedly

When I tried to run git push origin master --force I just got Counting objects: 2649, done. Delta compression using up to 2 threads. Compressing objects: 100% (1280/1280), done. error: RPC failed; result=22, HTTP code = 413 | 116 KiB/s fatal: ...

How does DateTime.Now.Ticks exactly work?

In my application I generate files at random opportunities. To ensure a unique naming, I tried to use the nano seconds since 1.1.1970: long time = DateTime.Now.Ticks; String fileName = Convert.ToString(time); Console.WriteLine(fileName); Now I obs...

Complexities of binary tree traversals

What is the time complexity of inorder,postorder and preorder traversal of binary trees in data structures?? Is it O(n) or O(log n) or O(n^2)?? ...

How correctly produce JSON by RESTful web service?

I am writing a web service the first time. I created a RESTful web service based on Jersey. And I want to produce JSON. What do I need to do to generate the correct JSON type of my web service? Here's one of my methods: @GET @Path("/friends") @Prod...

Converting a JToken (or string) to a given Type

TL;DR Version I have a object of type JToken (but can also be a string) and I need to convert it into a Type contained in the type variable: Type type = typeof(DateTime); /* can be any other Type like string, ulong etc */ var obj = jsonObject["date...

Get list from pandas DataFrame column headers

I want to get a list of the column headers from a pandas DataFrame. The DataFrame will come from user input so I won't know how many columns there will be or what they will be called. For example, if I'm given a DataFrame like this: >>> my_...

Pointers in JavaScript?

Can we pass a reference of a variable that is immutable as argument in a function? Example: var x = 0; function a(x) { x++; } a(x); alert(x); //Here I want to have 1 instead of 0 ...

How to change the plot line color from blue to black?

I am stuck when I have generated a set of data and tried to color the plot line in python. For example I would like to change the line color from blue to black here. This is what I have and returns is the set of data that I got from pandas. ax=pl...

else & elif statements not working in Python

I'm a newbie to Python and currently learning Control Flow commands like if, else, etc. The if statement is working all fine, but when I write else or elif commands, the interpreter gives me a syntax error. I'm using Python 3.2.1 and the problem is...

Reading file using fscanf() in C

I need to read and print data from a file. I wrote the program like below, #include<stdio.h> #include<conio.h> int main(void) { char item[9], status; FILE *fp; if( (fp = fopen("D:\\Sample\\database.txt", "r+")) == NULL) { printf(...

Use a JSON array with objects with javascript

I have a function that will get a JSON array with objects. In the function I will be able to loop through the array, access a property and use that property. Like this: Variable that I will pass to the function will look like this: [{ "id": 28, ...

Android ListView in fragment example

Where can I find an example of using ListView in Fragment? I know that there is an example in samples, but unfortunately I could not find it. Maybe you can suggest something?...

One liner for If string is not null or empty else

I usually use something like this for various reasons throughout an application: if (String.IsNullOrEmpty(strFoo)) { FooTextBox.Text = "0"; } else { FooTextBox.Text = strFoo; } If I'm going to be using it a lot I will create a method tha...

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required?

I want to send an email from my application and i have written following code for sending mail MailMessage msg = new MailMessage(); msg.From = new MailAddress("mymailid"); msg.To.Add("receipientid"); msg.Subject = "test"; msg.Bo...

How to find out what group a given user has?

In Unix/Linux, how do you find out what group a given user is in via command line?...

How to access the first property of a Javascript object?

Is there an elegant way to access the first property of an object... where you don't know the name of your properties without using a loop like for .. in or jQuery's $.each For example, I need to access foo1 object without knowing the name of foo...

How to write to a file without overwriting current contents?

with open("games.txt", "w") as text_file: print(driver.current_url) text_file.write(driver.current_url + "\n") I'm using this code right now, but when it writes to the file it overwrites the old content. How can I simply add to it without e...

DateTime format to SQL format using C#

I am trying to save the current date time format from C# and convert it to an SQL Server date format like so yyyy-MM-dd HH:mm:ss so I can use it for my UPDATE query. This was my first code: DateTime myDateTime = DateTime.Now; string sqlFormattedDat...

Flutter command not found

bash: flutter: command not found Apparently, none of the flutter commands are working on the terminal of an android studio which I believe I am trying to run it at the root of my project....

Aggregate function in SQL WHERE-Clause

In a test at university there was a question; is it possible to use an aggregate function in the SQL WHERE clause. I always thought this isn't possible and I also can't find any example how it would be possible. But my answer was marked false and n...

Iterate through a HashMap

What's the best way to iterate over the items in a HashMap?...

How to open a folder in Windows Explorer from VBA?

I want to click a button on my access form that opens a folder in Windows Explorer. Is there any way to do this in VBA?...

Adding external library into Qt Creator project

How can I add external library into a project built by Qt Creator RC1 (version 0.9.2)? For example, the win32 function EnumProcesses() requires Psapi.lib to be added in the project to build....

Functions that return a function

I'm stuck with this concept of 'Functions that return functions'. I'm referring the book 'Object Oriented Javascript' by Stoyan Stefanov. Snippet One: _x000D_ _x000D_ function a() {_x000D_ _x000D_ alert('A!');_x000D_ _x000D_...

Command-line Tool to find Java Heap Size and Memory Used (Linux)?

Is there a Command-line Tool (Linux) to check Heap Size (and Used Memory) of a Java Application? I have tried through jmap. But it gives info. about internal memory areas like Eden/ PermGen etc., which is not useful to me. I am looking for somethi...

No route matches "/users/sign_out" devise rails 3

I've installed devise on my app and applied the following in my application.html.erb file: <div id="user_nav"> <% if user_signed_in? %> Signed in as <%= current_user.email %>. This cannot be cheese? <%= link_...

mysqli::mysqli(): (HY000/2002): Can't connect to local MySQL server through socket 'MySQL' (2)

I get this error when I try to connect to the mysql database using php mysqli class. Using following code: $db = new MySQLi("localhost","kamil","*****"); if (mysqli_connect_errno()) { echo "An error occured. Please try again later."; exit();...

Inner join vs Where

Is there a difference in performance (in oracle) between Select * from Table1 T1 Inner Join Table2 T2 On T1.ID = T2.ID And Select * from Table1 T1, Table2 T2 Where T1.ID = T2.ID ?...

Show row number in row header of a DataGridView

Is it possible to show row number in the row header of a DataGridView? I'm trying with this code, but it doesn't work: private void setRowNumber(DataGridView dgv) { foreach (DataGridViewRow row in dgv.Rows) { ...

What is the apply function in Scala?

I never understood it from the contrived unmarshalling and verbing nouns ( an AddTwo class has an apply that adds two!) examples. I understand that it's syntactic sugar, so (I deduced from context) it must have been designed to make some code more i...

Using moment.js to convert date to string "MM/dd/yyyy"

I need to take the date value from jquery datepicker turn it into string format "MM/dd/yyyy" so it can do the right ajax post. When the page loads or upon changing the datepicker, a jquery ajax call is made. I have this code: var sTimestamp = momen...

What exactly does an #if 0 ..... #endif block do?

In C/C++ What happens to code placed between an #if 0/#endif block? #if 0 //Code goes here #endif Does the code simply get skipped and therefore does not get executed?...

jQuery Set Select Index

I have an select box: <select id="selectBox"> <option value="0">Number 0</option> <option value="1">Number 1</option> <option value="2">Number 2</option> <option value="3">Number 3</op...

How to use Bootstrap in an Angular project?

I am starting my first Angular application and my basic setup is done. How can I add Bootstrap to my application? If you can provide an example then it would be a great help....

How to detect if a browser is Chrome using jQuery?

I have a bit of an issue with a function running in chrome that works properly in Safari, both webkit browsers... I need to customize a variable in a function for Chrome, but not for Safari. Sadly, I have been using this to detect if it is a webkit...

How do I replace NA values with zeros in an R dataframe?

I have a data frame and some columns have NA values. How do I replace these NA values with zeroes?...

How to get my Android device Internal Download Folder path

It is possible to get the Android device Internal Download Folder path?...

How to allow download of .json file with ASP.NET

How can I enable the download of *.json files from an old ASP.NET site (IIS6 I am led to believe)? I am getting a 404 page instead of the JSON file. Do I need to create a web.config file? What goes in it?...

How to put text in the upper right, or lower right corner of a "box" using css

How would I get the here and and here to be on the right, on the same lines as the lorem ipsums? See the following: Lorem Ipsum etc........here blah....................... blah blah.................. blah....................... lorem ipsums....

Unique random string generation

I'd like to generate random unique strings like the ones being generated by MSDN library.(Error Object), for example. A string like 't9zk6eay' should be generated....

Twitter Bootstrap inline input with dropdown

I'm trying to display a text input inline with a dropdown button. I can't figure out how to do this though. Here's the HTML I've tried (I've put all of it on a single line with no results): <div class="input-append"> <input type="text" ...

Bash command to sum a column of numbers

I want a bash command that I can pipe into that will sum a column of numbers. I just want a quick one liner that will do something essentially like this: cat FileWithColumnOfNumbers.txt | sum ...

Reading an image file into bitmap from sdcard, why am I getting a NullPointerException?

How can I read an image file into bitmap from sdcard? _path = Environment.getExternalStorageDirectory().getAbsolutePath(); System.out.println("pathhhhhhhhhhhhhhhhhhhh1111111112222222 " + _path); _path= _path + "/" + "flower2.jpg"; System....

How to export datagridview to excel using vb.net?

I have a datagridview in vb.net that is filled up from the database. I've researched and I found out that there is no built in support to print directly from datagridview. I don't want to use crystal report because I'm not familiar with it. I'm plan...

AngularJS Directive Restrict A vs E

I'm working in a small team, building in AngularJS and trying to maintain some basic standards & best practices; especially given we're relatively new with Angular. My question is with regards to Directives. More accurately, the restrict options...

Function stoi not declared

I'm trying to use stoi to convert a string to an integer, however it says it's not declared. I have the standard library and the <string> included, but it still says [Error] 'stoi' was not declared in this scope The code is the following: #in...

What is The Rule of Three?

What does copying an object mean? What are the copy constructor and the copy assignment operator? When do I need to declare them myself? How can I prevent my objects from being copied? ...

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="@(...

Select arrow style change

I'm trying to replace the arrow of a select with a picture of my own. I'm including the select in a div with the same size, I set the background of the select as transparent and I'm including a picture(with the same size as the arrow) in the right to...

How do I split a string in Rust?

From the documentation, it's not clear. In Java you could use the split method like so: "some string 123 ffd".split("123"); ...

ActionBar text color

how can I change the text color of the ActionBar? I've inherited the Holo Light Theme, I'm able to change the background of the ActionBar but I don't find out what is the attribute to tweak to change the text color. Ok, I'm able to change the text...

How do I make a <div> move up and down when I'm scrolling the page?

How can I make a div element move up and down the page when the user is scrolling the page? (where that element is always visible)...

Angular 2 Unit Tests: Cannot find name 'describe'

I'm following this tutorial from angular.io As they said, I've created hero.spec.ts file to create unit tests: import { Hero } from './hero'; describe('Hero', () => { it('has name', () => { let hero: Hero = {id: 1, name: 'Super Cat'}; ...

How can I print the contents of an array horizontally?

Why doesn't the console window print the array contents horizontally rather than vertically? Is there a way to change that? How can I display the content of my array horizontally instead of vertically, with a Console.WriteLine()? For example: int...

Insert variable values in the middle of a string

In C#: If I want to create a message like this: "Hi We have these flights for you: Flight A,B,C,D. Which one do you want" where just the section in bold is dynamic and I pass its value at run time, but its left and right parts are fixed. I can creat...

How do I PHP-unserialize a jQuery-serialized form?

Using $('#form').serialize(), I was able to send this over to a PHP page. Now how do I unserialize it in PHP? It was serialized in jQuery....

Replace all elements of Python NumPy Array that are greater than some value

I have a 2D NumPy array and would like to replace all values in it greater than or equal to a threshold T with 255.0. To my knowledge, the most fundamental way would be: shape = arr.shape result = np.zeros(shape) for x in range(0, shape[0]): for...

Uninitialized constant ActiveSupport::Dependencies::Mutex (NameError)

When I want to create a Ruby on Rails project, I get the message below. /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:55: uninitialized constant ActiveSupport::Dependencies::Mutex (NameError) from /usr/local/...

What is JavaScript's highest integer value that a number can go to without losing precision?

Is this defined by the language? Is there a defined maximum? Is it different in different browsers?...

How to purge tomcat's cache when deploying a new .war file? Is there a config setting?

I have a simple hello, world servlet application that I am just playing around with, and pushing it out to my tomcat server on a VPS. When I make a change to my code, and deploy it, tomcat doesn't serve the newly published code (even after starting ...

jQuery AJAX Call to PHP Script with JSON Return

I've been smashing my head against a brick wall with this one, i've tried loads of the solutions on stackoverflow but can't find one that works! Basically when I POST my AJAX the PHP returns JSON but the AJAX shows Undefined instead of the value: ...

How can one see the structure of a table in SQLite?

How can I see the structure of table in SQLite as desc was in Oracle?...

How to write a function that takes a positive integer N and returns a list of the first N natural numbers

I'm taking this online Python course and trying to solve the following problem called Coding Exercise: It's Natural: Write a function naturalNumbers which takes a positive integer n as input, and returns a list [1, 2, ...] consisting of the first...

Python convert decimal to hex

I have a function here that converts decimal to hex but it prints it in reverse order. How would I fix it? def ChangeHex(n): if (n < 0): print(0) elif (n<=1): print(n) else: x =(n%16) if (x < 10):...

UnicodeEncodeError: 'ascii' codec can't encode character u'\xef' in position 0: ordinal not in range(128)

I want to parse my XML document. So I have stored my XML document as below class XMLdocs(db.Expando): id = db.IntegerProperty() name=db.StringProperty() content=db.BlobProperty() Now my below is my code parser = make_parser() ...

Open a facebook link by native Facebook app on iOS

If the native Facebook app is installed on the iPhone. How do I open a facebook link into the native Facebook app from my app. In the case of opening by Safari, the link is same as: http://www.facebook.com/AlibabaUS Thank you....

How to use Google fonts in React.js?

I had built a website with React.js and webpack. I want to use Google fonts in the webpage, so I put the link in the section. Google Fonts <link href="https://fonts.googleapis.com/css?family=Bungee+Inline" rel="stylesheet"> And set CSS b...

Error: "Could Not Find Installable ISAM"

I've written some VBA code in an Excel workbook to retrieve data from an Access database in the same directory on a desktop. It works fine on my machine and several other machines running Windows XP, but when we tested this on a Vista machine, we en...

Test a string for a substring

Is there an easy way to test a Python string "xxxxABCDyyyy" to see if "ABCD" is contained within it?...

LEFT function in Oracle

I am looking in an Oracle (10g) stored procedure and come across the following LEFT/RIGHTfunction. TO_DATE(LEFT('01-Jun-1201',9)) In the Toad editor, I am not able to run this function and have to change it to LPAD TO_DATE(LPAD('01-Jun-1201',9)) ...

jQuery - Getting form values for ajax POST

I am trying to post form values via AJAX to a php file. How do I collect my form values to send inside of the "data" parameter? $.ajax({ type: "POST", data: "submit=1&username="+username+"&email="+email+"&password="+pass...

how to insert date and time in oracle?

Im having trouble inserting a row in my table. Here is the insert statement and table creation. This is part of a uni assignment hence the simplicity, what am i doing wrong? Im using oracle SQL developer Version 3.0.04.' The problem i am having is t...

How to dynamically add rows to a table in ASP.NET?

So today I started learning ASP.NET. Unfortunately I haven't found any good tutorials online, and I can't afford to buy books at the moment, so I've had to create a ASP.NET web application in Visual Studio 2010 and just play around with the default p...

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

Loop code for each file in a directory

I have a directory of pictures that I want to loop through and do some file calculations on. It might just be lack of sleep, but how would I use PHP to look in a given directory, and loop through each file using some sort of for loop? Thanks!...

CSS background-size: cover replacement for Mobile Safari

Hi I have several divs on my page which have background images that I want to expand to cover the entire div which in turn can expand to fill the width of the viewport. Obviously background-size: cover behaves unexpectedly on iOS devices. I've seen ...

Calculate the display width of a string in Java

How to calculate the length (in pixels) of a string in Java? Preferable without using Swing. EDIT: I would like to draw the string using the drawString() in Java2D and use the length for word wrapping....

Formatting floats without trailing zeros

How can I format a float so that it doesn't contain trailing zeros? In other words, I want the resulting string to be as short as possible. For example: 3 -> "3" 3. -> "3" 3.0 -> "3" 3.1 -> "3.1" 3.14 -> "3.14" 3.140 -> "3.14" ...

Making an svg image object clickable with onclick, avoiding absolute positioning

I have tried to change the images on my site from img to svg, changing img tags to embed and object tags. But, implementing the onclick function, which previously was contained in the img tag, is proving most difficult. I found onclick had no effect...

How do I vertically align something inside a span tag?

How do I get the "x" to be vertically-aligned in the middle of the span? .foo { height: 50px; border: solid black 1px; display: inline-block; vertical-align: middle; } <span class="foo"> x </span> ...

What exactly is \r in C language?

#include <stdio.h> int main() { int countch=0; int countwd=1; printf("Enter your sentence in lowercase: "); char ch='a'; while(ch!='\r') { ch=getche(); if(ch==' ') countwd++; else countch++; } printf("...

How to use Typescript with native ES6 Promises

I'm a complete beginner to Typescript and am wondering if it's possible to use ES6 promises in Typescript and what I would have to do to get them to work. I'm running node 0.11.14 and am getting an error during compilation "Cannot find name 'Promise'...

select count(*) from table of mysql in php

I am able to get both the value and row of the mysql query result. But I am struggling to get the single output of a query. e.g.: $result = mysql_query("SELECT COUNT(*) FROM Students;"); I need the result to display. But I am not getting the resu...

Simple DatePicker-like Calendar

Can anyone recommend a simple datepicker calendar that I can use for a blog to link to different urls rather than for a form? jquery or css based would be good. When clicking next/prev month I don't want it reload page....

What is the difference between hg forget and hg remove?

I want mercurial to remove several files from the current state of the repository. However, I want the files to exist in prior history. How do forget and remove differ, and can they do what I want?...

Appending to 2D lists in Python

I've encountered what I think is a strange behavior in Python, and I'd like somebody to explain it if possible. I've created an empty 2D list listy = [[]]*3 print listy [[], [], []] The following works as I'd expect: listy[1] = [1,2] yields [[...

Remove columns from DataTable in C#

I have a DataSet which I get a DataTable from that I am being passed back from a function call. It has 15-20 columns, however I only want 10 columns of the data. Is there a way to remove those columns that I don't want, copy the DataTable to another...

Image library for Python 3

What is python-3 using instead of PIL for manipulating Images?...

Are iframes considered 'bad practice'?

Somewhere along the line I picked up the notion that using iframes is 'bad practice'. Is this true? What are the pros/cons of using them?...

Anaconda export Environment file

How can I make anaconda environment file which could be use on other computers? I exported my anaconda python environment to YML using conda env export > environment.yml. The exported environment.yml contains this line prefix: /home/superdev/mini...

How to make code wait while calling asynchronous calls like Ajax

I am looking for something like this function someFunc() { callAjaxfunc(); //may have multiple ajax calls in this function someWait(); // some code which waits until async calls complete console.log('Pass2'); } function callAjaxfunc() { //All a...

How to get share counts using graph API

I can get the share count of an URL using PHP SDK and using the deprecated rest API, but didn't find a way to get the share counts of an URL using graph API. Is there any way to find out?...

Python: read all text file lines in loop

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

Cannot hide status bar in iOS7

I just upgraded my iPhone 5 iOS 7 to four beta version. Now when I run my app from Xcode 5 on this iPhone, status bar doesn’t hide, even though it should. Not Working: [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStat...

MySQL foreign key constraints, cascade delete

I want to use foreign keys to keep the integrity and avoid orphans (I already use innoDB). How do I make a SQL statment that DELETE ON CASCADE? If I delete a category then how do I make sure that it would not delete products that also are related t...

Create a map with clickable provinces/states using SVG, HTML/CSS, ImageMap

I am trying to create an interactive map where users can click on different provinces in the map to get info specific to that province. Example: archived: http://www.todospelaeducacao.org.br/ archived: http://code.google.com/p/svg2imap/ So far I...

Difference between F5, Ctrl + F5 and click on refresh button?

I have often experienced while developing my web applications that pressing F5 or refresh doesn't produce or refresh the proper result. But when we hit Ctrl + F5 it generates the correct result. What is the basic difference between simple F5 and Ctrl...

How to find controls in a repeater header or footer

I was wondering how one would find the controls in the HeaderTemplate or FooterTemplate of an Asp.Net Repeater control. I can access them on the ItemDataBound event, but I was wondering how to get them after (for example to retrieve a value of an in...

Server.UrlEncode vs. HttpUtility.UrlEncode

Is there a difference between Server.UrlEncode and HttpUtility.UrlEncode?...

How do I fix an "Invalid license data. Reinstall is required." error in Visual C# 2010 Express?

I've tried to install Visual C# 2010 Express edition onto my PC, but whenever I try to run it, I get a error message. Invalid license data. Reinstall is required. I've already tried reinstalling it, and the message persists. OS is Vista Home P...

Mock MVC - Add Request Parameter to test

I am using spring 3.2 mock mvc to test my controller.My code is @Autowired private Client client; @RequestMapping(value = "/user", method = RequestMethod.GET) public String initUserSearchForm(ModelMap modelMap) { User...

Initialize empty vector in structure - c++

I have a struct: typedef struct user { string username; vector<unsigned char> userpassword; } user_t; I need to initialize userpassword with an empty vector: struct user r={"",?}; What should I put instead of ??...

Bootstrap 4 - Glyphicons migration?

We have a project that uses glyphicons intensively. Bootstrap v4 drops the glyphicon font altogether. Is there an equivalent for icons shipped with Bootstrap V4? http://v4-alpha.getbootstrap.com/migration/...

Java: how do I initialize an array size if it's unknown?

I'm asking the user to enter some numbers between 1 and 100 and assign them into an array. The array size is not initialized since it is dependent on the number of times the user enters a number. How should I assign the array length? If user enters 5...

Toggle Class in React

I'm using react for a project where I have a menu button. <a ref="btn" href="#" className="btn-menu show-on-small"><i></i></a> And a Sidenav component like: <Sidenav ref="menu" /> And I wrote the following code to ...

How to set null value to int in c#?

int value=0; if (value == 0) { value = null; } How can I set value to null above? Any help will be appreciated....

How to create roles in ASP.NET Core and assign them to users?

I am using the ASP.NET Core default website template and have the authentication selected as "Individual User Accounts". How can I create roles and assign it to users so that I can use the roles in a controller to filter access?...

How to remove a variable from a PHP session array

I have PHP code that is used to add variables to a session: <?php session_start(); if(isset($_GET['name'])) { $name = isset($_SESSION['name']) ? $_SESSION['name'] : array(); $name[] = $_GET['name']; $_SESSION['...

How do I hide anchor text without hiding the anchor?

Say I have the following markup: <li><a href="somehwere">Link text</a></li> If I have a background image on the a tag, how would I hide the link text using just css? font-size:0 seems to work fine on the a tag apart...

Jquery resizing image

I'd like to start a discussion about the image resizing using jQuery. That's my contribution: But I think I'm far away from the solution. What about the cropping? Who can help me? $(document).ready(function() { $('.story-small img').each(functi...

Owl Carousel, making custom navigation

So i have an Owl Carousel that contains three images. I also added custom navigation arrows (.png images) on left and right sides. However, those arrows are currently useless, because I can't find a way to actually make them switch between images of ...

How to get input text value from inside td

<tr> <td> <input type="text" name="desc[]"> </td> <td> <input type="text" name="duration[]"> </td> <td> <input type="text" name="start[]" class="start"> </td> <td...

Facebook Callback appends '#_=_' to Return URL

Facebook callback has started appending #_=_ hash underscore to the Return URL Does anyone know why? What is the solution?...

HTML form readonly SELECT tag/input

According to HTML specs, the select tag in HTML doesn't have a readonly attribute, only a disabled attribute. So if you want to keep the user from changing the dropdown, you have to use disabled. The only problem is that disabled HTML form inputs do...

What does 'low in coupling and high in cohesion' mean

I have problems understanding the statement low in coupling and high in cohesion. I have googled and read a lot about this, but still finding it hard to understand. To what I understand is High cohesion means, that we should have classes that are sp...

Turn off display errors using file "php.ini"

I am trying to turn off all errors on my website. I have followed different tutorials on how to do this, but I keep getting read and open error messages. Is there something I am missing? I have tried the following in my php.ini file: ;Error display...

How to remove jar file from local maven repository which was added with install:install-file?

mvn install:install-file -Dfile=phonegap-1.1.0.jar -DgroupId?=phonegap -DartifactId?=phonegap -Dversion=1.1.0 -Dpackaging=jar I use above command to install local jar into maven local repo. Now I have got the dependency from maven repo. I want to r...

How do I set default values for functions parameters in Matlab?

Is it possible to have default arguments in Matlab? For instance, here: function wave(a, b, n, k, T, f, flag, fTrue=inline('0')) I would like to have the true solution be an optional argument to the wave function. If it is possible, can anyone d...

How would I extract a single file (or changes to a file) from a git stash?

I'd like to know if it is possible to extract a single file or diff of a file from a git stash without popping the stash changeset off. Might anyone be able to provide some suggestions/ideas about this?...

Purpose of Activator.CreateInstance with example?

Can someone explain Activator.CreateInstance() purpose in detail?...

What are valid values for the id attribute in HTML?

When creating the id attributes for HTML elements, what rules are there for the value?...

How to remove all .svn directories from my application directories

One of the missions of an export tool I have in my application, is to clean all .svn directories from my application directory tree. I am looking for a recursive command in the Linux shell that will traverse the entire tree and delete the .svn files....

file_put_contents: Failed to open stream, no such file or directory

I am trying to use dompdf to save a form to an easily-readable .pdf file, and my processing script is below. I am receiving the error Warning: file_put_contents(/files/grantapps/NAME0.pdf) [function.file-put-contents]: failed to open stream: No such ...

How to add external fonts to android application

I was looking for some stylish fonts for my android application. but the problem is how can i make my android application supportable for external fonts. Thank you....

Split data frame string column into multiple columns

I'd like to take data of the form before = data.frame(attr = c(1,30,4,6), type=c('foo_and_bar','foo_and_bar_2')) attr type 1 1 foo_and_bar 2 30 foo_and_bar_2 3 4 foo_and_bar 4 6 foo_and_bar_2 and use split() on the column...

What's the difference between "&nbsp;" and " "?

Both of them mean space, but is there any difference?...

How can I read the client's machine/computer name from the browser?

How can I read the client's machine/computer name from the browser? Is it possible using JavaScript and/or ASP.NET?...

phpMyAdmin - Error > Incorrect format parameter?

I have a WordPress production website. I've exported the database by the following commands: select database > export > custom > select all tables > select .zip compression > 'Go' I've downloaded the file which is example.sql.zip but...

How to make an embedded video not autoplay

I'm embedding a Flash video into an HTML and would like the user to have to click it to begin playing. According to the Adobe <object> / <embed> element documentation, there are variety of methods to do this: 1) Add a Flash parameter ins...

Java 8 NullPointerException in Collectors.toMap

The Java 8 Collectors.toMap throws a NullPointerException if one of the values is 'null'. I don't understand this behaviour, maps can contain null pointers as value without any problems. Is there a good reason why values cannot be null for Collectors...

How to make a 3D scatter plot in Python?

I am currently have a nx3 matrix array. I want plot the three columns as three axis's. How can I do that? I have googled and people suggested using Matlab, but I am really having a hard time with understanding it. I also need it be a scatter plot....

fork: retry: Resource temporarily unavailable

I tried installing Intel MPI Benchmark on my computer and I got this error: fork: retry: Resource temporarily unavailable Then I received this error again when I ran ls and top command. What is causing this error? Configuration of my machine: D...

Unknown Column In Where Clause

I have a simple query: SELECT u_name AS user_name FROM users WHERE user_name = "john"; I get Unknown Column 'user_name' in where clause. Can I not refer to 'user_name' in other parts of the statement even after select 'u_name as user_name'?...

What is the difference between FragmentPagerAdapter and FragmentStatePagerAdapter?

What is the difference between FragmentPagerAdapter and FragmentStatePagerAdapter? About FragmentPagerAdapter Google's guide says: This version of the pager is best for use when there are a handful of typically more static fragments to be page...

justify-content property isn't working

I have an odd issue that I'm having trouble with. So I've been working on this prototype html5 template that uses flexbox. Though I've been running into one slight problem. I'm trying to a small space to the sidebar and content area of the template b...

HTML5 Canvas Rotate Image

jQuery('#carregar').click(function() { var canvas = document.getElementById('canvas'); var image = document.getElementById('image'); var element = canvas.getContext("2d"); element.clearRect(0, 0, canvas.width, canvas.height); ...

How do I loop through rows with a data reader in C#?

I know I can use while(dr.Read()){...} but that loops every field on my table, I want to retrieve all the values from the first row, and then second... and so on. Let's say I have a table like this: ID--------------Value1--------------Value2-------...

What are abstract classes and abstract methods?

Possible Duplicate: Abstract class in Java I got several explanations but so far I'm not able to understand that what are the abstract classes and methods in Java. Some said it has to do something with the security of the program, other s...

What's the difference between 'r+' and 'a+' when open file in python?

I have try r+ and a+ to open file and read and write, but 'r+' and 'a+' are all append the str to the end of the file. So, what's the difference between r+ and a+ ? Add: I have found the reason: I have read the file object and forgot to seek(0...