Questions Tagged with #Quantmod

quantmod is a package for R designed to assist quantitative traders in the development, testing, and deployment of statistically based trading models.

Error in model.frame.default: variable lengths differ

On running a gam model using the mgcv package, I encountered a strange error message which I am unable to understand: “Error in model.frame.default(formula = death ~ pm10 + Lag(resid1, 1) + : ..

Javascript - Regex to validate date format

Is there any way to have a regex in JavaScript that validates dates of multiple formats, like: DD-MM-YYYY or DD.MM.YYYY or DD/MM/YYYY etc? I need all these in one regex and I'm not really good with it..

javascript if number greater than number

I have this javascript function to validate if a number is greater than another number function validateForm() { var x = document.forms["frmOrder"]["txtTotal"].value; var y = document.forms["..

Can I use library that used android support with Androidx projects.

I know, androidx and support dependency causing multidex error We can not use androidx and android support at a same time. So I totally migrate to androidx. but one of my dependency lib used android s..

How to set custom header in Volley Request

How can custom headers be set for a Volley request? At the moment, there is way to set body content for a POST request. I've a simple GET request, but I need to pass the custom headers alongwith. I do..

How to detect if numpy is installed

I'm writing Python code. I want to check if numpy and wxpython are installed on machine. How to do that??..

How to set bootstrap navbar active class with Angular JS?

If I have a navbar in bootstrap with the items Home | About | Contact How do I set the active class for each menu item when they are active? That is, how can I set class="active" when the angular r..

My Routes are Returning a 404, How can I Fix Them?

I've just started learning the Laravel framework and I'm having an issue with routing. The only route that's working is the default home route that's attached to Laravel out of the box. I'm using WA..

Convert .pfx to .cer

Is it possible to convert a .pfx (Personal Information Exchange) file to a .cer (Security Certificate) file? Unless I'm mistaken, isn't a .cer somehow embedded inside a .pfx? I'd like some way to extr..

Get the length of a String

How do you get the length of a String? For example, I have a variable defined like: var test1: String = "Scott" However, I can't seem to find a length method on the string...

Check orientation on Android phone

How can I check if the Android phone is in Landscape or Portrait? ..

How to animate RecyclerView items when they appear

How can I animate the RecyclerView Items when there are appearing? The default item animator only animates when a data is added or removed after the recycler data has been set. I'm new developing app..

How do I center list items inside a UL element?

How do I center list items inside a ul without using extra divs or elements. I have the following. I thought text-align:center would do the trick. I can't seem to figure it out. <style> ul { ..

What's the best way to add a drop shadow to my UIView

I am trying to add a drop shadow to views that are layered on top of one another, the views collapse allowing content in other views to be seen, in this vein i want to keep view.clipsToBounds ON so th..

Nth word in a string variable

In Bash, I want to get the Nth word of a string hold by a variable. For instance: STRING="one two three four" N=3 Result: "three" What Bash command/script could do this?..

How to make a copy of an object in C#

Let's say that I have a class: class obj { int a; int b; } and then I have this code: obj myobj = new obj(){ a=1, b=2} obj myobj2 = myobj; Now the above code makes a reference to the first o..

Using if-else in JSP

I'm using the following code to print the name of the user on the browser: <body> <form> <h1>Hello! I'm duke! What's you name?</h1> <input type="text" name="user"..

jquery 3.0 url.indexOf error

I am getting following error from jQuery once it has been updated to v3.0.0. jquery.js:9612 Uncaught TypeError: url.indexOf is not a function Any Idea why?..

How to set shape's opacity?

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

What does if __name__ == "__main__": do?

Given the following code, what does the if __name__ == "__main__": do? # Threading example import time, thread def myfunction(string, sleeptime, lock, *args): while True: lock.acquire() ..

How do I show a "Loading . . . please wait" message in Winforms for a long loading form?

I have a form that is very slow because there are many controls placed on the form. As a result the form takes a long time to loaded. How do I load the form first, then display it and while loadi..

'module' object is not callable - calling method in another file

I have a fair background in java, trying to learn python. I'm running into a problem understanding how to access methods from other classes when they're in different files. I keep getting module obj..

XDocument or XmlDocument

I am now learning XmlDocument but I've just ran into XDocument and when I try to search the difference or benefits of them I can't find something useful, could you please tell me why you would use one..

ggplot legends - change labels, order and title

I'm struggling a great deal to modify the legend in my plot. Here is a reproducible example: dtt <- structure(list(model = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3..

LEFT JOIN only first row

I read many threads about getting only the first row of a left join, but, for some reason, this does not work for me. Here is my structure (simplified of course) Feeds id | title | content -------..

JQuery ajax call default timeout value

I got a bug report that I can't duplicate, but ajax-call timeout is the current best guess. So I'm trying to find out the default value for timeout of a jQuery $.ajax() call. Anybody have an idea? C..

Force update of an Android app when a new version is available

I have an app in Google Play Store. When an update version is available, the older version will become unusable – that is, if users do not update the app, they do not enter in the app. How can I for..

Importing a Maven project into Eclipse from Git

How can I get the effect of choosing to import from both Maven and Git and have Eclipse properly generate my project? To get my project into Eclipse I can choose File->import->maven and then I get a..

How do I copy a string to the clipboard?

I'm trying to make a basic Windows application that builds a string out of user input and then adds it to the clipboard. How do I copy a string to the clipboard using Python?..

For loop in Oracle SQL

I am new to Oracle and I am unaware about using for loop in Oracle SQL (not PL/SQL). I had a requirement to increase the number by +1 in the query and execute the statements; is it possible to use a ..

Getting all files in directory with ajax

Backstory: I am creating a development tool for web development. This tool loads a users webpage into an iframe, this allows the program to resize the iframe and simulate mobile screen sizes. I also w..

Pass row number as variable in excel sheet

Suppose I have: a value of 5 in B1 I want to pass the number (5) in B1 as a row variable, which will be read in conjunction with column A into another cell (say C1) as "=A(B1)" i.e. "=A5" How wou..

Negative matching using grep (match lines that do not contain foo)

I have been trying to work out the syntax for this command: grep ! error_log | find /home/foo/public_html/ -mmin -60 OR: grep '[^error_log]' | find /home/baumerf/public_html/ -mmin -60 I need t..

SDK location not found. Define location with sdk.dir in the file or with an ANDROID_HOME environment variable

I recently tried to import sample Android games I downloaded from Google's developer website. After importing them into Android Studio, I'm getting the following error: Error: SDK location not fou..

Creating a script for a Telnet session?

Does anyone know of an easy way to create a script that can connect to a telnet server, do some usual telnet stuff, and then log off? I am dealing with users who are not familiar with telnet and the ..

How to get the last element of a slice?

What is the Go way for extracting the last element of a slice? var slice []int slice = append(slice, 2) slice = append(slice, 7) slice[len(slice)-1:][0] // Retrieves the last element The solution..

How to discard local commits in Git?

I'd been working on something, and decided it was completely screwed...after having committed some of it. So I tried the following sequence: git reset --hard git rebase origin git fetch git pull git ..

Failed to fetch URL, reason: Connection to refused

Using Android SDK Manager when I try to update it just gives the following messages about not being able to connect. I've tried disabled firewall and anti malware. I also tried to run as admin and m..

Displaying output of a remote command with Ansible

In an Ansible role I generate the user's SSH key. After that I want to print it to the screen and pause so the user can copy and paste it somewhere else. So far I have something like this: - name: Ge..

How do I use HTML as the view engine in Express?

I tried this simple change from the seed and created the corresponding .html files (e.g. index.html). //app.set('view engine', 'jade'); app.set('view engine', 'html'); and this file remained the sa..

How to write data to a text file without overwriting the current data

I can't seem to figure out how to write data to a file without overwriting it. I know I can use File.appendtext but I am not sure how to plug that into my syntax. Here is my code: TextWriter tsw = ne..

How to place div side by side

I have a main wrapper div that is set 100% width. Inside that i would like to have two divs, one that is fixed width and the other that fills the rest of the space. How do i float the second div to fi..

How do I replace multiple spaces with a single space in C#?

How can I replace multiple spaces in a string with only one space in C#? Example: 1 2 3 4 5 would be: 1 2 3 4 5 ..

C: scanf to array

I'm absolutely new to C, and right now I am trying master the basics and have a problem reading data from scanf straight into an array. Right now the code looks like this: int main() { int array..

Get login username in java

How can I get the username/login name in Java? This is the code I have tried... try{ LoginContext lc = new LoginContext(appName,new TextCallbackHandler()); lc.login(); Subject subject = ..

How Connect to remote host from Aptana Studio 3

I am using CODA from a long time .. now i use aptana studio 3 my Question How Connect to remote host from Aptana Studio 3? thanks..

What is fastest children() or find() in jQuery?

To select a child node in jQuery one can use children() but also find(). For example: $(this).children('.foo'); gives the same result as: $(this).find('.foo'); Now, which option is fastest or pr..

@RequestBody and @ResponseBody annotations in Spring

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

Refresh DataGridView when updating data source

What is the best way to refresh a DataGridView when you update an underlying data source? I'm updating the datasource frequently and wanted to display the outcome to the user as it happens. I've got..

Factorial in numpy and scipy

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

React router nav bar example

I am a beginner in React JS and would like to develop a react router based navigation for my Dashboard. The mockup is as follows: My app.js code which I created to try routing is as follows: impor..

How to use adb pull command?

Possible Duplicate: How to copy selected files from Android with adb pull I am using adb pull command like this: adb pull /sdcard/*.trace C:/ but i show me remote object '/sdcard/*.trace..

Easy way to get a test file into JUnit

Can somebody suggest an easy way to get a reference to a file as a String/InputStream/File/etc type object in a junit test class? Obviously I could paste the file (xml in this case) in as a giant Str..

How to determine tables size in Oracle

I use Oracle 11 and want to find out the size of my tables (like in megabytes). What should I do? Should I check the file size on server? Or is there any query to run?..

How do I get the day month and year from a Windows cmd.exe script?

How do I get the current day month and year from inside a Windows cmd script? I need to get each value into a separate variable...

Check if a value exists in ArrayList

How can I check if a value that is written in scanner exists in an ArrayList? List<CurrentAccount> lista = new ArrayList<CurrentAccount>(); CurrentAccount conta1 = new CurrentAccount("Al..

C++ undefined reference to defined function

I cannot figure out why this is not working. I will put up all three of my files and possibly someone can tell me why it is throwing this error. I am using g++ to compile the program. Program: #in..

How to check if type is Boolean

How can I check if a variable's type is of type Boolean? I mean, there are some alternatives such as: if(jQuery.type(new Boolean()) === jQuery.type(variable)) //Do something.. But that doesn..

Vue.js - How to properly watch for nested data

I'm trying to understand how to properly watch for some prop variation. I have a parent component (.vue files) that receive data from an ajax call, put the data inside an object and use it to render ..

Expand Python Search Path to Other Source

I have just joined a project with a rather large existing code base. We develop in linux and do not use and IDE. We run through the command line. I'm trying to figure out how to get python to search f..

How to Insert Double or Single Quotes

I have a long list of names that I need to have quotes around (it can be double or single quotes) and I have about 8,000 of them. I have them in Excel without any quotes and I can copy all of the name..

RESTful URL design for search

I'm looking for a reasonable way to represent searches as a RESTful URLs. The setup: I have two models, Cars and Garages, where Cars can be in Garages. So my urls look like: /car/xxxx xxx == car i..

When should use Readonly and Get only properties

In a .NET application when should I use "ReadOnly" properties and when should I use just "Get". What is the difference between these two. private readonly double Fuel= 0; public double FuelConsumpti..

how to check if the input is a number or not in C?

In the main function of C: void main(int argc, char **argv) { // do something here } In the command line, we will type any number for example 1 or 2 as input, but it will be treated as char arra..

How to build and run Maven projects after importing into Eclipse IDE

I am learning building a Java project in Eclipse using Maven. I created a Java project HelloWorld from “maven-archetype-quickstart” template in a folder D:/maven_projects. Then to convert the Mave..

What does "wrong number of arguments (1 for 0)" mean in Ruby?

What does "Argument Error: wrong number of arguments (1 for 0)" mean?..

Immutable array in Java

Is there an immutable alternative to the primitive arrays in Java? Making a primitive array final doesn't actually prevent one from doing something like final int[] array = new int[] {0, 1, 2, 3}; ar..

regex with space and letters only?

I made a regular expression that only accepts letters. I'm not really good in regex, thats why I don't know how to include spaces in my regex. My HTML: <input id="input" /> My js / jQuery c..

Get startup type of Windows service using PowerShell

How can I get the Windows service startup type using PowerShell and not using WMI? I looked inside the Get-Service command, and it does not provide something to display the "startup type"...

Define variable to use with IN operator (T-SQL)

I have a Transact-SQL query that uses the IN operator. Something like this: select * from myTable where myColumn in (1,2,3,4) Is there a way to define a variable to hold the entire list "(1,2,3,4)"..

Sequence contains no elements?

I'm currently using a single query in two places to get a row from a database. BlogPost post = (from p in dc.BlogPosts where p.BlogPostID == ID select p).Single(); ..

How to add property to object in PHP >= 5.3 strict mode without generating error

This has to be simple, but I can't seem to find an answer.... I have a generic stdClass object $foo with no properties. I want to add a new property $bar to it that's not already defined. If I do th..

When should I use UNSIGNED and SIGNED INT in MySQL?

When should I use UNSIGNED and SIGNED INT in MySQL ? What is better to use or this is just personal prefernce ? Because I've seen it used like this; id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT and..

Multiple commands in an alias for bash

I'd like to define an alias that runs the following two commands consecutively. gnome-screensaver gnome-screensaver-command --lock Right now I've added alias lock='gnome-screensaver-command --loc..

Python - round up to the nearest ten

If I get the number 46 and I want to round up to the nearest ten. How do can I do this in python? 46 goes to 50...

List View Filter Android

I have created a list view in android and I want to add edit text above the list and when the user enter text the list will be filtered according to user input can anyone tell me please if there is a..

Javascript onclick hide div

I want to hide this warning div using javascript inside it. I'm i getting the javascript right? I want to hide/close the div when i click on the close icon (images/close_icon.gif) <div> <..

Output (echo/print) everything from a PHP Array

Is it possible to echo or print the entire contents of an array without specifying which part of the array? The scenario: I am trying to echo everything from: while($row = mysql_fetch_array($result)..

Removing viewcontrollers from navigation stack

I have a navigation stack, with say 5 UIViewControllers. I want to remove the 3rd and 4th viewcontrollers in the stack on the click of a button in the 5th viewcontroller. Is it possible to do this? If..

Add leading zeroes/0's to existing Excel values to certain length

There are many, many questions and quality answers on SO regarding how to prevent leading zeroes from getting stripped when importing to or exporting from Excel. However, I already have a spreadsheet..

Accessing Session Using ASP.NET Web API

I realize session and REST don't exactly go hand in hand but is it not possible to access session state using the new Web API? HttpContext.Current.Session is always null...

Is there a good reason I see VARCHAR(255) used so often (as opposed to another length)?

In multiple courses, books, and jobs, I have seen text fields defined as VARCHAR(255) as kind of the default for "shortish" text. Is there any good reason that a length of 255 is chosen so often, oth..

How to make bootstrap column height to 100% row height?

I haven't found a suitable solution to this and it seems so trivial. I have two columns inside a row: <div class="row"> <div class="col-xs-9"> <div class="left-side"> &..

Sequelize.js delete query?

Is there a way to write a delete/deleteAll query like findAll? For example I want to do something like this (assuming MyModel is a Sequelize model...): MyModel.deleteAll({ where: ['some_field != ?',..

How to program a fractal?

I do not have any experience with programming fractals. Of course I've seen the famous Mandelbrot images and such. Can you provide me with simple algorithms for fractals. Programming language doesn'..

What is VanillaJS?

I have one simple question, that got stuck in my mind for a few days: What is VanillaJS? Some people refer to it as a framework, you can download a library from the official pages. But when I check s..

Query to check index on a table

I need a query to see if a table already has any indexes on it...

Python - Module Not Found

I am a beginner with Python. Before I start, here's my Python folder structure -project ----src ------model Under src I have a folder named model which has a P..

Reading images in python

I am trying to read a png image in python. The imread function in scipy is being deprecated and they recommend using imageio library. However, I am would rather restrict my usage of external librarie.. the system cannot find the file specified

I have a file named "word.txt". It is in the same directory as my java file. But when I try to access it in the following code this file not found error occurs: Exception in thread "main"

C++ trying to swap values in a vector

This is my swap function: template <typename t> void swap (t& x, t& y) { t temp = x; x = y; y = temp; return; } And this is my function (on a side note v stores string..

Finding diff between current and last version

Using Git, how can you find the difference between the current and the last version? git diff last version:HEAD ..

Add property to an array of objects

I have an array of objects as shown below Object {Results:Array[2]} Results:Array[2] [0-1] 0:Object id=1 name: "Rick" 1:Object id=2 name:'david' I want to..

Postgresql Select rows where column = array

This is a summary of what I am trying to do: $array[0] = 1; $array[1] = 2; $sql = "SELECT * FROM table WHERE some_id = $array" Obviously, there are some syntax issues, but this is what I want to d..

Cannot find java. Please use the --jdkhome switch

I have just installed Netbeans 8.0.2 on CentOS 6.5. When I try to run it, I get the message Cannot find java. Please use the --jdkhome switch I have /usr/share/java-1.7.0 so I typed /usr/local/n..

How to show an empty view with a RecyclerView?

I am used to put an special view inside the layout file as described in the ListActivity documentation to be displayed when there is no data. This view has the id "android:id/empty". <TextView ..

How to run single test method with phpunit?

I am struggling to run a single test method named testSaveAndDrop in the file escalation/EscalationGroupTest.php with phpunit. I tried the following combinations: phpunit EscalationGroupTest escalat..

How can I tell gcc not to inline a function?

Say I have this small function in a source file static void foo() {} and I build an optimized version of my binary yet I don't want this function inlined (for optimization purposes). is there a mac..

How do I copy a version of a single file from one git branch to another?

I've got two branches that are fully merged together. However, after the merge is done, I realise that one file has been messed up by the merge (someone else did an auto-format, gah), and it would ju..

Deleting elements from std::set while iterating

I need to go through a set and remove elements that meet a predefined criteria. This is the test code I wrote: #include <set> #include <algorithm> void printElement(int value) { std..

android pinch zoom

My layout contains buttons, textviews, etc. Is it possible to implement pinch zoom in my layout?..

Error in Python script "Expected 2D array, got 1D array instead:"?

I'm following this tutorial to make this ML prediction: import numpy as np import matplotlib.pyplot as plt from matplotlib import style style.use("ggplot") from sklearn import svm x = [1, 5, 1.5, 8..

dereferencing pointer to incomplete type

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

How to get first/top row of the table in Sqlite via Sql Query

I need to fetch the first/top row of a table in a Sqlite database. But my program throws an SQLException "Sqlite Syntax Error: Syntax error near '1' " for the query that I am using: SELECT TOP 1 * ..

What is the difference between a string and a byte string?

I am working with a library which returns a byte string and I need to convert this to a string. Although I'm not sure what the difference is - if any. ..

Wait until all jQuery Ajax requests are done?

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

fail to change placeholder color with Bootstrap 3

Two questions: I am trying to make the placeholder text white. But it doesn't work. I am using Bootstrap 3. JSFiddle demo Another question is how do I change placeholder color not globally. That is,..

How can I change Mac OS's default Java VM returned from /usr/libexec/java_home

(Wasn't sure if this should go on SU... migration is certainly an option, but more programmers read questions here, so here goes). I am running Mac OS X 10.8.4, and I have Apple's JDK 1.6.0_51 instal..

Best Timer for using in a Windows service

I need to create some windows service which will execute every N period of time. The question is: Which timer control should I use: System.Timers.Timer or System.Threading.Timer one? Does it influence..

How to checkout in Git by date?

I am working on a regression in the source code. I'd like to tell Git: "checkout the source based on a parameterized date/time". Is this possible? I also have staged changes in my current view tha..

jinja2.exceptions.TemplateNotFound error

i use flask and i got this error when i call this url: /login Here's my login method: @app.route('/login') def login(): if authenticateForPanel(): return redirect(url_for("panel")) e..

Why is the <center> tag deprecated in HTML?

I am just curious as to why the <center> tag in HTML was deprecated. The <center> was a simple way of quickly center-aligning blocks of text and images by encapsulating the container in a..

How can I close a dropdown on click outside?

I would like to close my login menu dropdown when the user click anywhere outside of that dropdown, and I'd like to do that with Angular2 and with the Angular2 "approach"... I have implemented a solu..

Gray out image with CSS?

What's the best way (if any) to make an image appear "grayed out" with CSS (i.e., without loading a separate, grayed out version of the image)? My context is that I have rows in a table that all have..

Python error: AttributeError: 'module' object has no attribute

I'm totally new to Python and I know this question was asked many times, but unfortunately it seems that my situation is a bit different... I have created a package (or so I think). The catalog tree i..

How to find files that match a wildcard string in Java?

This should be really simple. If I have a String like this: ../Test?/sample*.txt then what is a generally-accepted way to get a list of files that match this pattern? (e.g. it should match ../Test1..

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

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

How can I escape a double quote inside double quotes?

How can I escape double quotes inside a double string in Bash? For example, in my shell script #!/bin/bash dbload="load data local infile \"'gfpoint.csv'\" into table $dbtable FIELDS TERMINATED BY ..

Best way to select random rows PostgreSQL

I want a random selection of rows in PostgreSQL, I tried this: select * from table where random() < 0.01; But some other recommend this: select * from table order by random() limit 1000; I ha..

WCF service maxReceivedMessageSize basicHttpBinding issue

I can't seem to get my WCF service to accept large amounts of data being sent up to it. I configured the maxReceivedMessageSize for the client and could receive large data down just fine, that's no..

Using the value in a cell as a cell reference in a formula?

I'd like to know how to pull cell references from the value of another cell and insert them into a formula. For a simple example: In cell A1 I have this: COUNT(B4:H4) Instead of choosing the range ..

What is the iOS 6 user agent string?

What is the iOS 6.0 user agent string? Previous user-agent strings: iOS 5.1 - What is the iOS 5.1 user agent string? iOS 5.0 - What is the iOS 5.0 user agent string? iOS 4.0 - What is the iPhone ..

How can I calculate an md5 checksum of a directory?

I need to calculate a summary md5 checksum for all files of a particular type (*.py for example) placed under a directory and all sub-directories. What is the best way to do that? Edit: The proposed..

Why does ENOENT mean "No such file or directory"?

What does the ENT mean in ENOENT? Shouldn't the error: No such file or directory just be named by ENOFILE? Is there any story or reason?..

How to remove first and last character of a string?

I have worked in SOAP message to get LoginToken from Webservice, and store the LoginToken in String and used System.out.println(LoginToken); to print. This prints [wdsd34svdf], but I want only wdsd34s..

file_get_contents(): SSL operation failed with code 1, Failed to enable crypto

I’ve been trying to access this particular REST service from a PHP page I’ve created on our server. I narrowed the problem down to these two lines. So my PHP page looks like this: <?php $res..

Serializing an object as UTF-8 XML in .NET

Proper object disposal removed for brevity but I'm shocked if this is the simplest way to encode an object as UTF-8 in memory. There has to be an easier way doesn't there? var serializer = new XmlSer..

What is the syntax to insert one list into another list in python?

Given two lists: x = [1,2,3] y = [4,5,6] What is the syntax to: Insert x into y such that y now looks like [1, 2, 3, [4, 5, 6]]? Insert all the items of x into y such that y now looks like [1, 2,..

DatabaseError: current transaction is aborted, commands ignored until end of transaction block?

I got a lot of errors with the message : "DatabaseError: current transaction is aborted, commands ignored until end of transaction block" after changed from python-psycopg to python-psycopg2 as Dja..

Getting the class name from a static method in Java

How can one get the name of the class from a static method in that class. For example public class MyClass { public static String getClassName() { String name = ????; // what goes here so..

How to filter an array/object by checking multiple values

I'm playing around with arrays trying to understand them more since I tend to work with them alot lately. I got this case where I want to search an array and compare it's element values to another arr..

How to import JSON File into a TypeScript file?

I am building a map application using Angular Maps and want to import a JSON file as a list of markers defining locations. I'm hoping to use this JSON file as marker[] array inside the app.component.t..

Default fetch type for one-to-one, many-to-one and one-to-many in Hibernate

What is the default fetch type in hibernate mappings? What I got to know after exploring is: for one-to-one it is eager. for one-to-many it is lazy. But after testing it in Eclipse, it was eager ..

Public free web services for testing soap client

Are there any publicly available SOAP 1.2/WSDL 2.0 compliant free web services for testing a Python based soap client library (e.g. Zolera SOAP Infrastructure)? So far, it appears to me that Google ..

MySQL Creating tables with Foreign Keys giving errno: 150

I am trying to create a table in MySQL with two foreign keys, which reference the primary keys in 2 other tables, but I am getting an errno: 150 error and it will not create the table. Here is the SQ..

Executing a stored procedure within a stored procedure

I would like to execute a stored procedure within a stored procedure, e.g. EXEC SP1 BEGIN EXEC SP2 END But I only want SP1 to finish after SP2 has finished running so I need to find a way for SP..

Text overflow ellipsis on two lines

I know you can use a combination of CSS rules to make text end with ellipsis (...) when it's time to overflow (get out of parent's bounds). Is it possible (feel free to just say, no) to achieve the s..

Display HTML form values in same page after submit using Ajax

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

Dictionary with list of strings as value

I have a dictionary where my value is a List. When I add keys, if the key exists I want to add another string to the value (List)? If the key doesn't exist then I create a new entry with a new list wi..

Put icon inside input element in a form

How do I put an icon inside a form's input element? Live version at: Tidal Force theme..

Making a <button> that's a link in HTML

Basically, I like the way that <input type="submit"> is styled, with the clickable button when you add a little CSS. However, regular buttons are not styled as such, they have no such clickabili..

Sorting options elements alphabetically using jQuery

I'm trying to understand sorting option elements within a select element alphabetically. Ideally, I'd like to have this as a separate function where I can just pass in the select element since it need..

Is it possible to write to the console in colour in .NET?

Writing a small command line tool, it would be nice to output in different colours. Is this possible?..

Peak memory usage of a linux/unix process

Is there a tool that will run a command-line and report the peak RAM usage total? I'm imagining something analogous to /usr/bin/time..

Alternate table with new not null Column in existing table in SQL

How to add not null Column in existing table in SQL Server 2005?..

Best way to do a split pane in HTML

Is there a good technique to make a resizable split pane in HTML? May it be done using CSS / jQuery / JavaScript or is there a good JavaScript library that have been used? (An example of a split pane ..

How do you access the element HTML from within an Angular attribute directive?

The Angular docs provide an example for creating an attribute directive that changes the background color of an element: <p myHig..

Thread-safe List<T> property

I want an implementation of List<T> as a property which can be used thread-safely without any doubt. Something like this: private List<T> _list; private List<T> MyT { get { //..

Disable/Enable button in Excel/VBA

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

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

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

Changing the background color of a drop down list transparent in html

I'm trying to change the background color of a drop down list in HTML to transparent. HTML <select id="nname"> <option value="volvo">Volvo</option> <option value="saab">S..

How to prevent column break within an element?

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

Spring MVC: difference between <context:component-scan> and <annotation-driven /> tags?

Some days ago I began to study this Spring Hello World Tutorial: In this tutorial Spring DispatcherServlet is con..

How to Create a script via batch file that will uninstall a program if it was installed on windows 7 64-bit or 32-bit

I am in a small bind. The program in question can be installed in the program files directory (64bit) or X86 path. The program is already installed in over 200 machines. I am fairly certain the defaul..

Accessing a property in a parent Component

I have a property in a top level Component that is used data from a HTTP source like so (this is in a file called app.ts): import {UserData} from './services/user-data/UserData'; Component({ sel..

Matching a space in regex

I need to match a space character in a PHP regular expression. Anyone got any ideas? I mean like "gavin schulz", the space in between the two words. I am using a regular expression to make sure that ..

H2 in-memory database. Table not found

I've got a H2 database with URL "jdbc:h2:test". I create a table using CREATE TABLE PERSON (ID INT PRIMARY KEY, FIRSTNAME VARCHAR(64), LASTNAME VARCHAR(64));. I then select everything from this (empty..

Importing the private-key/public-certificate pair in the Java KeyStore

I used the following steps to create a new Java keystore with a pair of private/public key to be used by a Java (internal) server with TLS. Please notice that the certificate is selfsigned: 1) Genera..

How do I count occurrence of duplicate items in array

I would like to count the occurrence of each duplicate item in an array and end up with an array of only unique/non duplicate items with their respective occurrences. Here is my code; BUT I don't whe..

how do I join two lists using linq or lambda expressions

I have two lists List<WorkOrder> and List<PlannedWork> I would like join the two lists on the workorder number as detailed below. In other words I have a list of planned work but I need to..

How to put space character into a string name in XML?

i have defined some strings in the strings.xml file. Now I need to put some extra space between some numbers in the string. When I type extra space characters this is not showing on the application th..

How to select top n rows from a datatable/dataview in ASP.NET

How to the select top n rows from a datatable/dataview in ASP.NET? Currently I am using the following code, passing the table and number of rows to get the records. Is there a better way? public Data..

Center image in table td in CSS

I've been trying to align an image to the center of the table td. It worked with setting margin-left to a specific value but it also increased the size of td too and that isn't exactly what I wanted ..

How to simplify a null-safe compareTo() implementation?

I'm implementing compareTo() method for a simple class such as this (to be able to use Collections.sort() and other goodies offered by the Java platform): public class Metadata implements Comparable&..

Generating random whole numbers in JavaScript in a specific range?

How can I generate random whole numbers between two specified variables in JavaScript, e.g. x = 4 and y = 8 would output any of 4, 5, 6, 7, 8?..

How to get a value of an element by name instead of ID

How could I get the value of an element via the attribute name instead of the ID. eg if I use by id it would be $('#id').val();..

How to print in C

Very much a beginner to C, in fact this is my first tester program. I can't actually figure out how to print this number out to the terminal. #include <stdio.h> int addNumbers(int a, int b) { ..

When saving, how can you check if a field has changed?

In my model I have : class Alias(MyBaseModel): remote_image = models.URLField(max_length=500, null=True, help_text="A URL that is downloaded and cached for the image. Only used when the alias is..

Check folder size in Bash

I'm trying to write a script that will calculate a directory size and if the size is less than 10GB, and greater then 2GB do some action. Where do I need to mention my folder name? # 10GB SIZE="1074..

Open and write data to text file using Bash?

How can I write data to a text file automatically by shell scripting in Linux? I was able to open the file. However, I don't know how to write data to it...

How to get first two characters of a string in oracle query?

Suppose I have a column name OrderNo with value AO025631 in a table shipment. I am trying to query the table so that I can get only first two character of column value i.e. AO. Can I do this in the ..

Add content to a new open window

I don't know how to solve this issue, I've trying reading many post but no one answer to it. I need to open a new window with a page already coded (inside the same domain) and add some content. The ..

Service located in another namespace

I have been trying to find a way to define a service in one namespace that links to a Pod running in another namespace. I know that containers in a Pod running in namespaceA can access serviceX defin..

How to create a MySQL hierarchical recursive query?

I have a MySQL table which is as follows: id name parent_id 19 category1 0 20 category2 19 21 category3 20 22 category4 21 ... ... ... Now, I want to have a single MySQL query to w..

Styling a disabled input with css only

I have sort of a strange situation. I'm trying to style a disabled input button because I have an annoying hover turning the text to white. This makes it confusing to the user because its acting like..

Exception: Unexpected end of ZLIB input stream

There is something wrong with GZIPInputStream or GZIPOutputStream. Just please read the following code (or run it and see what happens): def main(a: Array[String]) { val name = "test.dat" new..

React eslint error missing in props validation

I have the next code, eslint throw: react/prop-types onClickOut; is missing in props validation react/prop-types children; is missing in props validation propTypes was defined but eslint does not re..

Create session factory in Hibernate 4

I'm having trouble generating a session factory in Hibernate 4. In Hibernate 3 I simple did: org.hibernate.cfg.Configuration conf= HibernateUtil .getLimsInitializedConfiguration(systemConfigurati..

Anaconda vs. miniconda

In the Anaconda repository, there are two types of installers: "Anaconda installers" and "Miniconda installers". What are their differences? Besides, for an installer file, Anaconda2-

What's the difference between a web site and a web application?

I'm stumped trying to come up to a difference between a website and a web application for myself. As I see it, a web site points to a specific page and a web application is more of some sort of 'porta..

How to get an MD5 checksum in PowerShell

I would like to calculate an MD5 checksum of some content. How do I do this in PowerShell?..

Python Array with String Indices

Is it possible to use strings as indices in an array in python? For example: myArray = [] myArray["john"] = "johns value" myArray["jeff"] = "jeffs value" print myArray["john"] ..

Map a 2D array onto a 1D array

I want to represent a 2D array with a 1D array. A function will pass the two indicies (x,y) and the value to store. These two indicies would represent a single element of a 1D array, and set it accord..

How do I set a background-color for the width of text, not the width of the entire element, using CSS?

What I want is for the green background to be just behind the text, not to be 100% of the page width. Here is my current code: _x000D_ _x000D_ h1 { _x000D_ text-align: center; _x000D_ backgro..

How can I check that JButton is pressed? If the isEnable() is not work?

How can I check that JButton is pressed? I know that there is a method that its name is "isEnabled" So I try to write a code to test. this code have 2 Jbuttons which are "Add" Button and "Checkout"..

The module ".dll" was loaded but the entry-point was not found

I have a DLL which cause to an error when I run the application. The error says that the service is not registered. So I run command regsvr32 with the name of the DLL. But it gives me an error, now th..

How can I combine multiple nested Substitute functions in Excel?

I am trying to set up a function to reformat a string that will later be concatenated. An example string would look like this: Standard_H2_W1_Launch_123x456_S_40K_AB Though sometimes the "S" doesn'..

Enter key in textarea

I have a textarea, On every Enter key pressed in textarea I want new line to be started with a bullet say (*). How to go about it ? No jQuery please. I can observe for the Enter key , after that !?..

SyntaxError: import declarations may only appear at top level of a module

I am trying to use a plugin called "Simplebar" found on GitHub, GitHub SimpleBar but after downloading the scripts and looking at the simple.js script, it looks like it has an error "SyntaxError: impo..

$(this).val() not working to get text from span using jquery

Giving this html, i want to grab "August" from it when i click on it: <span class="ui-datepicker-month">August</span> i tried $(".ui-datepicker-month").live("click", function () { ..

What is the equivalent of the C# 'var' keyword in Java?

One use of the var keyword in C# is implicit type declaration. What is the Java equivalent syntax for var?..

taking input of a string word by word

I just started learning C++. I was just playing around with it and came across a problem which involved taking input of a string word by word, each word separated by a whitespace. What I mean is, supp..

How to list only the file names that changed between two commits?

I have a bunch of commits in the repo. I want to see a list of files changed between two commits - from SHA1 to SHA2. What command should I use? ..

Why does C++ code for testing the Collatz conjecture run faster than hand-written assembly?

I wrote these two solutions for Project Euler Q14, in assembly and in C++. They implement identical brute force approach for testing the Collatz conjecture. The assembly solution was assembled with: n..

How can I create basic timestamps or dates? (Python 3.4)

As a beginner, creating timestamps or formatted dates ended up being a little more of a challenge than I would have expected. What are some basic examples for reference?..

How to make a radio button look like a toggle button

I want a group of radio buttons to look like a group of toggle buttons (but still function like radio buttons). It's not necessary that they look exactly like toggle buttons. How can I do this only w..

Bootstrap 3 dropdown select

We are trying re-implement our sign-up form with bootstrap. Our sign up form contains a drop-down list which represents a company type. I have searched extensively online but I do not see any example ..

How to copy directories in OS X 10.7.3?

Hi I'm trying to copy my rails_projects directory from haseebjaved/Desktop/rails_projects to my home directory, which is haseebjaved. How can I do this via the Command Line? Also, can I see my home ..

Get an element by index in jQuery

I have an unordered list and the index of an li tag in that list. I have to get the li element by using that index and change its background color. Is this possible without looping the entire list? I ..

how to add jquery in laravel project

I am new to laravel framework. I want to use jQuery in web application built using laravel framework. But don't know how to link to jQuery library in laravel project...

vertical-align: middle doesn't work

The css property vertical-align: middle does not work in this example. HTML: <div> <span class='twoline'>Two line text</span> <span class='float'> Float right </span..