Examples On Programing Languages

How do I create a Bash alias?

I'm on OSX and I need to put something like this, alias blah="/usr/bin/blah" in a config file but I don't know where the config file is. ...

How to create a Java / Maven project that works in Visual Studio Code?

I'm trying to create a maven project - so that I can compile Java files in the root folder and output the class files in another folder. I've already downloaded mvn. I'm trying to integrate with VS Code. My goal is to edit the java files in VS Code...

How does Facebook Sharer select Images and other metadata when sharing my URL?

When using Facebook Sharer, Facebook will offer the user the option of using 1 of a few images pulled from the source as a preview for their link. How are these images selected, and how can I ensure that any particular image on my page is always incl...

What does DIM stand for in Visual Basic and BASIC?

What does DIM stand for in Visual Basic? ...

An unhandled exception of type 'System.TypeInitializationException' occurred in EntityFramework.dll

I was trying to learn Entity Framework and SQLite using this tutorial. However, I get an error. The error thrown is: An unhandled exception of type 'System.TypeInitializationException' occurred in EntityFramework.dll Additional information:...

post checkbox value

I want to post values of check boxes on booking.php page. There are many checkboxes on the page but I don't know how to post on booking.php page. <form name="booking.php" method="post"> <label for="tour" class="tour-label">Add to ...

tar: add all files and directories in current directory INCLUDING .svn and so on

