Examples On Programing Languages

How to mount a single file in a volume

I am trying to dockerize a PHP application. In the dockerfile, I download the archive, extract it, etc. Everything works fine. However, if a new version gets released and I update the dockerfile, I have to reinstall the application, because the confi...

Angular 2 - Using 'this' inside setTimeout

I have a function like so in my class showMessageSuccess(){ var that = this; this.messageSuccess = true; setTimeout(function(){ that.messageSuccess = false; },3000); } How can I re-write this so I don't have to store a...

How do I mock a REST template exchange?

I have a service in which I need to ask an outside server via rest for some information: public class SomeService { public List<ObjectA> getListofObjectsA() { List<ObjectA> objectAList = new ArrayList<ObjectA>(); ...

Can I have two JavaScript onclick events in one element?

Can we put two JavaScript onclick events in one input type button tag? To call two different functions?...

Android: ProgressDialog.show() crashes with getApplicationContext

I can't seem to grasp why this is happening. This code: mProgressDialog = ProgressDialog.show(this, "", getString(R.string.loading), true); works just fine. However, this code: mProgressDialog = ProgressDialog.show(getApplicationContext(), "", ge...

How to make a script wait for a pressed key?

I want my script to wait until the user presses any key. How do I do that?...

Adding external resources (CSS/JavaScript/images etc) in JSP

I added an external CSS stylesheet to my project and placed in the WEB-CONTENTS folder of my project in Eclipse. When I deployed it on the Tomcat, the stylesheet was not applied. When I debugged it in Chrome and opened it, it gave me 404 file not fou...

How to order citations by appearance using BibTeX?

By default (using the plain style) BibTeX orders citations alphabetically. How to order the citations by order of appearance in the document?...

What's the best way to do a backwards loop in C/C#/C++?

I need to move backwards through an array, so I have code like this: for (int i = myArray.Length - 1; i >= 0; i--) { // Do something myArray[i] = 42; } Is there a better way of doing this? Update: I was hoping that maybe C# had some bu...

htaccess <Directory> deny from all

I've been cleaning up my project lately. I have a main .htaccess in the root directory and 6 others. 5 of them ran Options -Indexes which i didn't see anypoint of allowing any Directory viewing so moved that to the main one. so now i only have 2 .hta...

How to execute the start script with Nodemon

How can I execute the start script from a package.json file with Nodemon?...

How do I purge a linux mail box with huge number of emails?

I have setup some cron jobs and they send the crons result to an email. Now over the months I have accumulated a huge number of emails. Now my question is how can I purge all those emails from my mailbox?...

static and extern global variables in C and C++

I made 2 projects, the first one in C and the second one in C++, both work with same behavior. C project: header.h int varGlobal=7; main.c #include <stdio.h> #include <stdlib.h> #include "header.h" void function(int i) { static...

Regex, every non-alphanumeric character except white space or colon

How can I do this one anywhere? Basically, I am trying to match all kinds of miscellaneous characters such as ampersands, semicolons, dollar signs, etc....

How do I undo the most recent local commits in Git?

I accidentally committed the wrong files to Git, but didn't push the commit to the server yet. How can I undo those commits from the local repository?...

Git/GitHub can't push to master

I am new to Git/GitHub and ran into an issue. I created a test project and added it to the local repository. Now I am trying to add files/project to the remote repository. Here's what I did (and this worked) - git remote add origin git://github.com...

Raw_Input() Is Not Defined

I'm a seventh grade programmer so I may be missing a lot of things in this program, but for my coding club my instructor asked us to make a guess the number game. I have very limited knowledge on this subject, since I've only attended four classes. A...

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

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

A message body writer for Java type, class myPackage.B, and MIME media type, application/octet-stream, was not found

I am new at RESTful webservices and was trying to update my @OneToMany relationship from a standalone client application, but I am not able to do that. I am using the Jersey implementation of JAX-RS that ships with Glassfish 3.1.1. I have a class A ...

How do I serialize a C# anonymous type to a JSON string?

I'm attempting to use the following code to serialize an anonymous type to JSON: var serializer = new DataContractJsonSerializer(thing.GetType()); var ms = new MemoryStream(); serializer.WriteObject(ms, thing); var json = Encoding.Default.GetString(...

What is the Swift equivalent of respondsToSelector?

I've googled but not been able to find out what the swift equivalent to respondsToSelector: is. This is the only thing I could find (Swift alternative to respondsToSelector:) but isn't too relevant in my case as its checking the existence of the del...

java.lang.ClassNotFoundException: org.springframework.core.io.Resource

I'm using spring 4.0.5, Hibernate 4.3.5 and JSF for web developpement in eclipse, and this is the content of my lib folder : When I run my project I get this error : java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException...

Adding n hours to a date in Java?

How do I add n hours to a Date object? I found another example using days on StackOverflow, but still don't understand how to do it with hours....

PHP Call to undefined function

I am trying to call a function from another function. I get an error: Fatal error: Call to undefined function getInitialInformation() in controller.php on line 24 controller.php file: require_once("model/model.php"); function intake() { $i...

Regex pattern inside SQL Replace function?

SELECT REPLACE('<strong>100</strong><b>.00 GB', '%^(^-?\d*\.{0,1}\d+$)%', ''); I want to replace any markup between two parts of the number with above regex, but it does not seem to work. I'm not sure if it is regex syntax that's ...

Reverting to a previous revision using TortoiseSVN

What is the easiest way to revert my working copy to a previous revision using Windows TortoiseSVN? I did not find any "findable" command to do that quickly....

How can I modify a saved Microsoft Access 2007 or 2010 Import Specification?

Does anyone know how to modify an existing import specification in Microsoft Access 2007 or 2010? In older versions there used to be an Advanced button presented during the import wizard that allowed you to select and edit an existing specification....

TSQL select into Temp table from dynamic sql

This seems relatively simple, but apparently it's not. I need to create a temp table based on an existing table via the select into syntax: SELECT * INTO #TEMPTABLE FROM EXISTING_TABLE The problem is, the existing table name is accepted via a par...

align right in a table cell with CSS

I have the old classic code like this <td align="right"> which does what it says: it right aligns the content in the cell. So if I put 2 buttons in this cell, they will appear at the right site of the cell. But then I was refactoring this t...

You have not concluded your merge (MERGE_HEAD exists)

I made a branch called 'f' and did a checkout to master. When I tried the git pull command I got this message: You have not concluded your merge (MERGE_HEAD exists). Please, commit your changes before you can merge. When I try the git status, it g...

Is there a Mutex in Java?

Is there a Mutex object in java or a way to create one? I am asking because a Semaphore object initialized with 1 permit does not help me. Think of this case: try { semaphore.acquire(); //do stuff semaphore.release(); } catch (Exception e) ...

img src SVG changing the styles with CSS

html <img src="logo.svg" alt="Logo" class="logo-img"> css .logo-img path { fill: #000; } The above svg loads and is natively fill: #fff but when I use the above css to try change it to black it doesn't change, this is my first time play...

Set default format of datetimepicker as dd-MM-yyyy

I have a datetimepicker which on loading of windows form shows me format in 'MM-dd-yyyy', as follows: I would like it in dd-MM-yyyy. I tried the following: set custom format: "dd-MM-yyyy" But Its not changing. What could be the problem? Plea...

How to navigate a few folders up?

One option would be to do System.IO.Directory.GetParent() a few times. Is there a more graceful way of travelling a few folders up from where the executing assembly resides? What I trying to do is to find a text file that resides one folder above th...

How to reduce the image size without losing quality in PHP

I am trying to develop an image-based web site. I am really confused about the best image type for faster page loading speeds and best compression practices. Please advise me on the best way to compress image sizes....

What is The difference between ListBox and ListView

What is the difference between WPF's ListBox and ListView? I can not find any significant difference in their properties. Is there different typical use?...

Differentiate between function overloading and function overriding

Differentiate between function overloading and function overriding in C++?...

What's the best practice using a settings file in Python?

I have a command line script that I run with a lot of arguments. I have now come to a point where I have too many arguments, and I want to have some arguments in dictionary form too. So in order to simplify things I would like to run the script with...

Pure CSS to make font-size responsive based on dynamic amount of characters

I know that this could be solved fairly easily with Javascript, but I'm only interested in a pure CSS solution. I want a way to dynamically resize text so that it always fits into a fixed div. Here is the sample markup: _x000D_ _x000D_ <div sty...

Find a class somewhere inside dozens of JAR files?

How would you find a particular class name inside lots of jar files? (Looking for the actual class name, not the classes that reference it.)...

How to get the query string by javascript?

How to extract the query string from the URL in javascript? Thank you!...

IE 8: background-size fix

I've tried to add background size to IE but it's not working at all: HTML <h2 id="news">Notícias <img src="white-marker.png" alt="" /></h2> CSS: div#content h2#news { background: url('../images/news-background.jpg') no-rep...

Making a Bootstrap table column fit to content

I'm using Bootstrap, and drawing a table. The rightmost column has a button in it, and I want it to drop down to the minimum size it needs to fit said button. _x000D_ _x000D_ <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstr...

How to implement the Android ActionBar back button?

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

How to set the "Content-Type ... charset" in the request header using a HTML link

I have a simple HTML-page with a UTF-8 encoded link. <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body> <a charset='UTF-8' href='http://server/search?q=%C3...

Resolving require paths with webpack

I'm still confused how to resolve module paths with webpack. Now I write: myfile = require('../../mydir/myfile.js') but I'd like to write myfile = require('mydir/myfile.js') I was thinking that resolve.alias may help since I see a similar exa...

PHP Deprecated: Methods with the same name

I am getting an error saying Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; TSStatus has a deprecated constructor in C:\Program Files (x86)\Zend\Apache24\htdocs\viewer\modules\tsstatus\t...

Making Python loggers output all messages to stdout in addition to log file

Is there a way to make Python logging using the logging module automatically output things to stdout in addition to the log file where they are supposed to go? For example, I'd like all calls to logger.warning, logger.critical, logger.error to go to ...

Rotating a Vector in 3D Space

I am making an android project in opengl es that uses accelerometer to calculate change in specific axes and my aim is to rotate my spacecraft-like object's movement vector. The problem is that i can't understand the math behind rotation matrices. De...

how to prevent adding duplicate keys to a javascript array

I found a lot of related questions with answers talking about for...in loops and using hasOwnProperty but nothing I do works properly. All I want to do is check whether or not a key exists in an array and if not, add it. I start with an empty array ...

How to set an image's width and height without stretching it?

If I have: #logo { width: 400px; height: 200px; } then <img id="logo" src="logo.jpg"/> will stretch to fill that space. I want the image to stay the same size, but for it to take up that much space in the DOM. Do I have to add an...

intl extension: installing php_intl.dll

I'm trying to locate php_intl.dll and install it. Does anyone have any tips?...

How to handle change text of span

I'm using jQuery and I want to show some calculation in a span (called span1) and I want when text of span1 changed do some calculation on it's value and show in other spans (called `span2 ,span3,...). How I can handle text change of span?...

Reading/parsing Excel (xls) files with Python

What is the best way to read Excel (XLS) files with Python (not CSV files). Is there a built-in package which is supported by default in Python to do this task?...

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '''')' at line 2

I am getting an Error in MySQL: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '''')' at line 2'. HTML Code: <form action="read_message.php" method="post"...

how to log in to mysql and query the database from linux terminal

I am using debian linux. I have a linux machine on which mysql is install. I can log in to my linux machine using root user as well as other user. I can connect to mysql database on linux machine from windows machine using sqlyog. Now I want to execu...

laravel Unable to prepare route ... for serialization. Uses Closure

When I clear caches in my Laravel 5.2 project, I see this error message: [LogicException] Unable to prepare route [panel] for serialization. Uses Closure. I think that it's related with a route Route::get('/article/{slug}', 'Front@slug'); ass...

Find a string by searching all tables in SQL Server Management Studio 2008

Is there any way to search for a string in all tables of a database in SQL Server Management Studio 2008? I want to search for string say john. The result should show the tables and their respective row that contain john. ...

How to write macro for Notepad++?

I would like to write a macro for Notepad++ which should replace char1, char2, char3 with char4, char5, char6, respectively....

sql primary key and index

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

How do I change the font-size of an <option> element within <select>?

I have built this fiddle as an example of what I am doing. What I am trying to do works fine in Firefox. With the font-size being 14px when you open up the select options. However looking at it in Google Chrome it picks the inherited font-size of 34p...

Google maps API V3 - multiple markers on exact same spot

Bit stuck on this one. I am retrieving a list of geo coords via JSON and popping them onto a google map. All is working well except in the instance when I have two or more markers on the exact same spot. The API only displays 1 marker - the top on...

javascript getting my textbox to display a variable

So I have some basic code in html here, i just have two textbox which u can type numbers in and when you click the button, it adds em both up, and in a perfect world, it would display the answer in that third textbox. <html> <head> </h...

FileNotFoundException while getting the InputStream object from HttpURLConnection

I am trying to send a post request to a url using HttpURLConnection (for using cUrl in java). The content of the request is xml and at the end point, the application processes the xml and stores a record to the database and then sends back a respons...

How to enable explicit_defaults_for_timestamp?

When I try to start my mySQL server I get message: [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). I find answer on: http://dev....

How can I get the browser's scrollbar sizes?

How can I determine the height of a horizontal scrollbar, or the width of a vertical one, in JavaScript?...

Getting Spring Application Context

Is there a way to statically/globally request a copy of the ApplicationContext in a Spring application? Assuming the main class starts up and initializes the application context, does it need to pass that down through the call stack to any classes t...

Can you set a border opacity in CSS?

Is there a straight forward CSS way to make the border of an element semi-transparent with something like this? border-opacity: 0.7; If not, does anyone have an idea how I could do so without using images?...

How to iterate over the keys and values with ng-repeat in AngularJS?

In my controller, I have data like: $scope.object = data Now this data is the dictionary with keys and values from json. I can access the attribute with object.name in the template. Is there any way that I can iterate over the keys as well and disp...

Display all items in array using jquery

I have an array that I want to have displayed in html.. I don't want to write multiple lines for posting each item in the array but all should be exactly the same. ie var array = []; //code that fills the array.. $('.element').html('<span>'+ar...

IN-clause in HQL or Java Persistence Query Language

I have the following parametrised JPA, or Hibernate, query: SELECT entity FROM Entity entity WHERE name IN (?) I want to pass the parameter as an ArrayList<String>, is this possible? Hibernate current tells me, that java.lang.ClassCastExceptio...

How do I set a fixed background image for a PHP file?

I have an .html file with a login form and wish to recreate it and save it as a .php file. However, I'm encountering difficulties with setting the background image and other CSS related stuff. Below is my code for the .php which I'm sure it won't p...

ng-change not working on a text input

I am new to angular js. In my code there is color picker initialized from a text field. User changes the value of color and I want that color to be reflected as a background of a text in a span. It is not working. What is missing? HTML: <body ng...

No Persistence provider for EntityManager named

I have my persistence.xml with the same name using TopLink under the META-INF directory. Then, I have my code calling it with: EntityManagerFactory emfdb = Persistence.createEntityManagerFactory("agisdb"); Yet, I got the following error message: ...

Export HTML table to pdf using jspdf

I need to export the HTML table to pdf file using jspdf. I tried the below code but it displays the blank/empty output in pdf file. Any suggestions or sample code for this would be helpful. ` <script type="text/javascript"> function demo1(...

How can I specify working directory for popen

Is there a way to specify the running directory of command in Python's subprocess.Popen()? For example: Popen('c:\mytool\tool.exe', workingdir='d:\test\local') My Python script is located in C:\programs\python Is is possible to run C:\mytool\too...

Detect browser or tab closing

Is there any cross-browser JavaScript/jQuery code to detect if the browser or a browser tab is being closed, but not due to a link being clicked?...

how to get yesterday's date in C#

I want to retrieve yesterday's date in my ASP.NET web application using C#. I already digged about the topic but I guess I m not able to understand it. Code i m using is just giving me todays date string yr = DateTime.Today.Year.ToString()...

Uploading both data and files in one form using Ajax?

I'm using jQuery and Ajax for my forms to submit data and files but I'm not sure how to send both data and files in one form? I currently do almost the same with both methods but the way in which the data is gathered into an array is different, the ...

Losing Session State

I have an ASP.net application where Users aren't able to successfully complete certain actions, for reasons, I'm assuming, can only be related to losing their session (which is where I maintain their current user information, and how determine whethe...

Why are interface variables static and final by default?

Why are interface variables static and final by default in Java?...

Python constructors and __init__

Why are constructors indeed called "Constructors"? What is their purpose and how are they different from methods in a class? Also, can there be more that one __init__ in a class? I tried the following, can someone please explain the result?...

linux script to kill java process

I want linux script to kill java program running on console. Following is the process running as jar. [rapp@s1-dlap0 ~]$ ps -ef |grep java rapp 9473 1 0 15:03 pts/1 00:00:15 java -jar wskInterface-0.0.1-SNAPSHOT-jar-with-dependencies.jar ...

Where's the DateTime 'Z' format specifier?

[Update: Format specifiers are not the same thing as format strings; a format specifier is a piece of a custom format string, where a format string is 'stock' and doesn't provide customization. My problem is with specifiers not formats] I've been tr...

java.io.StreamCorruptedException: invalid stream header: 7371007E

I have a client Server application which communicate using objects. when I send only one object from the client to server all works well. when I attempt to send several objects one after another on the same stream I get StreamCorruptedException....

Converting Varchar Value to Integer/Decimal Value in SQL Server

How to convert the value of records in a table with data type varchar to integer or decimal so I can get the sum of the value. I use SQL Server 2005. Say that I have table structure like this: ID int Stuff varchar and the records ID = 1, Stuff =...

"Cannot allocate an object of abstract type" error

Error is here: vector<Graduate *> graduates; graduates.push_back(new AliceUniversity(identifier,id,salary,average)); Grandparent class: Graduate::Graduate(char identifier, long id, int salary, ...

Add ... if string is too long PHP

I have a description field in my MySQL database, and I access the database on two different pages, one page I display the whole field, but on the other, I just want to display the first 50 characters. If the string in the description field is less t...

How to install mysql-connector via pip

I use sqlalchemy to access MySQL in my Python project. sqlalchemy's conf is like this: dialect=mysql driver=mysqlconnector So I need to install the Python module mysql connector via pip. Any help?...

How to run Pip commands from CMD

As I understand, Python 2.7.9 comes with Pip installed, however when I try to execute a Pip command from CMD (Windows) I get the following error: 'pip' is not recognized as an internal or external command, operable program or batch file. When I t...

Warning: Found conflicts between different versions of the same dependent assembly

I am currently developing a .NET application, which consists of 20 projects. Some of those projects are compiled using .NET 3.5, some others are still .NET 2.0 projects (so far no problem). The problem is that if I include an external component I al...

PostgreSQL delete with inner join

DELETE B.* FROM m_productprice B INNER JOIN m_product C ON B.m_product_id = C.m_product_id WHERE C.upc = '7094' AND B.m_pricelist_version_id = '1000020' i am getting the following error PostgreSQL 8.2.11 ERROR: syntax error at or ne...

Angular2 @Input to a property with get/set

I have an Angular2 component in that component it currently has a bunch fields that have @Input() applied before them to allow binding to that property, i.e. @Input() allowDay: boolean; What I would like to do is actually bind to a property with g...

Adding <script> to WordPress in <head> element

I'm trying to insert this code: <script type="text/javascript"> some Javascript codes comes here </script> to WordPress' <head></head> section in front end and in admin panel E.g., Joomla! 1.6 has an API that allows t...

Using tr to replace newline with space

Have output from sed: http://sitename.com/galleries/83450 72-profile Those two strings should be merged into one and separated with space like: http://sitename.com/galleries/83450 72-profile Two strings are pipelined to tr in order to replace n...

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

How to get C# Enum description from value?

I have an enum with Description attributes like this: public enum MyEnum { Name1 = 1, [Description("Here is another")] HereIsAnother = 2, [Description("Last one")] LastOne = 3 } I found this bit of code for retrieving the descr...

Split String by delimiter position using oracle SQL

I have a string and I would like to split that string by delimiter at a certain position. For example, my String is F/P/O and the result I am looking for is: Therefore, I would like to separate the string by the furthest delimiter. Note: some of ...

What is the best way to add a value to an array in state

I have an array in state, let's say this.state.arr. I want to add something to this state property, and then change some more properties. Option 1 onChange(event){ this.state.arr.push('newvalue'); ... this.setState({some:'val',arr:this....

Bootstrap tab activation with JQuery

I have the following code: <ul class="nav nav-tabs"> <li><a href="#aaa" data-toggle="tab">AAA</a></li> <li><a href="#bbb" data-toggle="tab">BBB</a&...

How can I find a specific element in a List<T>?

My application uses a list like this: List<MyClass> list = new List<MyClass>(); Using the Add method, another instance of MyClass is added to the list. MyClass provides, among others, the following methods: public void SetId(String Id...

How to change an Eclipse default project into a Java project

I checked out a project from SVN and did not specify the project type, so it checked out as a "default" project. What is the easiest way to quickly convert this into a "Java" project? I'm using Eclipse version 3.3.2....

How to solve time out in phpmyadmin?

I want import huge (at least 300 mb) sql scripts via phpMyAdmin. I've tried: post_max_size = 750M upload_max_filesize = 750M max_execution_time = 300 max_input_time = 540 memory_limit = 1000M in my php.ini file, but I'm still getting timeout erro...

How to set gradle home while importing existing project in Android studio

How to set gradle home while importing existing project in Android studio. While trying to import I need to set up this path. ...

Changing plot scale by a factor in matplotlib

I am creating a plot in python. Is there a way to re-scale the axis by a factor? The yscale and xscale commands only allow me to turn log scale off. Edit: For example. If I have a plot where the x scales goes from 1 nm to 50 nm, the x scale will ra...

How do I log a Python error with debug information?

I am printing Python exception messages to a log file with logging.error: import logging try: 1/0 except ZeroDivisionError as e: logging.error(e) # ERROR:root:division by zero Is it possible to print more detailed information about the ex...

C++ where to initialize static const

I have a class class foo { public: foo(); foo( int ); private: static const string s; }; Where is the best place to initialize the string s in the source file?...

Mockito: Inject real objects into private @Autowired fields

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

Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-2.1-all.zip'

I am a greenhorn in gradle and i just tried to create a new Android Gradle Project in IntelliJ. After filling up the necessities it started to download something which took hours so i decided to force quit my IDE and open the project again. And now ...

Write values in app.config file

can anyone please help me how can I set/store values in the app.config file using c#, is it possible at all?...

Check if an image is loaded (no errors) with jQuery

I'm using JavaScript with the jQuery library to manipulate image thumbnails contained in a unordered list. When the image is loaded it does one thing, when an error occurs it does something else. I'm using jQuery load() and error() methods as events....

Converting Symbols, Accent Letters to English Alphabet

The problem is that, as you know, there are thousands of characters in the Unicode chart and I want to convert all the similar characters to the letters which are in English alphabet. For instance here are a few conversions: ?->H ?->V ?->Y...

How to convert a table to a data frame

I have a table in R that has str() of this: table [1:3, 1:4] 0.166 0.319 0.457 0.261 0.248 ... - attr(*, "dimnames")=List of 2 ..$ x: chr [1:3] "Metro >=1 million" "Metro <1 million" "Non-Metro Counties" ..$ y: chr [1:4] "q1" "q2" "q3" "...

Adding a Button to a WPF DataGrid

I want to create a DataGrid control in WPF in which there is a button in the first cell of each row. Clicking this button will show RowDetailsTemplate or the SubRow. How do I add a button which will show/Hide the RowDetailsTemplate?...

node.js - request - How to "emitter.setMaxListeners()"?

When I do a GET on a certain URI using the node.js 'request' module; var options = {uri:"aURI", headers:headerData}; request.get(options, function (error, response, body) { } The error message is: [Error: Exceeded maxRedirects. Probably stuck in ...

Matplotlib tight_layout() doesn't take into account figure suptitle

If I add a subtitle to my matplotlib figure it gets overlaid by the subplot's titles. Does anybody know how to easily take care of that? I tried the tight_layout() function, but it only makes things worse. Example: import numpy as np import matplot...

How to prevent IFRAME from redirecting top-level window

Some websites have code to "break out" of IFRAME enclosures, meaning that if a page A is loaded as an IFRAME inside an parent page P some Javascript in A redirects the outer window to A. Typically this Javascript looks something like this: <scri...

Sum all the elements java arraylist

If I had: ArrayList<Double> m = new ArrayList<Double>(); with the double values ??inside, how should I do to add up all the ArrayList elements? public double incassoMargherita() { double sum = 0; for(int i = 0; i < m.size(); i++) {...

Get checkbox values using checkbox name using jquery

I have several input checkboxes, (they name is same for send array on server). So, I need get each value this checkboxes and I want use as selector checkbox names, this not works, help please. <form> <input type="checkbox" name="bla[]" v...

Token based authentication in Web API without any user interface

I am developing a REST API in ASP.Net Web API. My API will be only accessible via non-browser based clients. I need to implement security for my API so I decided to go with Token based authentication. I have a fair understanding of token based authen...

Querying date field in MongoDB with Mongoose

I'm trying to query documents in MongoDB using findOne(), but it's not working. The field I'm trying to filter by is 'date', and I'm not sure if perhaps it's a special word I shouldn't be using when inserting docs. Is there something I'm missing? Mo...

Can a table row expand and close?

Is it possible to make a table row expand and collapse? Can anyone refer me to a script or an example? I prefer jQuery if possible. I have a drawing concept I would like to achieve: ...

Can I run HTML files directly from GitHub, instead of just viewing their source?

If I have a .html file in a GitHub repository, e.g. for running a a set of JavaScript tests, is there any way I can view that page directly—thus running the tests? For example, could I somehow actually see the test results that would be produced b...

Incompatible implicit declaration of built-in function ‘malloc’

I'm getting this error: warning: incompatible implicit declaration of built-in function ‘malloc’ I am trying to do this: fileinfo_list* tempList = malloc(sizeof(fileinfo_list)); Just for the reference the struct used at hand is: typedef...

Assertion failure in dequeueReusableCellWithIdentifier:forIndexPath:

So I was making an rss reader for my school and finished the code. I ran the test and it gave me that error. Here is the code it's referring to: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)i...

How to show empty data message in Datatables

Suppose i get empty data from server sometimes, i want to display No Data found message in DataTables?. How is this possible?...

How to insert multiple rows from a single query using eloquent/fluent

I have the following query: $query = UserSubject::where('user_id', Auth::id())->select('subject_id')->get(); and as expected I get the following result: [{"user_id":8,"subject_id":9},{"user_id":8,"subject_id":2}] Is there a way of copyi...

PostgreSQL: Drop PostgreSQL database through command line

I'm trying to drop my database and create a new one through the command line. I log in using psql -U username and then do a \connect template1, followed by a DROP DATABASE databasename;. I get the error database databasename is being accessed b...

Function in JavaScript that can be called only once

I need to create a function which can be executed only once, in each time after the first it won't be executed. I know from C++ and Java about static variables that can do the work but I would like to know if there is a more elegant way to do this?...

MVC3 EditorFor readOnly

I want to make readOnly with EditorFor in edit page. I tried to put readonly and disabled as: <div class="editor-field"> @Html.EditorFor(model => model.userName, new { disabled = "disabled", @readonly = "readonly" }) </div&g...

insert data from one table to another in mysql

i want to read all data from one table and insert some data in to another table. my query is INSERT INTO mt_magazine_subscription ( magazine_subscription_id, subscription_name, magazine_id, status ) VALUES ( ...

Can I set the height of a div based on a percentage-based width?

Let's say I've got a div that has a width of 50% of the body. How do I make its height equal to that value? So that when the browser window is 1000px wide, the div's height and width are both 500px....

How to get the current logged in user Id in ASP.NET Core

I've done this before with MVC5 using User.Identity.GetUserId() but that doesn't seem to work here. The User.Identity doesnt have the GetUserId() method I am using Microsoft.AspNet.Identity...

How to compare only date components from DateTime in EF?

I am having two date values, one already stored in the database and the other selected by the user using DatePicker. The use case is to search for a particular date from the database. The value previously entered in the database always has time comp...

How do I add an integer value with javascript (jquery) to a value that's returning a string?

I have a simple html block like: <span id="replies">8</span> Using jquery I'm trying to add a 1 to the value (8). var currentValue = $("#replies").text(); var newValue = currentValue + 1; $("replies").text(newValue); What's happenin...

Regular expression containing one word or another

I need to create an expression matching a whole number followed by either "seconds" or ""minutes" I tried this expression: ([0-9]+)\s+(\bseconds\b)|(\bminutes\b) It works fine for seconds, but not minutes. E.g. "5 seconds" gives 5;seconds; while "...

Clear MySQL query cache without restarting server

Is there any way to clear mysql query cache without restarting mySQL server?...

Java: splitting a comma-separated string but ignoring commas in quotes

I have a string vaguely like this: foo,bar,c;qual="baz,blurb",d;junk="quux,syzygy" that I want to split by commas -- but I need to ignore commas in quotes. How can I do this? Seems like a regexp approach fails; I suppose I can manually scan and en...

Why do I get the error "Unsafe code may only appear if compiling with /unsafe"?

Why do I get the following error? Unsafe code may only appear if compiling with /unsafe"? I work in C# and Visual Studio 2008 for programming on Windows CE....

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 scp in Python?

What's the most pythonic way to scp a file in Python? The only route I'm aware of is os.system('scp "%s" "%s:%s"' % (localfile, remotehost, remotefile) ) which is a hack, and which doesn't work outside Linux-like systems, and which needs help fr...

Templated check for the existence of a class member function?

Is it possible to write a template that changes behavior depending on if a certain member function is defined on a class? Here's a simple example of what I would want to write: template<class T> std::string optionalToString(T* obj) { if (...

React Error: Target Container is not a DOM Element

I just got started using React so this is probably a very simple mistake, but here we go. My html code is very simple: <!-- base.html --> <html> <head> <title>Note Cards</title> <script src="http://fb.me/re...

INSERT IF NOT EXISTS ELSE UPDATE?

I've found a few "would be" solutions for the classic "How do I insert a new record or update one if it already exists" but I cannot get any of them to work in SQLite. I have a table defined as follows: CREATE TABLE Book ID INTEGER PRIMARY KEY...

When a 'blur' event occurs, how can I find out which element focus went *to*?

Suppose I attach an blur function to an HTML input box like this: <input id="myInput" onblur="function() { ... }"></input> Is there a way to get the ID of the element which caused the blur event to fire (the element which was clicked) ...

CSS :selected pseudo class similar to :checked, but for <select> elements

Is there a way to style the currently selected <option> element in a <select> element? I could then give a background color to the currently selected option element? That way I can style the option that's currently viewable in the closed...

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

I am trying to open a program for the first time on Windows XP Pro that uses PostgreSQL 9. I'm getting an error message that says : A problem was encountered while trying to log into or create the production database. Details: [Microsoft][ODBC ...

Send data from a textbox into Flask?

I was wondering if there was a way to take something from a text box in the HTML, feed it into flask, then parse that data with Python. I was thinking this might involve some JS but I could be wrong. Any ideas?...

String replacement in batch file

We can replace strings in a batch file using the following command set str="jump over the chair" set str=%str:chair=table% These lines work fine and change the string "jump over the chair" to "jump over the table". Now I want to replace the word "...

Write to text file without overwriting in Java

I am trying to write a method that makes a "log.txt file" if one does not already exist and then writes to the file. The problem that I am encountering is every time I call the method, it overwrites the existing log. How do I change the method so tha...

Call ASP.NET function from JavaScript?

I'm writing a web page in ASP.NET. I have some JavaScript code, and I have a submit button with a click event. Is it possible to call a method I created in ASP with JavaScript's click event?...

Create controller for partial view in ASP.NET MVC

How can I create an individual controller and model for a partial view? I want to be able to place this partial view any where on the site so it needs it's own controller. I am current rendering the partial as so @Html.Partial("_Testimonials") ...

Do something if screen width is less than 960 px

How can I make jQuery do something if my screen width is less than 960 pixels? The code below always fires the 2nd alert, regardless of my window size: if (screen.width < 960) { alert('Less than 960'); } else { alert('More than 960'); }...

How to check the maximum number of allowed connections to an Oracle database?

What's the best way, using SQL, to check the maximum number of connections that is allowed for an Oracle database? In the end, I would like to show the current number of sessions and the total number allowed, e.g. "Currently, 23 out of 80 connections...

GSON throwing "Expected BEGIN_OBJECT but was BEGIN_ARRAY"?

I'm trying to parse a JSON string like this one [ { "updated_at":"2012-03-02 21:06:01", "fetched_at":"2012-03-02 21:28:37.728840", "description":null, "language":null, "title":"JOHN", "url":"http://rus.JOHN.JOH...

TypeError: unhashable type: 'list' when using built-in set function

I have a list containing multiple lists as its elements eg: [[1,2,3,4],[4,5,6,7]] If I use the built in set function to remove duplicates from this list, I get the error TypeError: unhashable type: 'list' The code I'm using is TopP = sorted(se...

Reset the Value of a Select Box

I'm trying to reset the value of two select fields, structured like this, <select> <option></option> <option></option> <option></option> </select> <select> <option></option> ...

Modify the legend of pandas bar plot

I am always bothered when I make a bar plot with pandas and I want to change the names of the labels in the legend. Consider for instance the output of this code: import pandas as pd from matplotlib.pyplot import * df = pd.DataFrame({'A':26, 'B':20...

Multiple argument IF statement - T-SQL

How do I write an IF statement with multiple arguments in T-SQL? Current source error: DECLARE @StartDate AS DATETIME DECLARE @EndDate AS DATETIME SET @StartDate = NULL SET @EndDate = NULL IF (@StartDate IS NOT NULL AND @EndDate IS NOT NULL) ...

Difference between String replace() and replaceAll()

What's the difference between java.lang.String 's replace() and replaceAll() methods, other than later uses regex? For simple substitutions like, replace . with / , is there any difference?...

Remove innerHTML from div

I'm trying to clear the div's innerHTML before repopulating it. I tried removeData() but once that's called, when I try to add the data, I get nothing from the next line after remove whereas if I remove the removeData() it's fine again. I just want...

To find first N prime numbers in python

I am new to the programming world. I was just writing this code in python to generate N prime numbers. User should input the value for N which is the total number of prime numbers to print out. I have written this code but it doesn't throw the desire...

if statement in ng-click

Is there a way to put a condition inside an ng-click? Here, I want that the form is not submitted if there are any form errors, but then I got a parse exception. <input ng-click="{{if(profileForm.$valid) updateMyProfile()}}" name="submit" id="...

TypeScript sorting an array

I've been trying to figure out a very strange issue I ran into with typescript. It was treating an inline Boolean expression as whatever the first value's type was instead of the complete expression. So if you try something simple like the following...

How to run specific test cases in GoogleTest

I am trying to write a function/method for my project, which will ask to user which all test cases are you going to run? It looks like below..., Test_Cases_1 |_TestNo1 |_TestNo2....so on Test_Cases_2 |_TestNo1 |_T...

Huge performance difference when using group by vs distinct

I am performing some tests on a HSQLDB server with a table containing 500 000 entries. The table has no indices. There are 5000 distinct business keys. I need a list of them. Naturally I started with a DISTINCT query: SELECT DISTINCT business_key FR...

How to save a data frame as CSV to a user selected location using tcltk

I have a data frame called, Fail. I would like to save Fail as a CSV in a location that the user selects. Below is some example code that I found, but I don't know how to incorporate Fail into it. require(tcltk) fileName <- tclvalue(tkgetSave...

Using Java 8 to convert a list of objects into a string obtained from the toString() method

There are a lot of useful new things in Java 8. E.g., I can iterate with a stream over a list of objects and then sum the values from a specific field of the Object's instances. E.g. public class AClass { private int value; public int getValue()...

How to pass objects to functions in C++?

I am new to C++ programming, but I have experience in Java. I need guidance on how to pass objects to functions in C++. Do I need to pass pointers, references, or non-pointer and non-reference values? I remember in Java there are no such issues sinc...

Setting timezone in Python

Is it possible with Python to set the timezone just like this in PHP: date_default_timezone_set("Europe/London"); $Year = date('y'); $Month = date('m'); $Day = date('d'); $Hour = date('H'); $Minute = date('i'); I can't really install any other mod...

How to add a “readonly” attribute to an <input>?

How can I add readonly to a specific <input>? .attr('readonly') does not work....

How to display 3 buttons on the same line in css

I want to display 3 buttons on the same line in html. I tried two options: This one: <div style="width:500px;"> <div style="float: left; width: 130px"><button type="submit" class="msgBtn" onClick="return false;" >Save...

The import org.junit cannot be resolved

I need to solve a java problem for an interview, and they have sent me the test class. It starts with import org.junit.Before; and also has the following syntax at places: @RunWith(JUnit4.class) ... @Before ... @Test I haven't used Java in a w...

C# Syntax - Example of a Lambda Expression - ForEach() over Generic List

First, I know there are methods off of the generic List<> class already in the framework do iterate over the List<>. But as an example, what is the correct syntax to write a ForEach method to iterate over each object of a List<>, a...

Get the current language in device

How can we get the current language selected in the Android device?...

List<Object> and List<?>

I have two questions, actaully... First off, Why cant I do this: List<Object> object = new List<Object>(); And second, I have a method that returns a List<?>, how would I turn that into a List<Object>, would I be able to si...

How do you do a deep copy of an object in .NET?

I want a true deep copy. In Java, this was easy, but how do you do it in C#?...

List to array conversion to use ravel() function

I have a list in python and I want to convert it to an array to be able to use ravel() function....

Linux cmd to search for a class file among jars irrespective of jar path

I want to search for a particular class file among many jar files without giving the location of each jar file. Is this possible with a simple command? I tried this command: grep Hello.class *.jar Which did not return a list of jars containing t...

Trigger change event <select> using jquery

is there anyway i could trigger a change event on select box on page load and select a particular option. Also the function executed by adding the trigger after binding the function to the event. I was trying to output something like this <sel...

C# with MySQL INSERT parameters

Good day to all, I'm using Visual C# 2010 and MySQL Version 5.1.48-community. I hope you can help me with this code. I don't find it working on me. What am I missing? string connString = ConfigurationManager.ConnectionStrings["default"].ConnectionSt...

SELECT with a Replace()

I have a table of names and addresses, which includes a postcode column. I want to strip the spaces from the postcodes and select any that match a particular pattern. I'm trying this (simplified a bit) in T-SQL on SQL Server 2005: SELECT Replace(Pos...

Docker - Container is not running

I'm completely a newbie to docker. I tried to start a exited container like follows, I listed down all available containers using docker ps -a. It listed the following: I entered the following commands to start the container which is in the exited...

How to load a UIView using a nib file created with Interface Builder

I'm trying to do something a bit elaborate, but something that should be possible. So here is a challenge for all you experts out there (this forum is a pack of a lot of you guys :) ). I'm creating a Questionnaire "component", which I want to load o...

Possible to perform cross-database queries with PostgreSQL?

I'm going to guess that the answer is "no" based on the below error message (and this Google result), but is there anyway to perform a cross-database query using PostgreSQL? databaseA=# select * from databaseB.public.someTableName; ERROR: cross-dat...

Show/Hide Multiple Divs with Jquery

I want to use some buttons to show/hide multiple divs using jquery. The page will initially show all divs. The idea then is that there will be a button to reset (show all) and then separate buttons to show a particular div while hiding the rest. An...

Generating Unique Random Numbers in Java

I'm trying to get random numbers between 0 and 100. But I want them to be unique, not repeated in a sequence. For example if I got 5 numbers, they should be 82,12,53,64,32 and not 82,12,53,12,32 I used this, but it generates same numbers in a sequenc...

Pandas sum by groupby, but exclude certain columns

What is the best way to do a groupby on a Pandas dataframe, but exclude some columns from that groupby? e.g. I have the following dataframe: Code Country Item_Code Item Ele_Code Unit Y1961 Y1962 Y1963 2 Afghanistan 15 ...

java.net.ConnectException: localhost/127.0.0.1:8080 - Connection refused

I am using xampp apache server to serve resources to the application from my machine. But i am getting the above error. I got something on the google. pointing towards possible solution here http://groups.google.com/group/android-beginners/browse_t...

sed fails with "unknown option to `s'" error

I'm trying to use sed -i -e "s/.*seb.*/ \"$ftp_login_template\"/" $ftp_dir however I get this error: sed: -e expression #1, char 34: unknown option to `s' I don't understand why since this works perfectly: sed -i -e "s/.*wbspas...

PhpMyAdmin "Wrong permissions on configuration file, should not be world writable!"

I get this error when I try to access localhost/phpmyadmin: Wrong permissions on configuration file, should not be world writable! I have already chmoded every file to 555 from 777. What should I do next? I run Ubuntu 11.04....

Change selected value of kendo ui dropdownlist

I have a kendo ui dropdownlist in my view: $("#Instrument").kendoDropDownList({ dataTextField: "symbol", dataValueField: "symbol", dataSource: data, index: 0 }); How can I change the selected value of it using jQuery? I tried: $("...

How I can delete in VIM all text from current line to end of file?

I have very large files (more than 10Gb). I need only some lines from the top of the file. Is it possible (in vim) to delete the rest of the file (from current line to the end of file)?...

Visual Studio: Relative Assembly References Paths

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

sendUserActionEvent() is null

I've got a real doozy here. When I click on spinners, open menu items, or open context menus on long-clicks I get the same Logcat message: 08-02 21:20:57.264: E/ViewRootImpl(31835): sendUserActionEvent() mView == null The tag is ViewRootImpl, and...

Set database timeout in Entity Framework

My command keeps timing out, so I need to change the default command timeout value. I've found myDb.Database.Connection.ConnectionTimeout, but it's readonly. How can I set the command timeout in Entity Framework 5 ?...

Sum rows in data.frame or matrix

I have a very large dataframe with rows as observations and columns as genetic markers. I would like to create a new column that contains the sum of a select number of columns for each observation using R. If I have 200 columns and 100 rows, I would...

Jquery Smooth Scroll To DIV - Using ID value from Link

So i'm having some issues with my JQuery which is suppose to scroll to particular divs. HTML <div id="searchbycharacter"> <a class="searchbychar" href="#" id="#0-9" onclick="return false">0-9 |</a> <a class="searchbych...

Delete the 'first' record from a table in SQL Server, without a WHERE condition

Is it possible to delete the 'first' record from a table in SQL Server, without using any WHERE condition and without using a cursor?...

Do Git tags only apply to the current branch?

I'm currently working with a repository that has multiple branches. When I create a tag, does that tag refer to the then-current branch? In other words: Whenever I create a tag, do I need to switch to the desired branch and tag inside that branch s...

How to debug on a real device (using Eclipse/ADT)

I'm trying to figure out how to debug applications directly on my phone (HTC Desire). I've installed the USB driver that came with the phone and the phone is listed when using "adb devices". How do I configure eclipse/ADT to launch on the phone ins...

Composer - the requested PHP extension mbstring is missing from your system

I've recently tried to install package through Composer, but I have got an error the requested PHP extension mbstring is missing from your system. I removed semicolon from php.ini, but it still doesn't work. What should I do?...

Angular 2 - Setting selected value on dropdown list

I have run into an issue in pre-selecting values on a dropdown list in Angular 2. I set an array of colours in the component which I bind successfully to the dropdown list. The issue I'm experiencing is with pre-selecting a value on page init. ...

How do you copy the contents of an array to a std::vector in C++ without looping?

I have an array of values that is passed to my function from a different part of the program that I need to store for later processing. Since I don't know how many times my function will be called before it is time to process the data, I need a dyna...

What is the correct format to use for Date/Time in an XML file

What format do I use for Date/Time when writing to an XML file using .NET? Do I simply use DateTime.ToString(), or do I have to use a specific format?...

How do you validate a URL with a regular expression in Python?

I'm building an app on Google App Engine. I'm incredibly new to Python and have been beating my head against the following problem for the past 3 days. I have a class to represent an RSS Feed and in this class I have a method called setUrl. Input to...

What does the return keyword do in a void method in Java?

I'm looking at a path finding tutorial and I noticed a return statement inside a void method (class PathTest, line 126): if ((x < 0) || (y < 0) || (x >= map.getWidthInTiles()) || (y >= map.getHeightInTiles())) { return; } I'm a nov...

select2 - hiding the search box

For my more significant selects, the search box in Select2 is wonderful. However, in one instance, I have a simple selection of 4 hard-coded choices. In this case, the search box is superfluous and looks a little silly being present. Is it possible t...

How to deselect a selected UITableView cell?

I am working on a project on which I have to preselect a particular cell. I can preselect a cell using -willDisplayCell, but I can't deselect it when the user clicks on any other cell. - (void)tableView:(UITableView*)tableView willD...

Can I set max_retries for requests.request?

The Python requests module is simple and elegant but one thing bugs me. It is possible to get a requests.exception.ConnectionError with a message like: Max retries exceeded with url: ... This implies that requests can attempt to access the data se...

jQuery using append with effects

How can I use .append() with effects like show('slow') Having effects on append doesn't seem to work at all, and it give the same result as normal show(). No transitions, no animations. How can I append one div to another, and have a slideDown or ...

Modifying a query string without reloading the page

I am creating a photo gallery, and would like to be able to change the query string and title when the photos are browsed. The behavior I am looking for is often seen with some implementations of continuous/infinite page, where while you scroll down...

Warning: A non-numeric value encountered

Recently updated to PHP 7.1 and start getting following error Warning: A non-numeric value encountered in on line 29 Here is what line 29 looks like $sub_total += ($item['quantity'] * $product['price']); On localhost all works fine.. Any id...

How to send a html email with the bash command "sendmail"?

Anyone has a demo available? Sendmail is said to be not scalable,but it's free,so I decided to use it first for now:)...

What is "export default" in JavaScript?

File: SafeString.js // Build out our basic SafeString type function SafeString(string) { this.string = string; } SafeString.prototype.toString = function() { return "" + this.string; }; export default SafeString; I have never seen ex...

How to remove element from an array in JavaScript?

var arr = [1,2,3,5,6]; Remove the first element I want to remove the first element of the array so that it becomes: var arr = [2,3,5,6]; Remove the second element To extend this question, what if I want to remove the second element of the arra...

from list of integers, get number closest to a given value

Given a list of integers, I want to find which number is the closest to a number I give in input: >>> myList = [4, 1, 88, 44, 3] >>> myNumber = 5 >>> takeClosest(myList, myNumber) ... 4 Is there any quick way to do this?...

Writing to a file in a for loop

text_file = open("new.txt", "r") lines = text_file.readlines() for line in lines: var1, var2 = line.split(","); myfile = open('xyz.txt', 'w') myfile.writelines(var1) myfile.close() text_file.close() I have 10 lines...

How to undo local changes to a specific file

I'm trying to undo local changes to a specific file. Nothing has been committed. When I want to revert all changes, I can perform git revert --reset HEAD. However, in this case, I don't want to revert all changes to all files. Its not clear or obvi...

403 - Forbidden: Access is denied. You do not have permission to view this directory or page using the credentials that you supplied

I have my website. First time I can succesfully login. Default address: www.abc.com I typed this on browser and I redirected to my login page: www.abc.com/pages/landingpage.aspx I entered my login credential and log into the site. After some ti...

The developers of this app have not set up this app properly for Facebook Login?

I'm trying to make login with Facebook available in my script. I've done everything, but when I attempt to login with a Facebook account I get this error from Facebook: Error App Not Setup: The developers of this app have not set up this app...

How to remove leading zeros from alphanumeric text?

I've seen questions on how to prefix zeros here in SO. But not the other way! Can you guys suggest me how to remove the leading zeros in alphanumeric text? Are there any built-in APIs or do I need to write a method to trim the leading zeros? Exampl...

Oracle PL/SQL - Raise User-Defined Exception With Custom SQLERRM

Is it possible to create user-defined exceptions and be able to change the SQLERRM? For example: DECLARE ex_custom EXCEPTION; BEGIN RAISE ex_custom; EXCEPTION WHEN ex_custom THEN DBMS_OUTPUT.PUT_LINE(SQLERRM); END; / The...

ClassNotFoundException: org.slf4j.LoggerFactory

I am trying to run GWT RequestFactory and facing this error: ClassNotFoundException: org.slf4j.LoggerFactory I have tried to download slf4j-api-1.3.1.jar but it didnt resolve the issue Any idea exactly which jar I need to download ?...

What is the difference between cache and persist?

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

request exceeds the configured maxQueryStringLength when using [Authorize]

I have a MVC3 site in C#, I have a particular view being fed query parameters from a JavaScript function, the function redirects to the site via window.location.href = "../ActionName?" + query_string; query_string being the dynamic query para...

HintPath vs ReferencePath in Visual Studio

What exactly is the difference between the HintPath in a .csproj file and the ReferencePath in a .csproj.user file? We're trying to commit to a convention where dependency DLLs are in a "releases" svn repo and all projects point to a particular relea...

When to use throws in a Java method declaration?

So I thought I had a good basic understanding of exception-handling in Java, but I was recently reading some code that gave me some confusion and doubts. My main doubt that I want to address here is when should a person use throws in a Java method de...

C# DataTable.Select() - How do I format the filter criteria to include null?

This doesn't work DataTable myNewTable = myDataTable.Select("Name <> 'n/a'").CopyToDataTable(); myDataTable has a row named Name. I would like to select the rows from this table where Name is not equal to "n/a". It selects but still am missi...

http://localhost:8080/ Access Error: 404 -- Not Found Cannot locate document: /

I'm really very new to this Tomcat stuff. I downloaded Tomcat 7.0 windows installer and installed it using the default configuration. After installing, I typed localhost:8080 in my browser to see if Tomcat is working. However,it showed error message ...

ORA-12154 could not resolve the connect identifier specified

I have switched over to the 64bit Windows 7 and created a simple web app to test the connection to the database. I am using VS 2010 - plain asp.net web project and I am running the application from within VS. I am getting this error: "ORA-12154 cou...

When should I create a destructor?

For example: public class Person { public Person() { } ~Person() { } } When should I manually create a destructor? When have you needed to create a destructor? ...

Twitter Bootstrap 3: How to center a block

It seems to me that the class center-block is missing from the bootstrap 3 style sheets. Am I missing something? Its usage is described here, http://getbootstrap.com/css/#helper-classes-center...

Getting the client IP address: REMOTE_ADDR, HTTP_X_FORWARDED_FOR, what else could be useful?

I understand it's a standard practice to look at both these variables. Of course they can easily be spoofed. I'm curious how often can you expect these values (especially the HTTP_X_FORWARDED_FOR) to contain genuine information and not just be scramb...

How to fast get Hardware-ID in C#?

I need in my program to tie a license to a hardware ID. I tried use WMI, but it still slow. I need, for example, CPU, HDD, and motherboard info....

How to press/click the button using Selenium if the button does not have the Id?

I have 2 buttons Cancel and Next button on the same page but it has only one id (see the below code). I wanted to press Next but every time it is identifying the cancel button only not Next button. How to resolve this issue? <td align="center">...

What data type to use in MySQL to store images?

I need to store image and resume of user in the data base. I am using mysql data base and php5. I need to know which data types I should use. And also how do I set a limit (maximum size) for uploaded data....

How to get a list of current open windows/process with Java?

Does any one know how do I get the current open windows or process of a local machine using Java? What I'm trying to do is: list the current open task, windows or process open, like in Windows Taskmanager, but using a multi-platform approach - us...

SSRS - Checking whether the data is null

I've the following expression in my report. =FormatNumber(MAX(Fields!Reading.Value, "CellReading_Reading"),3) Now when the dataset is empty 'Fields!Reading.Value' becomes empty and finding their maximum is invalid. How can i check if the entire co...

Typescript es6 import module "File is not a module error"

I am using typescript 1.6 with es6 modules syntax. My files are: test.ts: module App { export class SomeClass { getName(): string { return 'name'; } } } main.ts: import App from './test'; var a = new App.SomeClass(); When I...

Batch script: how to check for admin rights

How do I check if the current batch script has admin rights? I know how to make it call itself with runas but not how to check for admin rights. The only solutions I've seen are crude hack jobs or use external programs. Well, actually I don't care i...

Closing Applications

What is best practice when closing a C# application? I have read that you can use: Environment.Exit(0); or Application.Exit(); But what is the difference? Furthermore, with regards to Environment.Exit(0), I have used exit codes before when worki...

How to use the "required" attribute with a "radio" input field

I am just wondering how to use the new HTML5 input attribute "required" in the right way on radio buttons. Does every radio button field need the attribute like below or is it sufficient if only one field gets it? <input type="radio" name="col...

Logging request/response messages when using HttpClient

I have a method that does a POST like below var response = await client.PostAsJsonAsync(url, entity); if (response.IsSuccessStatusCode) { // read the response as strongly typed object return await response.Content.ReadAsAsync<T&g...

What does [object Object] mean?

I am trying to alert a returned value from a function and I get this in the alert: [object Object] Here is the JavaScript code: <script type="text/javascript"> $(function () { var $main = $('#main'), $1 = $('#1'), $2 = $('#2'); $...

Your project path contains non-ASCII characters android studio

I was installing android studio, but I have this problem when the program is starting: Error:(1, 0) Your project path contains non-ASCII characters. This will most likely cause the build to fail on Windows. Please move your project to a diffe...

see if two files have the same content in python

Possible Duplicates: Finding duplicate files and removing them. In Python, is there a concise way of comparing whether the contents of two text files are the same? What is the easiest way to see if two files are the same content-wise in Py...

Navigation drawer: How do I set the selected item at startup?

My code works perfectly: every time an item in Navigation Drawer is clicked the item is selected. Of course I want to start the app with a default fragment (home), but Navigation Drawer doesn't have the item selected. How can I select that item prog...

How can I mock the JavaScript window object using Jest?

I need to test a function which opens a new tab in the browser openStatementsReport(contactIds) { window.open(`a_url_${contactIds}`); } I would like to mock the window's open function so I can verify the correct URL is passed in to the open functi...

Bootstrap-select - how to fire event on change

I'm using Bootstrap 3.0.2 and the Bootstrap-select plugin. Here's my select list: <select class="selectpicker" data-live-search="true" data-size="7"> <option>Petr Karel</option> <option>Honza Novák</option> <...

Create URL from a String

It is a very basic question. But i am unable to find an answer in Java documentation and unable to test it as well since i don't know if such method exist or not. I might receive a URL String which could be http://www.example1.com or http://www....

How do you programmatically set an attribute?

Suppose I have a python object x and a string s, how do I set the attribute s on x? So: >>> x = SomeObject() >>> attr = 'myAttr' >>> # magic goes here >>> x.myAttr 'magic' What's the magic? The goal of this, inc...

call a function in success of datatable ajax call

Is that possible to invoke a javascript function in success of datatable ajax call. Here is the code am trying to use, var oTable = $('#app-config').dataTable( { "bAutoWidth": false, ...

Difference between Divide and Conquer Algo and Dynamic Programming

What is the difference between Divide and Conquer Algorithms and Dynamic Programming Algorithms? How are the two terms different? I do not understand the difference between them. Please take a simple example to explain any difference between the two...

How to configure log4j with a properties file

How do I get log4j to pick up a properties file. I'm writing a Java desktop app which I want to use log4j. In my main method if have this: PropertyConfigurator.configure("log4j.properties"); The log4j.properties file sits in the same directory...

How to play a local video with Swift?

I have a short mp4 video file that I've added to my current Xcode6 Beta project. I want to play the video in my app. After hours searching, I can't find anything remotely helpful. Is there a way to accomplish this with Swift or do you have to use O...

Identifier not found error on function call

I have a program here where I invert the case of an entered string. This is the code in my .cpp file and I am using Visual Studio C++ IDE. I am not sure what I need in a header file or if I need one to make this work. Error with my function call swa...

Unable to access JSON property with "-" dash

I am unable to retrieve a value from a json object when the string has a dash character: { "profile-id":1234, "user_id":6789 } If I try to reference the parsed jsonObj.profile-id it returns ReferenceError: "id" is not defined but jsonObj.user_id w...

HashSet vs. List performance

It's clear that a search performance of the generic HashSet<T> class is higher than of the generic List<T> class. Just compare the hash-based key with the linear approach in the List<T> class. However calculating a hash key may its...

Duplicate keys in .NET dictionaries?

Are there any dictionary classes in the .NET base class library which allow duplicate keys to be used? The only solution I've found is to create, for example, a class like: Dictionary<string, List<object>> But this is quite irritating...

Xcode stops working after set "xcode-select -switch"

OMG, what I've done? Couple of days ago, I tried using macport to install something, because I'm using Xcode 4.3 and the command-line tool hadn't been installed by the time, macport wouldn't work. So I followed some guide to get command-line tool i...

"git checkout <commit id>" is changing branch to "no branch"

I am working on a branch in git. When I do git checkout <commit id> (commit id obtained from git log ), it is getting committed to that particular change but branch is changed to <No-branch>. Why is this happening? How do you resolve ...

Check if a string is html or not

I have a certain string for which I want to check if it is a html or not. I am using regex for the same but not getting the proper result. I validated my regex and it works fine here. var htmlRegex = new RegExp("<([A-Za-z][A-Za-z0-9]*)\b[^>]*...

Black transparent overlay on image hover with only CSS?

I'm trying to add a transparent black overlay to an image whenever the mouse is hovering over the image with only CSS. Is this possible? I tried this: http://jsfiddle.net/Zf5am/565/ But I can't get the div to show up. <div class="image">...

validate natural input number with ngpattern

I use ng-pattern="/0-9/" to set price_field do not accept decimal number. But when I input natural number (from 0 to 9999999),ng-show gets activated with Not valid number!. Where did I go wrong?. Please help. <form name="myform" data-ng-submit=...

Error in your SQL syntax; check the manual that corresponds to your MySQL server version

HTML CODE <!DOCTYPE html> <html> <head> <style> #right { margin-top:109px; margin-right:225px; } #button { margin-right:; margin-top:22px; } </style>...

How can I check if a string is a number?

I'd like to know on C# how to check if a string is a number (and just a number). Example : 141241 Yes 232a23 No 12412a No and so on... Is there a specific function?...

How do I remove blue "selected" outline on buttons?

I have some buttons using <button>, which when clicked get a blue selected color! Is there a way to remove this feature? ...

How to scroll page in flutter

My code for a page is like this. i need to scroll part below appbar. @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar(... ), body: new Stack( children: <Widget>[ new Con...

How can labels/legends be added for all chart types in chart.js (chartjs.org)?

The documentation for chart.js mentions "legend templates" but gives no resources or examples of such legends. How can these be displayed?...

How to compare two NSDates: Which is more recent?

I am trying to achieve a dropBox sync and need to compare the dates of two files. One is on my dropBox account and one is on my iPhone. I came up with the following, but I get unexpected results. I guess I'm doing something fundamentally wrong when...

How do I remove a library from the arduino environment?

In the Arduino GUI on windows, if I click on Sketch --> Import Library, at the bottom of the menu there is a section called "Contributed". Unfortunately, I had misclicked and added a library I did not want to that list. How can I remove it from tha...

Set Response Status Code

I have an API call for which I need to be able to run some checks and potentially return various status codes. I don't need custom views or anything, I just need to return the proper code. If the user hasn't passed proper credentials, I need to retur...

Can I assume (bool)true == (int)1 for any C++ compiler?

Can I assume (bool)true == (int)1 for any C++ compiler ?...

Twitter Bootstrap modal on mobile devices

Bootstrap modals don't work correctly on Android and iOS. The issue tracker acknowledges the problem but does not offer a working solution: Modals in 2.0 are broken on mobile. Modal window in 2.0 not positioning properly The screen darkens but th...

How do I create executable Java program?

I have programmed a Java Program in JCreator, everything is done, but I want to create an executable file from it, ie I dont want to have to run the program by loading the java classes and compiling then executing, but instead have it as a stand alon...

Adding a column to an existing table in a Rails migration

I have a Users model which needs an :email column (I forgot to add that column during the initial scaffold). I opened the migration file and added t.string :email, did rake db:migrate, and got a NoMethodError. Then I added the line add_column :u...

Improve INSERT-per-second performance of SQLite

Optimizing SQLite is tricky. Bulk-insert performance of a C application can vary from 85 inserts per second to over 96,000 inserts per second! Background: We are using SQLite as part of a desktop application. We have large amounts of configuration da...

How to get file name when user select a file via <input type="file" />?

I've seen similar questions before,which ends up with no solution,because of security reasons. But today I see hostmonster has successfully implemented this,when I open a ticket and attach a file in their backend. It works both with firefox and IE(...

Is there a way to get rid of accents and convert a whole string to regular letters?

Is there a better way for getting rid of accents and making those letters regular apart from using String.replaceAll() method and replacing letters one by one? Example: Input: orcpžsíáýd Output: orcpzsiayd It doesn't need to include all lette...

How to create permanent PowerShell Aliases

I want to create an alias of a cmdlet that doesn't expire after I close the current session of Powershell, let's say I have this alias : C:\Users\Aymen> New-Alias Goto Set-Location This perfectly creates the Goto alias, but I want to use it eve...

List files recursively in Linux CLI with path relative to the current directory

This is similar to this question, but I want to include the path relative to the current directory in unix. If I do the following: ls -LR | grep .txt It doesn't include the full paths. For example, I have the following directory structure: test1/...

Correct way of looping through C++ arrays

Recently I have found a lot of examples, most of them regards the C++ 98, anyways I have created my simple-array and a loop (codepad): #include <iostream> using namespace std; int main () { string texts[] = {"Apple", "Banana", "Orange"}; ...

How to convert Java String into byte[]?

Is there any way to convert Java String to a byte[] (not the boxed Byte[])? In trying this: System.out.println(response.split("\r\n\r\n")[1]); System.out.println("******"); System.out.println(response.split("\r\n\r\n")[1].getBytes().toString()); ...

html5 audio player - jquery toggle click play/pause?

i wonder what i'm doing wrong? $('.player_audio').click(function() { if ($('.player_audio').paused == false) { $('.player_audio').pause(); alert('music paused'); } else { $('.player_audio').play(); alert('...

MySql: Tinyint (2) vs tinyint(1) - what is the difference?

I knew boolean in mysql as tinyint (1). Today I see a table with defined an integer like tinyint(2), and also others like int(4), int(6) ... What does the size means in field of type integer and tinyint ?...

Why does git say "Pull is not possible because you have unmerged files"?

When I try to pull in my project directory in the terminal, I see the following error: harsukh@harsukh-desktop:~/Sites/branch1$ git pull origin master U app/config/app.php U app/config/database.php U app/routes.php Pull is not possible because you h...

Push an associative item into an array in JavaScript

How can I correct the following code? _x000D_ _x000D_ var arr = []; var name = "name"; var val = 2; arr.push(val); //works , but not associative arr[name] = val; //does not work console.log(arr);_x000D_ _x000D_ _x000D_ JSFiddle...

How do I format axis number format to thousands with a comma in matplotlib?

How can I change the format of the numbers in the x-axis to be like 10,000 instead of 10000? Ideally, I would just like to do something like this: x = format((10000.21, 22000.32, 10120.54), "#,###") Here is the code: import matplotlib.pyplot as p...

How to get POST data in WebAPI?

I'm sending a request to server in the following form: http://localhost:12345/api/controller/par1/par2 The request is correctly resolved to a method like: [HttpPost] public void object Post(string par1, string par2) However, I pass additional d...

Please explain the exec() function and its family

What is the exec() function and its family? Why is this function used and how does its work? Please anyone explain these functions....

How to extract duration time from ffmpeg output?

To get a lot of information about a media file one can do ffmpeg -i <filename> where it will output a lot of lines, one in particular Duration: 00:08:07.98, start: 0.000000, bitrate: 2080 kb/s I would like to output only 00:08:07.98, so I...

In Perl, how to remove ^M from a file?

I have a script that is appending new fields to an existing CSV, however ^M characters are appearing at the end of the old lines so the new fields end up on a new row instead of the same one. How do I remove ^M characters from a CSV file using Perl?...

How do I determine the size of an object in Python?

I want to know how to get size of objects like a string, integer, etc. in Python. Related question: How many bytes per element are there in a Python list (tuple)? I am using an XML file which contains size fields that specify the size of value. I m...

How do I select last 5 rows in a table without sorting?

I want to select the last 5 records from a table in SQL Server without arranging the table in ascending or descending order....

MVC which submit button has been pressed

I have two buttons on my MVC form: <input name="submit" type="submit" id="submit" value="Save" /> <input name="process" type="submit" id="process" value="Process" /> From my Controller action how do I know which one have been pressed?...

RegExp in TypeScript

How can I implement Regexp in TypeScript? My Example: var trigger = "2" var regex = new RegExp('^[1-9]\d{0,2}$', trigger); // where I have exception in Chrome console ...

How do I put hint in a asp:textbox

How do I put a hint/placeholder inside a asp:TextBox? When I say a hint I mean some text which disappears when the user clicks on it. Is there a way to achieve the same using html / css?...

How can I print using JQuery

I have nested divs..in which images generate dynamically ...this is the html code ..my problem is if i click the print button the corresponding image need to be printed. <div id="outputTemp" style="display:none"> <div id="rightoutputimgae"&...

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

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

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

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

Pandas unstack problems: ValueError: Index contains duplicate entries, cannot reshape

I am trying to unstack a multi-index with pandas and I am keep getting: ValueError: Index contains duplicate entries, cannot reshape Given a dataset with four columns: id (string) date (string) location (string) value (float) I first set a thr...

append to url and refresh page

I am looking to write a piece of javascript that will append a parameter to the current url and then refresh the page - how can I do this?...

Insert an element at a specific index in a list and return the updated list

I have this: >>> a = [1, 2, 4] >>> print a [1, 2, 4] >>> print a.insert(2, 3) None >>> print a [1, 2, 3, 4] >>> b = a.insert(3, 6) >>> print b None >>> print a [1, 2, 3, 6, 4] Is the...

Angular JS: Full example of GET/POST/DELETE/PUT client for a REST/CRUD backend?

I've implemented a REST/CRUD backend by following this article as an example: http://coenraets.org/blog/2012/10/creating-a-rest-api-using-node-js-express-and-mongodb/ . I have MongoDB running locally, I'm not using MongoLabs. I've followed the Googl...

How to force view controller orientation in iOS 8?

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

How can I build for release/distribution on the Xcode 4?

Build for debug is just press on the PLAY symbol, but I don't know how to Build for distribution/release? ...

ActionBarCompat: java.lang.IllegalStateException: You need to use a Theme.AppCompat

I am getting a RuntimeException on Android 2.3.5 but I am using Theme.AppCompat (res/values/themes.xml). This is the phone: http://www.gsmarena.com/samsung_galaxy_y_s5360-4117.php <!-- res/values/themes.xml --> <?xml version="1.0" encodin...

Simple If/Else Razor Syntax

I'm trying to do a simple If/Else within a foreach with this code: @{ var count = 0; foreach (var item in Model) { if (count++ % 2 == 0) { @:<tr class="alt-row"> } else { @:<tr> } <td> ...

Add item to array in VBScript

How do you add an item to an existing array in VBScript? Is there a VBScript equivalent to the push function in Javascript? i.e. myArray has three items, "Apples", "Oranges", and "Bananas" and I want to add "Watermelons" to the end of the array....

How to abort an interactive rebase if --abort doesn't work?

I've got myself into a muddle via an interactive rebase, and I now wish to abort it. (i.e. go back to the point before I was dropped into interactive rebase mode, in my case via git pull --rebase.) The way to do this seems to be via git rebase --ab...

How do I convert an NSString value to NSData?

How do I convert an NSString value to NSData?...

Error - trustAnchors parameter must be non-empty

I'm trying to configure my e-mail on Jenkins/Hudson, and I constantly receive the error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty I've seen a good amount of information online about the err...

How can I do string interpolation in JavaScript?

Consider this code: var age = 3; console.log("I'm " + age + " years old!"); Are there any other ways to insert the value of a variable in to a string, apart from string concatenation?...

tmux status bar configuration

How is the status bar is customized? I noticed in this youtube video (at 3:05 - image below), the status bar looks very different than the default one that I see after installing tmux on my Mac OS X. In particular, I like how the middle of the statu...

How does Java deal with multiple conditions inside a single IF statement

Lets say I have this: if(bool1 && bool2 && bool3) { ... } Now. Is Java smart enough to skip checking bool2 and bool2 if bool1 was evaluated to false? Does java even check them from left to right? I'm asking this because i was "sort...

Type List vs type ArrayList in Java

(1) List<?> myList = new ArrayList<?>(); (2) ArrayList<?> myList = new ArrayList<?>(); I understand that with (1), implementations of the List interface can be swapped. It seems that (1) is typically used in an application...

C++ compile time error: expected identifier before numeric constant

I have read other similar posts but I just don't understand what I've done wrong. I think my declaration of the vectors is correct. I even tried to declare without size but even that isn't working.What is wrong?? My code is: #include <vector>...

Error: unexpected symbol/input/string constant/numeric constant/SPECIAL in my code

I received one of these errors. Error: unexpected symbol in "<my code>" Error: unexpected input in "<my code>" Error: unexpected string constant in "<my code>" Error: unexpected numeric constant in "<my code>" Erro...

How to find the operating system version using JavaScript?

How can I find the OS name and OS version using JavaScript? ...

Use of Application.DoEvents()

Can Application.DoEvents() be used in C#? Is this function a way to allow the GUI to catch up with the rest of the app, in much the same way that VB6's DoEvents does?...

How to see query history in SQL Server Management Studio

Is the query history stored in some log files? If yes, can you tell me how to find their location? If not, can you give me any advice on how to see it?...

Update records using LINQ

I need to set a value in a table for a subset of rows. In SQL, I would do this: UPDATE dbo.Person SET is_default = 0 WHERE person_id = 5 Is there a way to do this in LINQ? I currently use the: var result = (from p in Context.People....) notati...

tar: Error is not recoverable: exiting now

when I untar doctrine -rw-r--r-- 1 root root 660252 2010-10-16 23:06 Doctrine-1.2.0.tgz I always get this error messages root@X100e:/usr/local/lib/Doctrine/stable# tar -xvzf Doctrine-1.2.0.tgz . . . Doctrine-1.2.0/tests/ViewTestCase.php Doctrin...

Installing SetupTools on 64-bit Windows

I'm running Python 2.7 on Windows 7 64-bit, and when I run the installer for setuptools it tells me that Python 2.7 is not installed. The specific error message is: `Python Version 2.7 required which was not found in the registry` My installed ve...

How can I return the sum and average of an int array?

I need to define two methods for returning the sum and average of an int array. The method defining is as follow:- public int Sum(params int[] customerssalary) { // I tried the following but it fails return customerssalary.sum(...

How to position the Button exactly in CSS

I have been trying to make a simple site like this. However , I do now realize that I am bad at CSS Positioning for the button never does show up as intended. As you might have guessed , I want the button (#play_button) to show up exactly on the play...

jQuery keypress() event not firing?

I am trying to fire an event on the right and left arrow key presses with jQuery. Using the following code, I can fire events on any of the alphanumeric keys, but the cursor keys (up, down, left, right) fire nothing. I am developing the site primaril...

Viewing all `git diffs` with vimdiff

I setup git diff to wrap into vimdiff, using "Git Diff with Vimdiff" as a guide, and it's working as expected unless there are many files with changes. When there are multiple files with changes and I run git diff, it opens the first file and, afte...

How to import Maven dependency in Android Studio/IntelliJ?

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

Using regular expression in css?

I have an html page with divs that have id(s) of the form s1, s2 and so on. <div id="sections"> <div id="s1">...</div> <div id="s2">...</div> ... </div> I want to apply a css property to a subset of th...

Epoch vs Iteration when training neural networks

What is the difference between epoch and iteration when training a multi-layer perceptron?...

Async always WaitingForActivation

I am trying to figure out what the async & await keywords are all about, however the output isn't what I'm expecting. The console application is as follows: class Program { static void Main(string[] args) { Console.WriteLine("Fo...

Git with SSH on Windows

I've went through the excellent guide provided by Tim Davis which is about configuring Git to work with SSH under Windows in order to produce a Git Server in order to have a main place for my DVCS. I am in the process of creating a clone for my pro...

How can I delete a user in linux when the system says its currently used in a process

I am trying to delete a user I created on ubuntu. However when I use the following command: userdel -r cafe_fixer I get the following message: user cafe_fixer is currently used by process 15945 I am not using this user for anything I just crea...

Test class with a new() call in it with Mockito

I have a legacy class that contains a new() call to instantiate a LoginContext(): public class TestedClass { public LoginContext login(String user, String password) { LoginContext lc = new LoginContext("login", callbackHandler); } } I want...

How to send data in request body with a GET when using jQuery $.ajax()

The service API I am consuming has a given GET method that requires the data be sent in the body of the request. The data required in the body is a list of id's separated by hypen and could potentially be very large and thus it must be sent in the...

Upload Image using POST form data in Python-requests

I'm working with wechat APIs ... here I've to upload an image to wechat's server using this API http://admin.wechat.com/wiki/index.php?title=Transferring_Multimedia_Files url = 'http://file.api.wechat.com/cgi-bin/media/upload?access_token=%s&...

Force to open "Save As..." popup open at text link click for PDF in HTML

I have some big size PDF catalogs at my website, and I need to link these as download. When I googled, I found such a thing noted below. It should open the "Save As..." popup at link click... <head> <meta name="content-disposition" con...

Moving items around in an ArrayList

I've been playing around with ArrayLists. What I'm trying to achieve is a method to do something like this: Item 1 Item 2 Item 3 Item 4 I'm trying to be able to move items up in the list, unless it is already at the top in which case it will stay ...

Python naming conventions for modules

I have a module whose purpose is to define a class called "nib". (and a few related classes too.) How should I call the module itself? "nib"? "nibmodule"? Anything else?...

MySQL - DATE_ADD month interval

I face a problem with the function DATE_ADD in MySQL. My request looks like this : SELECT * FROM mydb WHERE creationdate BETWEEN "2011-01-01" AND DATE_ADD("2011-01-01", INTERVAL 6 MONTH) GROUP BY MONTH(creationdate) The problem is that, in the...

Could not load file or assembly '***.dll' or one of its dependencies

I have this dll that I created a long time ago and use to connect to the db of a specific software that I develop for. I have had no issues for well over 4 years and countless applications with this dll. Trying to deploy my latest creation, I get th...

Automatic date update in a cell when another cell's value changes (as calculated by a formula)

I have a formula in C2, say =A2+B2. Whenever C2 changes value (actual value, not formula) I want to have the present date and time updated in D2. I have tried a lot of VBA codes and tricks and none of them works if a formula is entered in C2. BUT if...

What is the standard naming convention for html/css ids and classes?

Does it depend on the platform you are using, or is there a common convention that most developers suggest/follow? There are several options: id="someIdentifier"' - looks pretty consistent with javascript code. id="some-identifier" - looks more l...

convert nan value to zero

I have a 2D numpy array. Some of the values in this array are NaN. I want to perform certain operations using this array. For example consider the array: [[ 0. 43. 67. 0. 38.] [ 100. 86. 96. 100. 94.] [ 76. 79. 83. 89. 5...

HTML: can I display button text in multiple lines?

I have a button with long text like "Click here to start playing". I want to control the width and display the text in multiple lines. Is it possible in html/css?...

Mapping object to dictionary and vice versa

Are there any elegant quick way to map object to a dictionary and vice versa? Example: IDictionary<string,object> a = new Dictionary<string,object>(); a["Id"]=1; a["Name"]="Ahmad"; // ..... becomes SomeClass...

E: gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation

I have installed docker on windows 10 pro. I am facing an issue while running the following command in git-bash. docker-compose up -d --build and got following error. E: gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is re...

ActionLink htmlAttributes

WORKS <a href="@Url.Action("edit", "markets", new { id = 1 })" data-rel="dialog" data-transition="pop" data-icon="gear" class="ui-btn-right">Edit</a> DOES NOT WORK - WHY? @Html.ActionLink("Edit", "edit", "markets", new { ...

How to support different screen size in android

I'm developing an app in android and I have to support all different screen sizes and density. So i've created different folder for layout : layout-small layout-large and layout. Then I've created different folder for image: ldpi, mdpi and hdpi. In...

Multiple "order by" in LINQ

I have two tables, movies and categories, and I get an ordered list by categoryID first and then by Name. The movie table has three columns ID, Name and CategoryID. The category table has two columns ID and Name. I tried something like the followin...

Key Shortcut for Eclipse Imports

It's been a while since I last used Eclipse. I used to love this handy key shortcut that added all the imports to the top of the source file, but I've forgotten it. Does anyone know what this shortcut is?...

Finding element's position relative to the document

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

How to handle iframe in Selenium WebDriver using java

<div> <iframe id="cq-cf-frame "> <iframe id="gen367"> <body spellcheck="false" id="CQrte" style="height: 255px; font-size: 12px; font-family:tahoma,arial,helvetica,sans-serif; background-image: url(&quo...

Java HashMap: How to get a key and value by index?

I am trying to use a HashMap to map a unique string to a string ArrayList like this: HashMap<String, ArrayList<String>> Basically, I want to be able to access the keys by number, not by using the key's name. And I want to be able to ac...

Algorithm to generate all possible permutations of a list?

Say I have a list of n elements, I know there are n! possible ways to order these elements. What is an algorithm to generate all possible orderings of this list? Example, I have list [a, b, c]. The algorithm would return [[a, b, c], [a, c, b,], [b, a...

How to Ping External IP from Java Android

I am developing a Ping application for Android 2.2. I try my code and it works, but only in local IPs, that's my problem I want to do ping to external servers too. Here is my code: private OnClickListener milistener = new OnClickListener() { ...

Dependency Walker reports IESHIMS.DLL and WER.DLL missing?

On a Windows XP Professional SP3 with Internet Explorer 8 box, when I run Dependency Walker on an executable of mine it reports that: IESHIMS.DLL and WER.DLL can't be found. Do I need these DLL's? Where can I get them? I believe they are supposed...

Create local maven repository

I want to create local maven repository. I did the following steps: Installed maven plugin in eclipse Created one folder localrepository in apache server which is accessible using http://< my-domain>/localrepository In my project pom.xml I h...

SQL Server: Get table primary key using sql query

I want to get a particular table's primary key using SQL query for SQL Server database. In MySQL I am using following query to get table primary key: SHOW KEYS FROM tablename WHERE Key_name = 'PRIMARY' What is equivalent of above query for SQL Se...

How do I remove all .pyc files from a project?

I've renamed some files in a fairly large project and want to remove the .pyc files they've left behind. I tried the bash script: rm -r *.pyc But that doesn't recurse through the folders as I thought it would. What am I doing wrong?...

Pass variables from servlet to jsp

How can I pass variable from servlet to jsp? setAttribute and getAttribute didn't work for me :-(...

How to output JavaScript with PHP

I am new to PHP. I need to output the following JavaScript with PHP. This is my code: <html> <body> <?php echo "<script type="text/javascript">"; echo "document.write("Hello World!")"; echo "</script>"; ?> </body&g...

What is the meaning of "this" in Java?

Normally, I use this in constructors only. I understand that it is used to identify the parameter variable (by using this.something), if it have a same name with a global variable. However, I don't know that what the real meaning of this is in Ja...

Add views below toolbar in CoordinatorLayout

I have the following layout: <android.support.design.widget.CoordinatorLayout android:id="@+id/main_content" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:la...

How to initialize const member variable in a class?

#include <iostream> using namespace std; class T1 { const int t = 100; public: T1() { cout << "T1 constructor: " << t << endl; } }; When I am trying to initialize the const member variable t with 100. But it...

Run bash script from Windows PowerShell

In cygwin, I could just do ./script.sh args, but this opens the script file in notepad in PowerShell. What do I need to do have it execute?...

Redirecting from HTTP to HTTPS with PHP

I'm working on a shopping cart website and I would like to redirect the user to a HTTPS page when he's entering his billing details and maintain the HTTPS connection for the next pages until he logs out. What do I need to install on the server (I'm ...

Multiple submit buttons on HTML form – designate one button as default

I have a form that has three submit buttons as follows: <input type="submit" name="COMMAND" value="&lsaquo; Prev"> <input type="submit" name="COMMAND" value="Save"> <input type="reset" name="NOTHING" value="Reset"> <input t...

Why does typeof array with objects return "object" and not "array"?

Possible Duplicate: JavaScript: Check if object is array? Why is an array of objects considered an object, and not an array? For example: $.ajax({ url: 'http://api.twitter.com/1/statuses/user_timeline.json', data: { screen_name: '...

Delete files older than 10 days using shell script in Unix

I'm new to shell scripts, can anyone help? I want to delete scripts in a folder from the current date back to 10 days. The scripts looks like: 2012.11.21.09_33_52.script 2012.11.21.09_33_56.script 2012.11.21.09_33_59.script The script will run in ...

What is the exact meaning of Git Bash?

Git Bash I have been working with Git Bash for the last two days. I know now the basic operations such as commit, push, pull, fetch, and merge. But I still don't know what Git Bash itself actually is! I've searched a lot about Git Bash, but all sit...

How to count the number of files in a directory using Python

I need to count the number of files in a directory using Python. I guess the easiest way is len(glob.glob('*')), but that also counts the directory itself as a file. Is there any way to count only the files in a directory?...

Fix height of a table row in HTML Table

Kindly look at the following code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> </head> <body...

How can I use a batch file to write to a text file?

I need to make a script that can write one line of text to a text file in the same directory as the batch file....

How to set background color of a View

I'm trying to set the background color of a View (in this case a Button). I use this code: // set the background to green v.setBackgroundColor(0x0000FF00 ); v.invalidate(); It causes the Button to disappear from the screen. What am I doing wron...

git push rejected

I give up! Whenever I try to push I get a stupid: ! [rejected] master -> master (non-fast forward) error: failed to push some refs to '[email protected]:companyX/projectX.git' Our team has a new git setup. Instead of making private branche...

Prevent Caching in ASP.NET MVC for specific actions using an attribute

I have an ASP.NET MVC 3 application. This application requests records through jQuery. jQuery calls back to a controller action that returns results in JSON format. I have not been able to prove this, but I'm concerned that my data may be getting cac...

Finding all objects that have a given property inside a collection

I have some complicated object, such as a Cat, which has many properties, such as age, favorite cat food, and so forth. A bunch of Cats are stored in a Java Collection, and I need to find all the Cats that are aged 3, or those whose favorite cat f...

Print Combining Strings and Numbers

To print strings and numbers in Python, is there any other way than doing something like: first = 10 second = 20 print "First number is %(first)d and second number is %(second)d" % {"first": first, "second":second} ...

C++ performance vs. Java/C#

My understanding is that C/C++ produces native code to run on a particular machine architecture. Conversely, languages like Java and C# run on top of a virtual machine which abstracts away the native architecture. Logically it would seem impossible...

How to stop tracking and ignore changes to a file in Git?

I have cloned a project that includes some .csproj files. I don't need/like my local csproj files being tracked by Git (or being brought up when creating a patch), but clearly they are needed in the project. I have added *.csproj to my LOCAL .gitign...

Getting number of elements in an iterator in Python

Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting?...

Attach a file from MemoryStream to a MailMessage in C#

I am writing a program to attach a file to email. Currently I am saving file using FileStream into disk, and then I use System.Net.Mail.MailMessage.Attachments.Add( new System.Net.Mail.Attachment("file name")); I do not want to store file in...

Vue.js redirection to another page

I'd like to make a redirection in Vue.js similar to the vanilla javascript window.location.href = 'some_url' How could I achieve this in Vue.js?...

How do I create a WPF Rounded Corner container?

We are creating an XBAP application that we need to have rounded corners in various locations in a single page and we would like to have a WPF Rounded Corner container to place a bunch of other elements within. Does anyone have some suggestions or s...

Accessing a resource via codebehind in WPF

I have a custom collection defined in my window resources as follows (in a Sketchflow app so the window is actually a UserControl): <UserControl.Resources> <ds:MyCollection x:Key="myKey" x:Name="myName" /> </UserControl.Resources&...

TypeError: 'int' object is not subscriptable

I'm trying to create a simple program that tells you your lucky number according to numerology. I keep on getting this error: File "number.py", line 12, in <module> sumln = (int(sumall[0])+int(sumall[1])) TypeError: 'int' object is not sub...

Add a CSS class to <%= f.submit %>

My question is easy: <%= f.submit %> Where does the class declaration go? I'm getting errors on multiple attempts....

Xcode 10 Error: Multiple commands produce

error: Multiple commands produce '/Users/uesr/Library/Developer/Xcode/DerivedData/OptimalLive-fxatvygbofczeyhjsawtebkimvwx/Build/Products/Debug-iphoneos/OptimalLive.app/Info.plist': 1) Target 'OptimalLive' has copy command from '/Users/uesr/...

How to decode HTML entities using jQuery?

How do I use jQuery to decode HTML entities in a string?...

exit application when click button - iOS

Possible Duplicate: Exit application in iOS 4.0 I have a AlertView which displays some text and an "OK" button. Is there any way to exit application when clicked on OK button?...

- java.lang.NullPointerException - setText on null object reference

This is what I'm trying to do for several hours: I've got a MainActivity.java file (listing below) and a fragment_start.xml file with a start button. Tapping the start-button should display the activity_main.xml file with points-/round- and countdown...

Oracle "ORA-01008: not all variables bound" Error w/ Parameters

This is the first time I've dealt with Oracle, and I'm having a hard time understanding why I'm receiving this error. I'm using Oracle's ODT.NET w/ C# with the following code in a query's where clause: WHERE table.Variable1 = :VarA AND (:VarB IS ...

How do I run a shell script without using "sh" or "bash" commands?

I have a shell script which I want to run without using the "sh" or "bash" commands. For example: Instead of: sh script.sh I want to use: script.sh How can I do this? P.S. (i) I don't use shell script much and I tried reading about aliases, but I...

How to stop C# console applications from closing automatically?

My console applications on Visual Studio are closing automatically, so I'd like to use something like C's system("PAUSE") to "pause" the applications at the end of its execution, how can I achieve that? ...

What does API level mean?

I am wondering what exactly API level means. I couldn't seem to find an answer by searching on Google. Could anyone please explain what the term API level means?...

How to force an entire layout View refresh?

I want to force the main layout resource view to redraw / refresh, in say the Activity.onResume() method. How can I do this ? By main layout view, I mean the one ('R.layout.mainscreen' below) that is called in my Activity.onCreate(), like this:- p...

Removing body margin in CSS

I'm new to web development, and met a problem when removing margin of body. There's space between the very top of the browser and "logo" text. And my code is here on jsbin. Is body { margin: 0;} wrong if I'd like to remove the space?...

Is it possible to execute multiple _addItem calls asynchronously using Google Analytics?

Would the following code work? _gaq.push(['_addTrans', '7171717117', // order ID - required '', // affiliation or store name '2222', // total - required '', // tax '', // shipping '', ...

Open a folder using Process.Start

I saw the other topic and I'm having another problem. The process is starting (saw at task manager) but the folder is not opening on my screen. What's wrong? System.Diagnostics.Process.Start("explorer.exe", @"c:\teste"); ...

Is there a wikipedia API just for retrieve content summary?

I need just to retrieve first paragraph of a Wikipedia page. Content must be html formated, ready to be displayed on my website (so NO BBCODE, or WIKIPEDIA special CODE!)...

Set a DateTime database field to "Now"

In VB.net code, I create requests with SQL parameters. It I set a DateTime parameter to the value DateTime.Now, what will my request look like ? UPDATE table SET date = "2010/12/20 10:25:00"; or UPDATE table SET date = GETDATE(); In the first c...

How can I execute Python scripts using Anaconda's version of Python?

I recently downloaded the Anaconda distribution for Python. I noticed that if I write and execute a Python script (by double-clicking on its icon), my computer (running on Windows 8) will execute it using my old version of Python rather than Anaconda...

Getting the URL of the current page using Selenium WebDriver

I'm attempting to get the URL of the currently open page. I am using Selenium WebDriver and Java. I am accessing the current URL via: WebDriver driver = new WebDriver(); String url = driver.getCurrentUrl(); however, the URL does not appear to ac...

How to create byte array from HttpPostedFile

I'm using an image component that has a FromBinary method. Wondering how do I convert my input stream into a byte array HttpPostedFile file = context.Request.Files[0]; byte[] buffer = new byte[file.ContentLength]; file.InputStream.Read(buffer, 0, fi...

Strip HTML from Text JavaScript

Is there an easy way to take a string of html in JavaScript and strip out the html? ...

how to change namespace of entire project?

I'm modifying demo application from this article: http://msdn.microsoft.com/en-us/magazine/dd419663.aspx I need to update all files to use my namespace, for example now file located here: MySolution\MyApp\DemoApp\ViewModel\MainWindowViewModel.cs ...

Bootstrap 3 - set height of modal window according to screen size

I am trying to create a kind of responsive megamenu using Bootstrap 3 modal dialog. I would like to set the width and height of the whole modal window to 80% of the viewport, while setting the modal-body to a max-height in order not to populate the w...

Implement division with bit-wise operator

How can I implement division using bit-wise operators (not just division by powers of 2)? Describe it in detail....

DevTools failed to load SourceMap: Could not load content for chrome-extension

I'm trying to display an image selected from the local machine and I need the location of that image for a javascript function. I have recently started learning javascript. I am facing this error and unable to get the location of the image. For getti...

Which font is used in Visual Studio Code Editor and how to change fonts?

I tried Visual Studio Code editor(https://code.visualstudio.com/) which is recently announced at build. I tried it on Windows and Ubuntu. I can see that default font of Visual Studio Code Editor is not consolas which prefer on my code editors. So w...

text-align: right on <select> or <option>

Does anyone know if it's possible to align text to the right of a <select> or more specifically <option> element in WebKit. This does not need to be a cross-browser solution including IE, but should be pure CSS if it is possible. I have ...

Difference between null and empty ("") Java String

What is the difference between null and the "" (empty string)? I have written some simple code: String a = ""; String b = null; System.out.println(a == b); // false System.out.println(a.equals(b)); // false Both statements return false. It seems...

Parsing a JSON string in Ruby

I have a string that I want to parse in Ruby: string = '{"desc":{"someKey":"someValue","anotherKey":"value"},"main_item":{"stats":{"a":8,"b":12,"c":10}}}' Is there an easy way to extract the data?...

CSS3 Box Shadow on Top, Left, and Right Only

Greetings, I am trying to apply a CSS3 box shadow to only the top, right, and left of a DIV with a radius that matches the result of the following CSS (minus the bottom shadow) #div { -webkit-box-shadow: 0px 0px 10px #000; -moz-box-shadow:...

Read a plain text file with php

I have a text file with this information in my server: Data1 Data2 Data3 . . . DataN How do I read all the information from the text file (line by line) using PHP?...

How to get item count from DynamoDB?

I want to know item count with DynamoDB querying. I can querying for DynamoDB, but I only want to know 'total count of item'. For example, 'SELECT COUNT(*) FROM ... WHERE ...' in MySQL $result = $aws->query(array( 'TableName' => 'game_table...

How to avoid "cannot load such file -- utils/popen" from homebrew on OSX

I'm getting an error when I run brew in the terminal: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- utils/popen (LoadError) from /System/Libr...

How to hide console window in python?

I am writing an IRC bot in Python. I wish to make stand-alone binaries for Linux and Windows of it. And mainly I wish that when the bot initiates, the console window should hide and the user should not be able to see the window. What can I do for ...

PHP - Session destroy after closing browser

Though this question has multiple duplicates i could not find proper solution for me. Need Some help. I have used ini_set('session.cookie_lifetime', 0); in my configuration file. But it is not helping me to destroy session on browser close. Appl...

How do I calculate the date six months from the current date using the datetime Python module?

I am using the datetime Python module. I am looking to calculate the date 6 months from the current date. Could someone give me a little help doing this? The reason I want to generate a date 6 months from the current date is to produce a review dat...

How do I format a Microsoft JSON date?

I'm taking my first crack at Ajax with jQuery. I'm getting my data onto my page, but I'm having some trouble with the JSON data that is returned for Date data types. Basically, I'm getting a string back that looks like this: /Date(1224043200000)/ ...

Full examples of using pySerial package

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

Wait for all promises to resolve

So I have a situation where I have multiple promise chains of an unknown length. I want some action to run when all the CHAINS have been processed. Is that even possible? Here is an example: app.controller('MainCtrl', function($scope, $q, $timeout) ...

Missing Microsoft RDLC Report Designer in Visual Studio

In Visual Studio 2015, I cannot find the designer for RDLC reports anymore. Does anyone know if this is only a bug and if it is provided later on or if Microsoft wants to kill the RDLC or if they want us to use an external designer and when, which de...

Change the Theme in Jupyter Notebook?

I like dark themes. However, the default theme of Jupyter notebooks is light, and I can't find the option to change the theme/background-color. How is this done?...

Add a pipe separator after items in an unordered list unless that item is the last on a line

Is it possible to style this html ... <ul> <li>Dogs</li> <li>Cats</li> <li>Lions</li> <li>Tigers</li> <li>Zebras</li> <li>Giraffes</li> <li&...

Appending to list in Python dictionary

Is there a more elegant way to write this code? What I am doing: I have keys and dates. There can be a number of dates assigned to a key and so I am creating a dictionary of lists of dates to represent this. The following code works fine, but I was...

Given a URL to a text file, what is the simplest way to read the contents of the text file?

In Python, when given the URL for a text file, what is the simplest way to access the contents off the text file and print the contents of the file out locally line-by-line without saving a local copy of the text file? TargetURL=http://www.myhost.c...

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

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

Subversion stuck due to "previous operation has not finished"?

If I try to update my subversion repo, it says I must run cleanup. If I run cleanup, it says a file is missing. (I deleted a MASSIVE directory of files that failed to commit this morning from my home pc, but then I commit the same set of files from w...

Using "&times" word in html changes to ×

I am using the following code. HTML Code : <div class="test">&times</div> Javascript: alert($(".test").html()); I am getting × in alert. I need to get &times as result. Anybody knows or faces this problem? Please update yo...

Does VBScript have a substring() function?

Is there a substring() function in VBScript similar to Java's string.substring()?...

Express.js: how to get remote client address

I don't completely understand how I should get a remote user IP address. Let's say I have a simple request route such as: app.get(/, function (req, res){ var forwardedIpsStr = req.header('x-forwarded-for'); var IP = ''; if (forwardedIpsSt...

Are there any Open Source alternatives to Crystal Reports?

Are there any Open Source alternatives to Crystal Reports?...

Angular: 'Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays'

I've created an angular app which gets data from a json file. But I'm having issues with showing the data in html. A lot of variables are in dutch, I'm sorry for that. I'm also a bit new to all of this :) This is my service: import {Injectable} fro...

Connect to external server by using phpMyAdmin

I have phpMyAdmin installed on my local machine. How can I make it connect to an external server?...

Simulate low network connectivity for Android

I would like to test my application for cases of low network connectivity. Except standing in the elevator, what is the best way to do this? I've tried wrapping my phone in an aluminum foil, but it didn't help much. I need to test it on a real devic...

Send email from localhost running XAMMP in PHP using GMAIL mail server

I try to send an email from localhost to my yahoo email account using php mail() function, the return says I successfully send the email but I did not get any email. I've been reading and trying many so called 'simple way' to send email but the resul...

How to print out all the elements of a List in Java?

I am trying to print out all the elements of a List, however it is printing the pointer of the Object rather than the value. This is my printing code... for(int i=0;i<list.size();i++){ System.out.println(list.get(i)); } Could anyone pleas...

How to get store information in Magento?

In Magento, how can I get active store information, like store name, line number, etc?...

Iterating through populated rows

So I am trying to iterate through a worksheet in an Excel spreadsheet using VBA. I want to iterate through each row, and then through each column, and despite googling, I can't actually find an intuitive way to do this. I'm assuming that the first c...

Sort Go map values by keys

When iterating through the returned map in the code, returned by the topic function, the keys are not appearing in order. How can I get the keys to be in order / sort the map so that the keys are in order and the values correspond? Here is the code...

Comparing two NumPy arrays for equality, element-wise

What is the simplest way to compare two NumPy arrays for equality (where equality is defined as: A = B iff for all indices i: A[i] == B[i])? Simply using == gives me a boolean array: >>> numpy.array([1,1,1]) == numpy.array([1,1,1]) arra...

How to set placeholder value using CSS?

I want to set the placeholder value of an input box using only CSS and no JavaScript or jQuery. How can I do this?...

Remove HTML tags from a String

Is there a good way to remove HTML from a Java string? A simple regex like replaceAll("\\<.*?>", "") will work, but things like &amp; wont be converted correctly and non-HTML between the two angle brackets will be remo...

firefox proxy settings via command line

How do I change Firefox Proxy settings via command line on windows xp/2k? Thanks...

Java System.out.print formatting

Here is my code (well, some of it). The question I have is, can I get the first 9 numbers to show with a leading 00 and numbers 10 - 99 with a leading 0. I have to show all of the 360 monthly payments, but if I don't have all month numbers at the sa...

How to execute Python code from within Visual Studio Code

Visual Studio Code was recently released and I liked the look of it and the features it offered, so I figured I would give it a go. I downloaded the application from the downloads page, fired it up, messed around a bit with some of the features ... a...

How do I include image files in Django templates?

I'm new to Django and I'm trying to learn it through a simple project I'm developing called 'dubliners' and an app called 'book'. The directory structure is like this: dubliners/book/ [includes models.py, views.py, etc.] dubliners/templates/book/ ...

Using CSS in Laravel views?

I've just began learning Laravel, and can do the basics of a controller and routing. My OS is Mac OS X Lion, and it's on a MAMP server. My code from routes.php: Route::get('/', function() { return View::make('home.index'); }); Route::get('bus...

Convert String[] to comma separated string in java

i have one String[] String[] name = {"amit", "rahul", "surya"}; i want to send name as parameter in sql query inside IN clause so how do i convert into a format 'amit','rahul','surya' ...

How to serialize SqlAlchemy result to JSON?

Django has some good automatic serialization of ORM models returned from DB to JSON format. How to serialize SQLAlchemy query result to JSON format? I tried jsonpickle.encode but it encodes query object itself. I tried json.dumps(items) but it ret...

JavaScript checking for null vs. undefined and difference between == and ===

How do I check a variable if it's null or undefined and what is the difference between the null and undefined? What is the difference between == and === (it's hard to search Google for "===" )? ...

mysql: get record count between two date-time

I am stuck with a problem in MySQL. I want to get the count of records between two date-time entries. For example: I have a column in my table named 'created' having the datetime data type. I want to count records which were created date-time betwee...

How to resize Image in Android?

I am creating an application and want to setup a gallery view. I do not want the images in the gallery view to be full size. How do I resize images in Android?...

How to write a JSON file in C#?

I need to write the following data into a text file using JSON format in C#. The brackets are important for it to be valid JSON format. [ { "Id": 1, "SSN": 123, "Message": "whatever" }, { "Id": 2, "SSN": 125, "Message":...

Using ExcelDataReader to read Excel data starting from a particular cell

I am using ExcelDataReader to read data from my Excel workbook in C#. But structure of my Excel sheet is such that data to be read can start from any particular cell and not necessarily A1. Can any one Please suggest a way on how this can be achieve...

Are the shift operators (<<, >>) arithmetic or logical in C?

In C, are the shift operators (<<, >>) arithmetic or logical?...

Changing Java Date one hour back

I have a Java date object: Date currentDate = new Date(); This will give the current date and time. Example: Thu Jan 12 10:17:47 GMT 2012 Instead, I want to get the date, changing it to one hour back so it should give me: Thu Jan 12 09:17:47 G...

Plot multiple lines (data series) each with unique color in R

I am fairly new to R and I have the following queries : I am trying to generate a plot in R which has multiple lines (data series). Each of these lines is a category and I want it to have a unique color. Currently my code is setup in this way : F...

What are the differences between the different saving methods in Hibernate?

Hibernate has a handful of methods that, one way or another, takes your object and puts it into the database. What are the differences between them, when to use which, and why isn't there just one intelligent method that knows when to use what? The ...

SQL Server Creating a temp table for this query

I have this query: DECLARE @ProjectID int = 3, @Year int = 2010, @MeterTypeID int = 1, @StartDate datetime, @EndDate datetime SET @StartDate = '07/01/' + CAST(@Year as VARCHAR) SET @EndDate = '06/30/' + CAST(@Year+1 as VARCHAR) SELECT tblMEP_Sit...

Jackson: how to prevent field serialization

I have an entity class with a password field: class User { private String password; //setter, getter.. } I want this field to be skipped during serialization. But it should still be able to deserialize. This is needed, so that the client ca...

Illegal pattern character 'T' when parsing a date string to java.util.Date

I have a date string and I want to parse it to normal date use the java Date API,the following is my code: public static void main(String[] args) { String date="2010-10-02T12:23:23Z"; String pattern="yyyy-MM-ddThh:mm:ssZ"; SimpleDateForm...

How do you set your pythonpath in an already-created virtualenv?

What file do I edit, and how? I created a virtual environment....

input[type='text'] CSS selector does not apply to default-type text inputs?

The default input type is 'text'. I have always assumed then that CSS declarations targeting input[type='text'] would affect those inputs even if the type was not explicitly declared on the control. However, I just noticed that my default-type text i...

Can VS Code run on Android?

Does anybody know about plans of MS to support running VS Code so it can run on Android OS?...

Create comma separated strings C#?

I have an object which holds many values, some of them (not all values from the object) need to be put in a csv string. My approach was this: string csvString = o.number + "," + o.id + "," + o.whatever .... Somehow I think there is a better, more ...

Ansible: Set variable to file content

I'm using the ec2 module with ansible-playbook I want to set a variable to the contents of a file. Here's how I'm currently doing it. Var with the filename shell task to cat the file use the result of the cat to pass to the ec2 module. Example c...

Get statistics for each group (such as count, mean, etc) using pandas GroupBy?

I have a data frame df and I use several columns from it to groupby: df['col1','col2','col3','col4'].groupby(['col1','col2']).mean() In the above way I almost get the table (data frame) that I need. What is missing is an additional column that con...

Load an image from a url into a PictureBox

I want to load an image into a PictureBox. This is the image I want to load: http://www.gravatar.com/avatar/6810d91caff032b202c50701dd3af745?d=identicon&r=PG How do I do this?...

Center Plot title in ggplot2

This simple code (and all my scripts from this morning) has started giving me an off center title in ggplot2: Ubuntu version: 16.04 R studio version: Version 0.99.896 R version: 3.3.2 GGPLOT2 version: 2.2.0 I have freshly installed the above this...

How should the ViewModel close the form?

I'm trying to learn WPF and the MVVM problem, but have hit a snag. This question is similar but not quite the same as this one (handling-dialogs-in-wpf-with-mvvm)... I have a "Login" form written using the MVVM pattern. This form has a View...

Bootstrap 3 and Youtube in Modal

I'm trying to use the Modal feature from Bootstrap 3 to show my Youtube video. It works, but I can't click on any buttons in the Youtube video. Any help on this? Here's my code: <div id="link">My video</div> <div id="myModal" clas...

Find an object in SQL Server (cross-database)

If I've been told a table (or proc) name, but not which connected database the object is located in, is there any simple script to search for it? Maybe search somewhere in the System Databases? (I'm using SQL Server 2005)...

INSERT INTO a temp table, and have an IDENTITY field created, without first declaring the temp table?

I need to select a bunch of data into a temp table to then do some secondary calculations; To help make it work more efficiently, I would like to have an IDENTITY column on that table. I know I could declare the table first with an identity, then in...

How can I add (simple) tracing in C#?

I want to introduce some tracing to a C# application I am writing. Sadly, I can never really remember how it works and would like a tutorial with reference qualities to check up on every now and then. It should include: App.config / Web.config stuff...

Gaussian fit for Python

I'm trying to fit a Gaussian for my data (which is already a rough gaussian). I've already taken the advice of those here and tried curve_fit and leastsq but I think that I'm missing something more fundamental (in that I have no idea how to use the c...

How to get a jqGrid selected row cells value

Does anyone know how to get the cells value of the selected row of JQGrid ? i m using mvc with JQGrid, i want to access the value of the hidden column of the selected row ?...

Customize list item bullets using CSS

Is it possible to change the size of an <li> element's bullet? Take a look at the code below: li { list-style: square; // I want to change the size of this squared bullet. } I can't seem to find any way to achieve that....

How to convert a HTMLElement to a string

I am going to create an XML element in JavaScript to exchange data with server side. I found I can do it with document.createElement. But I do not know how to convert it to string. Is there any API in browser to make it easier? Or is there any JS lib...

Editing legend (text) labels in ggplot

I have spent hours looking in the documentation and on StackOverflow, but no solution seems to solve my problem. When using ggplot I can't get the right text in the legend, even though it's in my dataframe. I have tried scale_colour_manual, scale_fi...

WebSocket with SSL

Is it possible to have WebSockets with HTTPS? When switching to HTTPS, my WebSocket returns a security error and works perfectly with regular HTTP. Below, a snippet; socket = new WebSocket("ws://my_www:1235"); ...

jQuery - Redirect with post data

How can I redirect with post data? How to move to new page with $_POST? How to do this? How is it done and whyfore shall it be done...

Parsing JSON with Unix tools

I'm trying to parse JSON returned from a curl request, like so: curl 'http://twitter.com/users/username.json' | sed -e 's/[{}]/''/g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' The above splits the JSON int...

How to set an environment variable from a Gradle build?

I'm trying to set an environment variable from my Gradle build. I'm on MacOS X (El Capitan). The command is "gradle test". I'm trying this in my build.gradle: task setenv(type: Exec) { commandLine "export", "SOME_TEST_VAR=aaa" } test.dependsOn ...

Use virtualenv with Python with Visual Studio Code in Ubuntu

I have a Python project and navigation/autocomplete work perfectly within files in the project. I want to specify a virtualenv so that navigation/autocomplete work with packages inside that virtualenv. I tried this in settings.py, but navigation/auto...

TypeScript and React - children type?

I have a very simple functional component as follows: import * as React from 'react'; export interface AuxProps { children: React.ReactNode } const aux = (props: AuxProps) => props.children; export default aux; And another component:...

SVN icon overlays not showing properly

I'm testing SVN. After the configuration, I can add/commit the files successfully. However, I can't see the status icons on the files and folders. Can anybody tell me why?...

Moment.js: Date between dates

I'm trying to detect with Moment.js if a given date is between two dates. Since version 2.0.0, Tim added isBefore() and isAfter() for date comparison. Since there's no isBetween() method, I thought this would work: var date = moment("15/02/2013", "...

Strip all non-numeric characters from string in JavaScript

Consider a non-DOM scenario where you'd want to remove all non-numeric characters from a string using JavaScript/ECMAScript. Any characters that are in range 0 - 9 should be kept. var myString = 'abc123.8<blah>'; //desired output is 1238 Ho...

Transparent image - background color

I'm wondering if it is possible to set a background color for transparent images? (only the image will have background color)...

How to retrieve images from MySQL database and display in an html tag

I created a MySQL database with a table using phpmyadmin. I created this table with a BLOB column to hold a jpeg file. I have issues with regards to the php variable $result here. My code so far: (catalog.php): <body> <?php $link = mys...

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

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

Update or Insert (multiple rows and columns) from subquery in PostgreSQL

I'm trying to do something like this in postgres: UPDATE table1 SET (col1, col2) = (SELECT col2, col3 FROM othertable WHERE othertable.col1 = 123); INSERT INTO table1 (col1, col2) VALUES (SELECT col1, col2 FROM othertable) But point 1 is not poss...

notifyDataSetChanged example

I'm trying to use in my Android Application the notifyDataSetChanged() method for an ArrayAdapter but it doesn't work for me. I found as answer here, that notifyDataSetChanged() should run in the main thread, but there was no example for that. Cou...

Html5 Full screen video

Is there any way to do this? I wan to play video in full screen. Without browser. setting width:100%; height:100%; keep browser visible yet...