Examples On Programing Languages

Print content of JavaScript object?

Typically if we just use alert(object); it will show as [object Object]. How to print all the content parameters of an object in JavaScript?...

Find all paths between two graph nodes

I am working on an implemtation of Dijkstras Algorithm to retrieve the shortest path between interconnected nodes on a network of routes. I have the implentation working. It returns all the shortest paths to all the nodes when I pass the start node i...

Install an apk file from command prompt?

I want to install a file using the Windows command line. First I want to build after compiling all the .jar files to create an .apk file for an Android application without using Eclipse. Does anyone know how this can be done without the use of Eclip...

Connecting to Postgresql in a docker container from outside

I have Postgresql on a server in a docker container. How can I connect to it from the outside, that is, from my local computer? What setting should I apply to allow that?...

Exception: Can't bind to 'ngFor' since it isn't a known native property

What am I doing wrong? import {bootstrap, Component} from 'angular2/angular2' @Component({ selector: 'conf-talks', template: `<div *ngFor="talk of talks"> {{talk.title}} by {{talk.speaker}} <p>{{talk.description}} </...

Change column type in pandas

I want to convert a table, represented as a list of lists, into a Pandas DataFrame. As an extremely simplified example: a = [['a', '1.2', '4.2'], ['b', '70', '0.03'], ['x', '5', '0']] df = pd.DataFrame(a) What is the best way to convert the column...

Change Project Namespace in Visual Studio

How can I change the project namespace in Visual Studio? The namespace is currently WindowsFormsApplication16, and I want the namespace to be MyName....

Unable to connect to SQL Server instance remotely

I’m trying to access the SQL Server instance on my VPS from SQL Server Management Studio on my local machine. It’s not working (the error I’m getting is: A network-related or instance-specific error occurred while establishing a connectio...

Nested ifelse statement

I'm still learning how to translate a SAS code into R and I get warnings. I need to understand where I'm making mistakes. What I want to do is create a variable which summarizes and differentiates 3 status of a population: mainland, overseas, foreign...

How to send a stacktrace to log4j?

Say you catch an exception and get the following on the standard output (like, say, the console) if you do a e.printStackTrace() : java.io.FileNotFoundException: so.txt at java.io.FileInputStream.<init>(FileInputStream.java) at...

Best way to concatenate List of String objects?

What is the best way to concatenate a list of String objects? I am thinking of doing this way: List<String> sList = new ArrayList<String>(); // add elements if (sList != null) { String listString = sList.toString(); listString ...

MySQL: Insert datetime into other datetime field

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

How to send FormData objects with Ajax-requests in jQuery?

The XMLHttpRequest Level 2 standard (still a working draft) defines the FormData interface. This interface enables appending File objects to XHR-requests (Ajax-requests). Btw, this is a new feature - in the past, the "hidden-iframe-trick" was used (...

Angular 4 setting selected option in Dropdown

several questions about this and diffrent answeres. But none of them realy answeres the question. So again: Setting default of a Dropdown select by value isnt working in my case. why? This is from the dynamic Form tutorial of Angular 4: <select ...

POST data in JSON format

I have some data that I need to convert to JSON format and then POST it with a JavaScript function. <body onload="javascript:document.myform.submit()"> <form action="https://www.test.net/Services/RegistrationService.svc/InviteNewContact" me...

How to make external HTTP requests with Node.js

The question is fairly simple. I want to use a Node.js server as a proxy to log, authenticate, and forward HTTP queries to a backend HTTP server (PUT, GET, and DELETE requests). What library should I use for that purpose? I'm afraid I can't find one...

Change URL without refresh the page

I would like to replace an url without page refresh. I need to change: https://example.com/en/step1 to https://example.com/en/step2 How to do that ?...

Inline list initialization in VB.NET

Possible Duplicate: Collection initialization syntax in Visual Basic 2008? How is the following C# code translated to VB.NET? var theVar = new List<string>{"one", "two", "three"}; ...

Programmatically open new pages on Tabs

I'm trying to "force" Safari or IE7 to open a new page using a new tab. Programmatically I mean something like: window.open('page.html','newtaborsomething'); ...

jQuery get the location of an element relative to window

Given an HTML DOM ID, how to get an element's position relative to the window in JavaScript/JQuery? This is not the same as relative to the document nor offset parent since the element may be inside an iframe or some other elements. I need to get t...

Get the device width in javascript

Is there a way to get the users device width, as opposed to viewport width, using javascript? CSS media queries offer this, as I can say @media screen and (max-width:640px) { /* ... */ } and @media screen and (max-device-width:960px) { ...

What exactly do "u" and "r" string flags do, and what are raw string literals?

While asking this question, I realized I didn't know much about raw strings. For somebody claiming to be a Django trainer, this sucks. I know what an encoding is, and I know what u'' alone does since I get what is Unicode. But what does r'' do exa...

SQL query to select dates between two dates

I have a start_date and end_date. I want to get the list of dates in between these two dates. Can anyone help me pointing the mistake in my query. select Date,TotalAllowance from Calculation where EmployeeId=1 and Date between 2011/02/25 and 201...

JWT (JSON Web Token) library for Java

I am working on a web application developed using Java and AngularJS and chose to implement token authentication and authorization. For the exercise purpose, I've come to the point where I send the credentials to the server, generate a random token s...

Find if current time falls in a time range

Using .NET 3.5 I want to determine if the current time falls in a time range. So far I have the currentime: DateTime currentTime = new DateTime(); currentTime.TimeOfDay; I'm blanking out on how to get the time range converted and compared. Would...

How to find the mime type of a file in python?

Let's say you want to save a bunch of files somewhere, for instance in BLOBs. Let's say you want to dish these files out via a web page and have the client automatically open the correct application/viewer. Assumption: The browser figures out which ...

How do I view an older version of an SVN file?

I have an SVN file which is now missing some logic and so I need to go back about 40 revisions to the time when it had the logic I need. Other than trying to view a diff of the file in the command line (very hard to read), is there any way I could ge...

Live Video Streaming with PHP

I have a PHP/AJAX/MYSQL chat application. I want to add video chatting to my application. How can I create live video streaming to be used for live video conferences/chatting in a PHP application. What are the key-terms I need to know if I wanted to ...

Mysql service is missing

I have installed Mysql server locally and everything was working Ok but today when I tried to get a connection to the local db, I got an error. After checking services showed that the MySql service is missing... What can the problem be? Thanks in a...

TypeScript: casting HTMLElement

Does anyone know how to cast in TypeScript? I'm trying to do this: var script:HTMLScriptElement = document.getElementsByName("script")[0]; alert(script.type); but it's giving me an error: Cannot convert 'Node' to 'HTMLScriptElement': Type 'Node'...

What does `unsigned` in MySQL mean and when to use it?

What does "unsigned" mean in MySQL and when should I use it?...

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 Change Font Size in drawString Java

How to make the font size bigger in g.drawString("Hello World",10,10); ?...

Where to find "Microsoft.VisualStudio.TestTools.UnitTesting" missing dll?

I am getting following error in my C# visual studio project: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) I also tried to find the microsoft.dll file but couldn't...

Waiting until the task finishes

How could I make my code wait until the task in DispatchQueue finishes? Does it need any CompletionHandler or something? func myFunction() { var a: Int? DispatchQueue.main.async { var b: Int = 3 a = b } // wait unti...

Vue.JS: How to call function after page loaded?

I have got next Vue component. Login as calling Login function. checkAuth -- is calling checking Authorization status between page refresh. But how I can call checkAuth without pushing on button? var GuestMenu = Vue.extend({ props: ['username', '...

Removing duplicate objects with Underscore for Javascript

I have this kind of array: var foo = [ { "a" : "1" }, { "b" : "2" }, { "a" : "1" } ]; I'd like to filter it to have: var bar = [ { "a" : "1" }, { "b" : "2" }]; I tried using _.uniq, but I guess because { "a" : "1" } is not equal to itself, it d...

Is there any way to call a function periodically in JavaScript?

Is there any way to call a function periodically in JavaScript?...

Is there a code obfuscator for PHP?

Has anybody used a good obfuscator for PHP? I've tried some but they don't work for very big projects. They can't handle variables that are included in one file and used in another, for instance. Or do you have any other tricks for stopping the spre...

Escape dot in a regex range

For some reason those two regex act the same way: "43\\gf..--.65".replace(/[^\d.-]/g, "");? // 43..--.65 "43\\gf..--.65".replace(/[^\d\.-]/g, "");? // 43..--.65 Demo In the first regex I don't escape the dot(.) while in the second regex I do(\....

How to check that a JCheckBox is checked?

How can I check if a JCheckBox is checked?...

How to check for a JSON response using RSpec?

I have the following code in my controller: format.json { render :json => { :flashcard => @flashcard, :lesson => @lesson, :success => true } In my RSpec controller test I want to verify that a certain ...

How to reset par(mfrow) in R

I set par(mfrow =c(1,2)) and now everytime I plot it shows splits it into 2 plots. How can I reset this to only show one plot. Thanks so much....

Load arrayList data into JTable

I'm trying to set items from a method called FootballClub and so far it's fine. but then I created an arrayList from it and I somehow can't find a way to store this information into a JTable. The problem is that i cant find a way to set a fixed numbe...

SeekBar and media player in android

I have a simple player and recorder. Everything works great but have a one problem. I want to add seek bar to see progress in playing record and use this seek bar to set place from player should play. I have onProgress but with no effect. This is co...

How to clear all input fields in a specific div with jQuery?

I am trying to use jQuery to do a simple thing: clear the input fields of a group of input field within a div whenever the form loads, or if the user changes a picklist; but I'm having a devil of a time getting the selector to work. First, here's m...

What is the equivalent of 'describe table' in SQL Server?

I have a SQL Server database and I want to know what columns and types it has. I'd prefer to do this through a query rather than using a GUI like Enterprise Manager. Is there a way to do this?...

How do I convert a IPython Notebook into a Python file via commandline?

I'm looking at using the *.ipynb files as the source of truth and programmatically 'compiling' them into .py files for scheduled jobs/tasks. The only way I understand to do this is via the GUI. Is there a way to do it via command line?...

What’s the difference between Response.Write() andResponse.Output.Write()?

Possible Duplicate: What’s the difference between Response.Write() and Response.Output.Write()? How is it different from response.write() and response.output.write()? Please explain....

How to change text transparency in HTML/CSS?

I'm very new to HTML/CSS and I'm trying to display some text as like 50% transparent. So far I have the HTML to display the text with full opacity <html><font color=\"black\" face=\"arial\" size=\"4\">THIS IS MY TEXT</font></ht...

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

Android failed to load JS bundle

I'm trying to run AwesomeProject on my Nexus5 (android 5.1.1). I'm able to build the project and install it on the device. But when I run it, I got a red screen saying Unable to download JS bundle. Did you forget to start the development server or c...

git diff between two different files

In HEAD (the latest commit), I have a file named foo. In my current working tree, I renamed it to bar, and also edited it. I want to git diff foo in HEAD, and bar in my current working tree....

Get encoding of a file in Windows

This isn't really a programming question, is there a command line or Windows tool (Windows 7) to get the current encoding of a text file? Sure I can write a little C# app but I wanted to know if there is something already built in?...

How do I revert a Git repository to a previous commit?

How do I revert from my current state to a snapshot made on a certain commit? If I do git log, then I get the following output: $ git log commit a867b4af366350be2e7c21b8de9cc6504678a61b` Author: Me <[email protected]> Date: Thu Nov 4 18:59:41 2010 ...

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

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

jQuery.click() vs onClick

I have a huge jQuery application, and I'm using the below two methods for click events. First method HTML <div id="myDiv">Some Content</div> jQuery $('#myDiv').click(function(){ //Some code }); Second method HTML <div id=...

AmazonS3 putObject with InputStream length example

I am uploading a file to S3 using Java - this is what I got so far: AmazonS3 s3 = new AmazonS3Client(new BasicAWSCredentials("XX","YY")); List<Bucket> buckets = s3.listBuckets(); s3.putObject(new PutObjectRequest(buckets.get(0).getName(), fi...

ASP.Net which user account running Web Service on IIS 7?

I want to know which account running my Web Service/Application so that I can assign the read/write access to that account. I have researched and see most of the sources mentions about ASPNET account, but on my 2008 server, there is not any acount na...

Use dynamic variable names in JavaScript

In PHP you can do amazing/horrendous things like this: $a = 1; $b = 2; $c = 3; $name = 'a'; echo $$name; // prints 1 Is there any way of doing something like this with Javascript? E.g. if I have a var name = 'the name of the variable'; can I get ...

Disable/enable an input with jQuery?

$input.disabled = true; or $input.disabled = "disabled"; Which is the standard way? And, conversely, how do you enable a disabled input?...

How can I count the rows with data in an Excel sheet?

I am trying to count the number of rows in a spreadsheet which contain at least one non-blank value over a few columns: i.e. row 1 has a text value in column A row 2 has a text value in column B row 3 has a text value in column C row 4 has no values...

Strip out HTML and Special Characters

I'd like to use any php function or whatever so that i can remove any HTML code and special characters and gives me only alpha-numeric output $des = "Hello world)<b> (*&^%$#@! it's me: and; love you.<p>"; I want the output ...

Access Form - Syntax error (missing operator) in query expression

I am receiving a syntax error in a form that I have created over a query. I created the form to restrict access to changing records. While trying to set filters on the form, I receive syntax errors for all attributes I try to filter on. I believe ...

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

What in layman's terms is a Recursive Function using PHP

Can anyone please explain a recursive function to me in PHP (without using Fibonacci) in layman language and using examples? i was looking at an example but the Fibonacci totally lost me! Thank you in advance ;-) Also how often do you use them in we...

Angularjs - simple form submit

I am going through learning curve with AngularJs and I am finding that there are virtually no examples that serve real world use. I am trying to get a clear understanding of how to submit a form with the most standard components and pass it on to a ...

How does MySQL process ORDER BY and LIMIT in a query?

I have a query that looks like this: SELECT article FROM table1 ORDER BY publish_date LIMIT 20 How does ORDER BY work? Will it order all records, then get the first 20, or will it get 20 records and order them by the publish_date field? If it's th...

mysql - move rows from one table to another

If i have two tables that are identical in structure, how can i move a set of rows from 1 table to the other? The set of rows will be determined from a select query. for example: customer table person_id | person_name | person_email 123 t...

Grant all on a specific schema in the db to a group role in PostgreSQL

Using PostgreSQL 9.0, I have a group role called "staff" and would like to grant all (or certain) privileges to this role on tables in a particular schema. None of the following work GRANT ALL ON SCHEMA foo TO staff; GRANT ALL ON DATABASE mydb TO s...

How do I run a Java program from the command line on Windows?

I'm trying to execute a Java program from the command line in Windows. Here is my code: import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.Outp...

How can you use optional parameters in C#?

Note: This question was asked at a time when C# did not yet support optional parameters (i.e. before C# 4). We're building a web API that's programmatically generated from a C# class. The class has method GetFooBar(int a, int b) and the API has a me...

What is __future__ in Python used for and how/when to use it, and how it works

__future__ frequently appears in Python modules. I do not understand what __future__ is for and how/when to use it even after reading the Python's __future__ doc. Can anyone explain with examples? A few answers regarding the basic usage of __futur...

How do function pointers in C work?

I had some experience lately with function pointers in C. So going on with the tradition of answering your own questions, I decided to make a small summary of the very basics, for those who need a quick dive-in to the subject....

In log4j, does checking isDebugEnabled before logging improve performance?

I am using Log4J in my application for logging. Previously I was using debug call like: Option 1: logger.debug("some debug text"); but some links suggest that it is better to check isDebugEnabled() first, like: Option 2: boolean debugEnabled =...

How to find path of active app.config file?

I'm trying to finish this exception handler: if (ConfigurationManager.ConnectionStrings["ConnectionString"]==null) { string pathOfActiveConfigFile = ...? throw new ConfigurationErrorsException( "You either forgot to set the connection...

How to change background color of cell in table using java script

I need to change background color of single cell in table using java script. During document i need style of all cell should be same ( so used style sheet to add this. ) , but on button click i need to change color of first cell. following is the ...

Make hibernate ignore class variables that are not mapped

I thought hibernate takes into consideration only class variables that are annotated with @Column. But strangely today when I added a variable (that is not mapped to any column, just a variable i need in the class), it is trying to include that vari...

How to check if object property exists with a variable holding the property name?

I am checking for the existence of an object property with a variable holding the property name in question. var myObj; myObj.prop = "exists"; var myProp = "p"+"r"+"o"+"p"; if(myObj.myProp){ alert("yes, i have that property"); }; This is und...

How to run java application by .bat file

I need to run my Java Application through .bat file. Can anybody help please....

JavaScript Regular Expression Email Validation

This code is always alerting out "null", which means that the string does not match the expression. var pattern = "^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$"; function isEmailAddress(str) { str = "[email protected]"; alert(str.match(patte...

Git - deleted some files locally, how do I get them from a remote repository

I've deleted some files on my PC, how do I download them again? Pull says: "Already up-to-date"....

load external URL into modal jquery ui dialog

why doesn't this display ibm.com into a 400x500px modal? The section appears to be correct, but it doesn't cause the popup modal to appear. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.d...

Google Chrome: This setting is enforced by your administrator

I recently updated my Chrome browser and noticed something very weird. Many fields in the Settings have been disabled. "This setting is enforced by your administrator" appears next to many fields including my saved passwords section (which I need to ...

How do I list / export private keys from a keystore?

How do I list and export a private key from a keystore?...

How do I set hostname in docker-compose?

In my docker-compose.yml file, I have the following. However the container does not pick up the hostname value. Any ideas? dns: image: phensley/docker-dns hostname: affy domainname: affy.com volumes: - /var/run/docker.sock:/docker.sock ...

Get first day of week in PHP?

Given a date MM-dd-yyyy format, can someone help me get the first day of the week?...

How to prevent a browser from storing passwords

I need to stop browsers from storing the username & password values, because I'm working on a web application which contains more secure data. My client asked me to do this. I tried the autocomplete="off" attribute in the HTML form and password ...

How do I call paint event?

My program draws text on its panel,but if I'd like to remove the text I have to repaint. How do I call(raise) the paint event by hand?...

What's the difference between tilde(~) and caret(^) in package.json?

After I upgraded to the latest stable node and npm, I tried npm install moment --save. It saves the entry in the package.json with the caret ^ prefix. Previously, it was a tilde ~ prefix. Why are these changes made in npm? What is the difference bet...

How to select into a variable in PL/SQL when the result might be null?

Is there a way in to just run a query once to select into a variable, considering that the query might return nothing, then in that case the variable should be null. Currently, I can't do a select into a variable directly, since if the query returns...

How to recover corrupted Eclipse workspace?

I just managed to corrupt contents of my Eclipse .metadata directory. Starting up with eclipse -clean did not work out. Deleting .metadata and then importing all projects, plugins and setting does not sound too interesting. I ended up moving .metadat...

moment.js - UTC gives wrong date

Why does moment.js UTC always show the wrong date. For example from chrome's developer console: moment(('07-18-2013')).utc().format("YYYY-MM-DD").toString() // or moment.utc(new Date('07-18-2013')).format("YYYY-MM-DD").toString() Both of them will...

Is there a way to make mv create the directory to be moved to if it doesn't exist?

So, if I'm in my home directory and I want to move foo.c to ~/bar/baz/foo.c , but those directories don't exist, is there some way to have those directories automatically created, so that you would only have to type mv foo.c ~/bar/baz/ and everyt...

Can you find all classes in a package using reflection?

Is it possible to find all classes or interfaces in a given package? (Quickly looking at e.g. Package, it would seem like no.)...

Resizing Images in VB.NET

I'd like to make a simple VB utility to resize images using vb.net. I am having trouble figuring out what vb class to use to actually manipulate the images. The Image class and the Bitmap class don't work. Any ideas, hints, tips, tutorial links are ...

Does functional programming replace GoF design patterns?

Since I started learning F# and OCaml last year, I've read a huge number of articles which insist that design patterns (especially in Java) are workarounds for the missing features in imperative languages. One article I found makes a fairly strong cl...

How to find EOF through fscanf?

I am reading matrix through file with the help of fscanf(). How can i find EOF? Even if i try to find EOF after every string caught in arr[] then also i am not able to find it. with the help of count i am reading the input file -12 23 3 1 2 4 in...

How to set the color of "placeholder" text?

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

How to change the color of the axis, ticks and labels for a plot in matplotlib

I'd like to Change the color of the axis, as well as ticks and value-labels for a plot I did using matplotlib and PyQt. Any ideas?...

Python how to write to a binary file?

I have a list of bytes as integers, which is something like [120, 3, 255, 0, 100] How can I write this list to a file as binary? Would this work? newFileBytes = [123, 3, 255, 0, 100] # make file newFile = open("filename.txt", "wb") # write to fi...

Change the default editor for files opened in the terminal? (e.g. set it to TextEdit/Coda/Textmate)

Is there a way to make files opened for editing in the terminal open in Textedit instead? For example, where a command might open a file for editing (like git commit), instead of opening that file in vim or emacs, it would open in Textedit (or perh...

Git commit -a "untracked files"?

When I do a git commit -a, I am seeing the following: # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch better_tag_show # Changes to be committ...

How to change working directory in Jupyter Notebook?

I couldn't find a place for me to change the working directory in Jupyter Notebook, so I couldn't use the pd.read_csv method to read in a specific csv document. Is there any way to make it? FYI, I'm using Python3.5.1 currently. Thanks!...

CMake link to external library

How to get CMake to link an executable to an external shared library that is not build within the same CMake project? Just doing target_link_libraries(GLBall ${CMAKE_BINARY_DIR}/res/mylib.so) gives the error make[2]: *** No rule to make target `res...

C# looping through an array

I am looping through an array of strings, such as (1/12/1992 apple truck 12/10/10 orange bicycle). The array's length will always be divisible by 3. I need to loop through the array and grab the first 3 items (I'm going to insert them into a DB) and ...

Count records for every month in a year

I have a table with total no of 1000 records in it.It has the following structure: EMP_ID EMP_NAME PHONE_NO ARR_DATE 1 A 545454 2012/03/12 I want to calculate no of records for every month in year-2012 Is there any way that shoul...

Converting pixels to dp

I have created my application with the height and width given in pixels for a Pantech device whose resolution is 480x800. I need to convert height and width for a G1 device. I thought converting it into dp will solve the problem and provide the same...

Replace String in all files in Eclipse

How can I search and replace a String in all files of my current project? Let's say I have the string "/sites/default/" now I want it to be "/public/sites/default/", but there are almost 1000 files....

Equal sized table cells to fill the entire width of the containing table

Is there a way using HTML/CSS (with relative sizing) to make a row of cells stretch the entire width of the table within which it is contained? The cells should be equal widths and the outer table size is also dynamic with <table width="100%">...

Sort a List of Object in VB.NET

I have a list of passengers(object) where it has a differents properties.. passenger.name passenger.age passenger.surname And I want to sort this list by age criterion, how can i do this? I know in a list of integer/string List.Sort() works, but ...

Regular expression to match any character being repeated more than 10 times

I'm looking for a simple regular expression to match the same character being repeated more than 10 or so times. So for example, if I have a document littered with horizontal lines: ================================================= It will match t...

Android Volley - BasicNetwork.performRequest: Unexpected response code 400

Problem statement: I am trying to access an REST API that will return a JSON object for various HTTP status codes (400, 403, 200 etc) using Volley. For any HTTP status other than 200, it seems the 'Unexpected response code 400' is a problem. Does a...

Insert image after each list item

What would be the best way to insert a small image after each list element? I tried it with a pseudo class but something is not right... ul li a:after { display: block; width: 3px; height: 5px; background: url ('../images/small_triangle.png'...

pip install returning invalid syntax

I've just installed python 3.6 which comes with pip However, in Windows command prompt, when I do: 'pip install bs4' it returns 'SyntaxError: invalid syntax' under the install word. Typing 'python' returns the version, which means it is installed c...

Ruby: character to ascii from a string

this wiki page gave a general idea of how to convert a single char to ascii http://en.wikibooks.org/wiki/Ruby_Programming/ASCII But say if I have a string and I wanted to get each character's ascii from it, what do i need to do? "string".each_byte ...

Remove all occurrences of a value from a list?

In Python remove() will remove the first occurrence of value in a list. How to remove all occurrences of a value from a list? This is what I have in mind: >>> remove_values_from_list([1, 2, 3, 4, 2, 2, 3], 2) [1, 3, 4, 3] ...

Select All checkboxes using jQuery

I have the following html code: <input type="checkbox" id="ckbCheckAll" /> <p id="checkBoxes"> <input type="checkbox" class="checkBoxClass" id="Checkbox1" /> <br /> <input type="checkbox" cl...

Invoking Java main method with parameters from Eclipse

During development (and for debugging) it is very useful to run a Java class' public static void main(String[] argv) method directly from inside Eclipse (using the Run As context menu). Is there a similarily quick way to specify command line parame...

"ImportError: no module named 'requests'" after installing with pip

I am getting ImportError : no module named 'requests'. But I have installed the requests package using the command pip install requests. On running the command pip freeze in the command prompt, the result is requests==2.7.0 So why is this sort ...

MAX() and MAX() OVER PARTITION BY produces error 3504 in Teradata Query

I am trying to produce a results table with the last completed course date for each course code, as well as the last completed course code overall for each employee. Below is my query: SELECT employee_number, MAX(course_completion_date) ...

More than 1 row in <Input type="textarea" />

I'm having troubles getting my <input type="textarea" /> to have more than 1 row, I tried adding the properties in the html, like you would do with a normal <textarea></textarea> like this: <input type="textarea" rows="x" cols="...

gradlew: Permission Denied

I am attempting to run gradlew from my command line, but am constantly facing the following error. Brendas-MacBook-Pro:appx_android brendalogy$ ./gradlew compileDebug --stacktrace -bash: ./gradlew: Permission denied I am already running this comma...

Display Bootstrap Modal using javascript onClick

I need to be able to open a Twitter bootstrap modal window using the onClick="" or similar function. Just need the code to go into the onClick="". I am trying to make a click-able div to open the modal. Code Excerpts: Div Code: <div class="span...

Add onClick event to document.createElement("th")

I am dynamically adding columns to a table by using document.createElement("th") var newTH = document.createElement('th'); Is there a way to set an onClick attribute for this so a user can delete the column by clicking on the header? Any help woul...

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

RSA encryption and decryption in Python

I need help using RSA encryption and decryption in Python. I am creating a private/public key pair, encrypting a message with keys and writing message to a file. Then I am reading ciphertext from file and decrypting text using key. I am having tr...

Blue and Purple Default links, how to remove?

This is one of the links in my nav: <li><a href="#live-now" class="navBtn"><span id="navLiveNow" class="white innerShadow textShadow">Live Now</span></a></li> I also have the following in my css: a { text-decor...

How can I output a UTF-8 CSV in PHP that Excel will read properly?

I've got this very simple thing that just outputs some stuff in CSV format, but it's got to be UTF-8. I open this file in TextEdit or TextMate or Dreamweaver and it displays UTF-8 characters properly, but if I open it in Excel it's doing this silly �...

Setting default value for TypeScript object passed as argument

function sayName(params: {firstName: string; lastName?: string}) { params.lastName = params.lastName || 'smith'; // <<-- any better alternative to this? var name = params.firstName + params.lastName alert(name); } sayName({firstNa...

How to prevent going back to the previous activity?

When the BACK button is pressed on the phone, I want to prevent a specific activity from returning to its previous one. Specifically, I have login and sign up screens, both start a new activity called HomeScreen when successful login/signup occurs. ...

Visual Studio Code Tab Key does not insert a tab

I'm using Visual Studio Code as my code editor. I did a search on google but wasn't able to find anything about my issue. The issue is simple, pressing ? Tab in the editor does nothing. I'm expecting it to insert 4 spaces. Anyone know what I can do t...

How do I set/unset a cookie with jQuery?

How do I set and unset a cookie using jQuery, for example create a cookie named test and set the value to 1?...

Java Command line arguments

I am trying to detect whether the 'a' was entered as the first string argument. ...

How can I echo a newline in a batch file?

How can you you insert a newline from your batch file output? I want to do something like: echo hello\nworld Which would output: hello world ...

Parsing boolean values with argparse

I would like to use argparse to parse boolean command-line arguments written as "--foo True" or "--foo False". For example: my_program --my_boolean_flag False However, the following test code does not do what I would like: import argparse parser ...

How do I create an array of strings in C?

I am trying to create an array of strings in C. If I use this code: char (*a[2])[14]; a[0]="blah"; a[1]="hmm"; gcc gives me "warning: assignment from incompatible pointer type". What is the correct way to do this? edit: I am curious why this sh...

How to Force New Google Spreadsheets to refresh and recalculate?

There were some codes written for this purpose but with the new add-ons they are no longer applicable....

Razor View Engine : An expression tree may not contain a dynamic operation

I have a model similar to this: public class SampleModel { public Product Product { get; set; } } And in my controller I get an exception trying to print out @Html.TextBoxFor(p => p.Product.Name) This is the error: Exception: An expre...

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">Saab</option> <option value="mercedes"&g...

How to get a random number between a float range?

randrange(start, stop) only takes integer arguments. So how would I get a random number between two float values?...

Regex to match string containing two names in any order

I need logical AND in regex. something like jack AND james agree with following strings 'hi jack here is james' 'hi james here is jack' ...

Copy table from one database to another

I've just created an empty database on my machine. I now wish to copy a table from our server database to this local database. What sql commands do I need to run to do this? I wish to create the new table, copy data from the old table and insert it ...

Any way to replace characters on Swift String?

I am looking for a way to replace characters in a Swift String. Example: "This is my string" I would like to replace " " with "+" to get "This+is+my+string". How can I achieve this?...

uppercase first character in a variable with bash

I want to uppercase just the first character in my string with bash. foo="bar"; //uppercase first character echo $foo; should print "Bar";...

How do I call a JavaScript function on page load?

Traditionally, to call a JavaScript function once the page has loaded, you'd add an onload attribute to the body containing a bit of JavaScript (usually only calling a function) <body onload="foo()"> When the page has loaded, I want to run s...

How do I import from Excel to a DataSet using Microsoft.Office.Interop.Excel?

What I want to do I'm trying to use the Microsoft.Office.Interop.Excel namespace to open an Excel file (XSL or CSV, but sadly not XSLX) and import it into a DataSet. I don't have control over the worksheet or column names, so I need to allow for chan...

How to insert a blob into a database using sql server management studio

How can I easily insert a blob into a varbinary(MAX) field? As an example: thing I want to insert is: c:\picture.png the table is mytable the column is mypictureblob the place is recid=1...

Spring default behavior for lazy-init

I am beginner to spring, ESP Inversion of control. I was puzzled understanding the difference between the following <bean id="demo" class="Demo" lazy-init="false"/> <bean id="demo" class="Demo" lazy-init="true"/> <bean id="demo" c...

How to loop through a collection that supports IEnumerable?

How to loop through a collection that supports IEnumerable?...

Convert a dataframe to a vector (by rows)

I have a dataframe with numeric entries like this one test <- data.frame(x = c(26, 21, 20), y = c(34, 29, 28)) How can I get the following vector? > 26, 34, 21, 29, 20, 28 I was able to get it using the following, but I guess there should...

Execute an action when an item on the combobox is selected

I have a jcombobox containing item1 and item2, also I have a jtextfield.. when I select item1 on my jcombobox I want 30 to appear on my jtextfield while 40 if Item2 was selected... How do I do that?...

C++ display stack trace on exception

I want to have a way to report the stack trace to the user if an exception is thrown. What is the best way to do this? Does it take huge amounts of extra code? To answer questions: I'd like it to be portable if possible. I want information to pop u...

Programmatically get the version number of a DLL

Is it possible to get the version number programmatically from any .NET DLL? If yes, how?...

Using headers with the Python requests library's get method

So I recently stumbled upon this great library for handling HTTP requests in Python; found here http://docs.python-requests.org/en/latest/index.html. I love working with it, but I can't figure out how to add headers to my get requests. Help?...

Why does the program give "illegal start of type" error?

here is the relevent code snippet: public static Rand searchCount (int[] x) { int a ; int b ; int c ; int d ; int f ; int g ; int h ; int i ; int j ; Rand countA = new Rand () ; for (int l= 0;...

How would I stop a while loop after n amount of time?

how would I stop a while loop after 5 minutes if it does not achieve what I want it to achieve. while true: test = 0 if test == 5: break test = test - 1 This code throws me in an endless loop....

Kotlin: How to get and set a text to TextView in Android using Kotlin?

I'm newbie. I want to change text of TextView While click on it. My code: val text: TextView = findViewById(R.id.android_text) as TextView text.setOnClickListener { text.setText(getString(R.string.name)) } Output: I got the...

How to do this in Laravel, subquery where in

How can I make this query in Laravel: SELECT `p`.`id`, `p`.`name`, `p`.`img`, `p`.`safe_name`, `p`.`sku`, `p`.`productstatusid` FROM `products` p WHERE `p`.`id` IN ( SELECT `product_id` FROM `product_...

How do I force make/GCC to show me the commands?

I'm trying to debug a compilation problem, but I cannot seem to get GCC (or maybe it is make??) to show me the actual compiler and linker commands it is executing. Here is the output I am seeing: CCLD libvirt_parthelper libvirt_parthelper-par...

How to do a deep comparison between 2 objects with lodash?

I have 2 nested objects which are different and I need to know if they have difference in one of their nested properties. var a = {}; var b = {}; a.prop1 = 2; a.prop2 = { prop3: 2 }; b.prop1 = 2; b.prop2 = { prop3: 3 }; The object could be much ...

How to create a sub array from another array in Java?

How to create a sub-array from another array? Is there a method that takes the indexes from the first array such as: methodName(object array, int start, int end) I don't want to go over making loops and making my program suffer. I keep getting er...

How to hide a mobile browser's address bar?

Safari and Chrome on mobile devices both include a visible address bar when a page loads. As the body of the page scrolls, these browsers will scroll the address bar off screen to give more real estate to the website as shown in this image: I'm ru...

How to write subquery inside the OUTER JOIN Statement

I want to join two table CUSTMR and DEPRMNT. My needed is: LEFT OUTER JOIN OF two or more Tables with subquery inside the LEFT OUTER JOIN as shown below: Table: CUSTMR , DEPRMNT Query as: SELECT cs.CUSID ,dp.DEPID FROM CUSTMR cs ...

source command not found in sh shell

I have a script that uses sh shell. I get an error in the line that uses the source command. It seems source is not included in my sh shell. If I explicitly try to run source from shell I get: sh: 1: source: not found Should I somehow install "s...

android pick images from gallery

I want to create a picture chooser from gallery. I use code intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, TFRequestCodes.GALLERY); My problem is that in th...

How to convert hashmap to JSON object in Java

How to convert or cast hashmap to JSON object in Java, and again convert JSON object to JSON string?...

HTML: Image won't display?

I'm kind of new to HTML. I'm trying to display an image on my website but for some reason, it just shows a blue box with a question mark in it. I've looked everywhere on the internet, but none of the solutions seemed to work for me. I've tried: <...

Get Selected value from Multi-Value Select Boxes by jquery-select2?

I am using Select2 Jquery to bind my dropdown which is used for multiple selection . I am using select2 jquery. It's working fine, I can bind my dropdown but I need to get the selected value from my multi-value selector. I am l...

How do I compare two DateTime objects in PHP 5.2.8?

Having a look on the PHP documentation, the following two methods of the DateTime object would both seem to solve my problem: DateTime::diff : Get the difference and use that to determine which is more ancient. DateTime::getTimestamp : Get the UNIX...

Check if a variable is of function type

Suppose I have any variable, which is defined as follows: var a = function() {/* Statements */}; I want a function which checks if the type of the variable is function-like. i.e. : function foo(v) {if (v is function type?) {/* do something */}}; ...

jQuery multiple events to trigger the same function

Is there a way to have keyup, keypress, blur, and change events call the same function in one line or do I have to do them separately? The problem I have is that I need to validate some data with a db lookup and would like to make sure validation is...

How to make a jquery function call after "X" seconds

I have a jquery function and I need to call it after opening the website in an Iframe. I am trying to open a weblink in an Iframe and after opening it I need to call the below function. So how do I do that? Here is my function: <script type="te...

What does the "$" sign mean in jQuery or JavaScript?

Possible Duplicate: What is the meaning of “$” sign in JavaScript Now this must seem to be an easy and stupid question to ask but I must know why we use the dollar ($) symbol in jQuery and JavaScript. I always put a dollar in m...

1114 (HY000): The table is full

I'm trying to add a row to an InnoDB table with a simply query: INSERT INTO zip_codes (zip_code, city) VALUES ('90210', 'Beverly Hills'); But when I attempt this query, I get the following: ERROR 1114 (HY000): The table zip_codes is full Doi...

Eclipse gives “Java was started but returned exit code 13”

All hell broke loose after i uninstalled my java 6 and installed java 7 (both jdk and jre). On opening eclipse it gave the error that "No JVM found at.....". So, i explicitly gave the location of javaw.exe as -vm C:\Progra~2\Java\jdk1.7.0_45\bin\...

Using .htaccess to make all .html pages to run as .php files?

I need to run all of my .html files as .php files and I don't have time to change all of the links before our presentation tomorrow. Is there any way to "hack" this with my Apache server?...

How to install Xcode Command Line Tools

How do I get the command-line build tools installed with the current Xcode/Mac OS X v10.8 (Mountain Lion) or later? Unlike Xcode there is no installer, it's just a bundle. It looks like all the command line tools are in the bundle, under Contents/D...

How to print a stack trace in Node.js?

Does anyone know how to print a stack trace in Node.js?...

Using find to locate files that match one of multiple patterns

I was trying to get a list of all python and html files in a directory with the command find Documents -name "*.{py,html}". Then along came the man page: Braces within the pattern (‘{}’) are not considered to be special (that is, find . -nam...

How can I switch to another branch in git?

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

A formula to copy the values from a formula to another column

I have a column of values created from a formula, I know I can copy the values over to another column by using the clipboard. BUT...I want my spreadsheet to be automatic whilst avoiding the use of VBA coding, so it would be ideal if I could create a ...

How do I get video durations with YouTube API version 3?

I'm using YouTube API v3 to search YouTube. https://developers.google.com/youtube/v3/docs/search As you can see, the response JSON doesn't contains video durations. Is there way to get video durations? Preferably not calling an API for each elemen...

How to add parameters to HttpURLConnection using POST using NameValuePair

I am trying to do POST with HttpURLConnection(I need to use it this way, can't use HttpPost) and I'd like to add parameters to that connection such as post.setEntity(new UrlEncodedFormEntity(nvp)); where nvp = new ArrayList<NameValuePair>()...

How to check if a file exists in Ansible?

I have to check whether a file exists in /etc/. If the file exists then I have to skip the task. Here is the code I am using: - name: checking the file exists command: touch file.txt when: $(! -s /etc/file.txt) ...

Auto-loading lib files in Rails 4

I use the following line in an initializer to autoload code in my /lib directory during development: config/initializers/custom.rb: RELOAD_LIBS = Dir[Rails.root + 'lib/**/*.rb'] if Rails.env.development? (from Rails 3 Quicktip: Auto reload lib ...

SQL Server: Get data for only the past year

I am writing a query in which I have to get the data for only the last year. What is the best way to do this? SELECT ... FROM ... WHERE date > '8/27/2007 12:00:00 AM' ...

How to remove spaces from a string using JavaScript?

How to remove spaces in a string? For instance: Input: '/var/www/site/Brand new document.docx' Output: '/var/www/site/Brandnewdocument.docx' ...

List of all index & index columns in SQL Server DB

How do I get a list of all index & index columns in SQL Server 2005+? The closest I could get is: select s.name, t.name, i.name, c.name from sys.tables t inner join sys.schemas s on t.schema_id = s.schema_id inner join sys.indexes i on i.object_...

How to export private key from a keystore of self-signed certificate

I just created a self-signed certificate on a linux box running tomcat 6. I created the keys like this, valid for 10 years: keytool -genkey -alias tomcatorange -keyalg RSA -validity 3650 and copied the keystore into a folder in tomcat, and update...

How do I drop a function if it already exists?

I know this must be simple, but how do I preface the creation of a function with a check to see if it already exists? If it exists, I want to drop and re-create it. ...

Python Flask, how to set content type

I am using Flask and I return an XML file from a get request. How do I set the content type to xml ? e.g. @app.route('/ajax_ddl') def ajax_ddl(): xml = 'foo' header("Content-type: text/xml") return xml ...

Can't append <script> element

Any idea why the piece of code below does not add the script element to the DOM? var code = "<script></script>"; $("#someElement").append(code); ...

How to display activity indicator in middle of the iphone screen?

When we draw the image, we want to display the activity indicator. Can anyone help us?...

Android: How can I print a variable on eclipse console?

I wanted to print the value of a variable on the console for my debugging purpose, but System.out.println doesn't work....

How to remove a package in sublime text 2

I would like to remove and/or deactivate the Emmet package in Sublime Text 2. Should I just remove the Emmet directory or what is the typical workflow for removal of a package?...

Nesting queries in SQL

The goal of my query is to return the country name and its head of state if it's headofstate has a name starting with A, and the capital of the country has greater than 100,000 people utilizing a nested query. Here is my query: SELECT country.name ...

What is %0|%0 and how does it work?

If you run a .bat or .cmd file with %0|%0 inside, your computer starts to use a lot of memory and after several minutes, is restarted. Why does this code block your Windows? And what does this code programmatically do? Could it be considered a "bug"?...

How can I safely create a nested directory?

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

How do you get the current text contents of a QComboBox?

Using pyqt4 and python 2.6, I am using a qcombobox to provide a list of options. I am having problems with using the selected option. I have been able to use a signal to trigger a method when the option is selected, but the problem is that when the u...

What is the difference between id and class in CSS, and when should I use them?

#main { background: #000; border: 1px solid #AAAAAA; padding: 10px; color: #fff; width: 100px; } <div id="main"> Welcome </div> Here I gave an id to the div element and it's applying the relevant CSS for it. O...

how to use html2canvas and jspdf to export to pdf in a proper and simple way

I am currently working on a school management software that usually requires exporting of html contents that contains data tables and div tag. I have tried all possible means to write a code that will be able to export my html data in a good way, w...

How to check if current thread is not main thread

I need to check if the thread running a certain piece of code is the main (UI) thread or not. How can I achieve this?...

GridView VS GridLayout in Android Apps

I have to use a Grid to implement Photo Browser in Android. So, I would like to know the difference between GridView and GridLayout. So that I shall choose the right one. Currently I'm using GridView to display the images dynamically....

Simulate user input in bash script

I am creating my own bash script, but I am stuck at the moment. Basically, the script would be used to automate server setup in CentOS. Some software normally asks the user to type a password. I want the script to put the password that I have generat...

Jackson - Deserialize using generic class

I have a json string, which I should deSerialize to the following class class Data <T> { int found; Class<T> hits } How do I do it? This is the usual way mapper.readValue(jsonString, Data.class); But how do I mention what T ...

Slidedown and slideup layout with animation

how can I display a layout in the center with slideUp when I press the button, and press again to hide ... slideDown in ANDROID help me with that, thnkss...

How to get date representing the first day of a month?

I need functionality in a script that will enable me to insert dates into a table. What SQL do I need to insert a date of the format 01/08/2010 00:00:00 where the date is the first day of the current month. What do I need to change order that I c...

Import one schema into another new schema - Oracle

I have a data dmp file exported from one schema user1 using the exp commandline utility. I want to import this dump onto another newly created (empty) schema user 2 using the imp commandline utility. I tried a few things like: imp system/password...

How to determine SSL cert expiration date from a PEM encoded certificate?

If I have the actual file and a Bash shell in Mac or Linux, how can I query the cert file for when it will expire? Not a web site, but actually the certificate file itself, assuming I have the csr, key, pem and chain files....

Pipe to/from the clipboard in Bash script

Is it possible to pipe to/from the clipboard in Bash? Whether it is piping to/from a device handle or using an auxiliary application, I can't find anything. For example, if /dev/clip was a device linking to the clipboard we could do: cat /dev/clip...

Messages Using Command prompt in Windows 7

How to send message over network using command prompt in windows 7 ? ...

Append file contents to the bottom of existing file in Bash

Possible Duplicate: Shell script to append text to each file? How to append output to the end of text file in SHELL Script? I'm trying to work out the best way to insert api details into a pre-existing config. I thought about using sed t...

JavaScript post request like a form submit

I'm trying to direct a browser to a different page. If I wanted a GET request, I might say document.location.href = 'http://example.com/q=a'; But the resource I'm trying to access won't respond properly unless I use a POST request. If this were no...

Download a file from NodeJS Server using Express

How can I download a file that is in my server to my machine accessing a page in a nodeJS server? I'm using the ExpressJS and I've been trying this: app.get('/download', function(req, res){ var file = fs.readFileSync(__dirname + '/upload-folder/...

"find: paths must precede expression:" How do I specify a recursive search that also finds files in the current directory?

I am having a hard time getting find to look for matches in the current directory as well as its subdirectories. When I run find *test.c it only gives me the matches in the current directory. (does not look in subdirectories) If I try find . -name...

AngularJS : automatically detect change in model

Suppose I wanted to do something like automatically run some code (like saving data to a server) whenever a model's values change. Is the only way to do this by setting something like ng-change on each control that could possibly alter the model? Ie...

Angular CLI Error: The serve command requires to be run in an Angular project, but a project definition could not be found

When running the terminal commands ng server or ng serve --live-reload=true, I'm getting this issue: The serve command requires to be run in an Angular project, but a project definition could not be found. ...

Programmatically trigger "select file" dialog box

I have a hidden file input element. Is it possible to trigger its select file dialog box from a button's click event?...

How can I get a list of repositories 'apt-get' is checking?

I want a list of repositories in sources.list, plus those in sources.list.d/. Can I get this list in a form suitable for setting up another host so it watches the same repositories? Additionally, how do I determine which repository is the source of a...

how to move elasticsearch data from one server to another

How do I move Elasticsearch data from one server to another? I have server A running Elasticsearch 1.1.1 on one local node with multiple indices. I would like to copy that data to server B running Elasticsearch 1.3.4 Procedure so far Shut down ES...

How to properly stop the Thread in Java?

I need a solution to properly stop the thread in Java. I have IndexProcessorclass which implements the Runnable interface: public class IndexProcessor implements Runnable { private static final Logger LOGGER = LoggerFactory.getLogger(IndexProc...

Checkout remote branch using git svn

I have checked out a svn repository using git svn. Now I need to checkout one of the branches and track it. Which is the best way to do it?...

Numpy: Creating a complex array from 2 real ones?

I want to combine 2 parts of the same array to make a complex array: Data[:,:,:,0] , Data[:,:,:,1] These don't work: x = np.complex(Data[:,:,:,0], Data[:,:,:,1]) x = complex(Data[:,:,:,0], Data[:,:,:,1]) Am I missing something? Does numpy not like ...

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 do I import a namespace in Razor View Page?

How to import a namespace in Razor View Page?...

Start new Activity and finish current one in Android?

Currently I'm starting a new Activity and calling finish on a current one. Is there any flag that can be passed to Intent that enables finishing current Activity without a need to call finish manually from code?...

What is "stdafx.h" used for in Visual Studio?

A file named stdafx.h is automatically generated when I start a project in Visual Studio 2010. I need to make a cross-platform C++ library, so I don't/can't use this header file. What is stdafx.h used for? Is it OK that I just remove this header fil...

An error occurred while updating the entries. See the inner exception for details

When i delete an item in a listbox, i get the error in the question as shown in the screenshot below: I do not know where the inner exception is, but i tried try, catch but i got the same error in the question. Here is all of the code : namespace...

How to close current tab in a browser window?

I want to create a link on a webpage that would close the currently active tab in a browser without closing other tabs in the browser. When the user clicks the close link, an alert message should appear asking the user to confirm with two buttons, "Y...

Registry key for global proxy settings for Internet Explorer 10 on Windows 8

I have a program that sets proxy settings and it has worked through prior versions of Windows until Windows 8 and IE 10. It sets the keys below. In Windows 8, other browsers (like firefox) recognize the change and use the proxy settings. For IE 10...

Can I have an IF block in DOS batch file?

In a DOS batch file we can only have 1 line if statement body? I think I found somewhere that I could use () for an if block just like the {} used in C-like programming languages, but it is not executing the statements when I try this. No error messa...

Generate random numbers uniformly over an entire range

I need to generate random numbers within a specified interval, [max;min]. Also, the random numbers should be uniformly distributed over the interval, not located to a particular point. Currenly I am generating as: for(int i=0; i<6; i++) { D...

How to support HTTP OPTIONS verb in ASP.NET MVC/WebAPI application

I've setup an ASP.NET web application starting with a MVC 4/Web API template. It seems as though things are working really well - no problems that I'm aware of. I've used Chrome and Firefox to go through the site. I've tested using Fiddler and all of...

Random number between 0 and 1 in python

I want a random number between 0 and 1, like 0.3452. I used random.randrange(0, 1) but it is always 0 for me. What should I do?...

Print the data in ResultSet along with column names

I am retrieving columns names from a SQL database through Java. I know I can retrieve columns names from ResultSet too. So I have this sql query select column_name from information_schema.columns where table_name='suppliers' The problem is I don...

Get records with max value for each group of grouped SQL results

How do you get the rows that contain the max value for each grouped set? I've seen some overly-complicated variations on this question, and none with a good answer. I've tried to put together the simplest possible example: Given a table like that ...

How to get the last N records in mongodb?

I can't find anywhere it has been documented this. By default, the find() operation will get the records from beginning. How can I get the last N records in mongodb? Edit: also I want the returned result ordered from less recent to most recent, not ...

How to create two columns on a web page?

I want to have two columns on my web page. For me the simples way to do that is to use a table: <table> <tr> <td> Content of the first column. </td> <td> Content of the second colu...

How to create user for a db in postgresql?

I have installed PostgreSQL 8.4 on my CentOS server and connected to root user from shell and accessing the PostgreSQL shell. I created the database and user in PostgreSQL. While trying to connect from my PHP script it shows me authentication faile...

How can I convert an image into a Base64 string?

What is the code to transform an image (maximum of 200 KB) into a Base64 String? I need to know how to do it with Android, because I have to add the functionality to upload images to a remote server in my main app, putting them into a row of th...

What's the difference between :: (double colon) and -> (arrow) in PHP?

There are two distinct ways to access methods in PHP, but what's the difference? $response->setParameter('foo', 'bar'); and sfConfig::set('foo', 'bar'); I'm assuming -> (dash with greater than sign or chevron) is used for functions for va...

How to execute a command in a remote computer?

I have a shared folder in a server and I need to remotely execute a command on some files. How do I do that? What services need to be running on the server to make that work? Some details: Only C# can be used. Nothing can be installed in the serve...

Recursively list files in Java

How do I recursively list all files under a directory in Java? Does the framework provide any utility? I saw a lot of hacky implementations. But none from the framework or nio ...

How to format a numeric column as phone number in SQL

I have table in the database with a phone number column. The numbers look like this: 123456789 I want to format that to look like this: 123-456-789 ...

Generating PDF files with JavaScript

I’m trying to convert XML data into PDF files from a web page and I was hoping I could do this entirely within JavaScript. I need to be able to draw text, images and simple shapes. I would love to be able to do this entirely in the browser....

Is it possible to deserialize XML into List<T>?

Given the following XML: <?xml version="1.0"?> <user_list> <user> <id>1</id> <name>Joe</name> </user> <user> <id>2</id> <name>John</name> ...

TCPDF output without saving file

How to use TCPDF to output pdf file in browser without saving like in ezpdf? ...

is there a css hack for safari only NOT chrome?

im trying to find a css hack for just safari NOT chrome, i know these are both webkit browsers but im having problems with div alignments in chrome and safari, each displays differently. i have been trying to use this but it affects chrome as well, ...

What is the difference between char * const and const char *?

What's the difference between: char * const and const char * ...

Does a "Find in project..." feature exist in Eclipse IDE?

Does Eclipse have a way to search a whole project for some text like Xcode's "find in project" feature?...

Docker is in volume in use, but there aren't any Docker containers

EDIT (2/19/21): A lot of time has elapsed since I asked this original question years ago and I've seen a flurry of activity since then. I re-selected an answer which I think is consistent with the most localized and safe option for solving this issue...

SQL SELECT from multiple tables

How can I get all products from customers1 and customers2 include their customer names? customer1 table cid name1 1 john 2 joe customer2 table cid name2 p1 sandy p2 linda product table pid cid pname 1 1 phone 2 2 pencil 3 p1 pen 4...

Set max-height on inner div so scroll bars appear, but not on parent div

I have my HTML, CSS set up as per the code below. I have also added a JSFiddle link since it will be far more convenient to see the code in action. The problem I'm having is that when there is a lot of text in the #inner-right div within the #right-...

HTTP Status 500 - org.apache.jasper.JasperException: java.lang.NullPointerException

I deployed my project on the production server and getting the below error. It's a live project so , after getting error i replaced this with previous version that was running fine but now that is also throwing the same error.Please suggest me what ...

initializing a boolean array in java

I have this code public static Boolean freq[] = new Boolean[Global.iParameter[2]]; freq[Global.iParameter[2]] = false; could someone tell me what exactly i'm doing wrong here and how would i correct it? I just need to initialize all the array elem...

How to detect duplicate values in PHP array?

I am working with a one dimensional array in PHP. I would like to detect the presence of duplicate values, then count the number of duplicate values and out put the results. For example, given the following array: $array = array('apple', 'orange',...

Using PUT method in HTML form

Can I use a PUT method in an HTML form to send data from the form to a server?...

Multiple WHERE clause in Linq

I'm new to LINQ and want to know how to execute multiple where clause. This is what I want to achieve: return records by filtering out certain user names. I tried the code below but not working as expected. DataTable tempData = (DataTable)grdUsageRe...

Transpose a range in VBA

I am Trying to Transpose a range of cells in Excel through VBA macro but I am getting some errors, mostly Error 91. I am pretty new to VBA and don't have much idea about functions either. Range(InRng).Select Set Range1 = Selection Dim DestRange As...

Are there any style options for the HTML5 Date picker?

I am really stoked about the HTML5 date picker. It is refreshing to know that the W3C is finally picking up some of the slack so we don't have to keep re-inventing such a common form of input. The caveat is that I don't see or foresee much in the wa...

What is the role of "Flatten" in Keras?

I am trying to understand the role of the Flatten function in Keras. Below is my code, which is a simple two-layer network. It takes in 2-dimensional data of shape (3, 2), and outputs 1-dimensional data of shape (1, 4): model = Sequential() model.ad...

When should I use a trailing slash in my URL?

When should a trailing slash be used in a URL? For example - should my URL look like /about-us/ or like /about-us? I am fully aware of the SEO-related issues - duplicate content and the canonical thing; I'm trying to figure out which one I should us...

MySQL order by before group by

There are plenty of similar questions to be found on here but I don't think that any answer the question adequately. I'll continue from the current most popular question and use their example if that's alright. The task in this instance is to get t...

How do I get the difference between two Dates in JavaScript?

I'm creating an application which lets you define events with a time frame. I want to automatically fill in the end date when the user selects or changes the start date. I can't quite figure out, however, how to get the difference between the two t...

'cannot find or open the pdb file' Visual Studio C++ 2013

I just downloaded VS 2013 Community Edition and I wrote my first app. When I run it it shows in the output section: 'ConsoleApplication1.exe' (Win32): Loaded 'C:\Users\Toshiba\Documents\Visual Studio 2013\Projects\ConsoleApplication1\Debug\ConsoleAp...

Set a button background image iPhone programmatically

In Xcode, how do you set the background of a UIButton as an image? Or, how can you set a background gradient in the UIButton?...

How to get span tag inside a div in jQuery and assign a text?

I use the following , <div id='message' style="display: none;"> <span></span> <a href="#" class="close-notify">X</a> </div> Now i want to find the span inside the div and assign a text to it... function Erro...

How to change the new TabLayout indicator color and height

I was playing around with the new android.support.design.widget.TabLayout, and found a problem, in the class definition, there are no methods to change the indicator color, and default height. Doing some research, found that the default indicator c...

How do I run git log to see changes only for a specific branch?

I have a local branch tracking the remote/master branch. After running git-pull and git-log, the log will show all commits in the remote tracking branch as well as the current branch. However, because there were so many changes made to the remote bra...

Set a Fixed div to 100% width of the parent container

I have a wrapper with some padding, I then have a floating relative div with a percentage width (40%). Inside the floating relative div I have a fixed div which I would like the same size as its parent. I understand that a fixed div is removed from...

What is System, out, println in System.out.println() in Java

Possible Duplicate: What's the meaning of System.out.println in Java? I was looking for the answer of what System, out and println are in System.out.println() in the Java. I searched and found a different answer like these: System...

VBScript to send email without running Outlook

I have written an automated test that runs each night, and I would like to email the results each night once the test is finished. In order to do this I attempted to put the following at the end of my batchfile: Set MyApp = CreateObject("Outlook.Ap...

Spring transaction REQUIRED vs REQUIRES_NEW : Rollback Transaction

I have a method that has the propagation = Propagation.REQUIRES_NEW transactional property: @Transactional(propagation = Propagation.REQUIRES_NEW) public void createUser(final UserBean userBean) { //Some logic here that requires modification in ...

Is it not possible to stringify an Error using JSON.stringify?

Reproducing the problem I'm running into an issue when trying to pass error messages around using web sockets. I can replicate the issue I am facing using JSON.stringify to cater to a wider audience: // node v0.10.15 > var error = new Error('sim...

check / uncheck checkbox using jquery?

I have some input text fields in my page and am displaying their values using JavaScript. I am using .set("value","") function to edit the value, add an extra checkbox field, and to pass a value. Here I want to check that if value == 1, then this c...

How to enumerate an object's properties in Python?

I C# we do it through reflection. In Javascript it is simple as: for(var propertyName in objectName) var currentPropertyValue = objectName[propertyName]; How to do it in Python?...

Reference to non-static member function must be called

I'm using C++ (not C++11). I need to make a pointer to a function inside a class. I try to do following: void MyClass::buttonClickedEvent( int buttonId ) { // I need to have an access to all members of MyClass's class } void MyClass::setEvent()...

Looping through a DataTable

Well. I have a DataTable with multiple columns and multiple rows. I want to loop through the DataTable dynamically basically the output should look as follows excluding the braces : Name (DataColumn) Tom (DataRow) Peter (DataRow) Surname (DataCol...

How to add custom method to Spring Data JPA

I am looking into Spring Data JPA. Consider the below example where I will get all the crud and finder functionality working by default and if I want to customize a finder then that can be also done easily in the interface itself. @Transactional(rea...

Background color for Tk in Python

I'm writing a slideshow program with Tkinter, but I don't know how to change the background color to black instead of the standard light gray. How can this be done? import os, sys import Tkinter import Image, ImageTk import time root = Tkinter.Tk()...

How to edit an Android app?

I need to edit an Android app just to change some text that was written incorrectly. I have the .apk files, so how would I modify them?...

Clearing Magento Log Data

I have a question regarding clearing of the log data in Magento. I have more than 2.3GB of data in Magento 1.4.1, and now I want to optimize the database, because it's too slow due to the size of the data. I checked the log info (URL,Visitors) and i...

Indentation shortcuts in Visual Studio

I'm new to Visual Studio 2010 and C#. How can I indent the selected text to left/right by using shortcuts? In the Delphi IDE the equivalents are Ctrl+Shift+I and Ctrl+Shift+U...

How to insert array of data into mysql using php

Currently I have an Array that looks like the following when output thru print_r(); Array ( [0] => Array ( [R_ID] => 32 [email] => [email protected] [name] => Bob ) [1] => Array ...

Convert dataframe column to 1 or 0 for "true"/"false" values and assign to dataframe

In the R cli I am able to do the following on a character column in a data frame: > data.frame$column.name [data.frame$column.name == "true"] <- 1 > data.frame$column.name [data.frame$column.name == "false"] <- 0 > data.frame$column.n...

mysql select from n last rows

I have a table with index (autoincrement) and integer value. The table is millions of rows long. How can I search if a certain number appear in the last n rows of the table most efficiently?...

Select SQL Server database size

how can i query my sql server to only get the size of database? I used this : use "MY_DB" exec sp_spaceused I got this : database_name database_size unallocated space My_DB 17899.13 MB 5309.39 MB It returns me several column th...

Changing the URL in react-router v4 without using Redirect or Link

I'm using react-router v4 and material-ui in my React app. I was wondering how to change the URL once there is a click on a GridTile within GridList. My initial idea was to use a handler for onTouchTap. However, the only way I can see to redirect is...

Angularjs Template Default Value if Binding Null / Undefined (With Filter)

I have a template binding that displays a model attribute called 'date' which is a date, using Angular's date filter. <span class="gallery-date">{{gallery.date | date:'mediumDate'}}</span> So far so good. However at the moment, if ther...

Setting Inheritance and Propagation flags with set-acl and powershell

I am trying to mimic the action of right-clicking on a folder, setting "modify" on a folder, and having the permissions apply to the specific folder and subfolders and files. I'm mostly there using Powershell, however the inheritance is only being s...

Is there a way to catch the back button event in javascript?

Is there a way to respond to the back button being hit (or backspace being pressed) in javascript when only the location hash changes? That is to say when the browser is not communicating with the server or reloading the page....

Match line break with regular expression

<li><a href="#">Animal and Plant Health Inspection Service Permits Provides information on the various permits that the Animal and Plant Health Inspection Service issues as well as online access for acquiring those permits. I want t...

How do I force a vertical scrollbar to appear?

My site has both very short and longer pages. Since I center it in the viewport with margin: 0 auto, it jumps around a few pixels when switching from a page that has a scrollbar to one that hasn't and the other way around. Is there a way to force th...

error MSB6006: "cmd.exe" exited with code 1

When I'm trying to build my VC++ code using 2010 I'm getting the error message > C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(151,5): error MSB6006: "cmd.exe" exited with code 1. Please tell how to overcome this?...

How do I view the full content of a text or varchar(MAX) column in SQL Server 2008 Management Studio?

In this live SQL Server 2008 (build 10.0.1600) database, there's an Events table, which contains a text column named Details. (Yes, I realize this should actually be a varchar(MAX) column, but whoever set this database up did not do it that way.) T...

How do you change library location in R?

Due to the new R 2.11 release, I want to implement Dirk's suggestion here. So for that I am asking - How can I (permanently) change R's library path? (The best solution would be one that can be run from within R)...

Using jquery to get all checked checkboxes with a certain class name

I know I can get all checked checkboxes on a page using this: $('input[type=checkbox]').each(function () { var sThisVal = (this.checked ? $(this).val() : ""); }); But I am now using this on a page that has some other checkboxes that I don't wa...

Make 2 functions run at the same time

I am trying to make 2 functions run at the same time. def func1(): print 'Working' def func2(): print 'Working' func1() func2() Does anyone know how to do this?...

Docker remove <none> TAG images

root@server:~# docker images -a REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE <none> <none> 5e2dfc857e73 5 days ago 261.6 MB <none...

how to check if input field is empty

I'm making a form with inputs, if the input type is empty then the button submit is disabled but, if the input fields is with length > 0 the submit button is enabled <input type='text' id='spa' onkeyup='check()'><br> <input type='text...

Add new attribute (element) to JSON object using JavaScript

How do I add new attribute (element) to JSON object using JavaScript?...

Select multiple elements from a list

I have a list in R some 10,000 elements long. Say I want to select only elements, 5, 7, and 9. I'm not sure how I would do that without a for loop. I want to do something like mylist[[c(5,7,9]] but that doesn't work. I've also tried the lapply funct...

Getting binary (base64) data from HTML5 Canvas (readAsBinaryString)

Is there any way of reading the contents of a HTML Canvas as binary data? At the moment I've got the following HTML to show an input file and the canvas below it: <p><button id="myButton" type="button">Get Image Content</button>&l...

Windows command for file size only

Is there a Windows command that will output the size in bytes of a specified file like this? > filesize test.jpg 65212 I know that the dir command outputs this information, but it outputs other information also. I could easily write such a pro...

How to set 24-hours format for date on java?

I have been developing Android application where I use this code: Date d=new Date(new Date().getTime()+28800000); String s=new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").format(d); I need to get date after 8 hours from current moment, and I want that...

svn over HTTP proxy

I'm on laptop (Ubuntu) with a network that use HTTP proxy (only http connections allowed). When I use svn up for url like 'http://.....' everything is cool (google chrome repository works perfect), but right now I need to svn up from server with 'svn...

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

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

How to bring back "Browser mode" in IE11?

UPDATE: The old question applies only to IE11 preview; browser mode had returned in final release of IE11. But there is a catch: it is next to useless, because it does not emulate conditional comments. For example, if you use them to enable HTML5 sup...

How to do constructor chaining in C#

I know that this is supposedly a super simple question, but I've been struggling with the concept for some time now. My question is, how do you chain constructors in C#? I'm in my first OOP class, so I'm just learning. I don't understand how co...

How to have git log show filenames like svn log -v

SVN's log has a "-v" mode that outputs filenames of files changed in each commit, like so: jes5199$ svn log -v ------------------------------------------------------------------------ r1 | jes5199 | 2007-01-03 14:39:41 -0800 (Wed, 03 Jan 2007) | 1...

Detect change to selected date with bootstrap-datepicker

I have an input element with an attached datepicker created using bootstrap-datepicker. <div class="well"> <div class="input-append date" id="dp3" data-date="2012-01-02" data-date-format="yyyy-mm-dd"> <input type="text" id...

Regex - how to match everything except a particular pattern

How do I write a regex to match any string that doesn't meet a particular pattern? I'm faced with a situation where I have to match an (A and ~B) pattern....

What do the icons in Eclipse mean?

What do the icons in the Eclipse debugger mean? What do the icon decorators in Eclipse mean? What do the icons in Eclipse's Package Explorer mean? What do the little letters on top of Eclipse icons mean? What's the difference between the two error i...

How to change the text on the action bar

Currently it just displays the name of the application and I want it to display something custom and be different for each screen in my app. For example: my home screen could say 'page1' in the action bar while another activity that the app switches...

W3WP.EXE using 100% CPU - where to start?

An ASP.NET web app running on IIS6 periodically shoots the CPU up to 100%. It's the W3WP that's responsible for nearly all CPU usage during these episodes. The CPU stays pinned at 100% anywhere from a few minutes to over an hour. This is on a stagi...

How do I get a list of all subdomains of a domain?

I want to find out all the subdomains of a given domain. I found a hint which tells me to dig the authoritative Nameserver with the following option: dig @ns1.foo.bar some_domain.com axfr But this never works. Has anyone a better idea/approach...

What is Python Whitespace and how does it work?

I've been searching google and this website for some time now, but I just can't seem to find a straight answer on the subject. What is whitespace in Python? I know it's something to do with indenting with each line, but I'm not sure exactly how to ...

What does it mean to have an index to scalar variable error? python

import numpy as np with open('matrix.txt', 'r') as f: x = [] for line in f: x.append(map(int, line.split())) f.close() a = array(x) l, v = eig(a) exponent = array(exp(l)) L = identity(len(l)) for i in xrange(len(l)): L[i][i]...

Errors: Data path ".builders['app-shell']" should have required property 'class'

I am getting this error while running my application. Here are the details of my application. Angular CLI: 7.3.3 Node: 10.15.1 Angular: 7.2.7 @angular-devkit/architect -0.13.3 @angular-devkit/build-angular- 0.800.1 @angular-devkit/build-optimi...

How to get input from user at runtime

I want to take runtime input from user in Oracle 10g PL/SQL blocks (i.e. interactive communication with user). Is it possible? declare x number; begin x=&x; end this code gives error as & can't be used in oracle 10g ...

Syntax error: Illegal return statement in JavaScript

I am getting a really weird JavaScript error when I run this code: <script type = 'text/javascript'> var ask = confirm('".$message."'); if (ask == false) { return false; } else { return true; } </script> In the JavaScript...

Utilizing multi core for tar+gzip/bzip compression/decompression

I normally compress using tar zcvf and decompress using tar zxvf (using gzip due to habit). I've recently gotten a quad core CPU with hyperthreading, so I have 8 logical cores, and I notice that many of the cores are unused during compression/decom...

What is the difference between WCF and WPF?

I am a naive developer and I am building up my concepts, I was asked to create a sample application in wcf, and so I am asking a bit subjective question here. I want to know the diffrence and functionality of the above two, in which terms we prefer o...

MAC addresses in JavaScript

I know that we can get the MAC address of a user via IE (ActiveX objects). Is there a way to obtain a user's MAC address using JavaScript?...

What is the best way to give a C# auto-property an initial value?

How do you give a C# auto-property an initial value? I either use the constructor, or revert to the old syntax. Using the Constructor: class Person { public Person() { Name = "Initial Name"; } public string Name { get; s...

ModelState.AddModelError - How can I add an error that isn't for a property?

I am checking my database in Create(FooViewModel fvm){...} to see if the fvm.prop1 and fvm.prop2 already exist in that combination; if so, I want to add an error to the modelstate, then return the whole view. I tried: public ActionResult Create(Foo...

How can I create an object based on an interface file definition in TypeScript?

I have defined an interface like this: interface IModal { content: string; form: string; href: string; $form: JQuery; $message: JQuery; $modal: JQuery; $submits: JQuery; } I define a variable like this: var modal: IMo...

how to convert milliseconds to date format in android?

I have milliseconds. I need it to be converted to date format of example: 23/10/2011 How to achieve it?...

Force a screen update in Excel VBA

My Excel tool performs a long task, and I'm trying to be kind to the user by providing a progress report in the status bar, or in some cell in the sheet, as shown below. But the screen doesn't refresh, or stops refreshing at some point (e.g. 33%). Th...

Easier way to debug a Windows service

Is there an easier way to step through the code than to start the service through the Windows Service Control Manager and then attaching the debugger to the thread? It's kind of cumbersome and I'm wondering if there is a more straightforward approach...

How do you implement a circular buffer in C?

I have a need for a fixed-size (selectable at run-time when creating it, not compile-time) circular buffer which can hold objects of any type and it needs to be very high performance. I don't think there will be resource contention issues since, alth...

Use Invoke-WebRequest with a username and password for basic authentication on the GitHub API

With cURL, we can pass a username with an HTTP web request as follows: $ curl -u <your_username> https://api.github.com/user The -u flag accepts a username for authentication, and then cURL will request the password. The cURL example is for...

MySQL: Get column name or alias from query

I'm not asking for the SHOW COLUMNS command. I want to create an application that works similarly to heidisql, where you can specify an SQL query and when executed, returns a result set with rows and columns representing your query result. The colum...

How to remove specific session in asp.net?

I am facing a problem. I have created two sessions: Session["userid"] = UserTbl.userid; Session["userType"] = UserTbl.type; I know how to remove sessions using Session.clear(). I want to remove the session "userType". How do I remove a specific ...

How to create UILabel programmatically using Swift?

How do I create a UILabel programmatically using Swift in Xcode 6? I have started with a new "Single View Application" in Xcode 6 and selected Swift for this project. I have my files AppDelegate.swift and ViewController.swift and I'm not sure what t...

How to write to file in Ruby?

I need to read the data out of database and then save it in a text file. How can I do that in Ruby? Is there any file management system in Ruby?...

Increase heap size in Java

I am working on a Windows 2003 server (64-bit) with 8 GB RAM. How can I increase the heap memory maximum? I am using the -Xmx1500m flag to increase the heap size to 1500 Mb. Can I increase the heap memory to 75% of physical memory (6 GB Heap)?...

Dynamically converting java object of Object class to a given class when class name is known

Yeah, I know. Long title of question... So I have class name in string. I'm dynamically creating object of that class in this way: String className = "com.package.MyClass"; Class c = Class.forName(className); Object obj = c.newInstance(); How...

Python object.__repr__(self) should be an expression?

I was looking at the builtin object methods in the Python documentation, and I was interested in the documentation for object.__repr__(self). Here's what it says: Called by the repr() built-in function and by string conversions (reverse quote...

how to calculate percentage in python

This is my program print" Welcome to NLC Boys Hr. Sec. School " a=input("\nEnter the Tamil marks :") b=input("\nEnter the English marks :") c=input("\nEnter the Maths marks :") d=input("\nEnter the Science marks :") e=input("\nEnter the Social scien...

Sum a list of numbers in Python

I have a list of numbers such as [1,2,3,4,5...], and I want to calculate (1+2)/2 and for the second, (2+3)/2 and the third, (3+4)/2, and so on. How can I do that? I would like to sum the first number with the second and divide it by 2, then sum the ...

How to get cell value from DataGridView in VB.Net?

I have a problem, how can i get value from cell of datagridview ---------------------------------- id | p/w | post | ---------------------------------- 1 | 1234 | A | ---------------------------------- 2 | 456...

how to use javascript Object.defineProperty

I looked around for how to use the Object.defineProperty method, but couldn't find anything decent. Someone gave me this snippet of code: Object.defineProperty(player, "health", { get: function () { return 10 + ( player.level * 15 ); ...

How to make primary key as autoincrement for Room Persistence lib

I am creating an Entity (Room Persistence Library) class Food, where I want to make foodId as autoincrement. @Entity class Food(var foodName: String, var foodDesc: String, var protein: Double, var carbs: Double, var fat: Double) { @PrimaryKey ...

How to use UIScrollView in Storyboard

I have a scroll view with content that is 1000px tall and would like to be able to lay it out for easy design on the storyboard. I know it can be done programmatically but I really want to be able to see it visually. Every time I put a scroll view on...

Counting repeated elements in an integer array

I have an integer array crr_array and I want to count elements, which occur repeatedly. First, I read the size of the array and initialize it with numbers read from the console. In the array new_array, I store the elements that are repeated. The arra...

Django download a file

I'm quite new to using Django and I am trying to develop a website where the user is able to upload a number of excel files, these files are then stored in a media folder Webproject/project/media. def upload(request): if request.POST: fo...

VBA using ubound on a multidimensional array

Ubound can return the max index value of an array, but in a multidimensional array, how would I specify WHICH dimension I want the max index of? For example Dim arr(1 to 4, 1 to 3) As Variant In this 4x3 array, how would I have Ubound return 4, a...

Custom pagination view in Laravel 5

Laravel 4.2 has the option to specify a custom view in app/config/view.php such as: /* |-------------------------------------------------------------------------- | Pagination View |-------------------------------------------------------------------...

Change the maximum upload file size

I have a website hosted on a PC I have no access to. I have an upload form allowing people to upload mp3 files up to 30MB big. My server side script is done in PHP. Every time I try and upload a file, I receive an error claiming that the file exceed...

SQL LEFT JOIN Subquery Alias

I'm running this SQL query: SELECT wp_woocommerce_order_items.order_id As No_Commande FROM wp_woocommerce_order_items LEFT JOIN ( SELECT meta_value As Prenom FROM wp_postmeta WHERE meta_key = '_shipping_first_name' ...

Type definition in object literal in TypeScript

In TypeScript classes it's possible to declare types for properties, for example: class className { property: string; }; How do declare the type of a property in an object literal? I've tried the following code but it doesn't compile: var obj ...

Only read selected columns

Can anyone please tell me how to read only the first 6 months (7 columns) for each year of the data below, for example by using read.table()? Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 2009 -41 -27 -25 -31 -31 -39 -...

Oracle Differences between NVL and Coalesce

Are there non obvious differences between NVL and Coalesce in Oracle? The obvious differences are that coalesce will return the first non null item in its parameter list whereas nvl only takes two parameters and returns the first if it is not null, ...

Convert Date format into DD/MMM/YYYY format in SQL Server

I have a query in SQL, I have to get a date in a format of dd/mm/yy Example: 25/jun/2013. How can I convert it for SQL server?...

Calculating Page Table Size

I'm reading through an example of page tables and just found this: Consider a system with a 32-bit logical address space. If the page size in such a system is 4 KB (2^12), then a page table may consist of up to 1 million entries (2^32/2^12). Assumin...

How to remove all whitespace from a string?

So " xx yy 11 22 33 " will become "xxyy112233". How can I achieve this?...

Automatically open default email client and pre-populate content

I need to automatically open a user's default email client when they save some content on a page. I need to populate the email subject, to address, and put some content in the email body. What is the best option to achieve this? I'm aware of the ma...

How to get the root dir of the Symfony2 application?

What is the best way to get the root app directory from inside the controller? Is it possible to get it outside of the controller? Now I get it by passing it (from parameters) to the service as an argument, like this: services: sr_processor: ...

Delete worksheet in Excel using VBA

I have a macros that generates a number of workbooks. I would like the macros, at the start of the run, to check if the file contains 2 spreadsheets, and delete them if they exist. The code I tried was: If Sheet.Name = "ID Sheet" Then Applicati...

C++ multiline string literal

Is there any way to have multi-line plain-text, constant literals in C++, à la Perl? Maybe some parsing trick with #includeing a file? I can't think of one, but boy, that would be nice. I know it'll be in C++0x....

What does a Status of "Suspended" and high DiskIO means from sp_who2?

I'm trying to troubleshoot some intermittent slowdowns in our application. I've got a separate question here with more details. I ran sp_who2 to and I've noticed a few connections that have a status of SUSPENDED and high DiskIO. Can someone explai...

How do I create an abstract base class in JavaScript?

Is it possible to simulate abstract base class in JavaScript? What is the most elegant way to do it? Say, I want to do something like: - var cat = new Animal('cat'); var dog = new Animal('dog'); cat.say(); dog.say(); It should output: 'bark', 'm...

flutter corner radius with transparent background

Below is my code which I expect to render a round-corner container with a transparent background. return new Container( //padding: const EdgeInsets.all(32.0), height: 800.0, //color: const Color(0xff...

JSON formatter in C#?

Looking for a function that will take a string of Json as input and format it with line breaks and indentations. Validation would be a bonus, but isn't necessary, and I don't need to parse it into an object or anything. Anyone know of such a library...

How do I sort a table in Excel if it has cell references in it?

I have a table of data in excel in sheet 1 which references various different cells in many other sheets. When I try to sort or filter the sheet, the references change when the cell moves. However, I don't want to manually go into each cell and inser...

How to split csv whose columns may contain ,

Given 2,1016,7/31/2008 14:22,Geoff Dalgas,6/5/2011 22:21,http://stackoverflow.com,"Corvallis, OR",7679,351,81,b437f461b3fd27387c5d8ab47a293d35,34 How to use C# to split the above information into strings as follows: 2 1016 7/31/2008 14:22 G...

PHP CURL CURLOPT_SSL_VERIFYPEER ignored

For some reason I am unable to use CURL with HTTPS. Everything was working fine untill I ran upgrade of curl libraries. Now I am experiencing this response when trying to perform CURL requests: Problem with the SSL CA cert (path? access rights?) Fo...

How to redirect output of an entire shell script within the script itself?

Is it possible to redirect all of the output of a Bourne shell script to somewhere, but with shell commands inside the script itself? Redirecting the output of a single command is easy, but I want something more like this: #!/bin/sh if [ ! -t 0 ]; th...

How do I run SSH commands on remote system using Java?

I am new to this kind of Java application and looking for some sample code on how to connect to a remote server using SSH , execute commands, and get output back using Java as programming language....

How to remove folders with a certain name

In Linux, how do I remove folders with a certain name which are nested deep in a folder hierarchy? The following paths are under a folder and I would like to remove all folders named a. 1/2/3/a 1/2/3/b 10/20/30/a 10/20/30/b 100/200/300/a 100/200/...

How do I add indices to MySQL tables?

I've got a very large MySQL table with about 150,000 rows of data. Currently, when I try and run SELECT * FROM table WHERE id = '1'; the code runs fine as the ID field is the primary index. However, for a recent development in the project, I have ...

How to save and extract session data in codeigniter

I save some data in session on my verify controller then I extract this session data into user_activity model and insert session data into activity table. My problem is only username data saved in session and I can get and insert only username data a...

Set focus on TextBox in WPF from view model

I have a TextBox and a Button in my view. Now I am checking a condition upon button click and if the condition turns out to be false, displaying the message to the user, and then I have to set the cursor to the TextBox control. if (companyref == nu...

What is the difference between YAML and JSON?

What are the differences between YAML and JSON, specifically considering the following things? Performance (encode/decode time) Memory consumption Expression clarity Library availability, ease of use (I prefer C) I was planning to use one of these ...

Scanning Java annotations at runtime

What is the best way of searching the whole classpath for an annotated class? I'm doing a library and I want to allow the users to annotate their classes, so when the Web application starts I need to scan the whole classpath for certain annotation. ...

Finding the second highest number in array

I'm having difficulty to understand the logic behind the method to find the second highest number in array. The method used is to find the highest in the array but less than the previous highest (which has already been found). The thing that I still ...

How to change onClick handler dynamically?

I'm sure there are a million posts about this out there, but surprisingly I'm having trouble finding something. I have a simple script where I want to set the onClick handler for an <A> link on initialization of the page. When I run this I i...

What does it mean when a PostgreSQL process is "idle in transaction"?

What does it mean when a PostgreSQL process is "idle in transaction"? On a server that I'm looking at, the output of "ps ax | grep postgres" I see 9 PostgreSQL processes that look like the following: postgres: user db 127.0.0.1(55658) idle in trans...

IE11 meta element Breaks SVG

I've embedded an SVG files data directly into my html. It shows in Chrome and Firefox, but in IE11 it doesn't show at all. The pastebin link to the SVG is http://pastebin.com/eZpLXFfD I've tried adding a META TAG but to no avail. At first I thought...

Difference between two dates in Python

I have two different dates and I want to know the difference in days between them. The format of the date is YYYY-MM-DD. I have a function that can ADD or SUBTRACT a given number to a date: def addonDays(a, x): ret = time.strftime("%Y-%m-%d",tim...

Find CRLF in Notepad++

How can I find/replace all CR/LF characters in Notepad++? I am looking for something equivalent to the ^p special character in Microsoft Word....

What languages are Windows, Mac OS X and Linux written in?

I was just wondering who knows what programming languages Windows, Mac OS X and Linux are made up from and what languages are used for each part of the OS (ie: Kernel, plug-in architecture, GUI components, etc). I assume that there are multiple lang...

__init__() got an unexpected keyword argument 'user'

i am using Django to create a user and an object when the user is created. But there is an error __init__() got an unexpected keyword argument 'user' when calling the register() function in view.py. The function is: def register(request): ''...

Add space between cells (td) using css

I am trying to add a table with space between cell as the background colour of the cell is white and the background color of the table is blue, you can easily see that padding and margin are not working (I am applying it to the td), it will only add ...

Random integer in VB.NET

I need to generate a random integer between 1 and n (where n is a positive whole number) to use for a unit test. I don't need something overly complicated to ensure true randomness - just an old-fashioned random number. How would I do that?...

Change background color of selected item on a ListView

I want to know on how I can change the background color of the selected item on my listView. I only want to change the specific item clicked by the user, meaning if the user clicks another item it will be the one which is highlighted. Well since I wa...

RegEx for Javascript to allow only alphanumeric

I need to find a reg ex that only allows alphanumeric. So far, everyone I try only works if the string is alphanumeric, meaning contains both a letter and a number. I just want one what would allow either and not require both....

Convert a String of Hex into ASCII in Java

I hope this isn't too much of a stupid question, I have looked on 5 different pages of Google results but haven't been able to find anything on this. What I need to do is convert a string that contains all Hex characters into ASCII for example Str...

Android Studio : Failure [INSTALL_FAILED_OLDER_SDK]

Today I have downloaded Android Studio v 0.8.0 beta. I am trying to test my app on SDK 17 . Android studio error Failure [INSTALL_FAILED_OLDER_SDK] Here is my android manifest <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:andr...

Python progression path - From apprentice to guru

I've been learning, working, and playing with Python for a year and a half now. As a biologist slowly making the turn to bio-informatics, this language has been at the very core of all the major contributions I have made in the lab. I more or less fe...

Fit cell width to content

Given the following markup, how could I use CSS to force one cell (all cells in column) to fit to the width of the content within it rather than stretch (which is the default behaviour)? <style type="text/css"> td.block { border: 1px solid bla...

How to check if a query string value is present via JavaScript?

How can I check if the query string contains a q= in it using JavaScript or jQuery?...

Specifying Style and Weight for Google Fonts

I am using Google fonts in a few of my pages and hit a wall when trying to use variations of a font. Example: http://www.google.com/webfonts#QuickUsePlace:quickUse/Family:Open+Sans I am importing three faces, Normal, Bold, ExtraBold via the link tag...

JPA: unidirectional many-to-one and cascading delete

Say I have a unidirectional @ManyToOne relationship like the following: @Entity public class Parent implements Serializable { @Id @GeneratedValue private long id; } @Entity public class Child implements Serializable { @Id @Gen...

Using Pipes within ngModel on INPUT Elements in Angular

I've an HTML INPUT field. <input [(ngModel)]="item.value" name="inputField" type="text" /> and I want to format its value and use an existing pipe: .... [(ngModel)]="item.value | useMyPipeToFormatThatValue" .... and get ...

C# Linq Group By on multiple columns

public class ConsolidatedChild { public string School { get; set; } public string Friend { get; set; } public string FavoriteColor { get; set; } public List<Child> Children { get; set; } } public class Child { public string...

How to read value of a registry key c#

At start up of my application I am trying to see if the user has a specific version of a software installed, specifically the MySQL connector, all using c#. In the registry, the MySQL contains a version entry. So what I am trying to accomplish is thi...

Rethrowing exceptions in Java without losing the stack trace

In C#, I can use the throw; statement to rethrow an exception while preserving the stack trace: try { ... } catch (Exception e) { if (e is FooException) throw; } Is there something like this in Java (that doesn't lose the original stack...

Change Circle color of radio button

I want to change the color of the circle of RadioButton in one of my project, I could not understand which property to set. The background color I am having is black so it gets invisible. I want to set the color of the circle to white....

Print in Landscape format

Possible Duplicate: Landscape printing from HTML I am using below code to show print window on button click: function print_onclick() { window.print(); return false; } I want the page to be printed in Landscape format. Is there ...

Warning: mysql_connect(): Access denied for user 'root'@'localhost' (using password: YES)

Warning: mysql_connect(): Access denied for user 'root'@'localhost' (using password: YES) in C:\xampp\htdocs\Login\sessionHandler.php on line 35 So this is what's on the line 35. //to make a connection with database $conn = mysql_connect("l...

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 turn off the Eclipse code formatter for certain sections of Java code?

I've got some Java code with SQL statements written as Java strings (please no OR/M flamewars, the embedded SQL is what it is - not my decision). I've broken the SQL statements semantically into several concatenated strings over several lines of cod...

Permission denied (publickey,keyboard-interactive)

I tried to connect to planetlab node using ssh. It throws me error like Permission denied (publickey,keyboard-interactive). What does this mean? Here is the verbose of the exception. > OpenSSH_5.1p1 Debian-5ubuntu1, OpenSSL > 0.9.8g 19 Oct 200...

How do I provide a username and password when running "git clone [email protected]"?

I know how to provide a username and password to an HTTPS request like this: git clone https://username:password@remote But I'd like to know how to provide a username and password to the remote like this: git clone [email protected] I've tried lik...

Installing SciPy with pip

It is possible to install NumPy with pip using pip install numpy. Is there a similar possibility with SciPy? (Doing pip install scipy does not work.) Update The package SciPy is now available to be installed with pip!...

PostgreSQL database service

I downloaded PostgreSQL from their site - http://www.postgresql.org/download/windows However, I can't create a database from pgAdmin and get a message: could not connect to server: Connection refused (0x0000274D/10061) Is the server running ...

invalid target release: 1.7

I have seen similar questions, but haven't yet found the answer. Using maven compile, I get: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project api: Fatal error compiling: invali...

Define an alias in fish shell

I would like to define some aliases in fish. Apparently it should be possible to define them in ~/.config/fish/functions but they don't get auto loaded when I restart the shell. Any ideas?...

What is a magic number, and why is it bad?

What is a magic number? Why should it be avoided? Are there cases where it's appropriate?...

How do I add a library (android-support-v7-appcompat) in IntelliJ IDEA

I created a project, copied the resource files in the project, library, added it to the project structure, prescribed style Theme.AppCompat. Compiled without errors, but when you start the relegation Exception: 08-03 00:50:00.406: ERROR/AndroidRunti...

How do I print out the contents of an object in Rails for easy debugging?

I think I'm trying to get the PHP equivalent of print_r() (print human-readable); at present the raw output is: ActiveRecord::Relation:0x10355d1c0 What should I do?...

java.lang.RuntimeException: Unable to start activity ComponentInfo

I know this error appeared on forum million of times, but please help me find what I missed. I'm trying to do simple tab orientated application,I don't have much (except errors) 1) my main activity is based on tablayout tutorial what I found public...

PHP check if url parameter exists

I have a URL which i pass parameters into example/success.php?id=link1 I use php to grab it $slide = ($_GET["id"]); then an if statement to display content based on parameter <?php if($slide == 'link1') { ?> //content } ?> J...

Add line break within tooltips

How can line breaks be added within a HTML tooltip? I tried using <br/> and \n within the tooltip as follows: <a href="#" title="Some long text <br/> Second line text \n Third line text">Hover me</a> However, this was use...

WHERE Clause to find all records in a specific month

I want to be able to give a stored procedure a Month and Year and have it return everything that happens in that month, how do I do this as I can't compare between as some months have different numbers of days etc? What's the best way to do this? Ca...

How to change Visual Studio 2012,2013 or 2015 License Key?

I have a Copy of Visual Studio 2012 Pro on my machine with a Serial key that i'm no longer suppose to use because i have to use another one. My problem is i keep Uninstalling Visual studio but the Registration information is still there after re-inst...

How to read PDF files using Java?

I want to read some text data from a PDF file using Java. How can I do that?...

Eclipse comment/uncomment shortcut?

I thought this would be easy to achieve, but so far I haven't found solutions for comment/uncomment shortcut on both Java class editor and jsf faceted webapp XHTML file editor : to quickly comment/uncomment a line (like ctrl + d is for removing sin...

How to style the menu items on an Android action bar

There's been many questions on styling on action bars, but the ones I've found either are relating to styling the tabs, or have answers that don't work for me. The question is really quite simple. I want to be able to change the text styling (even j...

HTML Entity Decode

How do I encode and decode HTML entities using JavaScript or JQuery? var varTitle = "Chris&apos; corner"; I want it to be: var varTitle = "Chris' corner"; ...

Can I rollback a transaction I've already committed? (data loss)

I committed an incorrect UPDATE statement and have lost some data. Is it possible to rollback now, after I've already committed? Any help? ROLLBACK says NOTICE: there is no transaction in progress....

fork: retry: Resource temporarily unavailable

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

How do I link a JavaScript file to a HTML file?

How do you properly link a JavaScript file to a HTML document? Secondly, how do you use jQuery within a JavaScript file?...

How to print GETDATE() in SQL Server with milliseconds in time?

I want to print GETDATE() in SQL Server 2008, I need the time with milliseconds (this is for debugging purpose - to find sp's execution time ) I find this Difference SELECT GETDATE() returns 2011-03-15 18:43:44.100 print GETDATE() returns Mar 15...

How can I remove a button or make it invisible in Android?

How can I remove a button in Android, or make it invisible?...

invalid command code ., despite escaping periods, using sed

Being forced to use CVS for a current client and the address changed for the remote repo. The only way I can find to change the remote address in my local code is a recursive search and replace. However, with the sed command I'd expect to work: fin...

How to click a href link using Selenium

I have a html href link <a href="/docs/configuration">App Configuration</a> using Selenium I need to click the link. Currently, I am using below code - Driver.findElement(By.xpath("//a[text()='App Configuration']")).c...

What's the UIScrollView contentInset property for?

Can someone explain to me what the contentInset property in a UIScrollView instance is used for? And maybe provide an example?...

Set value for particular cell in pandas DataFrame with iloc

I have a question similar to this and this. The difference is that I have to select row by position, as I do not know the index. I want to do something like df.iloc[0, 'COL_NAME'] = x, but iloc does not allow this kind of access. If I do df.iloc[0]...

How do I make a JAR from a .java file?

I was writing a simple program using a Java application (not application that has projects, but application within a project; .java) that has a single frame. Both of the files are .java so I can't write a manifest needed by the JAR. The MyApp.java st...

GetElementByID - Multiple IDs

doStuff(document.getElementById("myCircle1" "myCircle2" "myCircle3" "myCircle4")); This doesn't work, so do I need a comma or semi-colon to make this work?...

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

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

String.equals() with multiple conditions (and one action on result)

Is it possible to do something like this in Java for Android (this is a pseudo code) IF (some_string.equals("john" OR "mary" OR "peter" OR "etc."){ THEN do something } ? At the moment this is done via multiple String.equals() condition with ||...

How to use select/option/NgFor on an array of objects in Angular2

I'm having trouble creating a select in Angular2 that is backed by an array of Objects instead of strings. I knew how to do it in AngularJS using ngOptions, but it doesn't seem to work in Angular2 (I'm using alpha 42). In the sample below, I have fo...

How to use variables in SQL statement in Python?

Ok so I'm not that experienced in Python. I have the following Python code: cursor.execute("INSERT INTO table VALUES var1, var2, var3,") where var1 is an integer, var2 & var3 are strings. How can I write the variable names without python in...

how to change php version in htaccess in server

I'm using php 5.3 on my local machine. On our webserver we have php 4.8. Our server is a shared server. So I want to change the php version on our server via .htaccess file. Is it possible to do it? If yes how to do it?...

FragmentActivity to Fragment

I haven't found any question like this on here so I wanted to ask. Please keep in mind that I'm new to Fragments & FragmentActivity (not Android) and I don't really know how to work with them quite yet but I'm learning. My question is I want to k...

Introducing FOREIGN KEY constraint may cause cycles or multiple cascade paths - why?

I've been wrestling with this for a while and can't quite figure out what's happening. I have a Card entity which contains Sides (usually 2) - and both Cards and Sides have a Stage. I'm using EF Codefirst migrations and the migrations are failing w...

How to connect to remote Redis server?

I have URL and PORT of remote Redis server. I am able to write into Redis from Scala. However I want to connect to remote Redis via terminal using redis-server or something similar in order to make several call of hget, get, etc. (I can do it with my...

Iterating over Typescript Map

I'm trying to iterate over a typescript map but I keep getting errors and I could not find any solution yet for such a trivial problem. My code is: myMap : Map<string, boolean>; for(let key of myMap.keys()) { console.log(key); } And I ge...

Remove CSS from a Div using JQuery

I'm new to JQuery. In my App I have the following: $("#displayPanel div").live("click", function(){ $(this).css({'background-color' : 'pink', 'font-weight' : 'bolder'}); }); When I click on a Div, the color of that Div is changed. Within that Cl...

Breaking out of nested loops

Is there an easier way to break out of nested loops than throwing an exception? (In Perl, you can give labels to each loop and at least continue an outer loop.) for x in range(10): for y in range(10): print x*y if x*y > 50: ...

IndexOf function in T-SQL

Given an email address column, I need to find the position of the @ sign for substringing. What is the indexof function, for strings in T-SQL? Looking for something that returns the position of a substring within a string. in C# var s = "abcde"; ...

Omitting the second expression when using the if-else shorthand

Can I write the if else shorthand without the else? var x=1; x==2 ? dosomething() : doNothingButContinueCode(); I've noticed putting null for the else works (but I have no idea why or if that's a good idea). Edit: Some of you seem bemused w...

JBoss default password

What's the JBoss 5.x EAP default web console password?...

How to get the current time in YYYY-MM-DD HH:MI:Sec.Millisecond format in Java?

The code below gives me the current time. But it does not tell anything about milliseconds. public static String getCurrentTimeStamp() { SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//dd/MM/yyyy Date now = ...

How to get screen width without (minus) scrollbar?

I have an element and need it's width without(!) vertical scrollbar. Firebug tells me body width is 1280px. Either of these work fine in Firefox: console.log($('.element').outerWidth() ); console.log($('.element').outerWidth(true) ); $detour = $(...

Vuejs: Event on route change

In my main page I have dropdowns that show v-show=show by clicking on link @click = "show=!show" and I want to set show=false when I change route. Advise me please how to realize this thing....

How to create many labels and textboxes dynamically depending on the value of an integer variable?

Is there any way to dynamically create and display 'n' Labels with 'n' corresponding Textboxs when we know value of 'n' after for example, clicking "Display" button. Let me know if anything make you don't understand my question. Thank you! I am wor...

How to analyze information from a Java core dump?

If a process crashes and leaves a core dump or I create one with gcore then how can I analyze it? I'd like to be able to use jmap, jstack, jstat etc and also to see values of all variables. This way I can find the reasons for a crashed or frozen ...

Ping site and return result in PHP

I'd like to create a small IF procedure that will check if Twitter is available (unlike now, for example), and will return true or false. Help :)...

Add JsonArray to JsonObject

I googled a lot today for this subject. But I can't find it, How can I add a JSONArray to a JSONObject? Because everytime I do this I get this error: Stackoverflow JSONObject fillBadkamerFormaatFromContentlet(Structure structure, String for...

How can I add new dimensions to a Numpy array?

I'm starting off with a numpy array of an image. In[1]:img = cv2.imread('test.jpg') The shape is what you might expect for a 640x480 RGB image. In[2]:img.shape Out[2]: (480, 640, 3) However, this image that I have is a frame of a video, which i...

How to check if C string is empty

I'm writing a very small program in C that needs to check if a certain string is empty. For the sake of this question, I've simplified my code: #include <stdio.h> #include <string> int main() { char url[63] = {'\0'}; do { printf...

Loading state button in Bootstrap 3

I'm new to Bootstrap 3. Can't figure out how to activate the loading state button function. My code below is from the documents on getboostrap.com. <button type="button" data-loading-text="Loading..." class="btn btn-primary"> Loading state &...

Convert base64 png data to javascript file objects

I have two base64 encoded in PNG, and I need to compare them using Resemble.JS I think that the best way to do it is to convert the PNG's into file objects using fileReader. How can I do it?...

Stash just a single file

I'd like to be able to stash just the changes from a single file: git stash save -- just_my_file.txt The above doesn't work though. Any alternatives?...

.keyCode vs. .which

I thought this would be answered somewhere on Stack Overflow, but I can’t find it. If I’m listening for a keypress event, should I be using .keyCode or .which to determine if the Enter key was pressed? I’ve always done something like the foll...

Generate a heatmap in MatPlotLib using a scatter data set

I have a set of X,Y data points (about 10k) that are easy to plot as a scatter plot but that I would like to represent as a heatmap. I looked through the examples in MatPlotLib and they all seem to already start with heatmap cell values to generate ...

dynamic_cast and static_cast in C++

I am quite confused with the dynamic_cast keyword in C++. struct A { virtual void f() { } }; struct B : public A { }; struct C { }; void f () { A a; B b; A* ap = &b; B* b1 = dynamic_cast<B*> (&a); // NULL, becaus...

Making an image act like a button

I'm working on a simple HTML page where I have this image that I want to act as a button. Here is the code for my image: <div style="position: absolute; left: 10px; top: 40px;"> <img src="logg.png" width="114" height="38"> </div...

LaTeX: remove blank page after a \part or \chapter

How to remove a blank page that gets added automatically after \part{} or \chapter{} in a book document class? I need to add some short text describing the \part. Adding some text after the part command results in at least 3 pages with an empty page...

What are the advantages and disadvantages of recursion?

With respect to using recursion over non-recursive methods in sorting algorithms or, for that matter, any algorithm what are its pros and cons?...

What exactly is Apache Camel?

I don't understand what exactly Camel does. If you could give in 101 words an introduction to Camel: What exactly is it? How does it interact with an application written in Java? Is it something that goes together with the server? Is it an inde...

C# - How to get Program Files (x86) on Windows 64 bit

I'm using: FileInfo( System.Environment.GetFolderPath( System.Environment.SpecialFolder.ProgramFiles) + @"\MyInstalledApp" In order to determine if a program is detected on a users machine (it's not ideal, but the program I'm look...

Android: show/hide a view using an animation

I've been looking through many google results / questions on here to determine how to show/hide a view via a vertical animation, but I can't seem to find one that's exactly right or not too vague. I have a layout (undo bar) that's below another layo...

How to check if a string is a number?

I want to check if a string is a number with this code. I must check that all the chars in the string are integer, but the while returns always isDigit = 1. I don't know why that if doesn't work. char tmp[16]; scanf("%s", tmp); int isDigit = 0; int...

How to call on a function found on another file?

I'm recently starting to pick up C++ and the SFML library, and I was wondering if I defined a Sprite on a file appropriately called "player.cpp" how would I call it on my main loop located at "main.cpp"? Here is my code (Be aware that this is SFML 2...

How to condense if/else into one line in Python?

Possible Duplicate: Python Ternary Operator Putting a simple if-then statement on one line Is there a way to compress an if/else statement to one line in Python? I oftentimes see all sorts of shortcuts and suspect it can apply here too....

How to convert a currency string to a double with jQuery or Javascript?

I have a text box that will have a currency string in it that I then need to convert that string to a double to perform some operations on it. "$1,100.00" ? 1100.00 This needs to occur all client side. I have no choice but to leave the currency st...

What programming language does facebook use?

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

T-SQL CASE Clause: How to specify WHEN NULL

I wrote a T-SQL Statement similar like this (the original one looks different but I want to give an easy example here): SELECT first_name + CASE last_name WHEN null THEN 'Max' ELSE 'Peter' END AS Name FROM dbo.person This Statement does not h...

Scala: join an iterable of strings

How do I "join" an iterable of strings by another string in Scala? val thestrings = Array("a","b","c") val joined = ??? println(joined) I want this code to output a,b,c (join the elements by ",")....

AttributeError: Can only use .dt accessor with datetimelike values

Hi I am using pandas to convert a column to month. When I read my data they are objects: Date object dtype: object So I am first making them to date time and then try to make them as months: import pandas as pd file = '/pathtocsv.csv' ...

Populate XDocument from String

I'm working on a little something and I am trying to figure out whether I can load an XDocument from a string. XDocument.Load() seems to take the string passed to it as a path to a physical XML file. I want to try and bypass the step of first having...

NameError: name 'python' is not defined

Am encountering this error in Windows Command line,done a wide search but could not get a perfect answer.Please find the error below and help in solving. python Traceback (most recent call last): File "<stdin>", line 1, in <module> Nam...

How do I rewrite URLs in a proxy response in NGINX

I'm used to using Apache with mod_proxy_html, and am trying to achieve something similar with NGINX. The specific use case is that I have an admin UI running in Tomcat on port 8080 on a server at the root context: http://localhost:8080/ I need to...

How to calculate age (in years) based on Date of Birth and getDate()

I have a table listing people along with their date of birth (currently a nvarchar(25)) How can I convert that to a date, and then calculate their age in years? My data looks as follows ID Name DOB 1 John 1992-01-09 00:00:00 2 Sally...

Where can I read the Console output in Visual Studio 2015

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

How to set "style=display:none;" using jQuery's attr method?

Following is the form with id msform that I want to apply style="display:none" attribute to. <form id="msform" style="display:none;"> </form> Also the check should be performed before adding the "style=display:none;" property. That is ...

Call PowerShell script PS1 from another PS1 script inside Powershell ISE

I want call execution for a myScript1.ps1 script inside a second myScript2.ps1 script inside Powershell ISE. The following code inside MyScript2.ps1, works fine from Powershell Administration, but doesn't work inside PowerShell ISE: #Call myScript1...

WAMP shows error 'MSVCR100.dll' is missing when install

When I tried to install WAMP, that popped up the following alert, I clicked OK, it continued to install WAMP. When I start, the WAMP logo is always 'yellow'. It isn't turning 'green', meaning there's something wrong. What exactly is the MSVCR100.dl...

jQuery: How to get the event object in an event handler function without passing it as an argument?

I have an onclick attribute on my link: <a href="#" onclick="myFunc(1,2,3)">click</a> That points to this event handler in JavaScript: function myFunc(p1,p2,p3) { //need to refer to the current event object: alert(evt.type); ...

Printing to the console in Google Apps Script?

I am very new to programming (have taken some of the JS courses on Codecademy). I am trying to create a simple script to determine, if given a spreadsheet with results from a poker game, who should pay whom. I opened up Google Apps Script, and wrote ...

How to sort Map values by key in Java?

I have a Map that has strings for both keys and values. Data is like following: "question1", "1" "question9", "1" "question2", "4" "question5", "2" I want to sort the map based on its keys. So, in the end, I will have question1, que...

How to add icon to mat-icon-button

I am using Angular with Material <button mat-icon-button><mat-icon svgIcon="thumb-up"></mat-icon>Start Recording</button> I am trying to add an icon to button, but I can't figure out how to do it, and can't find documentat...

Comparing floating point number to zero

The C++ FAQ lite "[29.17] Why doesn't my floating-point comparison work?" recommends this equality test: #include <cmath> /* for std::abs(double) */ inline bool isEqual(double x, double y) { const double epsilon = /* some small nu...

Casting objects in Java

I'm confused about what it means to cast objects in Java. Say you have... Superclass variable = new Subclass object(); (Superclass variable).method(); What is happening here? Does the variable type change, or is it the object within the variable ...

How to convert dd/mm/yyyy string into JavaScript Date object?

How to convert a date in format 23/10/2015 into a JavaScript Date format: Fri Oct 23 2015 15:24:53 GMT+0530 (India Standard Time) ...

Enable SQL Server Broker taking too long

I have a Microsoft SQL server 2005 and I tried to enable Broker for my database with those T-SQL: SELECT name, is_broker_enabled FROM sys.databases -- checking its status 0 in my case ALTER DATABASE myDatabase SET ENABLE_BROKER The Alter Datab...

html select option separator

How do you make a separator in a select tag? New Window New Tab ----------- Save Page ------------ Exit ...

MySQL - Replace Character in Columns

Being a self-taught newbie, I created a large problem for myself. Before inserting data in to my database, I've been converting apostrophes (') in a string, to double quotes (""), instead of the required back-slash and apostrophe (\'), which MySQL ac...

Pandas DataFrame to List of Dictionaries

I have the following DataFrame: customer item1 item2 item3 1 apple milk tomato 2 water orange potato 3 juice mango chips which I want to translate it to list of dictionaries per row...

Qt: resizing a QLabel containing a QPixmap while keeping its aspect ratio

I use a QLabel to display the content of a bigger, dynamically changing QPixmap to the user. It would be nice to make this label smaller/larger depending on the space available. The screen size is not always as big as the QPixmap. How can I modify t...

How do I get the current username in .NET using C#?

How do I get the current username in .NET using C#?...

Cannot resolve symbol AppCompatActivity - Support v7 libraries aren't recognized?

I'm trying to figure out why the heck my Android studio isn't recognizing the AppCompat v7 library correctly. The import statement below shows up as gray and says there's no package for support.v7.app. Below is my activity file: import android.suppo...

Comprehensive beginner's virtualenv tutorial?

I've been hearing the buzz about virtualenv lately, and I'm interested. But all I've heard is a smattering of praise, and don't have a clear understanding of what it is or how to use it. I'm looking for (ideally) a follow-along tutorial that can tak...