I try to tar.gz a directory and use tar -czf workspace.tar.gz * The resulting tar includes .svn directories in subdirs but NOT in the current directory (as * gets expanded to only 'visible' files before it is passed to tar I tried to tar -czf w...

How do I get only directories using Get-ChildItem?

I'm using PowerShell 2.0 and I want to pipe out all the subdirectories of a certain path. The following command outputs all files and directories, but I can't figure out how to filter out the files. Get-ChildItem c:\mypath -Recurse I've tried usin...

How to change a text with jQuery

I have an h1 with id of toptitle that is dynamically created, and I am not able to change the HTML. It will have a different title depends on a page. Now when it is Profile, I want to change it to New word with jQuery. <h1 id="toptitle">Profil...

How to get the difference between two dictionaries in Python?

I have two dictionaries. I need to find the difference between the two which should give me both key and value. I have searched and found some addons/packages like datadiff, dictdiff-master but when I try it in Python 2.7 it says no such module defi...

How can I generate a self-signed certificate with SubjectAltName using OpenSSL?

I am trying to generate a self-signed certificate with OpenSSL with SubjectAltName in it.While I am generating the csr for the certificate, my guess is I have to use v3 extensions of OpenSSL x509. I am using : openssl req -new -x509 -v3 -key private...

Using Ansible set_fact to create a dictionary from register results

In Ansible I've used register to save the results of a task in the variable people. Omitting the stuff I don't need, it has this structure: { "results": [ { "item": { "name": "Bob" }, "...

Write HTML file using Java

I want my Java application to write HTML code in a file. Right now, I am hard coding HTML tags using java.io.BufferedWriter class. For Example: BufferedWriter bw = new BufferedWriter(new FileWriter(file)); bw.write("<html><head><title...

What is the purpose of the "role" attribute in HTML?

I keep seeing role attributes in some people's work. I use it too, but I'm not sure about its effect. For example: <header id="header" role="banner"> Header stuff in here </header> Or: <section id="facebook" role="contentinfo"...

Using global variables between files?

I'm bit confused about how the global variables work. I have a large project, with around 50 files, and I need to define global variables for all those files. What I did was define them in my projects main.py file, as following: # ../myproject/main...

What is a good practice to check if an environmental variable exists or not?

I want to check my environment for the existence of a variable, say "FOO", in Python. For this purpose, I am using the os standard library. After reading the library's documentation, I have figured out 2 ways to achieve my goal: Method 1: if "FOO...

What does "opt" mean (as in the "opt" directory)? Is it an abbreviation?

What does "opt" mean (as in the "opt" directory)? I commonly see this directory in Unix systems with development tools inside. Is it an abbreviation?...

How to initialize a struct in accordance with C programming language standards

I want to initialize a struct element, split in declaration and initialization. This is what I have: typedef struct MY_TYPE { bool flag; short int value; double stuff; } MY_TYPE; void function(void) { MY_TYPE a; ... a = { true, 15, 0.12...

Aligning a float:left div to center?

I want to have a group of images display horizontally across the page. Each image has a few link below it so I need to put a container around each image/link-group. The closest I have gotten to what I want is putting them in divs that float:left. Th...

Bootstrap 4 img-circle class not working

I'm writing a website in HTML5 and Bootstrap 4 and I'm trying to turn a square image into a circle. In Bootstrap 3 this was easily do-able with .img-circle, but now I can't seem to get it to work and I can't find any answers online. Has Bootstrap dro...

What is the format for the PostgreSQL connection string / URL?

What is the format for the PostgreSQL connection string (URL postgres://...) when the host is not the localhost?...

Single line sftp from terminal

Several times throughout the day, I may be running a test where I need to look through a log file on a remote server. I've gotten used to using my terminal to sftp into the remote server and pull the desired log file down to /tmp on my local machine....

How to easily map c++ enums to strings

I have a bunch of enum types in some library header files that I'm using, and I want to have a way of converting enum values to user strings - and vice-versa. RTTI won't do it for me, because the 'user strings' need to be a bit more readable than t...

How can multiple rows be concatenated into one in Oracle without creating a stored procedure?

How can I achieve the following in oracle without creating a stored procedure? Data Set: question_id element_id 1 7 1 8 2 9 3 10 3 11 3 12 Desired Result: question_...

Change cursor to hand when mouse goes over a row in table

How do I change the cursor pointer to hand when my mouse goes over a <tr> in a <table> <table class="sortable" border-style:> <tr> <th class="tname">Name</th><th class="tage">Age</th> </tr&g...

Determine version of Entity Framework I am using?

I believe there are two versions 1 and 2? And version 2 is referred to as Entity Framework 4.0? How can I tell what version is being used in an application? This is in my web.config does this mean I am using version 2? <add assembly="System.Da...

What is a web service endpoint?

Let's say my web service is located at http://localhost:8080/foo/mywebservice and my WSDL is at http://localhost:8080/foo/mywebservice?wsdl. Is http://localhost:8080/foo/mywebservice an endpoint, i.e., is it the same as the URI of my web service or ...

Define a fixed-size list in Java

Is it possible to define a list with a fixed size that's 100? If not why isn't this available in Java?...

Hiding user input on terminal in Linux script

I have bash script like the following: #!/bin/bash echo "Please enter your username"; read username; echo "Please enter your password"; read password; I want that when the user types the password on the terminal, it should not be displayed (or s...

Android EditText Hint

I have set a hint for an EditText, currently the hint visibility is gone. When a user starts typing, I want to remove the hint text, when the cursor is visible in the EditText, not at the time when a user starts to type. How can I do that? <EditT...

Hide all elements with class using plain Javascript

I normally use document.getElementById('id').style.display = 'none' to hide a single div via Javascript. Is there a similarly simple way to hide all elements belonging to the same class? I need a plain Javascript solution that does not use jQuery....

Mockito test a void method throws an exception

I have a method with a void return type. It can also throw a number of exceptions so I'd like to test those exceptions being thrown. All attempts have failed with the same reason: The method when(T) in the type Stubber is not applicable for the a...

Use of def, val, and var in scala

class Person(val name:String,var age:Int ) def person = new Person("Kumar",12) person.age = 20 println(person.age) These lines of code outputs 12, even though person.age=20 was successfully executed. I found that this happens because I used def in ...

App.Config Transformation for projects which are not Web Projects in Visual Studio?

For Visual Studio 2010 Web based application we have Config Transformation features by which we can maintain multiple configuration files for different environments. But the same feature is not available for App.Config files for Windows Services/WinF...

How to put php inside JavaScript?

I've tried (but its not working): <?php $htmlString= 'testing'; ?> <html> <body> <script type="text/javascript"> var htmlString=<?php echo $htmlString; ?>; alert(htmlString); </script> ...

String.Format not work in TypeScript

String.Format does not work in TypeScript. Error: The property 'format' does not exist on value of type '{ prototype: String; fromCharCode(...codes: number[]): string; (value?: any): string; new(value?: any): String; }'. attributes["Title"...

Print line numbers starting at zero using awk

Can anyone tell me how to print line numbers including zero using awk? Here is my input file stackfile2.txt when I run the below awk command I get actual_output.txt awk '{print NR,$0}' stackfile2.txt | tr " ", "," > actual_output.txt wher...

Check if application is installed - Android

I'm trying to install apps from Google Play. I can understand that on opening the Google Play store URL, it opens the Google Play and when I press the back button, the activity resumes. Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(...

Remove all git files from a directory?

I have a folder under version control. I want to make a copy of it to send around, but don't want to include all the .git directories and the files underneath it. Is there a way to remove all the git files instead of manually deleting all of them?...

How to declare a global variable in JavaScript

How can I declare a global variable in JavaScript?...

The model backing the <Database> context has changed since the database was created

The error message : "The model backing the 'AddressBook' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the Rec...

How to sparsely checkout only one single file from a git repository?

How do I checkout just one file from a git repo?...

jQuery Mobile - back button

I am developing the application using jQuery Mobile 4.1. In my app, I have two html pages like login.html and home.html. In the home.html have 3 pages. () like menupage, searchpage, resultpage. The project flow is login.html ---> home.html. In hom...

Update with two tables?

I am trying to update table A with data from table B. I thought I could do something like: UPDATE A SET A.name = B.name WHERE A.id = B.id but alas, this does not work. Anyone have an idea of how I can do this?...

Getting request payload from POST request in Java servlet

I have a javascript library that is sending a POST request to my Java servlet, but in the doPost method, I can't seem to get the contents of the request payload. In chrome Developer Tools, all the content is in the Request Payload section in the head...

The 'json' native gem requires installed build tools

I have ruby 1.9.2p180 (2011-02-18) [i386-mingw32] installed on my windows 7 machine. Now I tried to install the JSON gem using the command, "gem install json" and got the following error. ERROR: Error installing JSON: The 'json' native gem requ...

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

Chrome, Javascript, window.open in new tab

In chrome this opens in a new tab: <button onclick="window.open('newpage.html', '_blank')" /> this opens in a new window (but I'd like this to open in a new tab as well: <script language="javascript"> window.open('newpage.html', '_b...

Return generated pdf using spring MVC

I am using Spring MVC .I have to write a service that would take input from the request body, add the data to the pdf and returns the pdf file to the browser. The pdf document is generated using itextpdf. How can I do this using Spring MVC. I have tr...

Python: how to print range a-z?

1. Print a-n: a b c d e f g h i j k l m n 2. Every second in a-n: a c e g i k m 3. Append a-n to index of urls{hello.com/, hej.com/, ..., hallo.com/}: hello.com/a hej.com/b ... hallo.com/n...

Select all elements with a "data-xxx" attribute without using jQuery

Using only pure JavaScript, what is the most efficient way to select all DOM elements that have a certain data- attribute (let's say data-foo). The elements may be different, for example: <p data-foo="0"></p><br/><h6 da...

How to set the From email address for mailx command?

I am working on a KornShell (ksh) script running on a Solaris server that will send out an email when and error condition is met. I am sending the email via mailx. Question: How do I set the "From" email address on the mailx command? Current Cod...

Printing column separated by comma using Awk command line

I have a problem here. I have to print a column in a text file using awk. However, the columns are not separated by spaces at all, only using a single comma. Looks something like this: column1,column2,column3,column4,column5,column6 How would I pr...

html select option separator

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

LDAP Authentication using Java

I need to do LDAP Authentication for an application. I tried the following program: import java.util.Hashtable; import javax.naming.Context; import javax.naming.NamingException; import javax.naming.ldap.InitialLdapContext; import javax.nam...

How do I pass multiple parameters into a function in PowerShell?

If I have a function which accepts more than one string parameter, the first parameter seems to get all the data assigned to it, and remaining parameters are passed in as empty. A quick test script: Function Test([string]$arg1, [string]$arg2) { ...

How do I shutdown, restart, or log off Windows via a bat file?

I've been using Remote Desktop Connection to get into a workstation. But in this environment, I cannot use the power options in Start Menu. I need an alternative way to shutdown or restart. How do I control my computer's power state through the comm...

java.sql.SQLException: Missing IN or OUT parameter at index:: 1

I made some Java 1.6-Oracle11g-JDBC (using OJDBC 6) code (below). I am getting an exception - java.sql.SQLException: Missing IN or OUT parameter at index:: 1 Why is this happening and how do I fix it ? My output is- create CREATE TABLE employee(emp...

Force table column widths to always be fixed regardless of contents

I have an html table with table-layout: fixed and a td with a set width. The column still expands to hold the contents of text that doesn't contain a space. Is there a way to fix this other than wrapping the contents of each td in a div? Example: ...

SQL Server insert if not exists best practice

I have a Competitions results table which holds team member's names and their ranking on one hand. On the other hand I need to maintain a table of unique competitors names: CREATE TABLE Competitors (cName nvarchar(64) primary key) Now I have some...

XPath Query: get attribute href from a tag

I want to use XPath to get the href attribute from an a-tag, but it has two occurrences within the same file. How am I getting along? I need to check IF there is an href attribute with value $street/object, I have got this code and it does not work: ...

How to use PHP to connect to sql server

I want to use PHP to connect to sql server database. I installed xampp 1.7.0(php 5.2) and SQLSRV20. I've added the extensions in php.ini and I get this error: Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: 10.85.8...

Auto expand a textarea using jQuery

How can I make a textarea automatically expand using jQuery? I have a textbox for explaining the agenda of the meeting, so I want to expand that textbox when my agenda's text keep growing that textbox area....

HTML Table cell background image alignment

I need the background image of a table cell to be aligned as Top in vertical side - Right in Horizontal But it is displaying as, Center in Vertical side ; Right in Horizontal Take a look at this page: http://www.chemfluence.org.in/monetar...

Match whitespace but not newlines

I sometimes want to match whitespace but not newline. So far I've been resorting to [ \t]. Is there a less awkward way?...

Convert an array into an ArrayList

I'm having a lot of trouble turning an array into an ArrayList in Java. This is my array right now: Card[] hand = new Card[2]; "hand" holds an array of "Cards". How this would look like as an ArrayList?...

JavaScript blob filename without link

How do you set the name of a blob file in JavaScript when force downloading it through window.location? function newFile(data) { var json = JSON.stringify(data); var blob = new Blob([json], {type: "octet/stream"}); var url = wi...

Download a file from HTTPS using download.file()

I would like to read online data to R using download.file() as shown below. URL <- "https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2Fss06hid.csv" download.file(URL, destfile = "./data/data.csv", method="curl") Someone suggested to me that...

CentOS: Enabling GD Support in PHP Installation

How do I go about enabling GD Support in a CentOS Installation?...

Call web service in excel

In a VBA module in excel 2007, is it possible to call a web service? If so, any code snippets? How would I add the web reference?...

SQL: Group by minimum value in one field while selecting distinct rows

Here's what I'm trying to do. Let's say I have this table t: key_id | id | record_date | other_cols 1 | 18 | 2011-04-03 | x 2 | 18 | 2012-05-19 | y 3 | 18 | 2012-08-09 | z 4 | 19 | 2009-06-01 | a 5 | 19 | 2011-04-03 | b ...

How to make Twitter Bootstrap tooltips have multiple lines?

I am currently using the below function to create text that will be displayed using Bootstrap’s tooltip plugin. How come multiline tooltips only work with <br> and not \n? I prefer that there is not any HTML in my links’ title attributes. ...

How to connect to Mysql Server inside VirtualBox Vagrant?

I mounted a new VirtualBox Machine with Vagrant, and inside that VM I installed Mysql Server. How can I connect to that server outside the vm? I already forward the port 3306 of the Vagrantfile , but when I try to connect to the mysql server, it`s re...

Difference between classification and clustering in data mining?

Can someone explain what the difference is between classification and clustering in data mining? If you can, please give examples of both to understand the main idea....

How to convert a PNG image to a SVG?

How to convert a PNG image to a SVG?...

How can I check if mysql is installed on ubuntu?

I need to check if mysql is installed on a ubuntu server. Is there a way to determine if mySql has been installed ? Thanks....

how to remove the dotted line around the clicked a element in html

I found that if there is a a link in the page which does not link to a new page,then when user click it,there will be a dotted line around the element,it will only disappear when user click anything else in the page,how to remove this? Example: Note...

Property [title] does not exist on this collection instance

I am following Laracasts' videos: Basic Model/Controller/View Workflow. I have a table holds contact information. CREATE TABLE `about` ( `id` int(10) UNSIGNED NOT NULL, `title` varchar(500) COLLATE utf8_unicode_ci NOT NULL, `content` text COLLATE u...

Joining 2 SQL SELECT result sets into one

I've got 2 select statements, returning data like this: Select 1 col_a col_b Select 2 col_a col_c If I do union, I get something like col_a col_b And rows joined. What i need is getting it like this: col_a col_b col_c Joined on data i...

C# windows application Event: CLR20r3 on application start

I created a C# application and installed it on my test box. My app works perfect on my dev box, but when I install in on a different machine it crashes in the Main(). I get the EventType: CLR20r3 here is the Event Message Problem signature: ...

how to find all indexes and their columns for tables, views and synonyms in oracle

I jotted down the following query which will list the index name and its columns for a particular table: select b.uniqueness, a.index_name, a.table_name, a.column_name from all_ind_columns a, all_indexes b where a.index_name=b.index_name and a.ta...

jquery (or pure js) simulate enter key pressed for testing

What the best way to simulate the user pressing "enter"? $(element).keypress() doesn't seem to allow me to pass in the actual key that was pressed. This is for unit testing. ...

How to change MySQL column definition?

I have a mySQL table called test: create table test( locationExpect varchar(120) NOT NULL; ); I want to change the locationExpect column to: create table test( locationExpect varchar(120); ); How can it be done quickly?...

How can I make Bootstrap 4 columns all the same height?

Disclaimer. This question was asked many times before. But since time has passed and now we are close to Bootstrap 4 release with full flexbox support, it is time for new answers for the same question. I want to create equal column height with Boots...

Java 8 Iterable.forEach() vs foreach loop

Which of the following is better practice in Java 8? Java 8: joins.forEach(join -> mIrc.join(mSession, join)); Java 7: for (String join : joins) { mIrc.join(mSession, join); } I have lots of for loops that could be "simplified" with lam...

Export to csv in jQuery

I am dynamically generating a div which is like : <div id='PrintDiv'> <table id="mainTable"> <tr> <td> Col1 </td> <td> ...

How to get first and last day of week in Oracle?

I need to get the first day and the last day of the week from some strings that have the format like this: '201118' where 2011 is the year and 18 is the number of the week. Knowing the number of the week, how do I get the first and the last day of...

VARCHAR to DECIMAL

I want to convert a varchar(max) column to decimal(10,4). When I try to use cast or convert I am getting an arithmetic overflow exception. The issue is that the data stored in the varchar column may contain different precisions and different scales...

how to sort order of LEFT JOIN in SQL query?

OK I tried googling for an answer like crazy, but I couldn't resolve this, so I hope someone will be able to help. Let's say I have a table of users, very simple table: id | userName 3 Michael 4 Mike 5 George and I have another table of ...

How to test if string exists in file with Bash?

I have a file that contains directory names: my_list.txt : /tmp /var/tmp I'd like to check in Bash before I'll add a directory name if that name already exists in the file....

RecyclerView - How to smooth scroll to top of item on a certain position?

On a RecyclerView, I am able to suddenly scroll to the top of a selected item by using: ((LinearLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(position, 0); However, this abruptly moves the item to the top position. I w...

Iterating through struct fieldnames in MATLAB

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

Accessing JPEG EXIF rotation data in JavaScript on the client side

I'd like to rotate photos based on their original rotation, as set by the camera in JPEG EXIF image data. The trick is that all this should happen in the browser, using JavaScript and <canvas>. How could JavaScript access JPEG, a local file AP...

How do I use PHP namespaces with autoload?

I get this error when I try to use autoload and namespaces: Fatal error: Class 'Class1' not found in /usr/local/www/apache22/data/public/php5.3/test.php on line 10 Can anyone tell me what I am doing wrong? Here is my code: Class1.php: <?p...

How can I reload .emacs after changing it?

How can I get Emacs to reload all my definitions that I have updated in .emacs without restarting Emacs?...

How to create a JQuery Clock / Timer

I have a simple quiz application and I want display a nice timer / clock at the top of the page which shows the user how long they've been going for. (If I could somehow show them a timer for Total Quiz Time and also a second one for This Question Ti...

Getting index value on razor foreach

I'm iterating a List<T> in a razor foreach loop in my view which renders a partial. In the partial I'm rendering a single record for which I want to have 4 in a row in my view. I have a css class for the two end columns so need to determine in ...

How do I list all remote branches in Git 1.7+?

I've tried git branch -r, but that only lists remote branches that I've tracked locally. How do I find the list of those that I haven't? (It doesn't matter to me whether the command lists all remote branches or only those that are untracked.)...

PHP Curl UTF-8 Charset

I have an php script which calls another web page and writes all the html of the page and everything goes ok however there is a charset problem. My php file encoding is utf-8 and all other php files work ok (that means there is no problem with server...

Java how to replace 2 or more spaces with single space in string and delete leading and trailing spaces

Looking for quick, simple way in Java to change this string " hello there " to something that looks like this "hello there" where I replace all those multiple spaces with a single space, except I also want the one or more spaces at the b...

Passing functions with arguments to another function in Python?

Is it possible to pass functions with arguments to another function in Python? Say for something like: def perform(function): return function() But the functions to be passed will have arguments like: action1() action2(p) action3(p,r) ...

passing object by reference in C++

The usual way to pass a variable by reference in C++(also C) is as follows: void _someFunction(dataType *name){ // dataType e.g int,char,float etc. /**** definition */ } int main(){ dataType v; _somefunction(&v); //address of variable ...

Update R using RStudio

How can I update R via RStudio?...

ORACLE and TRIGGERS (inserted, updated, deleted)

I would like to use a trigger on a table which will be fired every time a row is inserted, updated, or deleted. I wrote something like this: CREATE or REPLACE TRIGGER test001 AFTER INSERT OR DELETE OR UPDATE ON tabletest001 REFERENCING OLD AS o...

Changing font size and direction of axes text in ggplot2

I am plotting a graph with a categorical variable on the x axis and a numerical variable on the y axis. For the x axis, given that there are many data points, the default text formatting causes the label for each tick mark to overlap with other labe...

What is the best way to generate a unique and short file name in Java

I don't necessarily want to use UUIDs since they are fairly long. The file just needs to be unique within its directory. One thought which comes to mind is to use File.createTempFile(String prefix, String suffix), but that seems wrong because the f...

CSS full screen div with text in the middle

I have a css class defined so I can make a div to use all the browser's viewport, the rule is the following: .fullscreenDiv { background-color: #e8e8e8; width: 100%; height: auto; bottom: 0px; top: 0px; left: 0; position:...

How to add subject alernative name to ssl certs?

I'm using openssl to create self-signed certs. I'm getting this error with the certs I generated: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present Does anyone know how to sp...

How to get the indexpath.row when an element is activated?

I have a tableview with buttons and I want to use the indexpath.row when one of them is tapped. This is what I currently have, but it always is 0 var point = Int() func buttonPressed(sender: AnyObject) { let pointInTable: CGPoint = sende...

Set initially selected item in Select list in Angular2

I've managed to get a Select list to bind with my model for the purpose of saving, but I cannot work out how to make Angular2 automatically select the correct option on the Select list if I'm providing editing functionality. In other words, if I'm ed...

Zoom to fit: PDF Embedded in HTML

I am embedding a local pdf file into a simple webpage and I am looking to set the initial zoom to fit to the object size. Here is what I tried but it is not affecting the zoom. <embed src="filename.pdf?zoom=50" width="575" height="500"> doe...

How to disable HTML button using JavaScript?

I’ve read that you can disable (make physically unclickable) an HTML button simply by appending disable to its tag, but not as an attribute, as follows: <input type="button" name=myButton value="disable" disabled> Since this setting is not...

jQuery $.ajax(), $.post sending "OPTIONS" as REQUEST_METHOD in Firefox

Having trouble with what I thought was a relatively simple jQuery plugin... The plugin should fetch data from a php script via ajax to add options to a <select>. The ajax request is pretty generic: $.ajax({ url: o.url, type: 'post', co...

How to split a string into an array in Bash?

In a Bash script, I would like to split a line into pieces and store them in an array. For example, given the line: Paris, France, Europe I would like to have the resulting array to look like so: array[0] = Paris array[1] = France array[2] = Europe ...

npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Nuwanst\package.json'

I just want to install socket.io to my project which is located on 3.chat folder. But when I run following command it shows following Warnings.And its not created a node_modules directory inside my project folder. How to fix this? C:\Users\Nuwanst\D...

How do I center text horizontally and vertically in a TextView?

How do I center the text horizontally and vertically in a TextView, so that it appears exactly in the middle of the TextView in Android?...

Java random numbers using a seed

This is my code to generate random numbers using a seed as an argument: double randomGenerator(long seed) { Random generator = new Random(seed); double num = generator.nextDouble() * (0.5); return num; } Every time I give a seed and t...

Search for string and get count in vi editor

I want to search for a string and find the number of occurrences in a file using the vi editor....

MySql export schema without data

I'm using a MySql database with a Java program, now I want to give the program to somebody else. How to export the MySql database structure without the data in it, just the structure?...

How can I escape double quotes in XML attributes values?

From the following trials <tag attr="\""> <tag attr="<![CDATA["]]>"> <tag attr='"'> Only the last one works for an XML parser that I'm using here. Is there an alternative?...

How do I make a Git commit in the past?

I'm converting everything over to Git for my own personal use and I found some old versions of a file already in the repository. How do I commit it to the history in the correct order according the file's "date modified" so I have an accur...

Set focus and cursor to end of text input field / string w. Jquery

I have the following function that adds a selector to a search input as an advanced option, just like stack overflows advanced search. When you click what you are searching for it adds a prefix. See Jquery below: <script> $(document).ready(fu...

Why Git is not allowing me to commit even after configuration?

This question seems like a duplicate but it's really not. Just a slight difference that keeps on repeating. git keeps on telling me: "please tell me who you are", even after setting it up. when I run git commit, this is what I get.... $ git commit ...

Getting a count of objects in a queryset in django

How can I add a field for the count of objects in a database. I have the following models: class Item(models.Model): name = models.CharField() class Contest(models.Model); name = models.CharField() class Votes(models.Model): user = mod...

Ant build failed: "Target "build..xml" does not exist"

When I run the ant file in verbose mode, I got an error like the one below. Does anyone have any ideas what is going wrong? I am new to this antlib:org.apache.tools.ant] Could not load definitions from resource org/apach e/tools/ant/antlib.xml. It c...

How to open mail app from Swift

Im working on a simple swift app where the user inputs an email address and presses a button which opens the mail app, with the entered address in the address bar. I know how to do this in Objective-C, but I'm having trouble getting it to work in Swi...

typedef struct vs struct definitions

I'm a beginner in C programming, but I was wondering what's the difference between using typedef when defining a structure versus not using typedef. It seems to me like there's really no difference, they accomplish the same goal. struct myStruct{ ...

How to input a string from user into environment variable from batch file

I want to prompt the user for some input detail, and then use it later as a command line argument....

Java Switch Statement - Is "or"/"and" possible?

I implemented a font system that finds out which letter to use via char switch statements. There are only capital letters in my font image. I need to make it so that, for example, 'a' and 'A' both have the same output. Instead of having 2x the amount...

Iterate over each line in a string in PHP

I have a form that allows the user to either upload a text file or copy/paste the contents of the file into a textarea. I can easily differentiate between the two and put whichever one they entered into a string variable, but where do I go from there...

How do I ignore files in a directory in Git?

What is the proper syntax for the .gitignore file to ignore files in a directory? Would it be config/databases.yml cache/* log/* data/sql/* lib/filter/base/* lib/form/base/* lib/model/map/* lib/model/om/* or /config/databases.yml /cache/* /log/*...

Trim a string in C

Briefly: I'm after the equivalent of .NET's String.Trim in C using the win32 and standard C api (compiling with MSVC2008 so I have access to all the C++ stuff if needed, but I am just trying to trim a char*). Given that there is strchr, strtok, a...

How do you stop MySQL on a Mac OS install?

I installed MySQL via MacPorts. What is the command I need to stop the server (I need to test how my application behave when MySQL is dead)?...

Change NULL values in Datetime format to empty string

I have a table which contains 'NULL' values which are of type 'Datetime'. Now i have to convert those into empty string but when when i use convert function ISNULL( [Accrued Out of Default] ,'' ) here accrued into default is of datetime type, what...

Map implementation with duplicate keys

I want to have a map with duplicate keys. I know there are many map implementations (Eclipse shows me about 50), so I bet there must be one that allows this. I know it's easy to write your own map that does this, but I would rather use some existing...

#define in Java

I'm beginning to program in Java and I'm wondering if the equivalent to the C++ #define exists. A quick search of google says that it doesn't, but could anyone tell me if something similar exists in Java? I'm trying to make my code more readable. ...

HTTP Status 405 - Request method 'POST' not supported (Spring MVC)

Im getting this error: HTTP Status 405 - Request method 'POST' not supported What I am trying to do is make a form with a drop down box that get populated based on the other value selected in another drop down box. For example when I select a name ...

Multiple Where clauses in Lambda expressions

I have a simple lambda expression that goes something like this: x=> x.Lists.Include(l => l.Title).Where(l=>l.Title != String.Empty) Now, if I want to add one more where clause to the expression, say, l.InternalName != String.Empty then w...

How to crop an image in OpenCV using Python

How can I crop images, like I've done before in PIL, using OpenCV. Working example on PIL im = Image.open('0.png').convert('L') im = im.crop((1, 1, 98, 33)) im.save('_0.png') But how I can do it on OpenCV? This is what I tried: im = cv.imread...

How do you discover model attributes in Rails?

I am finding it difficult to easily see what attributes/properties exist on all of my model classes since they are not explicitly defined in my class files. To discover model attributes, I keep the schema.rb file open and flip between it and whateve...

com.google.android.gms:play-services-measurement-base is being requested by various other libraries

I updated to gradle 4.0.1 and started receiving following error The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.4,15.0.4]], but resolves to 15.0.2. Disable the plugin a...

int object is not iterable?

inp = int(input("Enter a number:")) for i in inp: n = n + i; print (n) ... throws an error: 'int' object is not iterable I wanted to find out the total by adding each digit, for eg, 110. 1 + 1 + 0 = 2. How do I do that? Thanks...

How can I overwrite file contents with new content in PHP?

I tried to use fopen, but I only managed to append content to end of file. Is it possible to overwrite all contents with new content in PHP?...

sql server invalid object name - but tables are listed in SSMS tables list

I am attempting to create a Stored Procedure for a newly created database. However the SSMS intellisense does not recognize more than half of the tables which have been created. For example whilst in the left hand column under tables I have a table...

How to create a backup of a single table in a postgres database?

Is there a way to create a backup of a single table within a database using postgres? And how? Does this also work with the pg_dump command?...

How to kill a process running on particular port in Linux?

I tried to close the tomcat using ./shutdown.sh from tomcat /bin directory. But found that the server was not closed properly. And thus I was unable to restartMy tomcat is running on port 8080. I want to kill the tomcat process running on 8080. I fi...

Return rows in random order

Is it possible to write SQL query that returns table rows in random order every time the query run?...

Django: Model Form "object has no attribute 'cleaned_data'"

I am trying to make a search form for one of my classes. The model of the form is: from django import forms from django.forms import CharField, ModelMultipleChoiceField, ModelChoiceField from books.models import Book, Author, Category class SearchF...

Correct file permissions for WordPress

I've had a look over here but didn't find any details on the best file permissions. I also took a look at some of WordPress's form's questions over here too but anybody that suggests 777 obviously needs a little lesson in security. In short my ques...

What's the difference between SHA and AES encryption?

What's the difference between SHA and AES encryption?...

Downloading all maven dependencies to a directory NOT in repository?

I started to convert my project to maven because I needed to use a library that was distributed in binary form over maven only, but after banging my head against the wall on it for far too long I've decided to stop hurting myself and just use Ant. I...

Insert HTML into view from AngularJS controller

Is it possible to create an HTML fragment in an AngularJS controller and have this HTML shown in the view? This comes from a requirement to turn an inconsistent JSON blob into a nested list of id: value pairs. Therefore the HTML is created in the co...

Microsoft Excel mangles Diacritics in .csv files?

I am programmatically exporting data (using PHP 5.2) into a .csv test file. Example data: Numéro 1 (note the accented e). The data is utf-8 (no prepended BOM). When I open this file in MS Excel is displays as Numéro 1. I am able to open this ...

How can I list the contents of a directory in Python?

Can’t be hard, but I’m having a mental block....

How to enter ssh password using bash?

Everyday I am connecting to a server through ssh. I go through this routine: IC001:Desktop user$ ssh [email protected] [email protected]'s password: Last login: Tue Jun 4 10:09:01 2013 from 0.0.0.0 $ I would like to automate this process and ...

Address validation using Google Maps API

I have a task to validate addresses entered into a system I am currently creating. The system requires that address entered are validated against a valid data source. In the UK the dataset comes from the Royal Mail and is expensive to access. The ...

Error loading MySQLdb Module 'Did you install mysqlclient or MySQL-python?'

I am using windows 10 command line for a django project using python34 however, I am facing difficulties with SQL. I have already installed mysqlclient using pip install mysqlclient==1.3.5 and located the file to make sure I was not delusional. I t...

How to check if DST (Daylight Saving Time) is in effect, and if so, the offset?

This is a bit of my JS code for which this is needed: var secDiff = Math.abs(Math.round((utc_date-this.premiere_date)/1000)); this.years = this.calculateUnit(secDiff,(86400*365)); this.days = this.calculateUnit(secDiff-(this.years*(86400*365)),86400...

How to schedule a periodic task in Java?

I need to schedule a task to run in at fixed interval of time. How can I do this with support of long intervals (for example on each 8 hours)? I'm currently using java.util.Timer.scheduleAtFixedRate. Does java.util.Timer.scheduleAtFixedRate support ...

MySQL join with where clause

I have two tables I want to join. I want all of the categories in the categories table and also all of the categories subscribed to by a user in the category_subscriptions table. essentially this is my query so far: SELECT * FROM categories LEFT J...

Difference between .keystore file and .jks file

I have tried to find the difference between .keystore files and .jks files, yet I could not find it. I know jks is for "Java keystore" and both are a way to store key/value pairs. Is there any difference or a preference to use one over another?...

Difference between wait and sleep

What is difference between wait and sleep?...

How to use curl in a shell script?

I'm trying to run this shell script in order to install RVM in an Ubuntu box #!/bin/bash RVMHTTP="https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer" CURLARGS="-f -s -S -k" bash < <(curl $CURLARGS $RVMHTTP) but I get th...

jquery variable syntax

I'm learning jQuery by trying to understand other people's code. I ran into this: jQuery.fn.myFunc = function(options, callback) { //stuff jQuery(this)[settings.event](function(e) { var self = this, $self = jQuery( this ), $body = j...

How to sort a data frame by alphabetic order of a character variable in R?

I would like to sort a data frame by alphabetic order of a character variable in R. I've tried to do it with the order() function but it transforms my data frame into a list. Does anyone has a clue ?...

C++ getters/setters coding style

I have been programming in C# for a while and now I want to brush up on my C++ skills. Having the class: class Foo { const std::string& name_; ... }; What would be the best approach (I only want to allow read access to the name_ fiel...

jQuery show/hide not working

I have a basic html page with some JS and CSS: _x000D_ _x000D_ $('.expand').click(function() {_x000D_ $('.img_display_content').show();_x000D_ });_x000D_ @charset "utf-8";_x000D_ _x000D_ /* CSS Document */_x000D_ _x000D_ .wrap {_x000D_ margin-le...

HTML form with two submit buttons and two "target" attributes

I have one HTML <form>. The form has only one action="" attribute. However I wish to have two different target="" attributes, depending on which button you click to submit the form. This is probably some fancy JavaScript code, but I haven't a...

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test

I have scoured the internet for almost five days now looking for a fix to this issue, but I cannot seem to find and fix it on my own, mainly because I am so new to both Maven and PlayN so I'm not entirely sure at what I'm looking at exactly. But, it...

identifier "string" undefined?

I am receiving the error: identifier "string" undefined. However, I am including string.h and in my main file, everything is working fine. CODE: #pragma once #include <iostream> #include <time.h> #include <string.h> class diffic...

How to calculate number of days between two dates

I have two input dates taking from Date Picker control. I have selected start date 2/2/2012 and end date 2/7/2012. I have written following code for that. I should get result as 6 but I am getting 5. function SetDays(invoker) { var start = $...

MS SQL Date Only Without Time

Question Hello All, I've had some confusion for quite some time with essentially flooring a DateTime SQL type using T-SQL. Essentially, I want to take a DateTime value of say 2008-12-1 14:30:12 and make it 2008-12-1 00:00:00. Alot of the queries ...

Set Text property of asp:label in Javascript PROPER way

I have a series of textboxes on a form. When the user inserts numbers into these textboxes, calculations are made and <asp:Label> controls are updated via JavaScript to reflect these calculations: document.getElementById('<%=TotalLoans.Cli...

Android webview & localStorage

I have a problem with a webview which may access to the localStorage by an HTML5 app. The test.html file informs me that local storage is'nt supported by my browser (ie. the webview). If you have any suggestion.. package com.test.HelloWebView; im...

How do you divide each element in a list by an int?

I just want to divide each element in a list by an int. myList = [10,20,30,40,50,60,70,80,90] myInt = 10 newList = myList/myInt This is the error: TypeError: unsupported operand type(s) for /: 'list' and 'int' I understand why I am receiving th...

Remove All Event Listeners of Specific Type

I want to remove all event listeners of a specific type that were added using addEventListener(). All the resources I'm seeing are saying you need to do this: elem.addEventListener('mousedown',specific_function); elem.removeEventListener('mousedown'...

How to draw a custom UIView that is just a circle - iPhone app

How would I go about drawing a custom UIView that is literally just a ball (a 2D circle)? Would I just override the drawRect method? And can someone show me the code for drawing a blue circle? Also, would it be okay to change the frame of that view...

How to make a div 100% height of the browser window

I have a layout with two columns - a left div and a right div. The right div has a grey background-color, and I need it to expand vertically depending on the height of the user's browser window. Right now the background-color ends at the last piece ...

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

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

Can't install laravel installer via composer

I'm trying to install laravel installer with the composer on my Ubuntu PC, but I get this error during the installation. `Your requirements could not be resolved to an installable set of packages. Problem 1 - laravel/installer v1.4.1 requires ...

Converting Pandas dataframe into Spark dataframe error

I'm trying to convert Pandas DF into Spark one. DF head: 10000001,1,0,1,12:35,OK,10002,1,0,9,f,NA,24,24,0,3,9,0,0,1,1,0,0,4,543 10000001,2,0,1,12:36,OK,10002,1,0,9,f,NA,24,24,0,3,9,2,1,1,3,1,3,2,611 10000002,1,0,4,12:19,PA,10003,1,1,7,f,NA,74,74,0,2...

How can I convert this one line of ActionScript to C#?

I would like to convert this one line of code to C# code within a void: param1:Function=null I am aware that in the void, it would be like "thing here" param1, but I dont know what "thing here" would exactly be. Thanks for your help!...

jQuery Set Selected Option Using Next

How can I, using jQuery, set the "next" item of an already selected item as "selected." For example, if I have: <select> <option value="1" >Number 1</option> <option value="2" selected="selected">Number 2</option>...

How to concatenate strings with padding in sqlite

I have three columns in an sqlite table: Column1 Column2 Column3 A 1 1 A 1 2 A 12 2 C 13 2 B 11 2 I need to select Column1-Column2...

Critical t values in R

I need to determine the critical t values for one-sided tails of 75% and 99%, for 40 degrees of freedom. The following is code for a two-sided 99% critical t values: qt(0.01, 40) but how can I determine for a one-sided critical t value?...

Get only the date in timestamp in mysql

On my database under the t_stamp columns I have the date for example 2013-11-26 01:24:34 From that same column I only want to get the date 2013-11-26 How can i do this? Thank You!...

jQuery Loop through each div

I'm pretty sure this will be a really easy answer for you jQuery whizzes, and I'm also pretty such it involves a loop of some kind. I'm trying to perform essentially the same calculation on two separate divs, but assigning a different CSS width valu...

How to get method parameter names?

Given the Python function: def a_method(arg1, arg2): pass How can I extract the number and names of the arguments. I.e., given that I have a reference to func, I want the func.[something] to return ("arg1", "arg2"). The usage scenario for thi...

How do you reset the stored credentials in 'git credential-osxkeychain'?

I've followed the GitHub instructions for setting up my account, and I'm able to clone, but I'm unable to push remotely. When I do a "git push" I get the 403 error. It has the correct URL. I tried a "git credential-osxkeychain get" to see what it wa...

Gulp command not found after install

I installed gulp(globally) and it looks like it worked because it ran this code: +-- [email protected] +-- [email protected] +-- [email protected] +-- [email protected] +-- [email protected] +-- [email protected] +-- [email protected] +-- [email protected] (stream-co...

What is the difference between field, variable, attribute, and property in Java POJOs?

When referring to internal private variables of Java POJOs that have getters/setters, I've used the following terms: field variable attribute property Is there any difference between the above? If so, what is the correct term to use? Is there a d...

Disable text input history

Possible Duplicate: How do you disable browser Autocomplete on web form field / input tag? I am building an application which will be accepting credit card data. I would like to make sure that the browser does not remember what has been typ...

Reading numbers from a text file into an array in C

I'm a programming noob so please bear with me. I'm trying to read numbers from a text file into an array. The text file, "somenumbers.txt" simply holds 16 numbers as so "5623125698541159". #include <stdio.h> main() { FILE *myFile; my...

Why isn't textarea an input[type="textarea"]?

Why is there an element <textarea> instead of <input type="textarea">?...

MySQL add days to a date

I have a table in MySQL. What would be the sql statement look like to add say 2 days to the current date value in the table? UPDATE classes SET date = date + 1 where id = 161 this adds one second to the value, i don't want to update the time, i ...

log4net vs. Nlog

Anyone have experience for both? How do they stack up against each other? We are planning on using one of them for logging in an enterprise application. References: log4net nlog EDIT: We have no existing dependencies to either nlog or log4net....

Why does cURL return error "(23) Failed writing body"?

It works ok as a single tool: curl "someURL" curl -o - "someURL" but it doesn't work in a pipeline: curl "someURL" | tr -d '\n' curl -o - "someURL" | tr -d '\n' it returns: (23) Failed writing body What is the problem with piping the cURL ou...

Repeat command automatically in Linux

Is it possible in Linux command line to have a command repeat every n seconds? Say, I have an import running, and I am doing ls -l to check if the file size is increasing. I would like to have a command to have this repeat automatically....

How do I check form validity with angularjs?

I'm very new to angularjs. Say my app has a form. Using the inspector, I noticed that if angularjs thinks that the form is invalid, it adds an ng-invalid class to the form. Lovely. So it seems that in order to check if the form is valid I need to po...

Check whether a string is not null and not empty

How can I check whether a string is not null and not empty? public void doStuff(String str) { if (str != null && str != "**here I want to check the 'str' is empty or not**") { /* handle empty string */ } /* ... */ } ...

Pagination response payload from a RESTful API

I want to support pagination in my RESTful API. My API method should return a JSON list of product via /products/index. However, there are potentially thousands of products, and I want to page through them, so my request should look something like t...

How to Retrieve value from JTextField in Java Swing?

How do we retrieve value from a textfield and actionPerformed()? I need the value to be converted into String for further processing. I have created a textfield on clicking a button I need to store the value entered into a String can you please prov...

After updating Entity Framework model, Visual Studio does not see changes

If I do any changes to my EF 5.0 model, VS does not seem to see the changes. I have tried adding a new table, which shows up fine in the model, but then if I try to use it somewhere the table does not show up in intellisense and I can't use it. I ha...

Difference between "while" loop and "do while" loop

What is the difference between while loop and do while loop. I used to think both are completely same.Then I came across following piece of code: do { printf("Word length... "); scanf("%d", &wdlen); } while...

How to call URL action in MVC with javascript function?

I´m trying to render url action with javascript in an MVC project. I capture an event on my page which calls this function but I´m not sure how to call this certain URL. Can anyone help me please? :) function onDropDownChange(e) { var url =...

return results from a function (javascript, nodejs)

Could anyone help me with this code? I need to return a value form a routeToRoom function: var sys = require('sys'); function routeToRoom(userId, passw) { var roomId = 0; var nStore = require('nstore/lib/nstore').extend(require('nstore/lib/...

ORA-12528: TNS Listener: all appropriate instances are blocking new connections. Instance "CLRExtProc", status UNKNOWN

I'm getting this error if i try to login as db user. If lsnrctl status is run i get the below error. DB was working fine all these years and stopped working suddenly. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ABC.LOCAL)(PORT=1521) STAT...

get the margin size of an element with jquery

How can I get the properties of an element with jquery? I want to get the size of the margin of a div in particular. I have set the style of the div in a .css file, for instance, .item-form { margin:0px 0px 10px 0px; background: blue; } the h...

Android Gradle Apache HttpClient does not exist?

I am trying to convert an IntelliJ project to the Gradle system of Android Studio but I am running into errors with Apache HttpClient? Am I missing something, the errors I am getting are as follows: Error:(10, 30) error: package org.apache.http.clie...

How to make a list of n numbers in Python and randomly select any number?

I have taken a count of something and it came out to N. Now I would like to have a list, containing 1 to N numbers in it. Example: N = 5 then, count_list = [1, 2, 3, 4, 5] Also, once I have created the list, I would like to randomly select a num...

Windows-1252 to UTF-8 encoding

I've copied certain files from a Windows machine to a Linux machine. So all the Windows encoded (windows-1252) files need to be converted to UTF-8. The files which are already in UTF-8 should not be changed. I'm planning to use the recode utility for...

How do I fix the error 'Named Pipes Provider, error 40 - Could not open a connection to' SQL Server'?

I can't seem to connect to my database from a site. I get this error: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server I tried using the local IP address to connect as well as a public one. I've tried: Yes, the site...

Android Studio how to run gradle sync manually?

I'm debugging Gradle issues in Android Studio and see references to "Run gradle sync", but I'm not sure how to run this command. How do I run "Gradle sync" from Android studio or Mac terminal?...

Run CSS3 animation only once (at page loading)

I'm making a simple landing page driven by CSS3. To make it look awesome there's an <a> plopping up: @keyframes splash { from { opacity: 0; transform: scale(0, 0); } 50% { opacity: 1; transform: scal...

Unable to begin a distributed transaction

I'm trying to run SQL against a linked server, but I get the errors below : BEGIN DISTRIBUTED TRANSACTION SELECT TOP 1 * FROM Sessions OLE DB provider "SQLNCLI" for linked server "ASILIVE" returned message "No transaction i...

How to check permissions of a specific directory?

I know that using ls -l "directory/directory/filename" tells me the permissions of a file. How do I do the same on a directory? I could obviously use ls -l on the directory higher in the hierarchy and then just scroll till I find it but it's such a ...

Jquery to get the id of selected value from dropdown

I have a drop down list that fetches values from db as follows $.get('/getJobs', function (jobs) { seljobs = jobs; var i = 0; jobs.forEach(function (n) { alert("job id----"+n.id)// 32,67,45 ...

C# elegant way to check if a property's property is null

In C#, say that you want to pull a value off of PropertyC in this example and ObjectA, PropertyA and PropertyB can all be null. ObjectA.PropertyA.PropertyB.PropertyC How can I get PropertyC safely with the least amount of code? Right now I would c...

Getting Raw XML From SOAPMessage in Java

I've set up a SOAP WebServiceProvider in JAX-WS, but I'm having trouble figuring out how to get the raw XML from a SOAPMessage (or any Node) object. Here's a sample of the code I've got right now, and where I'm trying to grab the XML: @WebServicePr...

Add one day to date in javascript

I am sure that a lot of people asked this question but when I checked the answers it seems to me that they are wrong that what I found var startDate = new Date(Date.parse(startdate)); //The start date is right lets say it is 'Mon Jun 30 2014 00:00:0...

logger configuration to log to file and print to stdout

I'm using Python's logging module to log some debug strings to a file which works pretty well. Now in addition, I'd like to use this module to also print the strings out to stdout. How do I do this? In order to log my strings to a file I use followin...

How to replicate background-attachment fixed on iOS

I'm trying to get fixed-background-image divs working on iOS for a school project. I've been using background-attachment: fixed; But this is leading to weird sizing and no scrolling effects in mobile safari. Here is the site that I'm working with;...

Mapping object to dictionary and vice versa

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

Making WPF applications look Metro-styled, even in Windows 7? (Window Chrome / Theming / Theme)

I like the window chrome on the new Office Suite and Visual Studio: I'm still developing applications for Windows 7 of course, but I'm wondering if there's a quick and easy way (read: WPF style or Windows Library) to emulate this style. I've done...

http://localhost:50070 does not work HADOOP

I already installed Hadoop on my machine "Ubuntu 13.05" and now I have an error when browsing localhost:50070 the browser says that the page does not exist....

How do I split a multi-line string into multiple lines?

I have a multi-line string literal that I want to do an operation on each line, like so: inputString = """Line 1 Line 2 Line 3""" I want to do something like the following: for line in inputString: doStuff() ...

How to find list of possible words from a letter matrix [Boggle Solver]

Lately I have been playing a game on my iPhone called Scramble. Some of you may know this game as Boggle. Essentially, when the game starts you get a matrix of letters like so: F X I E A M L O E W B X A S T U The goal of the game is to find as man...

In the shell, what does " 2>&1 " mean?

In a Unix shell, if I want to combine stderr and stdout into the stdout stream for further manipulation, I can append the following on the end of my command: 2>&1 So, if I want to use head on the output from g++, I can do something like thi...

SQL how to increase or decrease one for a int column in one command

I have an Orders table which has a Quantity column. During check in or check out, we need to update that Quantity column by one. Is there a way to do this in one action or we have to get the existing value and then add or minus one on top of it? Ano...

Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)

I updated to macOS Mojave (this happens on Catalina update too, and seems to potentially occur on every major update thereafter) This morning I navigated to my work's codebase in the Command Line on my MacBook pro, typed in "git status" in ...

Visually managing MongoDB documents and collections

I'm using MongoDB in a reporting system and have to delete a whole bunch of test documents. While I don't have too much trouble using the JSON-based command-line tools, it gets extremely tedious to have to keep searching for documents, copy-and-past...

Sqlite primary key on multiple columns

What is the syntax for specifying a primary key on more than 1 column in SQLITE ? ...

Parse RSS with jQuery

I want to use jQuery to parse RSS feeds. Can this be done with the base jQuery library out of the box or will I need to use a plugin?...

Linking a qtDesigner .ui file to python/pyqt?

So if I go into QtDesigner and build a UI, it'll be saved as a .ui file. How can I make this as a python file or use this in python?...

rails 3 validation on uniqueness on multiple attributes

I use Rails 3.0.0.beta4 I want to add a validation on uniqueness on two attributes, that means that my model is valid if the couple of 'recorded_at' and 'zipcode' is unique. On one attribute here is the syntax validates :zipcode, :uniqueness =>...

Renaming part of a filename

I have loads of files which look like this: DET01-ABC-5_50-001.dat ... DET01-ABC-5_50-0025.dat and I want them to look like this: DET01-XYZ-5_50-001.dat ... DET01-XYZ-5_50-0025.dat How can I do this?...

Loading .sql files from within PHP

I'm creating an installation script for an application that I'm developing and need to create databases dynamically from within PHP. I've got it to create the database but now I need to load in several .sql files. I had planned to open the file and m...

Using <style> tags in the <body> with other HTML

<html> <body> <style type="text/css"> p.first {color:blue} p.second {color:green} </style> <p class="first">Hello World</p> <p class="second">Hello World</p> <styl...

Check if object value exists within a Javascript array of objects and if not add a new object to array

If I have the following array of objects: [ { id: 1, username: 'fred' }, { id: 2, username: 'bill' }, { id: 2, username: 'ted' } ] Is there a way to loop through the array to check whether a particular username value already exists and if it does ...

How do I timestamp every ping result?

Ping returns this by default: 64 bytes from 203.173.50.132: icmp_seq=0 ttl=244 time=57.746 ms Is there some way I can get it to add the timestamp? For example, Mon 21 May 2012 15:15:37 EST | 64 bytes from 203.173.50.132: icmp_seq=0 ttl=244 time=...

Getting Current date, time , day in laravel

I need to get the current date, time, day using laravel I tried to echo $ldate = new DateTime('today'); and $ldate = new DateTime('now'); But it is returning 1 always. How can i get the current date, time , day in larvel...

Angular HttpPromise: difference between `success`/`error` methods and `then`'s arguments

According to AngularJS doc, calls to $http return the following: Returns a promise object with the standard then method and two http specific methods: success and error. The then method takes two arguments a success and an error callback which wi...

ngModel cannot be used to register form controls with a parent formGroup directive

After upgrading to RC5 we began getting this error: ngModel cannot be used to register form controls with a parent formGroup directive. Try using formGroup's partner directive "formControlName" instead. Example: <div [formGroup]=...

php var_dump() vs print_r()

What is the difference between var_dump() and print_r() in terms of spitting out an array as string?...

How to compare 2 dataTables

I have 2 datatables and I just want to know if they are the same or not. By "the same", I mean do they have exactly the same number of rows with exactly the same data in each column, or not. I'd love to write (find) a method which accepts both table...

Installing OpenCV 2.4.3 in Visual C++ 2010 Express

How do you install and use OpenCV 2.4.3 under VC++ 2010 Express?...

Support for the experimental syntax 'classProperties' isn't currently enabled

While I was setting up React within Django project I came across this error ModuleBuildError in Module build failed (from ./node_modules/babel-loader/lib/index.js): SyntaxError: C:\Users\1Sun\Cebula3\cebula_react\assets\js\index.js:...

Microsoft.WebApplication.targets was not found, on the build server. What's your solution?

Trying to build my project on the build server gives me the following error: Microsoft (R) Build Engine Version 4.0.30319.1 error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamData\Microsoft.Data.Sche...

How to remove decimal values from a value of type 'double' in Java

I am invoking a method called "calculateStampDuty", which will return the amount of stamp duty to be paid on a property. The percentage calculation works fine, and returns the correct value of "15000.0". However, I want to display the value to the fr...

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

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

How can I change the Java Runtime Version on Windows (7)?

How can I change the Java Runtime Version on Windows. I installed Java 7 for some tests, and now I need the old java6 as system default, but I don't want to uninstall the Java 7 (I need it for later tests). Can I change the system-used JRE...

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

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

Which concurrent Queue implementation should I use in Java?

From the JavaDocs: A ConcurrentLinkedQueue is an appropriate choice when many threads will share access to a common collection. This queue does not permit null elements. ArrayBlockingQueue is a classic "bounded buffer", in which a fixed-sized array...

Easiest way to toggle 2 classes in jQuery

If I have class .A and class .B and want to switch in between on button click, what's a nice solution for that in jQuery? I still don't understand how toggleClass() works. Is there an inline solution to put it in onclick="" event?...

PHP Fatal error: Class 'PDO' not found

PHP Fatal error: Class 'PDO' not found in /home/bd/public_html/app/webroot/Cake/Model/Datasource/Database/Mysql.php on line 177 PHP INFO: PDO PDO support => enabled PDO drivers => sqlite, sqlite2, mysql pdo_mysql PDO Driver for MySQL =&g...

How to kill all processes matching a name?

Say I want to kill every process containing the word amarok. I can print out the commands I want to execute. But how do I actually make the shell execute them. ie. ps aux | grep -ie amarok | awk '{print "kill -9 " $2}' Output: kill -9 3052 kill -9 3...

HTTP response header content disposition for attachments

Background Write an XML document to a browser's response stream and cause the browser to display a "Save As" dialog. Problem Consider the following download() method: HttpServletResponse response = getResponse(); BufferedWriter bw = new Buff...

Is List<Dog> a subclass of List<Animal>? Why are Java generics not implicitly polymorphic?

I'm a bit confused about how Java generics handle inheritance / polymorphism. Assume the following hierarchy - Animal (Parent) Dog - Cat (Children) So suppose I have a method doSomething(List<Animal> animals). By all the rules of inheritanc...

How to select label for="XYZ" in CSS?

HTML: <label for="email">{t _your_email}:</label> CSS: label { display: block; width: 156px; cursor: pointer; padding-right: 6px; padding-bottom: 1px; } I wish to select the label based on the 'for' attribute to make...

'nuget' is not recognized but other nuget commands working

I am trying to create a nuget package using http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package#From_a_convention_based_working_directory as a reference. My Package Manger Console in Visual Studio is not allowing me to use ...

How to use terminal commands with Github?

I have forked a private repository (an iPhone project) as follows: cd nameofdirectory git init git clone forkedURL Now I want to push the changes done by me to my forked repository so that the main admin can review my written code and merge it wit...

Selecting a row in DataGridView programmatically

How can I select a particular range of rows in a DataGridView programmatically at runtime?...

MySql with JAVA error. The last packet sent successfully to the server was 0 milliseconds ago

I have read about this exception a lot, but I can't solve my. Mysql server is working. I can connect to it from NetBeans, but I can't connect to it from java code. Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.CommunicationsException...

Nested ng-repeat

I have some dummy XML file: <Week number="2013-W45"> <Day dow="1" templateDay="Monday"> <Job name="wake up" > <Job name="get dressed" > <Job name="prepare breakfast" > ...

Appending items to a list of lists in python

I'm getting mad with list indexes, and can't explain what I'm doing wrong. I have this piece of code in which I want to create a list of lists, each one containing values of the same circuit parameter (voltage, current etc..) that I'm reading from a...

Is mongodb running?

I have installed mongodb and the php drivers on my unix server. My question is how can I tell if mongodb is running? Is there a simple command line query to check status? If I start it once from the shell will it keep running if I exit the shell (thi...

Why do I need to configure the SQL dialect of a data source?

When we configure a data source using Hibernate, we should add the hibernate.dialect property (or eclipselink.target-database if you are using EclipseLink). I want to know what is the meaning of dialect? I configure this property according to the do...

string.split - by multiple character delimiter

i am having trouble splitting a string in c# with a delimiter of "][". For example the string "abc][rfd][5][,][." Should yield an array containing; abc rfd 5 , . But I cannot seem to get it to work, even if I try RegEx I cannot get a split on th...

You must enable the openssl extension to download files via https

I wanted to install Zend Framework 2. So I downloaded the skeleton application. As mentioned in the ZF2 manual, we have to issue the command php composer.phar install Inside the skeleton. But I'm getting an error You must enable the opens...

scp files from local to remote machine error: no such file or directory

I want to be able to transfer a directory and all its files from my local machine to my remote one. I dont use SCP much so I am a bit confused. I am connected to my remote machine via ssh and I typed in the command scp name127.0.0.1:local/machine/p...

Extract time from moment js object

How do i extract the time using moment.js? "2015-01-16T12:00:00" It should return "12:00:00 pm". The string return will be passed to the timepicker control below. http://jdewit.github.com/bootstrap-timepicker Any idea? ...

Java get last element of a collection

I have a collection, I want to get the last element of the collection. What's the most straighforward and fast way to do so? One solution is to first toArray(), and then return the last element of the array. Is there any other better ones?...

Set HTTP header for one request

I have one particular request in my app that requires Basic authentication, so I need to set the Authorization header for that request. I read about setting HTTP request headers, but from what I can tell, it will set that header for all requests of t...

Is there a date format to display the day of the week in java?

I know of date formats such as "yyyy-mm-dd" -which displays date in format 2011-02-26 "yyyy-MMM-dd"-which displays date in format 2011-FEB-26 to be used in eg: SimpleDateFormat formatter = new SimpleDateFormat( "yyyy/MMM/dd "); I...

How can I programmatically invoke an onclick() event from a anchor tag while keeping the ‘this’ reference in the onclick function?

The following doesn't work... (at least not in Firefox: document.getElementById('linkid').click() is not a function) <script type="text/javascript"> function doOnClick() { document.getElementById('linkid').click(); //Should...

org.hibernate.QueryException: could not resolve property: filename

I am using Hibernate Criteria to get values from column filename in my table contaque_recording_log. But when I'm getting the result, it throws an exception org.hibernate.QueryException: could not resolve property: filename of: com.contaque.hibe...

Cannot find the declaration of element 'beans'

I have the spring jars of spring-3.2.0.RC1.jar and trying to implement Apache ActiveMQ helloWorld program from tutorial given here. The xml configuration file is: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns:jms="http://www.springfr...

Detect if checkbox is checked or unchecked in Angular.js ng-change event

I want to detect if a checkbox has been checked or unchecked when a click is happening on the checkbox. This is what I have: <input type="checkbox" ng-model="answers[item.questID]" ng-change="stateChanged()" /> And then in the controller ...

VB.NET 'If' statement with 'Or' conditional has both sides evaluated?

Quick question, of which the quickest and easiest answer may well be to rearrange related code, but let's see... So I have an If statement (a piece of code which is a part of a full working solution written in C#) rewritten using VB.NET. I am aware ...

$watch an object

I want to watch for changes in a dictionary, but for some reason watch callback is not called. Here is a controller that I use: function MyController($scope) { $scope.form = { name: 'my name', surname: 'surname' } $scop...

how to increase the limit for max.print in R

I am using the Graph package in R for maxclique analysis of 5461 items. The final output item which I get is very long, so I am getting the following warning: reached getOption("max.print") -- omitted 475569 rows Can somebody please provide ...

How to write a CSS hack for IE 11?

How can I hack or write css only for IE 11? I have a website that looks bad in IE 11.I just search here and there but didnt find any solution yet. Is there any css selector?...

PHP: How to generate a random, unique, alphanumeric string for use in a secret link?

How would it be possible to generate a random, unique string using numbers and letters for use in a verify link? Like when you create an account on a website, and it sends you an email with a link, and you have to click that link in order to verify y...

How do I compare if a string is not equal to?

I'm trying to only show something based on if a string is not equal to: <c:if test="${content.getContentType().getName() != "MCE"}"> <li><a href="#publish-history" id="publishHistoryTab">Publish History</a></li> </c:...

Run JavaScript when an element loses focus

I have a standard HTML input that I want to run JavaScript code when it loses focus. Sadly my Google searches did not reveal how to do this. To make it clear, I'm looking for a way to do this: <input type="text" name="name" value="value" onlosef...

Laravel Eloquent limit and offset

This is mine $art = Article::where('id',$article)->firstOrFail(); $products = $art->products; I just wanna take a limit 'product' This is wrong way $products = $art->products->offset($offset*$limit)->take($limit)->get...

What is a simple C or C++ TCP server and client example?

I need to quickly implement a very small C or C++ TCP server/client solution. This is simply to transfer literally an array of bytes from one computer to another - doesn't need to be scalable / over-complicated. The simpler the better. Quick and dirt...

Get current date, given a timezone in PHP?

I want to get todays date given a time zone in Paul Eggert format(America/New_York) in PHP? ...

Why are there no ++ and --? operators in Python?

Why are there no ++ and -- operators in Python?...

How do I show a console output/window in a forms application?

To get stuck in straight away, a very basic example: using System; using System.Windows.Forms; class test { static void Main() { Console.WriteLine("test"); MessageBox.Show("test"); } } If I compile this with default ...

How to fix syntax error, unexpected T_IF error in php?

Parse error: syntax error, unexpected T_IF in view.php on line 27 I really dont see any problem in my code, why this is happening, please help. Im a beginner in PHP Where my LINE 21 is >> if(isset($_GET['page']) && is_numeric($_GET['page']...

Immediate exit of 'while' loop in C++

How do I exit a while loop immediately without going to the end of the block? For example, while (choice != 99) { cin >> choice; if (choice == 99) //Exit here and don't get additional input cin>>gNum; } Any ideas?...

PostgreSQL INSERT ON CONFLICT UPDATE (upsert) use all excluded values

When you are upserting a row (PostgreSQL >= 9.5), and you want the possible INSERT to be exactly the same as the possible UPDATE, you can write it like this: INSERT INTO tablename (id, username, password, level, email) VALUES (1, 'J...

remove space between paragraph and unordered list

<p>Text</p> <ul> <li>One</li> </ul> <p>Text 2</p> How do i remove the vertical space between paragraph and the list. To be more specific - how do I reduce the bottom margin/padding of the p tag O...

How to watch for form changes in Angular

In Angular, I might have a form that looks like this: <ng-form> <label>First Name</label> <input type="text" ng-model="model.first_name"> <label>Last Name</label> <input type="text" ng-model="m...

"installation of package 'FILE_PATH' had non-zero exit status" in R

By installing the package in R using the following command: install.packages('FILE_PATH', repos=NULL, type = "source") I got the following error: Installing package into ‘/home/p/R/x86_64-pc-linux-gnu-library/3.0’ (as ‘lib’ is un...

How to sort in-place using the merge sort algorithm?

I know the question is not too specific. All I want is someone to tell me how to convert a normal merge sort into an in-place merge sort (or a merge sort with constant extra space overhead). All I can find (on the net) is pages saying "it is too ...

Getting multiple keys of specified value of a generic Dictionary?

It's easy to get the value of a key from a .NET generic Dictionary: Dictionary<int, string> greek = new Dictionary<int, string>(); greek.Add(1, "Alpha"); greek.Add(2, "Beta"); string secondGreek = greek[2]; // Beta But trying to get t...

Basic Ajax send/receive with node.js

So I'm trying to make a very basic node.js server that with take in a request for a string, randomly select one from an array and return the selected string. Unfortunately I'm running into a few problems. Here's the front end: function newGame() {...

Best practice to look up Java Enum

We have a REST API where clients can supply parameters representing values defined on the server in Java Enums. So we can provide a descriptive error, we add this lookup method to each Enum. Seems like we're just copying code (bad). Is there a bet...

MySQL update CASE WHEN/THEN/ELSE

I am trying to update a LARGE MyISAM table (25 million records) using a CLI script. The table is not being locked/used by anything else. I figured instead of doing single UPDATE queries for each record, I might as well utilize the CASE feature. The...

How are SSL certificate server names resolved/Can I add alternative names using keytool?

These may be phrased as separate questions for clarity, but they are all related to the same issue. How are SSL certificate server names resolved? Why do browsers seem to use the CN field of the certificate, but Java's mechanism seem to only look a...

How to get the first day of the current week and month?

I have the date of several events expressed in milliseconds[1], and I want to know which events are inside the current week and the current month, but I can't figure out how to obtain the first day (day/month/year) of the running week and convert it ...

How can I set an SQL Server connection string?

I'm developing a simple C# application, and I'd like to know this: When I connect my application to SQL Server on my PC, I know the connection string (server name, password, etc.), but when I connect it to another PC, the SQL Server connection string...

Reload child component when variables on parent component changes. Angular2

I have a MasterComponent which loads header, footer, sidebar etc. On the header there is a dropdown whose options are set once the user is logged in. I want the header to be constant even if I navigate to different routes which loads different child ...

How do I get the current absolute URL in Ruby on Rails?

How can I get the current absolute URL in my Ruby on Rails view? The request.request_uri only returns the relative URL....

Ping with timestamp on Windows CLI

On the Windows command prompt cmd, I use ping -t to 10.21.11.81 Reply from 10.21.11.81: bytes=32 time=3889ms TTL=238 Reply from 10.21.11.81: bytes=32 time=3738ms TTL=238 Reply from 10.21.11.81: bytes=32 time=3379ms TTL=238 Are there any possibilit...

Angular 2 declaring an array of objects

I have the following expression: public mySentences:Array<string> = [ {id: 1, text: 'Sentence 1'}, {id: 2, text: 'Sentence 2'}, {id: 3, text: 'Sentence 3'}, {id: 4, text: 'Sentenc4 '}, ]; which is not working because my array...

Batch: Remove file extension

I have the following batch script from Wikipedia: @echo off for /R "C:\Users\Admin\Ordner" %%f in (*.flv) do ( echo %%f ) pause In the for-loop all files with the extension flv get echoed, but I want the make some actions with the file(s) ...

Install npm (Node.js Package Manager) on Windows (w/o using Node.js MSI)

The problem: while using nvm to install Node.js I was able to install the version of Node.js I need, but nvm does not install npm automatically. NPM's page provides no information about installing it. Being not much of a Windows user myself I am comp...

Git stash pop- needs merge, unable to refresh index

I can't pop my stash because I merged a branch which apparently conflicts with my stash and now my stash is seemingly unable to be popped. app.coffee: needs merge unable to refresh index Anyone know how to resolve this? FIXED! Turns out the actu...

Select every Nth element in CSS

Is it possible to select, say, every fourth element in a set of elements? Ex: I have 16 <div> elements... I could write something like. div:nth-child(4), div:nth-child(8), div:nth-child(12), div:nth-child(16) is there a better way to do thi...

Using the HTML5 "required" attribute for a group of checkboxes?

When using the newer browsers that support HTML5 (FireFox 4 for example); and a form field has the attribute required='required'; and the form field is empty/blank; and the submit button is clicked; the browsers detects that the "required" ...

Search and replace a particular string in a file using Perl

Possible Duplicate: How to replace a string in an existing file in Perl? I need to create a subroutine that does a search and replace in file. Here's the contents of myfiletemplate.txt: CATEGORY1=youknow_<PREF> CATEGORY2=your...

SQL Server: how to select records with specific date from datetime column

I am pretty new to SQL and hope someone here can help me with this: I have a table with one column dateX formatted as datetime and containing standard dates. How can I select all records from this table where this dateX equals a certain date, e.g....

download a file from Spring boot rest service

I am trying to download a file from a Spring boot rest service. @RequestMapping(path="/downloadFile",method=RequestMethod.GET) @Consumes(MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<InputStreamReader> downloadDocument( ...

How to check date of last change in stored procedure or function in SQL server

I need to check when function was changed last time. I know how to check creation date (it is in function properties window in SQL Server Management Studio). I found that in SQL Server 2000 it wasn't possible to check modify date ( look at this post:...

R: how to label the x-axis of a boxplot

apple=c(1,2,3,4,5) banana=c(5,4,3,2,1) watermelon=c(4,5,6,7,8) boxplot(apple, banana, watermelon) If I were to plot this, the x-axis of the boxplot is labeled as 1, 2 and 3. How can I change those to "apple", "banana", and "wate...

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

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

numbers not allowed (0-9) - Regex Expression in javascript

I want a regex pattern which will allow me any chars, but it will not allow (0-9) numbers?...

The right way of setting <a href=""> when it's a local file

I'm trying to link to a local file. I've set href as follows: <a href="file://C:/path/to/file/file.html">Link Anchor</a> In Firefox, when I right click and "open link in new tab", nothing happens. When I right click and "copy link loc...

text-align: right; not working for <label>

Simply enough I can't get text to align to right in a <label> element. HTML <div id="contact_form"> <label for="name" id="name_label">Name:</label> </div> CSS #contact_form label { text-align: right; } My page...

Python virtualenv questions

I'm using VirtualEnv on Windows XP. I'm wondering if I have my brain wrapped around it correctly: I ran virtualenv ENV and it created C:\WINDOWS\system32\ENV. I then changed my PATH variable to include C:\WINDOWS\system32\ENV\Scripts instead of C:\P...

How can I list all foreign keys referencing a given table in SQL Server?

I need to remove a highly referenced table in a SQL Server database. How can I get a list of all the foreign key constraints I will need to remove in order to drop the table? (SQL answers preferable over clicking about in the GUI of the management ...

How to properly reference local resources in HTML?

As it turns out, referencing local resources can be a rub point for some. I'm looking for a canonical answer to local resource referencing, and what they mean. Take these examples, what is the difference between these reference paths? <img src=...

How can I open multiple files using "with open" in Python?

I want to change a couple of files at one time, iff I can write to all of them. I'm wondering if I somehow can combine the multiple open calls with the with statement: try: with open('a', 'w') as a and open('b', 'w') as b: do_something() excep...

How to discard local commits in Git?

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

Maven plugins can not be found in IntelliJ

After updating IntelliJ from version 12 to 13, the following Maven-related plugins cannot be resolved: org.apache.maven.plugins:maven-clean-plugin:2.4.1 org.apache.maven.plugins:maven-deploy-plugin org.apache.maven.plugins:maven-install-plugin org.ap...

Get first word of string

Okay, here is my code with details of what I have tried to do: var str = "Hello m|sss sss|mmm ss"; //Now I separate them by "|" var str1 = str.split("|"); //Now I want to get the first word of every split-ed sting parts: for (var i = 0; i < cod...

How can I lock the first row and first column of a table when scrolling, possibly using JavaScript and CSS?

How can I create a table that has its first row and first column both locked, as in Excel, when you activate 'freeze panes'? I need the table to both scroll horizontally and vertically (a lot of solutions for this exist, but only allow vertical scro...

How do I move a redis database from one server to another?

I currently have a live redis server running on a cloud instance and I want to migrate this redis server to a new cloud instance and use that instance as my new redis server. If it were MySQL, I would export the DB from the old server and import it i...

'ng' is not recognized as an internal or external command, operable program or batch file

I tried running npm install -g angular-cli I also tried adding it to the Enviorment Variables under PATH: (C:\Users\Administrator\AppData\Roaming\npm\node_modules\angular-cli\bin\ng) , with no success also. ...

Difference between 2 dates in seconds

Possible Duplicates: Number of seconds from now() to Sunday midnight Calculates difference between two dates in PHP Hello All, In my project, I need to calculate the difference in seconds between two dates: For Example : $firstDay = "...

Visual Studio 2010 always thinks project is out of date, but nothing has changed

I have a very similar problem as described here. I also upgraded a mixed solution of C++/CLI and C# projects from Visual Studio 2008 to Visual Studio 2010. And now in Visual Studio 2010 one C++/CLI project always runs o...

What is the syntax of the enhanced for loop in Java?

I have been asked to use the enhanced for loop in my coding. I have only been taught how to use traditional for loops, and as such don't know about the differences between it and the enhanced for loop. How does an enhanced for loop differ from a ...

how to display toolbox on the left side of window of Visual Studio Express for windows phone 7 development?

I am new to Visual Studio development. Occasionally I hide the toolbox on the left side of window of Visual Studio Express. But then, sometimes, I would like to use it. How does one reactivate and display it?...

Windows 7 - Add Path

I need to add a new path (sumatraPDF) on my PATH variable. I don't know why it does not work... I think everything is right but when I try to execute sumatrapdf.exe from CMD it cannot find the program. This is what I did: The path is correct, I ch...

Can I convert a boolean to Yes/No in a ASP.NET GridView

I have a ASP.NET GridView with a column mapped to a boolean. I want do display "Yes"/"No" instead of "True"/"False". Well actually I want "Ja"/"Nej" (in Danish). Is this possible? <asp:gridview id="GridView1" runat="server" autogeneratecolumns=...

C++ -- expected primary-expression before ' '

I am new to C++ and programming, and have run into an error that I cannot figure out. When I try to run the program, I get the following error message: stringPerm.cpp: In function ‘int main()’: stringPerm.cpp:12: error: expected primary-expressio...

What does it mean when the size of a VARCHAR2 in Oracle is declared as 1 byte?

I know that I can declare a varchar2 using the number of the characters that it should be able to contain. However, in an Oracle database on which I am working, I found that a field (named PDF) is defined as follows: VARCHAR2(1 BYTE) What does th...

Is there a decent wait function in C++?

One of the first things I learned in C++ was that #include <iostream> int main() { std::cout<<"Hello, World!\n"; return 0; } would simply appear and disappear extremely quickly without pause. To prevent this, I had to go to not...

To check if string contains particular word

So how do you check if a string has a particular word in it? So this is my code: a.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub ...

Adding a Method to an Existing Object Instance

I've read that it is possible to add a method to an existing object (i.e., not in the class definition) in Python. I understand that it's not always good to do so. But how might one do this?...

SOAP vs REST (differences)

I have read articles about the differences between SOAP and REST as a web service communication protocol, but I think that the biggest advantages for REST over SOAP are: REST is more dynamic, no need to create and update UDDI(Universal Description...

There has been an error processing your request, Error log record number

I installed Magento, logged in admin panel. But if I press on any link to open let say CMS pages or users configuration, I get error like this: There has been an error processing your request Exception printing is disabled by default for se...

With Spring can I make an optional path variable?

With Spring 3.0, can I have an optional path variable? For example @RequestMapping(value = "/json/{type}", method = RequestMethod.GET) public @ResponseBody TestBean testAjax( HttpServletRequest req, @PathVariable String type, ...

PHP Session Destroy on Log Out Button

I'm currently working on a site that has a log-in (username and password) - The password protection is done by the operating system within the web server at folder level called a Realm within the OS. For now this will have to do, until we figure out ...

The project cannot be built until the build path errors are resolved.

While compiling an android project in eclipse 3.4.2, I am getting The project cannot be built until the build path errors are resolved. I got a temporary solution from the blog http://www.scottdstrader.com/blog/ether_archives/000921.html The reso...

Change background of LinearLayout in Android

I am working on an Android application. I want to change the background of a LinearLayout element. What attribute can I set in order to change its background?...

importing pyspark in python shell

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

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

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

Python/Json:Expecting property name enclosed in double quotes

I've been trying to figure out a good way to load JSON objects in Python. I send this json data: {'http://example.org/about': {'http://purl.org/dc/terms/title': [{'type': 'literal', 'value': "Anna's Homepage"}]}} to the backend where it will be re...

How do I find out if first character of a string is a number?

In Java is there a way to find out if first character of a string is a number? One way is string.startsWith("1") and do the above all the way till 9, but that seems very inefficient. ...

Best way to convert text files between character sets?

What is the fastest, easiest tool or method to convert text files between character sets? Specifically, I need to convert from UTF-8 to ISO-8859-15 and vice versa. Everything goes: one-liners in your favorite scripting language, command-line tools ...

correct way to define class variables in Python

I noticed that in Python, people initialize their class attributes in two different ways. The first way is like this: class MyClass: __element1 = 123 __element2 = "this is Africa" def __init__(self): #pass or something else The ...

Best way to reset an Oracle sequence to the next value in an existing column?

For some reason, people in the past have inserted data without using sequence.NEXTVAL. So when I go to use sequence.NEXTVAL in order to populate a table, I get a PK violation, since that number is already in use in the table. How can I update the n...

Number of days between two dates in Joda-Time

How do I find the difference in Days between two Joda-Time DateTime instances? With ‘difference in days’ I mean if start is on Monday and end is on Tuesday I expect a return value of 1 regardless of the hour/minute/seconds of the start and end da...

Email & Phone Validation in Swift

i am using the following code for phone number validation. But i am getting the following error. I cant able to proceed further. Help us to take it forward. class PhoneNumberValidation: Validation { let PHONE_REGEX = "^\\d{3}-\\d{3}-\\d{4}$" ...

Validate SSL certificates with Python

I need to write a script that connects to a bunch of sites on our corporate intranet over HTTPS and verifies that their SSL certificates are valid; that they are not expired, that they are issued for the correct address, etc. We use our own internal...

Select subset of columns in data.table R

I have a data table with a bunch of columns, e.g.: dt<-data.table(matrix(runif(10*10),10,10)) I want to perform some operation on the data table, such as producing a correlation matrix (cor(dt)). In order to do this, I want to remove a few colu...

What's the difference between SortedList and SortedDictionary?

Is there any real practical difference between a SortedList<TKey,TValue> and a SortedDictionary<TKey,TValue>? Are there any circumstances where you would specifically use one and not the other?...

Angular 2 execute script after template render

So I have this slider component that use materializecss javascript. So after it's rendered, I need to execute $(document).ready(function(){ $('body').on('Slider-Loaded',function(){ console.log('EVENT SLIDER LOADED'); $('.slider')...

Delete a closed pull request from GitHub

I accidentally made a wrong pull request and ended up closing the request myself. It's in a closed state right now but it's accessible via direct URL and showing on my activity bar. Is there any way to delete a pull request completely so it's no lon...

What does "commercial use" exactly mean?

There is a lot of open source engines and software with different licences conditions. Most of them are non-free for commercial use. The question is what does "commercial use" exactly mean? Example: I have site where I propose paid service or soft...

Trigger a Travis-CI rebuild without pushing a commit?

Using Travis-CI, is it possible to trigger a rebuild without pushing a new commit to GitHub? Use case: A build fails due to an externality. The source is actually correct. It would build OK and pass if simply re-run. For instance, an apt-get fails ...

How can I scale the content of an iframe?

How can I scale the content of an iframe (in my example it is an HTML page, and is not a popup) in a page of my web site? For example, I want to display the content that appears in the iframe at 80% of the original size....

Occurrences of substring in a string

Why is the following algorithm not halting for me? (str is the string I am searching in, findStr is the string I am trying to find) String str = "helloslkhellodjladfjhello"; String findStr = "hello"; int lastIndex = 0; int count = 0; while (lastInd...

How to replace all dots in a string using JavaScript

I want to replace all the occurrences of a dot(.) in a JavaScript string For example, I have: var mystring = 'okay.this.is.a.string'; I want to get: okay this is a string. So far I tried: mystring.replace(/./g,' ') but this ends up with all t...

What does getActivity() mean?

What does getActivity() mean? I saw in somewhere, they wrote MainActivity.this.startActionMode(mActionModeCallback) instead of getActivity(). could someone explain what this two lines mean? someView.setOnLongClickListener(new View.OnLongClickListe...

Xcode build failure "Undefined symbols for architecture x86_64"

An Xcode beginner's question: It is my first experience with Xcode 4.6.3. I am trying to write a very simple console program, that searches for paired BT devices and prints them to an NSLog. It builds with the following error: Undefined symbols f...

How to solve the “failed to lazily initialize a collection of role” Hibernate exception

I have this problem: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: mvc3.model.Topic.comments, no session or session was closed Here is the model: @Entity @Table(name = "T_TOPIC") public class To...

How to change already compiled .class file without decompile?

I want to change .class file's method. I installed JD Eclipse Decompiler and opened the .class file. I added some codes and save .class file. But, .class file is not changing. I don't know how to use decompiler. And if is it possible, how to change...

MyISAM versus InnoDB

I'm working on a projects which involves a lot of database writes, I'd say (70% inserts and 30% reads). This ratio would also include updates which I consider to be one read and one write. The reads can be dirty (e.g. I don't need 100% accurate inf...

How do I install Composer on a shared hosting?

I have these things: the file http://api.odtu.lu/composer.phar http://api.odtu.lu/phpinfo.php ftp access cPanel Cron jobs on FreeBSD PHP, Perl, CGI-BIN, Python, Curl. How can I install Composer? (My aim is to install Restler) Edit: I do not have...

How to send a message to a particular client with socket.io

I'm starting with socket.io + node.js, I know how to send a message locally and to broadcast socket.broadcast.emit() function:- all the connected clients receive the same message. Now, I would like to know how to send a private message to a particul...

git - pulling from specific branch

I have cloned a git repository to my dev server and then switched to the dev branch but now I can't do a git pull to update the branch. How do I update the code on the server ?...

How to create table using select query in SQL Server?

I try to make 50-100 tables using SYS queries SELECT windows_release, windows_service_pack_level, windows_sku, os_language_version FROM sys.dm_os_windows_info OPTION (RECOMPILE); -- DEGISIRSE INSERT ETSIN AYNI ISE DEGISMESIN -- Gives y...

Is there any difference between "!=" and "<>" in Oracle Sql?

I would like to know if there are any differences in between the two not equal operators <> and != in Oracle. Are there cases where they can give different results or different performance?...

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

PHP max_input_vars

I'm getting a max_input_vars error message. I understand there's a php.ini setting that can change this starting with version 5.3.9 however, I'm running version 5.1.6. When I view the configuration information for my 5.1.6 server it shows max_inp...

SQL Column definition : default value and not null redundant?

I've seen many times the following syntax which defines a column in a create/alter DDL statement: ALTER TABLE tbl ADD COLUMN col VARCHAR(20) NOT NULL DEFAULT "MyDefault" The question is: since a default value is specified, is it necessary to also ...

Using CSS to align a button bottom of the screen using relative positions

I need to position a button to the bottom of the screen. I need to use relative size and not absolute sizes, so it fits any screen size. my CSS code: position:relative; left:20%; right:20%; bottom:5%; top:60%; ...

How to compute the similarity between two text documents?

I am looking at working on an NLP project, in any programming language (though Python will be my preference). I want to take two documents and determine how similar they are....

How to install 2 Anacondas (Python 2 and 3) on Mac OS

I'm relatively new in Mac OS. I've just installed XCode (for c++ compiler) and Anaconda with the latest Python 3 (for myself). Now I'm wondering how to install properly second Anaconda (for work) with Python 2? I need both versions to work with iPyt...

Spring Could not Resolve placeholder

I'm fairly new to spring so excuse me if this is a dumb question. When I try to launch a program I get the following error: java.lang.IllegalArgumentException: Could not resolve placeholder 'appclient' in string value [${appclient}]. The error is thr...

Can't connect to local MySQL server through socket '/tmp/mysql.sock

When I attempted to connect to a local MySQL server during my test suite, it fails with the error: OperationalError: (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)") However, I'm able to at all times, connect to M...

jquery select option click handler

given: <select id="mySelect"> <option>..</option> ... </select> Using the select id, how can I trigger a click event on one of the options? I tried attaching the event directly to the select, but this triggers an event ...

DNS problem, nslookup works, ping doesn't

I am setting up a development server in my flat. I have set up an Ubuntu DNS server on it and have added the zone weddinglist (just weddinglist - no TLD. It's just an internal domain.) This works fine on my Ubuntu laptop. On all my Windows PCs (Vis...

Subquery returned more than 1 value.This is not permitted when the subquery follows =,!=,<,<=,>,>= or when the subquery is used as an expression

I have a stored procedure that select * from book table , using sub query my query is USE [library] GO /****** Object: StoredProcedure [dbo].[report_r_and_l] Script Date: 04/17/2013 12:42:39 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER...

In Python, how do I determine if an object is iterable?

Is there a method like isiterable? The only solution I have found so far is to call hasattr(myObj, '__iter__') But I am not sure how fool-proof this is....

Modifying a subset of rows in a pandas dataframe

Assume I have a pandas DataFrame with two columns, A and B. I'd like to modify this DataFrame (or create a copy) so that B is always NaN whenever A is 0. How would I achieve that? I tried the following df['A'==0]['B'] = np.nan and df['A'==0]['B'...

Escape regex special characters in a Python string

Does Python have a function that I can use to escape special characters in a regular expression? For example, I'm "stuck" :\ should become I\'m \"stuck\" :\\....

Squash my last X commits together using Git

How can I squash my last X commits together into one commit using Git?...

What is `related_name` used for in Django?

What is the related_name argument useful for on ManyToManyField and ForeignKey fields? For example, given the following code, what is the effect of related_name='maps'? class Map(db.Model): members = models.ManyToManyField(User, related_name='ma...

How to insert a new key value pair in array in php?

I've an array as follows named $test_package_data. For the reference I'm printing first two elements of it: Array ( [0] => Array ( [test_pack_id] => 9f27643023a83addd5eed41c4aade840 [test_pack_name] => Ex...

How to send HTML email using linux command line

I need to send email with html format. I have only linux command line and command "mail". Currently have used: echo "To: [email protected]" > /var/www/report.csv echo "Subject: Subject" >> /var/www/report.csv echo "Content-Type: text/htm...

Disable scrolling in webview?

Until now I have been an iPhone developer only and now I have decided to give Android a whirl. Something I haven't been able to figure out on Android is how to programmatically prevent scrolling in a WebView? Something similar to iPhones prevention ...

nginx: [emerg] "server" directive is not allowed here

I have reconfigured nginx but i can't get it to restart using the following config: conf: server { listen 80; server_name www.example.com; return 301 $scheme://example.com$request_uri; } server { listen 80; server_name example.com; access_log /v...

Fullscreen Activity in Android?

How do I make an activity full screen? I mean without the notification bar. Any ideas?...

Loaded nib but the 'view' outlet was not set

I added a new nib file to my project, and tried to load it. However, when I click on the toolbar icon that is supposed to take me to the view that I created, I get an NSInternalInconsistencyException with the message: Terminating app due to unca...

How to set String's font size, style in Java using the Font class?

Suppose I have a String, "Hello World". I want to change the style of this string to a BOLD font, and set the size of all the characters from 12 to 18 [pt]. After that I want to use this string in a JLabel and JButton. How can I do that?...

grabbing first row in a mysql query only

if i had a query such as select * from tbl_foo where name = 'sarmen' and this table has multiple instances of name = sarmen how can i virtually assign row numbers to each row without having to create a column that auto incriments? i have a reason ...

How to add an extra row to a pandas dataframe

If I have an empty dataframe as such: columns = ['Date', 'Name', 'Action','ID'] df = pd.DataFrame(columns=columns) is there a way to append a new row to this newly created dataframe? Currently I have to create a dictionary, populate it, then appe...

Laravel eloquent update record without loading from database

I'm quite new to laravel and I'm trying to update a record from form's input. However I see that to update the record, first you need to fetch the record from database. Isn't is possible to something like to update a record (primary key is set): $p...

How do I edit $PATH (.bash_profile) on OSX?

I am trying to edit an entry to PATH, as I did something wrong. I am using Mac OS X 10.10.3 I have tried: > touch ~/.bash_profile; open ~/.bash_profile But the file editor opens with nothing inside. My problem: I am trying to install AND...

What's the best way to detect a 'touch screen' device using JavaScript?

I've written a jQuery plug-in that's for use on both desktop and mobile devices. I wondered if there is a way with JavaScript to detect if the device has touch screen capability. I'm using jquery-mobile.js to detect the touch screen events and it wor...

How to extract a single value from JSON response?

First off, I will freely concede to being little more than a clumsy liberal arts guy who is completely self taught in this scripting thing. That said, I am attempting to get values from a the USGS Water Data Service using the code below: def main(ga...

SQL Server - Create a copy of a database table and place it in the same database?

I have a table ABC in a database DB. I want to create copies of ABC with names ABC_1, ABC_2, ABC_3 in the same DB. How can I do that using either Management Studio (preferably) or SQL queries ? This is for SQL Server 2008 R2....

Launch an app from within another (iPhone)

Is it possible to launch any arbitrary iPhone application from within another app?, For example in my application if I want the user to push a button and launch right into the Phone app (close the current app, open the Phone app). would this be poss...

Convert HashBytes to VarChar

I want to get the MD5 Hash of a string value in SQL Server 2005. I do this with the following command: SELECT HashBytes('MD5', 'HelloWorld') However, this returns a VarBinary instead of a VarChar value. If I attempt to convert 0x68E109F0F40CA72A15...

pip install gives error: Unable to find vcvarsall.bat

Using pip install zipline on Windows 8 with Python 2.7 gives me the error: Downloading/unpacking six (from python-dateutil==2.1->delorean->zipline[all]) Running setup.py egg_info for package six Installing collected packages: blist, pytz, r...

Matplotlib connect scatterplot points with line - Python

I have two lists, dates and values. I want to plot them using matplotlib. The following creates a scatter plot of my data. import matplotlib.pyplot as plt plt.scatter(dates,values) plt.show() plt.plot(dates, values) creates a line graph. But wha...

Joining two table entities in Spring Data JPA

I want to write a query like SELECT * FROM Release_date_type a LEFT JOIN cache_media b on a.id=b.id. I am new to Spring Data JPA. I don't know how to write entities for Join query. Here is an attempt: @Entity @Table(name = "Release_date_type") publi...

Is there such a thing as min-font-size and max-font-size?

I'm trying to make a font in a div responsive to the browser window. So far, it has worked perfectly, but the parent div has a max-width of 525px. Resizing the browser further will not make the font stop resizing. This has made me wonder if there is ...

How to specify the default error page in web.xml?

I am using <error-page> element in web.xml to specify the friendly error page when user encounters a certain error such as error with code of 404: <error-page> <error-code>404</error-code> <location>/Er...

Forward declaration of a typedef in C++

Why won't the compiler let me forward declare a typedef? Assuming it's impossible, what's the best practice for keeping my inclusion tree small?...

How do I get total physical memory size using PowerShell without WMI?

I'm trying to get the physical memory size using PowerShell, but without using get-wmiobject. I have been using the following PS cmdlet to get the physical memory size, but the value changes with each new poll. (get-counter -counter "\Memory\Availa...

Change content of div - jQuery

How is it possible to change the content of this div, when one of the LINKS is clicked? <div align="center" id="content-container"> <a href="#" class="click cgreen">Main Balance</a> <a href="#" class="click cgreen">Pa...

Delete all local git branches

I follow a development process where I create a new local branch for every new feature or story card. When finished I merge the branch into master and then push. What tends to happen over time due to a combination of laziness or forgetfulness, is t...

How to convert ASCII code (0-255) to its corresponding character?

How can I convert, in Java, the ASCII code (which is an integer from [0, 255] range) to its corresponding ASCII character? For example: 65 -> "A" 102 -> "f" ...

unexpected T_VARIABLE, expecting T_FUNCTION

I am expecting this to be a basic syntax error I overlooked, but I can't figure it out. In a PHP script, I keep getting the following error. Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in [path]/scripts/users/database_con...

Detect if user is scrolling

How can I detect in javascript if the user is scrolling?...

When are you supposed to use escape instead of encodeURI / encodeURIComponent?

When encoding a query string to be sent to a web server - when do you use escape() and when do you use encodeURI() or encodeURIComponent(): Use escape: escape("% +&="); OR use encodeURI() / encodeURIComponent() encodeURI("http://www.google....

Hex to ascii string conversion

i have an hex string and want it to be converted to ascii string in C. How can i accomplish this??...

error TS1086: An accessor cannot be declared in an ambient context in Angular 9

I'm learning Angular Material and I'm getting this error when importing { MatButtonModule } from "@angular/material/button". From what I read in other answers, it looks like package compatibility issues but I couldn't fix it. Here's the full error ...

Serializing class instance to JSON

I am trying to create a JSON string representation of a class instance and having difficulty. Let's say the class is built like this: class testclass: value1 = "a" value2 = "b" A call to the json.dumps is made like this: t = testclass() j...

How to set JAVA_HOME environment variable on Mac OS X 10.9?

I just purchased a brand new MacBook Pro. This is my first MAC ever and I'm still trying to get the hang of navigating my way around. Anyway, I'm also new to Java and I've been practicing on my Windows PC before it permanently died. Now that I'...

When to use @QueryParam vs @PathParam

I am not asking the question that is already asked here: What is the difference between @PathParam and @QueryParam This is a "best practices" or convention question. When would you use @PathParam vs @QueryParam. What I can think of that the decisi...

How do I add BundleConfig.cs to my project?

I have an ASP.Net MVC project and I want to implement bundling, but everything I can find on the internet directs me to open BundleConfig.cs in App_Start - however this file does not exist in my project. I have only three files in that folder: Filter...

Compile/run assembler in Linux?

I'm fairly new to Linux (Ubuntu 10.04) and a total novice to assembler. I was following some tutorials and I couldn't find anything specific to Linux. So, my question is, what is a good package to compile/run assembler and what are the command line c...

Use and meaning of "in" in an if statement?

In an example from Zed Shaw's Learn Python the Hard Way, one of the exercises displays the following code: next = raw_input("> ") if "0" in next or "1" in next: how_much = int(next) I'm having a hard time understanding the meaning of in in ...

Check if an object belongs to a class in Java

Is there an easy way to verify that an object belongs to a given class? For example, I could do if(a.getClass() = (new MyClass()).getClass()) { //do something } but this requires instantiating a new object on the fly each time, only to discard...

Calculate business days

I need a method for adding "business days" in PHP. For example, Friday 12/5 + 3 business days = Wednesday 12/10. At a minimum I need the code to understand weekends, but ideally it should account for US federal holidays as well. I'm sure I could com...

MySQL command line client for Windows

Is there any nice command line MySQL client for windows? I mean a single exe that allows connecting and running a sample query. I've googled and only could find big graphical environments like toad or mysql workbench. I need only a simple command lin...

Reading from stdin

What are the possible ways for reading user input using read() system call in Unix. How can we read from stdin byte by byte using read()?...

How to get folder path from file path with CMD

I need path to the folder that contains cmd file. With %0 I can get file name. But how to get folder name? c:\temp\test.cmd >> test.cmd P.S. My current directory != folder of the script....

The Import android.support.v7 cannot be resolved

I am new to Android. Currently, I have the adt-bundle-windows-x86-20131030.zip (Windows 32 bit) installed - and have successfully installed the Android SDK and Eclipse. Also, I have updated everything in the Android SDK manager. Now, I am working in ...

Formatting floats in a numpy array

If I have a numpy array like this: [2.15295647e+01, 8.12531501e+00, 3.97113829e+00, 1.00777250e+01] how can I move the decimal point and format the numbers so I end up with a numpy array like this: [21.53, 8.13, 3.97, 10.08] np.around(a, decima...

Detect whether there is an Internet connection available on Android

Possible Duplicate: How to check internet access on Android? InetAddress never timeouts I need to detect whether the Android device is connected to the Internet. The NetworkInfo class provides a non-static method isAvailable() that sounds perfect....

How to change the JDK for a Jenkins job?

I have imported the jenkins jobs from existing jenkins server from another machine. But the problem is, it has the JDK referenced as per the old machines and I want to change it to use the JDK configured in my new jenkins. But I am unable to find any...

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

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

Undo git pull, how to bring repos to old state

Is there any way to revert or undo git pull so that my source/repos will come to old state that was before doing git pull ? I want to do this because it merged some files which I didn't want to do so, but only merge other remaining files. So, I want ...

How do you format an unsigned long long int using printf?

#include <stdio.h> int main() { unsigned long long int num = 285212672; //FYI: fits in 29 bits int normalInt = 5; printf("My number is %d bytes wide and its value is %ul. A normal number is %d.\n", sizeof(num), num, normalInt); ...

Convert String to Carbon

I am using Laravel 5.1 Few days ago I used protected $dates = ['license_expire'] in my model to convert the string date to Carbon instances. In HTML the default value in create form for the date was Carbon\Carbon::now()->format('Y-m-d') In order...

What does \u003C mean?

I'm looking at twitter's javascript file, and I see this in the templates hash: Browse Interests{{/i}}\u003C/a\u003E\n \u003C/li\u003E\n {{#logged_in}}\n What do those codes represent?...

How to set the java.library.path from Eclipse

How can I set the java.library.path for a whole Eclipse Project? I'm using a Java library that relies on OS specific files and need to find a .dll/ .so/ .jnilib. But the Application always exits with an error message that those files are not found on...

Set field value with reflection

I'm working with one project which is not opensource and I need to modify one or more its classes. In one class is following collection: private Map<Integer, TTP> ttp = new HashMap<>(); All what I need to do is use reflection and use...

Installing RubyGems in Windows

I'm new to ruby. I tried to install Ruby Gems on my PC by following the steps given in the site http://rubygems.org/pages/download. I downloaded the package from the mentioned site, changed the directory to the directory in which the setup resides, a...

GIT commit as different user without email / or only email

I'm trying to commit some changes as a different user, but i do not have a valid email address, following command is not working for me: git commit --author="john doe" -m "some fix" fatal: No existing author found with 'john doe' I have the same p...

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

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

How to set div's height in css and html

I'm using Twitter Bootstrap. I wrote in my html: <div style="height:100px;" class="span12"> asdfashdjkfhaskjdf </div> Why the height is not 100px when I open that page? For posterity, the original code was : <div height="100px...

How to label scatterplot points by name?

I am trying to figure out how to get labels to show on either Google sheets, Excel, or Numbers. I have information that looks like this name|x_val|y_val ---------------- a | 1| 1 b | 2| 4 c | 1| 2 Then I would want my fina...

Convert hex color value ( #ffffff ) to integer value

I am receiving hex color values from a server (in this form, #xxxxxx , example #000000 for black) How do I convert this to an integer value? I tried doing Integer.valueOf("0x" + passedColor.substring(1, passedColor.length())) to get an even more h...

Import existing Gradle Git project into Eclipse

I've installed eclipse gradle plugin from here http://kaczanowscy.pl/tomek/2010-03/gradle-ide-integration-eclipse-plugin Is there a simple way to import into eclipse gradle project using gui, not doing stuff described here: http://gradle.org/docs...

Uncaught (in promise) TypeError: Failed to fetch and Cors error

having a problem with getting data back from database. I am trying my best to explain the problem. 1.If I leave "mode":"no-cors" inside the code below, then I can get data back from server with Postman, but not with from my own server. Thinking it h...

How to close TCP and UDP ports via windows command line

Does somebody knows how to close a TCP or UDP socket for a single connection via windows command line? Googling about this, I saw some people asking the same thing. But the answers looked like a manual page of netstat or netsh commands focusing on h...

StringIO in Python3

I am using Python 3.2.1 and I can't import the StringIO module. I use io.StringIO and it works, but I can't use it with numpy's genfromtxt like this: x="1 3\n 4.5 8" numpy.genfromtxt(io.StringIO(x)) I get the following error: TypeError: ...

Is there an equivalent to the SUBSTRING function in MS Access SQL?

I want to do something like this within an MS Access query, but SUBSTRING is an undefined function. SELECT DISTINCT SUBSTRING(LastName, 1, 1) FROM Authors; ...

Could not connect to SMTP host: smtp.gmail.com, port: 465, response: -1

while sending mail I am getting this error java.lang.RuntimeException: javax.mail.SendFailedException: Sending failed; nested exception is: class javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465, r...

java.lang.ClassNotFoundException:com.mysql.jdbc.Driver

I'm getting the exception java.lang.ClassNotFoundException when I am trying to run my code, My Code try { Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/simple", ...

What is the correct syntax of ng-include?

I’m trying to include an HTML snippet inside of an ng-repeat, but I can’t get the include to work. It seems the current syntax of ng-include is different than what it was previously: I see many examples using <div ng-include src="path/file.ht...

MySQL: Selecting multiple fields into multiple variables in a stored procedure

Can I SELECT multiple columns into multiple variables within the same select query in MySQL? For example: DECLARE iId INT(20); DECLARE dCreate DATETIME; SELECT Id INTO iId, dateCreated INTO dCreate FROM products WHERE pName=iName; What is the ...

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

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

How can I show figures separately in matplotlib?

Say that I have two figures in matplotlib, with one plot per figure: import matplotlib.pyplot as plt f1 = plt.figure() plt.plot(range(0,10)) f2 = plt.figure() plt.plot(range(10,20)) Then I show both in one shot plt.show() Is there a way to sho...

How to finish current activity in Android

I have an Android application. I am making a loading screen with a progress bar. I entered a delay in the onCreate method. When the timer finishes, I want to finish the current activity and start a new one. It just gives me an exception when it...

How to grep a string in a directory and all its subdirectories?

How to grep a string or a text in a directory and all its subdirectories'files in LINUX ??...

Android Studio Google JAR file causing GC overhead limit exceeded error

I am using Android Studio on OS X. I am getting this error message: FAILURE: Build failed with an exception. What went wrong: Execution failed for task ':app:preDexDebug'. com.android.ide.common.internal.LoggedErrorException: Fai...

How to check if Thread finished execution

I have following problem: I want to check (C#) if a thread has finished execution, i.e. if the thread method has returned. What I do now is call Thread.Join(1), but this gives a 1 ms delay. Is there any way to simply check if a thread has finished. ...

Find duplicate records in MySQL

I want to pull out duplicate records in a MySQL Database. This can be done with: SELECT address, count(id) as cnt FROM list GROUP BY address HAVING cnt > 1 Which results in: 100 MAIN ST 2 I would like to pull it so that it shows each row...

jQuery override default validation error message display (Css) Popup/Tooltip like

I'm trying to over ride the default error message label with a div instead of a label. I have looked at this post as well and get how to do it but my limitations with CSS are haunting me. How can I display this like some of these examples: Example #...

Python BeautifulSoup extract text between element

I try to extract "THIS IS MY TEXT" from the following HTML: <html> <body> <table> <td class="MYCLASS"> <!-- a comment --> <a hef="xy">Text</a> <p>something</p> THIS IS ...

MySQL Query GROUP BY day / month / year

Is it possible to make a simple query to count how many records I have in a determined period of time like a year, month, or day, having a TIMESTAMP field, like: SELECT COUNT(id) FROM stats WHERE record_date.YEAR = 2009 GROUP BY record_date.YEAR ...

Can an ASP.NET MVC controller return an Image?

Can I create a Controller that simply returns an image asset? I would like to route this logic through a controller, whenever a URL such as the following is requested: www.mywebsite.com/resource/image/topbanner The controller will look up topbann...

doGet and doPost in Servlets

I've developed an HTML page that sends information to a Servlet. In the Servlet, I am using the methods doGet() and doPost(): public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { String id ...

Getting error: ISO C++ forbids declaration of with no type

I'm getting the following errors: ISO C++ forbids declaration of ttTreeInsert with no type ISO C++ forbids declaration of ttTreeDelete with no type ISO C++ forbids declaration of ttTreePrint with no type prototype for int ttTree::ttTreePrint() does ...

How to import an existing directory into Eclipse?

I am on a mac, but I don't think it will make a difference. I have a directory that I want to fully import/add into Eclipse. What I did is this: Right click import General → Existing Projects into Workspace Then when I click browse for eith...

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

In Powershell what is the idiomatic way of converting a string to an int?

The only method I have found is a direct cast: > $numberAsString = "10" > [int]$numberAsString 10 Is this the standard approach in Powershell? Is it expected that a test will be done before to ensure that the conversion will succeed and if s...

Regex for Comma delimited list

What is the regular expression to validate a comma delimited list like this one: 12365, 45236, 458, 1, 99996332, ...... ...

How can I return the current action in an ASP.NET MVC view?

I wanted to set a CSS class in my master page, which depends on the current controller and action. I can get to the current controller via ViewContext.Controller.GetType().Name, but how do I get the current action (e.g. Index, Show etc.)?...

how to make a specific text on TextView BOLD

I don't know how to make a specific text on TextView become BOLD. its like this txtResult.setText(id+" "+name); I want the output to be like this: 1111 neil id and name are variables that I have retrieved the value from database, and I want...

How to add image in a TextView text?

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

Array to Collection: Optimized code

Is there a better way of achieving this? public static List<String> toList(String[] array) { List<String> list = new ArrayList(array.length); for(int i=0; i<array.length; i++) list.add(array[i]); return list; } ...

How to check if a radiobutton is checked in a radiogroup in Android?

I need to set validation that user must fill / select all details in a page. If any fields are empty wanna show Toast message to fill. Now I need set validation for RadioButton in the RadioGroup. I tried this code but didn't work properly. Suggest me...

programming a servo thru a barometer

i have a script which gets the air pressure from a website. and i wrote this function which says if the pressure gets different value if it rains or sunny weather or else now i have a servo which should change the angle depending on each value. We...

Bootstrap: wider input field

How can I make the input field wider than the default in Twitter's Bootstrap? I am trying to create a wider search form in the hero-unit class from the example. ...

Page vs Window in WPF?

What is the difference between a Page and a Window in WPF when you are adding a new file in the Solution Explorer?...

Add space between <li> elements

I have a nav-menu on which it seems that I can't add a space (margin: 3px;) between the <li> elements. You can see the HTML and CSS code on this jsfiddle or below. You will see that I've added a border-bottom: 2px solid #fff; to the #access...

Detect if a browser in a mobile device (iOS/Android phone/tablet) is used

Is there a way to detect if a handheld browser is used (iOS/Android phone/tablet)? I tried this with the goal to make an element half as wide in a browser on a handheld device but it doesn't make a difference. width: 600px; @media handheld { width:...

How do I move files in node.js?

How can I move files (like mv command shell) on node.js? Is there any method for that or should I read a file, write to a new file and remove older file?...

How can I count the occurrences of a list item?

Given an item, how can I count its occurrences in a list in Python?...

Moveable/draggable <div>

This is my updated and modified script, it works completely, except I would like to universalize it... observe the **** how can I make it so that I don't have to do function(e){BOX.Draggable.elemen = e.target || e.srcElement; elementDraggable(e); eve...

Warning: mysqli_connect(): (HY000/1045): Access denied for user 'username'@'localhost' (using password: YES)

Warning: mysqli_connect(): (HY000/1045): Access denied for user 'username'@'localhost' (using password: YES) in C:\Users\xampp\htdocs\PHP_Login_Script\config.php on line 6 Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli,...

Turn a number into star rating display using jQuery and CSS

I have been looking at jquery plugin and was wondering how to adapt that plugin to turn a number (like 4.8618164) into a 4.8618164 stars filled out of 5. Basically interpreting a number <5 into stars filled in a 5-star rating system using jQuery/J...

How should I escape commas and speech marks in CSV files so they work in Excel?

I'm generating a CSV file (delimited by commas rather than tabs). My users will most likely open the CSV file in Excel by double clicking it. My data may contain commas and speech marks, so I'm escaping those as follows. Reference, Title, Descriptio...

Declare an empty two-dimensional array in Javascript?

I want to create a two dimensional array in Javascript where I'm going to store coordinates (x,y). I don't know yet how many pairs of coordinates I will have because they will be dynamically generated by user input. Example of pre-defined 2d array: ...

Read/write files within a Linux kernel module

I know all the discussions about why one should not read/write files from kernel, instead how to use /proc or netlink to do that. I want to read/write anyway. I have also read Driving Me Nuts - Things You Never Should Do in the Kernel. However, the...

Download File Using Javascript/jQuery

I have a very similar requirement specified here. I need to have the user's browser start a download manually when $('a#someID').click(); But I cannot use the window.href method, since it replaces the current page contents with the file you're tryi...

Jquery change <p> text programmatically

EDIT: The solution was to add this to the profile page instead of the gender page. $('#profile').live( 'pageinit',function(event){ $('p#pTest').text(localStorage.getItem('gender')); }); I have a paragraph with som text in a listview that I want t...