Examples On Programing Languages

Disable elastic scrolling in Safari

I just wanted to diable the elastic scrolling/bounce effect in Safari (OSX Lion). I found the solution to set overflow: hidden for body in css, but as expected it only disables the scrollbar, so if the website is "longer" than the screen you won't b...

Git: How to rebase to a specific commit?

I'd like to rebase to a specific commit, not to a HEAD of the other branch: A --- B --- C master \ \-- D topic to A --- B --- C master \ \-- D topic instead of A --- B --- C ...

PHP function to build query string from array

I'm looking for the name of the PHP function to build a query string from an array of key value pairs. Please note, I am looking for the built in PHP function to do this, not a homebrew one (that's all a google search seems to return). There is one, ...

this is error ORA-12154: TNS:could not resolve the connect identifier specified?

I've this code : OracleConnection con = new OracleConnection("data source=localhost;user id=fastecit;password=fastecit"); con.Open(); string sql="Select userId from tblusers"; OracleCommand cmd = new OracleCommand(sql, con); OracleDataReader dr...

What is the command to exit a Console application in C#?

What is the command in C# for exit a Console Application?...

exclude @Component from @ComponentScan

I have a component that I want to exclude from a @ComponentScan in a particular @Configuration: @Component("foo") class Foo { ... } Otherwise, it seems to clash with some other class in my project. I don't fully understand the collision, but if I ...

How to get a variable value if variable name is stored as string?

How can I retrieve a bash variable value if I have the variable name as string? var1="this is the real value" a="var1" Do something to get value of var1 just using variable a. Context: I have some AMI's (Amazon Machine Image) and...

How should a model be structured in MVC?

I am just getting a grasp on the MVC framework and I often wonder how much code should go in the model. I tend to have a data access class that has methods like this: public function CheckUsername($connection, $username) { try { $dat...

Crystal Reports - Adding a parameter to a 'Command' query

Crystal Version - Crystal Reports 2008 Business Objects - XI I have written a query to populate a subreport and want to pull in a parameter to that query based on input from a user. My question is, what is the correct syntax I need to put in the fi...

OpenCV error: the function is not implemented

I'm trying to get OpenCV working with Python on my Ubuntu machine. I've downloaded and installed OpenCV, but when I attempt to run the following python code (which should capture images from a webcam and push them to the screen) import cv cv.Named...

Visual Studio 2013 error MS8020 Build tools v140 cannot be found

I had previously been using VS2013 express without issue, but suddenly it began crashing whenever I tried edit the code while it ran existing code fine. I tried uninstalling and switching over to VS2015, but it was crashing as well and wasn't compat...

How can I set response header on express.js assets

I need to set CORS to be enabled on scripts served by express. How can I set the headers in these returned responses for public/assets?...

How to set <Text> text to upper case in react native

How to set <Text> some text </Text> as upper case in react native <Text style={{}}> Test </Text> Need to show that Test as TEST....

How to connect to remote Redis server?

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

Get GMT Time in Java

In Java, I want to get the current time in GMT. I tried various options like this: Date date = new Date(); Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); date1 = calendar.getTime(); But the date is always is interpreted in...

How do you Sort a DataTable given column and direction?

I need to resort, in memory, a DataTable based on a column and direction that are coming from a GridView. The function needs to look like this: public static DataTable resort(DataTable dt, string colName, string direction) { DataTable dtOut = nu...

AWS S3: The bucket you are attempting to access must be addressed using the specified endpoint

I am trying to delete uploaded image files with the AWS-SDK-Core Ruby Gem. I have the following code: require 'aws-sdk-core' def pull_picture(picture) Aws.config = { :access_key_id => ENV["AWS_ACCESS_KEY_ID"], :secret_access...

Write bytes to file

I have a hexadecimal string (e.g 0CFE9E69271557822FE715A8B3E564BE) and I want to write it to a file as bytes. For example, Offset 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 00000000 0C FE 9E 69 27 15 57 82 2F E7 15 A8 B3 E5 64 BE .þ�...

Java: Sending Multiple Parameters to Method

Here is my Scenario: I've got to call a method. Let the parameters be: Parameter1, Parameter2, .. , .. , Parameter N But the Parameters to be sent to the method might change in each case. Case 1: Only Parameter1 is sent Case 2: A combination of Pa...

C# using Sendkey function to send a key to another application

I want to send a specific key (e.g. k) to another program named notepad, and below is the code that I used: private void SendKey() { [DllImport ("User32.dll")] static extern int SetForegroundWindow(IntPtr point); var p = Process.GetProc...

How to check if the string is empty?

Does Python have something like an empty string variable where you can do: if myString == string.empty: Regardless, what's the most elegant way to check for empty string values? I find hard coding "" every time for checking an empty string not as ...

no match for ‘operator<<’ in ‘std::operator

I am a C++ newbie.I tried out my first program here.To my eyes this program is correct. #include <iostream> using namespace std; class mystruct { private: int m_a; float m_b; public: mystruct(int x, float y) ...

"Debug only" code that should run only when "turned on"

I would like to add some C# "debug only" code that only runs if the person debugging requests it. In C++, I used to do something similar to the following: void foo() { // ... #ifdef DEBUG static bool s_bDoDebugOnlyCode = false; if (s_bDo...

Best way to encode Degree Celsius symbol into web page?

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

Difference between window.location.href, window.location.replace and window.location.assign

What is the difference between window.location.href="http://example.com"; window.location.replace("http://example.com"); window.location.assign("http://example.com"); I read in many forums that window.location.assign() just replaces the current ...

How do I capture the output into a variable from an external process in PowerShell?

I'd like to run an external process and capture it's command output to a variable in PowerShell. I'm currently using this: $params = "/verify $pc /domain:hosp.uhhg.org" start-process "netdom.exe" $params -WindowStyle Hidden -Wait I've confirmed t...

How to remove a package from Laravel using composer?

What is the correct way to remove a package from Laravel using composer? So far I've tried: Remove declaration from composer.json (in "require" section) Remove any Class Aliases from app.php Remove any references to the package from my cod...

error: invalid type argument of ‘unary *’ (have ‘int’)

I have a C Program: #include <stdio.h> int main(){ int b = 10; //assign the integer 10 to variable 'b' int *a; //declare a pointer to an integer 'a' a=(int *)&b; //Get the memory location of v...

How do I install imagemagick with homebrew?

I'm trying to install Imagemagick on OSX Lion but something is not working as expected. -> brew install imagemagick /usr/local/git/bin/git ==> Cloning https://github.com/adamv/ImageMagick.git Cloning into /Users/klebershimabuku/Library/Caches...

How to skip the first n rows in sql query

I want to fire a Query "SELECT * FROM TABLE" but select only from row N+1. Any idea on how to do this?...

Comment out HTML and PHP together

I have this code, <tr> <td><?php echo $entry_keyword; ?></td> <td><input type="text" name="keyword" value="<?php echo $keyword; ?>" /></td> </tr> <tr> <td&g...

GridView must be placed inside a form tag with runat="server" even after the GridView is within a form tag

<form runat="server" id="f1"> <div runat="server" id="d"> grid view: <asp:GridView runat="server" ID="g"> </asp:GridView> </div> <asp:TextBox runat="server" ID="t" TextMode="MultiL...

How do I delete NuGet packages that are not referenced by any project in my solution?

Somehow during the upgrade to VS2012 and .NET 4.5, I've managed to get NuGet confused. There are packages that appear in the package manager (and the packages folder) that I cannot delete (I believe they are legacy ASP.NET NuGet packages that have b...

How can I read SMS messages from the device programmatically in Android?

I want to retrieve the SMS messages from the device and display them?...

How to get HttpRequestMessage data

I have an MVC API controller with the following action. I don't understand how to read the actual data/body of the Message? [HttpPost] public void Confirmation(HttpRequestMessage request) { var content = request.Content; } ...

How do I get the SharedPreferences from a PreferenceActivity in Android?

I am using a PreferenceActivity to show some settings for my application. I am inflating the settings via a xml file so that my onCreate (and complete class methods) looks like this: public class FooActivity extends PreferenceActivity { @Overri...

Pass parameter from a batch file to a PowerShell script

In my batch file, I call the PowerShell script like this: powershell.exe "& "G:\Karan\PowerShell_Scripts\START_DEV.ps1" Now, I want to pass a string parameter to START_DEV.ps1. Let's say the parameter is w=Dev. How can I do this?...

S3 - Access-Control-Allow-Origin Header

Did anyone manage to add Access-Control-Allow-Origin to the response headers? What I need is something like this: <img src="http://360assets.s3.amazonaws.com/tours/8b16734d-336c-48c7-95c4-3a93fa023a57/1_AU_COM_180212_Areitbahn_Hahnkoplift_Bergst...

How to break lines at a specific character in Notepad++?

I have a text file containing text like: ['22APR2012 23:10', '23APR2012 07:10', 1, 3, 0], ['22APR2012 23:10', '23APR2012 07:20', 1, 3, 0], ['22APR2012 23:15', '23APR2012 06:40', 0, 1, 0], ['22APR2012 23:15', '23APR2012 06:40', 1, 3, 0], ['22APR2012...

How to test if list element exists?

Problem I would like to test if an element of a list exists, here is an example foo <- list(a=1) exists('foo') TRUE #foo does exist exists('foo$a') FALSE #suggests that foo$a does not exist foo$a [1] 1 #but it does exist In this example, I ...

macro - open all files in a folder

I want to open all files in a specified folder and have the following code Sub OpenFiles() Dim MyFolder As String Dim MyFile As String MyFolder = "\\ILAFILESERVER\Public\Documents\Renewable Energy\FiTs\1 Planning Department\Marks Tracker\...

Java unsupported major minor version 52.0

I can not launch my java application as a web applet in HTML (I am using HTML 4.01, I know it doesn't work in html5). The error message it returns is: java : Unsupported major.minor version 52.0 I have tried downgrading my java JRE/JDK/SDK but ...

Excel: Search for a list of strings within a particular string using array formulas?

I want to search a cell for a list of words. I thought this would work as an array formula: {=FIND(<list of words I want to search for>,<cell I want to search>)} But it only finds a match when a word that's in the cell I'm searching si...

How to send a GET request from PHP?

I'm planning to use PHP for a simple requirement. I need to download a XML content from a URL, for which I need to send HTTP GET request to that URL. How do I do it in PHP?...

Spring can you autowire inside an abstract class?

Spring is failing to autowire my object? Is it possible to autowire an object within an abstract class. Assume all schemas are supplied in application-context.xml Question: What annotation should be on the base and extending classes (if any) @Servic...

grep exclude multiple strings

I am trying to see a log file using tail -f and want to exclude all lines containing the following strings: "Nopaging the limit is"` and `"keyword to remove is" I am able to exclude one string like this: tail -f admin.log|grep -v "Nopaging the l...

How to round a floating point number up to a certain decimal place?

Suppose I have 8.8333333333333339, and I want to convert it to 8.84. How can I accomplish this in Python? round(8.8333333333333339, 2) gives 8.83 and not 8.84. I am new to Python or programming in general. I don't want to print it as a string, and ...

Java double comparison epsilon

I wrote a class that tests for equality, less than, and greater than with two doubles in Java. My general case is comparing price that can have an accuracy of a half cent. 59.005 compared to 59.395. Is the epsilon I chose adequate for those cases?...

Retrieve only the queried element in an object array in MongoDB collection

Suppose you have the following documents in my collection: { "_id":ObjectId("562e7c594c12942f08fe4192"), "shapes":[ { "shape":"square", "color":"blue" }, { "shape":"circle", "color"...

Replace one substring for another string in shell script

I have "I love Suzi and Marry" and I want to change "Suzi" to "Sara". #!/bin/bash firstString="I love Suzi and Marry" secondString="Sara" # do something... The result must be like this: firstString="I love Sara and Marry" ...

Deploy a project using Git push

Is it possible to deploy a website using git push? I have a hunch it has something to do with using git hooks to perform a git reset --hard on the server side, but how would I go about accomplishing this?...

Converting Milliseconds to Minutes and Seconds?

I have looked through previous questions, but none had the answer I was looking for. How do I convert milliseconds from a StopWatch method to Minutes and Seconds? I have: watch.start(); to start the stopwatch and watch.stop(); to stop the wa...

How do I set response headers in Flask?

This is my code: @app.route('/hello', methods=["POST"]) def hello(): resp = make_response() resp.headers['Access-Control-Allow-Origin'] = '*' return resp However, when I make a request from the browser to my server I get this error: X...

How do I do redo (i.e. "undo undo") in Vim?

In Vim, I did too much undo. How do I undo this (that is, redo)?...

How to set background color in jquery

How to set background color of td in jQuery? e.g $(this).css({**BackgroundColor:Red**}) Thanks...

Unable to connect PostgreSQL to remote database using pgAdmin

I installed PostgreSQL on my local server (Ubuntu) with IP 192.168.1.10. Now, I'm trying to access the database from my client machine (Ubuntu) with IP 192.168.1.11 with pgAdmin. I know I have to make changes in postgresql.conf and pg_hba.conf to a...

Android: Flush DNS

We recently released an android application that pulls information from an external server. Last week we moved from shared hosting to a dedicated server, that went smoothly up until we started getting complaints that users were getting server not fo...

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

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

What are WSDL, SOAP and REST?

What is WSDL? How is it related to SOAP? Where does REST fit in all of that?...

Could not load file or assembly "Oracle.DataAccess" or one of its dependencies

I am trying to run this web application. I keep getting this error "Could not load file or assembly "Oracle.DataAccess" or one of its dependencies. An attempt was made to load a program with an incorrect format." Exception details: System.BadImageFor...

How to get the xml node value in string

I tried the below code to get the value of a particular node, but while loading the xml this exception is thrown: Exception: Data at the root level is invalid. Line 1, position 1. XML <?xml version="1.0"?> <Data xmlns:xsd="http://www...

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

WCF timeout exception detailed investigation

We have an application that has a WCF service (*.svc) running on IIS7 and various clients querying the service. The server is running Win 2008 Server. The clients are running either Windows 2008 Server or Windows 2003 server. I am getting the followi...

Easiest way to develop simple GUI in Python

I'm done with my class project which I coded using Python. I'm working on the extra credit part i.e. GUI development - Windows platform. I need something simple, easy to use, possibly drag-and-drop GUI development tool for Python. GUI needs to look ...

If Radio Button is selected, perform validation on Checkboxes

I'm trying to work this form so when the first radio button is selected, run a certain validation. When the second radio button is selected, run a different validation, etc. Currently using Alerts to check the functionality, but whichever radio butto...

SVG drop shadow using css3

Is it possible to set drop shadow for an svg element using css3 , something like box-shadow: -5px -5px 5px #888; -webkit-box-shadow: -5px -5px 5px #888; I saw some remarks on creating shadow using filter effects. Is there an example of using css a...

How to ssh from within a bash script?

I am trying to create an ssh connection and do some things on the remote server from within the script. However the terminal prompts me for a password, then opens the connection in the terminal window instead of the script. The commands don't get ex...

How to use Global Variables in C#?

How do I declare a variable so that every class (*.cs) can access its content, without an instance reference?...

How do I update a Linq to SQL dbml file?

How do I update a Linq to SQL .dbml file?...

How to set the background image of a html 5 canvas to .png image

I would like to know how it is possible to set the background image of a canvas to a .png file. I do not want to add the image in the back of the canvas and make the canvas transparent. I want the user to be able to actually draw on that canvas wit...

Difference between CLOB and BLOB from DB2 and Oracle Perspective?

I have been pretty much fascinated by these two data types. According to Oracle Docs, they are presented as follows : BLOB : Variable-length binary large object string that can be up to 2GB (2,147,483,647) long. Primarily intended to hold non-tradit...

How do you get the width and height of a multi-dimensional array?

I have an array defined: int [,] ary; // ... int nArea = ary.Length; // x*y or total area This is all well and good, but I need to know how wide this array is in the x and y dimensions individually. Namely, ary.Length might return 12 - but does th...

Find OpenCV Version Installed on Ubuntu

I would like to find out what version of OpenCV is installed on my computer (i am running Ubuntu 10.04). Is there a simple way to check it if ? If not then can i find out the directories where files (samples, etc) are installed ? I am trying to run...

How do you clear your Visual Studio cache on Windows Vista?

I have a problem where my ASP.NET controls are not able to be referenced from the code behind files. I found a solution in Stack Overflow question ASP.NET controls cannot be referenced in code-behind in Visual Studio 2008. But I cannot seem t...

What is the difference between "Rollback..." and "Back Out Submitted Changelist #####" in Perforce P4V

I want to reverse the changes from one of my checkins. In the right-click context menu of the particular changelist, there are these two options: Rollback... Back Out Submitted Changelist What is the difference between these two? In what situati...

How can I list ALL DNS records?

Is there any way I can list ALL DNS records for a domain? I know about such things as dig and nslookup but they only go so far. For example, if I've got a subdomain A record as test A somedomain.co.uk then unless I specifically ask for it, eg. ...

load json into variable

I have to do something very simple, but there doesn't seem to be an easy way to do this, as far as I can tell. I just want to load JSON data from a remote source and store it in a global Javascript variable using jQuery. Here's what I have: var my_j...

Getting fb.me URL

How do I go about either making, or retrieving facebook short url's (fb.me) from a page, profile, event etc? I want to update my url shortener site - but if the user links to a facebook page I want to just return a fb.me link instead. Does facebook m...

Set object property using reflection

Is there a way in C# where I can use reflection to set an object property? Ex: MyObject obj = new MyObject(); obj.Name = "Value"; I want to set obj.Name with reflection. Something like: Reflection.SetProperty(obj, "Name") = "Value"; Is there a...

Image resolution for mdpi, hdpi, xhdpi and xxhdpi

I have a background for my app in resolutions 720x1280 pixels, 1080x1920 pixels and 1440x2560 pixels. In which folders (mdpi, hdpi, xhdpi and xxhdpi) should I put each background? ...

In jQuery, what's the best way of formatting a number to 2 decimal places?

This is what I have right now: $("#number").val(parseFloat($("#number").val()).toFixed(2)); It looks messy to me. I don't think I'm chaining the functions correctly. Do I have to call it for each textbox, or can I create a separate function?...

The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. on deploying to tomcat

I have built an application using Spring with Eclipse IDE. When I launch the project from Eclipse IDE everything is fine but when I package the maven project as a war file and deployed to separate tomcat I have this issue The origin server did not f...

How to print to stderr in Python?

There are several ways to write to stderr: # Note: this first one does not work in Python 3 print >> sys.stderr, "spam" sys.stderr.write("spam\n") os.write(2, b"spam\n") from __future__ import print_function print("spam", file=sys.stderr) ...

How do I tell a Python script to use a particular version

How do I, in the main.py module (presumably), tell Python which interpreter to use? What I mean is: if I want a particular script to use version 3 of Python to interpret the entire program, how do I do that? Bonus: How would this affect a virtualenv...

Multiple Cursors in Sublime Text 2 Windows

I have installed Sublime Text 2 in windows and I am trying to use the multiple cursors feature. Firstly I highlight the selection I am looking for (three lines). Then I can press CTRL + D to select each re-occurrence, or ALT + F3 to select all. Th...

Replacing a 32-bit loop counter with 64-bit introduces crazy performance deviations with _mm_popcnt_u64 on Intel CPUs

I was looking for the fastest way to popcount large arrays of data. I encountered a very weird effect: Changing the loop variable from unsigned to uint64_t made the performance drop by 50% on my PC. The Benchmark #include <iostream> #include ...

Implementing multiple interfaces with Java - is there a way to delegate?

I need to create a base class that implements several interfaces with lots of methods, example below. Is there an easier way to delegate these method calls without having to create a horde of duplicate methods? public class MultipleInterfaces imple...

Save modifications in place with awk

I am learning awk and I would like to know if there is an option to write changes to file, similar to sed where I would use -i option to save modifications to a file. I do understand that I could use redirection to write changes. However is there a...

AlertDialog.Builder with custom layout and EditText; cannot access view

I am trying to create an alert dialog with an EditText object. I need to set the initial text of the EditText programmatically. Here's what I have. AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); // ...Irrelevant code for customiz...

Code signing is required for product type Unit Test Bundle in SDK iOS 8.0

Getting Code signing is required for product type 'Unit Test Bundle' in SDK 'iOS 8.0' My app target is code signing just fine - but my test target is not. I bought a new computer, created a new development certificate from the computer, upd...

How can I set up an editor to work with Git on Windows?

I'm trying out Git on Windows. I got to the point of trying "git commit" and I got this error: Terminal is dumb but no VISUAL nor EDITOR defined. Please supply the message using either -m or -F option. So I figured out I need to have an env...

What is the purpose of meshgrid in Python / NumPy?

Can someone explain to me what is the purpose of meshgrid function in Numpy? I know it creates some kind of grid of coordinates for plotting, but I can't really see the direct benefit of it. I am studying "Python Machine Learning" from Sebastian Ras...

CSS / HTML Navigation and Logo on same line

I can't figure out how to put them on the same line. http://codepen.io/anon/pen/dovZdQ <body> <div class="navigation-bar"> <div id="navigation-container"> <img src="logo.png"> <ul>...

jQuery first child of "this"

I'm trying to pass "this" from a clicked span to a jQuery function that can then execute jQuery on that clicked element's first child. Can't seem to get it right... <p onclick="toggleSection($(this));"><span class="redClass"></span>...

WPF Button with Image

I'm trying to attach an image on a button in WPF, however this code fails. Seems strange after similar code would work perfectly in Mozilla XUL. <Button Height="49.086" Margin="3.636,12,231.795,0" Name="button2" VerticalAlignment="Top" ...

Checking if form has been submitted - PHP

What is the best way of checking whether or not a form has been submitted to determine whether I should pass the form's variables to my validation class? First I thought maybe: isset($_POST) But that will always return true as a superglobal is de...

Can't find the 'libpq-fe.h header when trying to install pg gem

I am using the Ruby on Rails 3.1 pre version. I like to use PostgreSQL, but the problem is installing the pg gem. It gives me the following error: $ gem install pg Building native extensions. This could take a while... ERROR: Error installing pg: ...

jQuery: Uncheck other checkbox on one checked

I am having total 6 checkbox ( may be add more in future ) and I want to allow only select one so when user checked any of them other should unchecked. I tried with this code and works fine if I defined ID but now just wonder how to make it vice ver...

How to force Chrome browser to reload .css file while debugging in Visual Studio?

I'm currently editing a .css file inside of Visual Studio 2012 (in debug mode). I'm using Chrome as my browser. When I make changes to my application's .css file inside of Visual Studio and save, refreshing the page will not load with the updated cha...

Best implementation for hashCode method for a collection

How do we decide on the best implementation of hashCode() method for a collection (assuming that equals method has been overridden correctly) ?...

JSON Structure for List of Objects

I would like to know, whats the right structure for a list of objects in JSON. We are using JAXB to convert the POJO's to JSON. Here is the choices, Please direct me what is right. foos: [ foo:{..}, foo:{..} ] or ...

When correctly use Task.Run and when just async-await

I would like to ask you on your opinion about the correct architecture when to use Task.Run. I am experiencing laggy UI in our WPF .NET 4.5 application (with Caliburn Micro framework). Basically I am doing (very simplified code snippets): public cl...

What is the difference between the | and || or operators?

I have always used || (two pipes) in OR expressions, both in C# and PHP. Occasionally I see a single pipe used: |. What is the difference between those two usages? Are there any caveats when using one over the other or are they interchangeable?...

Shell script variable not empty (-z option)

How to make sure a variable is not empty with the -z option ? errorstatus="notnull" if [ !-z $errorstatus ] then echo "string is not null" fi It returns the error : ./test: line 2: [: !-z: unary operator expected ...

Why can't decimal numbers be represented exactly in binary?

There have been several questions posted to SO about floating-point representation. For example, the decimal number 0.1 doesn't have an exact binary representation, so it's dangerous to use the == operator to compare it to another floating-point numb...

Python, how to read bytes from file and save it?

I want to read bytes from a file and then write those bytes to another file, and save that file. How do I do this?...

How to change column width in DataGridView?

I have created a database and table using Visual Studio's SQL Server Compact 3.5 with a dataset as my datasource. On my WinForm I have a DataGridView with 3 columns. However, I have been unable to figure out how to get the columns to take up the full...

CheckBox in RecyclerView keeps on checking different items

Here's the XML for my items inside the RecyclerView <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:id="@+id/cvItems" and...

jQuery Ajax File Upload

Can I use the following jQuery code to perform file upload using POST method of an ajax request ? $.ajax({ type: "POST", timeout: 50000, url: url, data: dataString, success: function (data) { alert('success'); ret...

How to add "active" class to Html.ActionLink in ASP.NET MVC

I'm trying to add an"active" class to my bootstrap navbar in MVC, but the following doesn't show the active class when written like this: <ul class="nav navbar-nav"> <li>@Html.ActionLink("Home", "Index", "Home", null, new {@class="acti...

How do I measure execution time of a command on the Windows command line?

Is there a built-in way to measure execution time of a command on the Windows command line?...

Java generics - ArrayList initialization

It is known that arraylist init. should be like this ArrayList<A> a = new ArrayList<A>(); ArrayList<Integer> a = new ArrayList<Number>(); // compile-time error so, why does java allow these ? 1. ArrayList<? extends...

Content Security Policy "data" not working for base64 Images in Chrome 28

In this simple example, I'm trying to set a CSP header with the meta http-equiv header. I included a base64 image and I'm trying to make Chrome load the image. I thought the data keyword should do that, but somehow it's not working. I just get the ...

What's the difference between implementation and compile in Gradle?

After updating to Android Studio 3.0 and creating a new project, I noticed that in build.gradle there is a new way to add new dependencies instead of compile there is implementation and instead of testCompile there is testImplementation. Example: ...

How to set max width of an image in CSS

On my website I would like to display images uploaded by user in a new window with a specific size (width: 600px). The problem is that the images may be big. So if they are bigger than these 600px, I would like to resize them, preserving the aspect r...

Why can't I call a public method in another class?

I have got these two classes interacting and I am trying to call four different classes from class one for use in class two. The methods are public and they do return values but for some reason there is not a connection being made. The error I get w...

Your password does not satisfy the current policy requirements

I want to create a new user in mysql with syntax: create user 'demo'@'localhost' identified by 'password'; But it returns an error: Your password does not satisfy the current policy requirements. I have tried many passwords but they don't w...

change directory in batch file using variable

Here's the question: set Pathname = C:\Program Files cd %Pathname% pause The above doesn't change the directory, as I would expect. Can anybody please tell me why?...

How to load image to WPF in runtime?

It seems like it's quite complicated to load an image in runtime to a WPF window. Image image; image = new Uri("Bilder/sas.png", UriKind.Relative); ????.Source = new BitmapImage(image); I'm trying this code, but I need some help to get it to work....

PHP errors NOT being displayed in the browser [Ubuntu 10.10]

I'm new to PHP and the whole LAMP stack but I've managed to get it up and running on my Ubuntu 10.10 system. Everything seems to be working with the exception of error reposting in the browser which I just can't seem to get working (and which I can't...

click or change event on radio using jquery

I have some radios in my page,and I want to do something when the checked radio changes,however the code does not work in IE: $('input:radio').change(...); And after googling,people suggest use the click instead. But it does not work. This is the...

Parse a URI String into Name-Value Collection

I've got the URI like this: https://google.com.ua/oauth/authorize?client_id=SS&response_type=code&scope=N_FULL&access_type=offline&redirect_uri=http://localhost/Callback I need a collection with parsed elements: NAME VA...

Java Refuses to Start - Could not reserve enough space for object heap

Background We have a pool of aproximately 20 linux blades. Some are running Suse, some are running Redhat. ALL share NAS space which contains the following 3 folders: /NAS/app/java - a symlink that points to an installation of a Java JDK. Curre...

How can I get useful error messages in PHP?

Quite often I will try and run a PHP script and just get a blank screen back. No error message; just an empty screen. The cause might have been a simple syntax error (wrong bracket, missing semicolon), or a failed function call, or something else ent...

how to "execute" make file

I tried to use a make file in code::blocks but I am doing it wrong. I have the version installed with the compilers included. http://sourceforge.net/projects/codeblocks/files/Binaries/10.05/Windows/codeblocks-10.05mingw-setup.exe/download. What do I ...

How can I get the current stack trace in Java?

How do I get the current stack trace in Java, like how in .NET you can do Environment.StackTrace? I found Thread.dumpStack() but it is not what I want - I want to get the stack trace back, not print it out....

Free ASP.Net and/or CSS Themes

Where can I get some decent looking free ASP.Net or CSS themes?...

git undo all uncommitted or unsaved changes

I'm trying to undo all changes since my last commit. I tried git reset --hard and git reset --hard HEAD after viewing this post. I responds with head is now at 18c3773... but when I look at my local source all the files are still there. What am I mis...

AngularJS event on window innerWidth size change

I'm looking for a way to watch changes on window inner width size change. I tried the following and it didn't work: $scope.$watch('window.innerWidth', function() { console.log(window.innerWidth); }); any suggestions?...

How to get base URL in Web API controller?

I know that I can use Url.Link() to get URL of a specific route, but how can I get Web API base URL in Web API controller?...

How to use regex with find command?

I have some images named with generated uuid1 string. For example 81397018-b84a-11e0-9d2a-001b77dc0bed.jpg. I want to find out all these images using "find" command: find . -regex "[a-f0-9\-]\{36\}\.jpg". But it doesn't work. Something wrong with ...

How to deal with missing src/test/java source folder in Android/Maven project?

I'm not very experienced with Maven in combination with Android yet, so I followed these instructions to make a new Android project. When the project has been created, I get the following error message: Project 'xxx-1.0-SNAPSHOT' is missing requ...

Splitting a table cell into two columns in HTML

I have the following table: <table border="1"> <tr> <th scope="col">Header</th> <th scope="col">Header</th> <th scope="col">Header</th> </tr> <tr> <th scope="row"&g...

What is an .axd file?

What kind of purpose do .axd files serve? I know that it is used in the ASP.Net AJAX Toolkit and its controls. I'd like to know more about it. I tried Googling for it, but could not find getting basic information....

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

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

How do I get the opposite (negation) of a Boolean in Python?

For the following sample: def fuctionName(int, bool): if int in range(...): if bool == True: return False else: return True Is there any way to skip the second if-statement? Just to tell the computer to ...

"NoClassDefFoundError: Could not initialize class" error

When I run my project, I get numerous outputs of this error: Sep 9, 2009 8:22:23 AM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet Jersey threw exception java.lang.NoClassDefFoundError: Could not initiali...

scrollTop jquery, scrolling to div with id?

So this is the current code I have $(document).ready(function() { $('.abouta').click(function(){ $('html, body').animate({scrollTop:308}, 'slow'); return false; }); $('.portfolioa').click(function(){ $('html, body...

How and when to use ‘async’ and ‘await’

From my understanding one of the main things that async and await do is to make code easy to write and read - but is using them equal to spawning background threads to perform long duration logic? I'm currently trying out the most basic example. I'v...

Deadly CORS when http://localhost is the origin

I am stuck with this CORS problem, even though I set the server (nginx/node.js) with the appropriate headers. I can see in Chrome Network pane -> Response Headers: Access-Control-Allow-Origin:http://localhost which should do the trick. Here's th...

Difference between onLoad and ng-init in angular

I am learning angular. I don't understand what is difference between onLoad and ng-init for initialization of a variable. In which scope it creates this variable. For example <ng-include onLoad="selectedReq=reqSelected" src="'partials/abc.html'"...

Android: How to turn screen on and off programmatically?

Before marking this post as a "duplicate", I am writing this post because no other post holds the solution to the problem. I am trying to turn off the device, then after a few minutes or sensor change, turn it back on. Turn Off Display Tests I am ...

Use JAXB to create Object from XML String

How can I use the below code to unmarshal a XML string an map it to the JAXB object below? JAXBContext jaxbContext = JAXBContext.newInstance(Person.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); Person person = (Person) unmars...

Print Combining Strings and Numbers

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

How to set HTTP headers (for cache-control)?

How to enable browser caching for my site? Do I just put cache-control:public somewhere up in my header like this? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" Cache-C...

How to wrap text in textview in Android

Does any one know how to wrap text in TextView in Android platform. i.e if the text in textview exceed the screen length it should be displayed in the second line. I have searched and tried the following: android:scrollHorizontally="false", android...

How to remove all the null elements inside a generic list in one go?

Is there a default method defined in .Net for C# to remove all the elements within a list which are null? List<EmailParameterClass> parameterList = new List<EmailParameterClass>{param1, param2, param3...}; Let's say some of the paramet...

How to use regex in file find

I was trying to find all files dated and all files 3 days or more ago. find /home/test -name 'test.log.\d{4}-d{2}-d{2}.zip' -mtime 3 It is not listing anything. What is wrong with it?...

Center align with table-cell

I'm trying to use the table-cell way to center a div vertically and horizontally. It works when I use the following code: div { display: table; } .logo { display: table-cell; position: absolute; vertical-align: middle; left: 0;...

How to iterate over array of objects in Handlebars?

This might seem a silly question but I can't seem to find the answer anywhere. I'm hitting this Web API that returns an array of objects in JSON format: Handlebars docs shows the following example: <ul class="people_list"> {{#each people...

Bootstrap $('#myModal').modal('show') is not working

I'm not sure why but all the modal functions are not working with me. I checked the version and the load they are fine. I keep getting this error message: Uncaught TypeError: $(...).modal is not a function for the hide I already found an alterna...

How to define a connection string to a SQL Server 2008 database?

I'm using MS Visual Studio 2010 to create an application with SQL Server 2008 database access, but what I did to create the database was add a new "SQL Server 2008 Database Project", it added it, and shows me everything on my Solution Explorer, but h...

how to print an exception using logger?

I have a situation in which I want to print all the exception caught in catch block using logger. try { File file = new File("C:\\className").mkdir(); fh = new FileHandler("C:\\className\\className.log"); logger.addHandler(f...

How to change row color in datagridview?

I would like to change the color of a particular row in my datagridview. The row should be changed to red when the value of columncell 7 is less than the value in columncell 10. Any suggestions on how to accomplish this?...

SVN 405 Method Not Allowed

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

Check whether a string matches a regex in JS

I want to use JavaScript (can be with jQuery) to do some client-side validation to check whether a string matches the regex: ^([a-z0-9]{5,})$ Ideally it would be an expression that returned true or false. I'm a JavaScript newbie, does match() do...

C# Change A Button's Background Color

How can the background color of a button once another button is pressed? What I have at the moment is: ButtonToday.Background = Color.Red; And it's not working....

ImportError: No module named 'Tkinter'

For some reason, I can't use the Tkinter or tkinter module. After running the following command in the python shell import Tkinter or import tkinter I got this error ModuleNotFoundError: No module named 'Tkinter' or ModuleNotFoundErr...

Adding elements to a collection during iteration

Is it possible to add elements to a collection while iterating over it? More specifically, I would like to iterate over a collection, and if an element satisfies a certain condition I want to add some other elements to the collection, and make sure ...

How to make inactive content inside a div?

How to make content in some div block inactive using JavaScript? Let's say there is a button with command "Enable / Disable". And there is one div block with some text. When pushing button "Enable / Disable", is it is "Enable", you can work with con...

Find html label associated with a given input

Let's say I have an html form. Each input/select/textarea will have a corresponding <label> with the for attribute set to the id of it's companion. In this case, I know that each input will only have a single label. Given an input element in ...

Change color and appearance of drop down arrow

I want to change the default appearance of the arrow of a dropdown list so that looks the same across browsers. Is there a way to override the default look and feel of the drop down arrow using CSS or otherwise ?...

How do I erase an element from std::vector<> by index?

I have a std::vector<int>, and I want to delete the n'th element. How do I do that? std::vector<int> vec; vec.push_back(6); vec.push_back(-17); vec.push_back(12); vec.erase(???); ...

m2e lifecycle-mapping not found

I am trying to use the solution described here to solve the annoying "Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:build-helper-maven-plugin:1.7:add-source (execution: default, phase: generate-sources)" when I place the ...

Prevent cell numbers from incrementing in a formula in Excel

I have a formula in Excel that needs to be run on several rows of a column based on the numbers in that row divided by one constant. When I copy that formula and apply it to every cell in the range, all of the cell numbers increment with the row, inc...

How to add icon to mat-icon-button

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

How to set default value to all keys of a dict object in python?

I know you can use setdefault(key, value) to set default value for a given key, but is there a way to set default values of all keys to some value after creating a dict ? Put it another way, I want the dict to return the specified default value for ...

The response content cannot be parsed because the Internet Explorer engine is not available, or

I need to download a channel 9 series using powershell, however the scripts I have tried have errors: This script $url="https://channel9.msdn.com/blogs/OfficeDevPnP/feed/mp4high" $rss=invoke-webrequest -uri $url $destination="D:\Videos\OfficePnP"...

How get the base URL via context path in JSF?

I have this structure: WebContent resources components top.xhtml company about_us.xhtml index.xhtml top.xhtml is a component, that is used in index.xthml and about_us.xhtml too. top.xhtml <ul> ...

how to read xml file from url using php

I have to read an XML file from an URL $map_url = "http://maps.google.com/maps/api/directions/xml?origin=".$merchant_address_url."&destination=".$customer_address_url."&sensor=false"; This gives me an URL like: http://maps.google.com/m...

How to expand textarea width to 100% of parent (or how to expand any HTML element to 100% of parent width)?

How to expand textarea width to 100% of parent? I try width 100% but it is not works it expands to 100% of page what crash layout. Here the question in visual way. Please provide some hints....

Regex to check whether a string contains only numbers

hash = window.location.hash.substr(1); var reg = new RegExp('^[0-9]$'); console.log(reg.test(hash)); I get false on both "123" and "123f". I would like to check if the hash only contains numbers. Did I miss something?...

How do I convert number to string and pass it as argument to Execute Process Task?

I am using Execute Process task in SSIS 2008 R2. I have a variable idVar which is of data type Int32. I need to pass this variable to property Arguments of the task so the process executable can take this variable as argument. I use expression to ass...

maximum value of int

Is there any code to find the maximum value of integer (accordingly to the compiler) in C/C++ like Integer.MaxValue function in java?...

Is there a way to "limit" the result with ELOQUENT ORM of Laravel?

Is there a way to "limit" the result with ELOQUENT ORM of Laravel? SELECT * FROM `games` LIMIT 30 , 30 And with Eloquent ? ...

How to convert an enum type variable to a string?

How to make printf to show the values of variables which are of an enum type? For instance: typedef enum {Linux, Apple, Windows} OS_type; OS_type myOS = Linux; and what I need is something like printenum(OS_type, "My OS is %s", myOS); which m...

What is the C++ function to raise a number to a power?

How do I raise a number to a power? 2^1 2^2 2^3 etc......

How to click a href link using Selenium

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

How to store directory files listing into an array?

I'm trying to store the files listing into an array and then loop through the array again. Below is what I get when I run ls -ls command from the console. total 40 36 -rwxrwxr-x 1 amit amit 36720 2012-03-31 12:19 1.txt 4 -rwxrwxr-x 1 amit amit 131...

Enter key press behaves like a Tab in Javascript

I'm looking to create a form where pressing the enter key causes focus to go to the "next" form element on the page. The solution I keep finding on the web is... <body onkeydown="if(event.keyCode==13){event.keyCode=9; return event.keyCode}"> ...

Do on-demand Mac OS X cloud services exist, comparable to Amazon's EC2 on-demand instances?

Amazon's EC2 service offers a variety of Linux and Windows OS choices, but I haven't found a service offering a similar "rent by the hour" service for a remote Mac OS X virtual machine. Does such a service exist? (iCloud looks to be just a data sto...

Android emulator shows nothing except black screen and adb devices shows "device offline"

I am just trying to start development in Android. So, the problem is that when I try to launch an emulator by issuing the command emulator @A2 , an emulator comes up on the screen. But even after waiting for as long as 2-3 hrs, all it shows is a bla...

SQLAlchemy: What's the difference between flush() and commit()?

What the difference is between flush() and commit() in SQLAlchemy? I've read the docs, but am none the wiser - they seem to assume a pre-understanding that I don't have. I'm particularly interested in their impact on memory usage. I'm loading some ...

How do I convert a javascript object array to a string array of the object attribute I want?

Possible Duplicate: Accessing properties of an array of objects Given: [{ 'id':1, 'name':'john' },{ 'id':2, 'name':'jane' }........,{ 'id':2000, 'name':'zack' }] What's the best way to get: ['john', 'jane', ........

How to convert datetime to timestamp using C#/.NET (ignoring current timezone)

How do I convert datetime to timestamp using C# .NET (ignoring the current timezone)? I am using the below code: private long ConvertToTimestamp(DateTime value) { long epoch = (value.ToUniversalTime().Ticks - 621355968000000000) / 10000000; ...

JSON to TypeScript class instance?

I've done quite some research, but I'm not totally satisfied with what I found. Just to be sure here's my question: What is actually the most robust and elegant automated solution for deserializing JSON to TypeScript runtime class instances? Say I g...

Event on a disabled input

Apparently a disabled <input> is not handled by any event Is there a way to work around this issue ? <input type="text" disabled="disabled" name="test" value="test" /> $(':input').click(function () { $(this).removeAttr('disabled')...

Using jQuery Fancybox or Lightbox to display a contact form

I would like to use jQuery Fancybox or Lightbox to load a contact form from a standard link in a web page. I have reviewed the documents at http://fancybox.net/example but the closest option is the iFrame one and it doesn't work with a standard page ...

changing iframe source with jquery

I've been trying this for a bit now and have looked at other answers to similar questions on SO, but when I am trying to change the src attribute of an iframe, it updates it for the whole window. Here is the following code I am using that works corre...

How to set initial size of std::vector?

I have a vector<CustomClass*> and I put a lot of items in the vector and I need fast access, so I don't use list. How to set initial size of vector (for example to be 20 000 places, so to avoid copy when I insert new)?...

get size of json object

i have a json object that gets returned by an AJAX request and I am having some trouble with the .length because it keeps returning undefined. Just wondering if I'm using it right: console.log(data.length); console.log(data.phones.length); They bo...

How can I parse String to Int in an Angular expression?

A number string '5' var num_str = '5'; How can I parseInt and let below answers correct at the same time? {{num_str + 1}} // 6 {{num_str - 1}} // 4 parseInt can't be used in an Angular expression, {{parseInt(num_str) - 1}} number filte...

How to use hex() without 0x in Python?

The hex() function in python, puts the leading characters 0x in front of the number. Is there anyway to tell it NOT to put them? So 0xfa230 will be fa230. The code is import fileinput f = open('hexa', 'w') for line in fileinput.input(['pattern0.txt...

App.Config file in console application C#

I have a console application in which I want to write the name of a file. Process.Start("blah.bat"); Normally, I would have something like that in windows application by writing the name of the file 'blah.bat' to Settings file in Properties. Howe...

How can I install Visual Studio Code extensions offline?

I have installed Visual Studio Code on a machine that is not, and cannot be, connected to the Internet. According to the documentation, I can install an extension from the command line if I have the .vsix, but I don't know how to get the .vsix from t...

Process with an ID #### is not running in visual studio professional 2013 update 3

I am trying to run any program on visual studio 2013 update 3 and I get the following alert box : Process with an ID #### is not running . // every time there is different ID number showing and in the error windows I get this error msg: The pro...

DIVs inside another DIV inside another DIV with CSS

Here's what I'm trying to achieve: This is the HTML code I wrote: <div id="wrapper"> <!--This is the Div 1 in the picture--> <div id="topBar"> <!--This is the Div 2 in the picture--> <div id="logo"></d...

How to use Python to login to a webpage and retrieve cookies for later usage?

I want to download and parse webpage using python, but to access it I need a couple of cookies set. Therefore I need to login over https to the webpage first. The login moment involves sending two POST params (username, password) to /login.php. Durin...

UnicodeDecodeError, invalid continuation byte

Why is the below item failing? Why does it succeed with "latin-1" codec? o = "a test of \xe9 char" #I want this to remain a string as this is what I am receiving v = o.decode("utf-8") Which results in: Traceback (most ...

chrome undo the action of "prevent this page from creating additional dialogs"

I sometimes find that I need to re-enable alerting for debugging. Of course I can close the tab and reload it but Is there a better way? ...

How do you get the current time of day?

How do you get the current time (not date AND time)? Example: 5:42:12 PM...

How do I get the parent directory in Python?

Could someone tell me how to get the parent directory of a path in Python in a cross platform way. E.g. C:\Program Files ---> C:\ and C:\ ---> C:\ If the directory doesn't have a parent directory, it returns the directory itself. The ques...

Add a column to existing table and uniquely number them on MS SQL Server

I want to add a column to an existing legacy database and write a procedure by which I can assign each record a different value. Something like adding a column and autogenerate the data for it. Like, if I add a new column called "ID" (number) I want...

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

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

Force Intellij IDEA to reread all maven dependencies

How to force intellij idea to reread/update all dependencies specified in the pom file ?...

How to make inline plots in Jupyter Notebook larger?

I have made my plots inline on my Ipython Notebook with "%matplotlib inline." Now, the plot appears. However, it is very small. Is there a way to make it appear larger using either notebook settings or plot settings? ...

ng-if, not equal to?

I have a simple ng-reapt that displays a list of values.. On some of the outputs, i have a couple of ng-if to show/hide DIVs. HTML: <div ng-repeat="details in myDataSet"> <p>{{ details.Name }}</p> <p>{{ details.DOB ...

AttributeError: 'str' object has no attribute 'strftime'

I am using the following code to use the date in a specific format and running into following error..how to put date in m/d/y format? from datetime import datetime, date def main (): cr_date = '2013-10-31 18:23:29.000227' crrdate = cr_date....

How do I pipe or redirect the output of curl -v?

For some reason the output always gets printed to the terminal, regardless of whether I redirect it via 2> or > or |. Is there a way to get around this? Why is this happening?...

Fastest method to escape HTML tags as HTML entities?

I'm writing a Chrome extension that involves doing a lot of the following job: sanitizing strings that might contain HTML tags, by converting <, > and & to &lt;, &gt; and &amp;, respectively. (In other words, the same as PHP's ...

How do I syntax check a Bash script without running it?

Is it possible to check a bash script syntax without executing it? Using Perl, I can run perl -c 'script name'. Is there any equivalent command for bash scripts?...

iOS 7 status bar back to iOS 6 default style in iPhone app?

In iOS 7 the UIStatusBar has been designed in a way that it merges with the view like this: (GUI designed by Tina Tavcar) It is cool, but it will somewhat mess up your view when you have something at the top part of your view, and it becomes over...

How do I rotate text in css?

How do I rotate text in css to get following output: hi, Edit: Thanks for quick suggestion. I have added my sample code in jsfidle: http://jsfiddle.net/koolkabin/yawYM/ HTML: <div class="mainWrapper"> <div class="rotateObj...

HTML5 iFrame Seamless Attribute

in HTML5 the iframe has new attributes like 'seamless' that should remove borders and scrollbars. I've tried it but doesn't seem to work, I still can see scrollbars and borders (I'm using Google Chrome as browser), Here's my code: <iframe seamles...

Does a foreign key automatically create an index?

I've been told that if I foreign key two tables, that SQL Server will create something akin to an index in the child table. I have a hard time believing this to be true, but can't find much out there related specifically to this. My real reason for...

How to sort an array in descending order in Ruby

I have an array of hashes: [ { :foo => 'foo', :bar => 2 }, { :foo => 'foo', :bar => 3 }, { :foo => 'foo', :bar => 5 }, ] I am trying to sort this array in descending order according to the value of :bar in each hash. I am ...

How can I display a pdf document into a Webview?

I want to display pdf contents on webview. Here is my code: WebView webview = new WebView(this); setContentView(webview); webview.getSettings().setJavaScriptEnabled(true); webview.loadUrl("http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_paramete...

chai test array equality doesn't work as expected

Why does the following fail? expect([0,0]).to.equal([0,0]); and what is the right way to test that?...

When should I use a List vs a LinkedList

When is it better to use a List vs a LinkedList?...

DataTable: Hide the Show Entries dropdown but keep the Search box

Is it possible to hide the Show Entries dropdown but keep the Search box in DataTable? I want to always display 10 rows with pagination at the bottom along with search box but do not want to display the Show entries dropdown....

How can I transform string to UTF-8 in C#?

I have a string that I receive from a third party app and I would like to display it correctly in any language using C# on my Windows Surface. Due to incorrect encoding, a piece of my string looks like this in Spanish: Acción whereas it s...

img tag displays wrong orientation

I have an image at this link: http://d38daqc8ucuvuv.cloudfront.net/avatars/216/2014-02-19%2017.13.48.jpg As you can see, this is a normal image with correct orientation. However, when I set this link to src attribute of my image tag, the image becom...

What's the @ in front of a string in C#?

This is a .NET question for C# (or possibly VB.net), but I am trying to figure out what's the difference between the following declarations: string hello = "hello"; vs. string hello_alias = @"hello"; Printing out on the console makes no differ...

How to scroll HTML page to given anchor?

I’d like to make the browser to scroll the page to a given anchor, just by using JavaScript. I have specified a name or id attribute in my HTML code: <a name="anchorName">..</a> or <h1 id="anchorName2">..</h1> I’d...

Importing JSON into an Eclipse project

I'm an aspiring Java programmer looking to use JSON in a project. I was following a programming tutorial (from a book) which asked me to import JSON into my project by using the following line: import com.google.appengine.repackaged.org.json.JSONArr...

Skip rows during csv import pandas

I'm trying to import a .csv file using pandas.read_csv(), however I don't want to import the 2nd row of the data file (the row with index = 1 for 0-indexing). I can't see how not to import it because the arguments used with the command seem ambiguou...

Convert char* to string C++

I know the starting address of the string(e.g., char* buf) and the max length int l; of the string(i.e., total number of characters is less than or equal to l). What is the simplest way to get the value of the string from the specified memory segmen...

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

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

iText - add content to existing PDF file

I want to do the following with iText: (1) parse an existing PDF file (2) add some data to it, on the existing single page of the document (such as a timestamp) (3) write out the document I just can't seem to figure out how to do this with iText....

Difference between iCalendar (.ics) and the vCalendar (.vcs)

I want to send booking information through mail in an attachment to add in MS Outlook. Which format is better? Especially for MS Outlook 2003?...

Rails server says port already used, how to kill that process?

I'm on a mac, doing: rails server I get: 2010-12-17 12:35:15] INFO WEBrick 1.3.1 [2010-12-17 12:35:15] INFO ruby 1.8.7 (2010-08-16) [i686-darwin10.4.0] [2010-12-17 12:35:15] WARN TCPServer Error: Address already in use - bind(2) Exiting I kn...

Can I use jQuery with Node.js?

Is it possible to use jQuery selectors/DOM manipulation on the server-side using Node.js?...

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

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

How to get week number of the month from the date in sql server 2008

In SQL Statement in microsoft sql server, there is a built-in function to get week number but it is the week of the year. Select DatePart(week, '2012/11/30') // **returns 48** The returned value 48 is the week number of the year. Instead of 48, ...

Network tools that simulate slow network connection

I would like to visually evaluate web pages response time for several Internet connections types (DSL, Cable, T1, dial-up etc.) while my browser and web server are on the same LAN or even on the same machine. Are there any simple network tools or bro...

how to make negative numbers into positive

I am having the negative floating point number as: a = -0.340515; to convert this into positive number I used the abs() method as: a = abs(a); the result is a = 0.000000; But I need the result as 0.340515. Can anyone tell me how to do this....

Shorten string without cutting words in JavaScript

I'm not very good with string manipulation in JavaScript, and I was wondering how you would go about shortening a string without cutting any word off. I know how to use substring, but not indexOf or anything really well. Say I had the following stri...

how to select rows based on distinct values of A COLUMN only

I need to query a table in order to return rows, but I am not able to query the table correctly. Here is my table view: Id MailId EmailAddress Name 1 1 [email protected] Mr. A 2 ...

MATLAB, Filling in the area between two sets of data, lines in one figure

I have a question about using the area function; or perhaps another function is in order... I created this plot from a large text file: The green and the blue represent two different files. What I want to do is fill in the area between the red lin...

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

Where can I find error log files?

Where can I find error log files? I need to check them for solving an internal server error shown after installing suPHP....

Map to String in Java

When I do System.out.println(map) in Java, I get a nice output in stdout. How can I obtain this same string representation of a Map in a variable without meddling with standard output? Something like String mapAsString = Collections.toString(map)?...

Embedding VLC plugin on HTML page

I have a html file (getStream.html) that takes a stream from a certain url and show it. The code is the following: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ht...

Drop default constraint on a column in TSQL

I have a table with a column like this that is currently live: name NVARCHAR(128) NOT NULL DEFAULT '' I am altering the column like this to make it nullable: ALTER TABLE mytable ALTER COLUMN name NVARCHAR(128) NULL However, the default constra...

Converting NumPy array into Python List structure?

How do I convert a NumPy array to a Python List (for example [[1,2,3],[4,5,6]] ), and do it reasonably fast?...

How to select a node of treeview programmatically in c#?

Used treeview.SelectedNode to select a child node. How to invoke treeview.AfterSelect event when a node is selected programmatically? this.treeView1.SelectedNode = this.treeView1.Nodes[0].Nodes[0].Nodes[0].Nodes[0]; if (this.treeView1.Nodes[0].Node...

How to protect Excel workbook using VBA?

With a trigger like a check box I want to protect my work book. I tried Excel 2003: thisworkbook.protect("password",true,true) thisworkbook.unprotect("password") It's not working. Any suggestions?...

How to store token in Local or Session Storage in Angular 2?

I want to use Local or session storage to save authentication token in angular 2.0.0. I use angular2-localstorage but it works only angular 2.0.0-rc.5 and when I used it in 2.0.0 it through me Type error. I want to use default local storage of Angul...

How to append a date in batch files

I have the following line in a batch file (that runs on an old Windows 2000 box): 7z a QuickBackup.zip *.backup How do I append the date to the QuickBackup.zip file. So if I ran the batch file today, ideally, the file would be QuickBackup20090514....

How to filter a data frame

I have a data frame and tried to select only the observations I'm interested in by this: data[data["Var1"]>10] Unfortunately, this command destroys the data.frame structure and returns a long vector. What I want to get is the data.frame shorte...

How to find the array index with a value?

Say I've got this imageList = [100,200,300,400,500]; Which gives me [0]100 [1]200 etc. Is there any way in JavaScript to return the index with the value? I.e. I want the index for 200, I get returned 1....

Toggle visibility property of div

I have an HTML 5 video in a div. I then have a custom play button - that works fine. And I have the video's visibility set to hidden on load and visible when the play button is clicked, how do I return it to hidden when the play button is clicked aga...

How do I calculate someone's age in Java?

I want to return an age in years as an int in a Java method. What I have now is the following where getBirthDate() returns a Date object (with the birth date ;-)): public int getAge() { long ageInMillis = new Date().getTime() - getBirthDate().ge...

How to generate the JPA entity Metamodel?

In the spirit of type safety associated with the CriteriaQuery JPA 2.0 also has an API to support Metamodel representation of entities. Is anyone aware of a fully functional implementation of this API (to generate the Metamodel as opposed to creati...

MS-access reports - The search key was not found in any record - on save

Occasionally my MS Access reports: The search key was not found in any record After this happens the solution is to close Access, compact and repair the backend and then delete the record. What causes this and how can I avoid it?...

macOS on VMware doesn't recognize iOS device

I am using Mac OS in VMWare for iOS app development. After updating the OS and Xcode, the iOS device isn't available so I cannot test it. When the device is plugged in to the PC, the device appears as connected in VMware and marked with green point...

Basic authentication with fetch?

I want to write a simple basic authentication with fetch, but I keep getting a 401 error. It would be awesome if someone tells me what's wrong with the code: let base64 = require('base-64'); let url = 'http://eu.httpbin.org/basic-auth/user/passwd'; ...

Edit existing excel workbooks and sheets with xlrd and xlwt

In the documentation for xlrd and xlwt I have learned the following: How to read from existing work-books/sheets: from xlrd import open_workbook wb = open_workbook("ex.xls") s = wb.sheet_by_index(0) print s.cell(0,0).value #Prints contents of cell ...

Visual Studio 2017 - Git failed with a fatal error

I am using Visual Studio 2017 Community Edition (CE), and I have signed into my Microsoft account and I am connected to VSTS. I can see all my projects and repositories, but when I attempt to pull/fetch/push any changes I get the following ...

How to declare 2D array in bash

I'm wondering how to declare a 2D array in bash and then initialize to 0. In C it looks like this: int a[4][5] = {0}; And how do I assign a value to an element? As in C: a[2][3] = 3; ...

Subscript out of bounds - general definition and solution?

When working with R I frequently get the error message "subscript out of bounds". For example: # Load necessary libraries and data library(igraph) library(NetData) data(kracknets, package = "NetData") # Reduce dataset to nonzero edges krack_full_no...

Split Strings into words with multiple word boundary delimiters

I think what I want to do is a fairly common task but I've found no reference on the web. I have text with punctuation, and I want a list of the words. "Hey, you - what are you doing here!?" should be ['hey', 'you', 'what', 'are', 'you', 'doing'...

Jenkins Slave port number for firewall

We use Jenkins 1.504 on Windows. We need to have Master and Slave in different sub-networks with firewall in between. We can't have ANY to ANY port firewall rules, we must specify exact port numbers. I know the port Master is listening on. I also ...

isolating a sub-string in a string before a symbol in SQL Server 2008

i am trying to extract a substring(everything before a hyphen, in this case) from a string as shown below: Net Operating Loss - 2007 Capital Loss - 1991 Foreign Tax Credit - 1997 and want the year and name(substring before hyphen) separately, usin...

Trying to make bootstrap modal wider

I am using this code but the modal is too thin: <div class="modal fade bs-example-modal-lg custom-modal" tabindex="-1" role="dialog" aria-labelledby="myModal" aria-hidden="true" id="myModal"> <div class="modal-dialog modal-lg"> ...

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

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

javascript set cookie with expire time

I am setting a cookie by Javascript and it is working fine but it is not taking the expire time I am giving. It keeps on taking session value regardless of what I give, below is the code which I took from here var now = new Date(); var time = now.ge...

"Press Any Key to Continue" function in C

How do I create a void function that will work as "Press Any Key to Continue" in C? What I want to do is: printf("Let the Battle Begin!\n"); printf("Press Any Key to Continue\n"); //The Void Function Here //Then I will call the function that will s...

The service cannot be started, either because it is disabled or because it has no enabled devices associated with it

I have SQL Server 2008 R2 inside Windows Server 2008. But when I tried to start the "SQL Server Browser" service, I got the following error: The service cannot be started, either because it is disabled or because it has no enabled devices associa...

How can I search Git branches for a file or directory?

In Git, how could I search for a file or directory by path across a number of branches? I've written something in a branch, but I don't remember which one. Now I need to find it. Clarification: I'm looking for a file which I created on one of my ...

Convert int to string?

How can I convert an int datatype into a string datatype in C#?...

jQuery: Get height of hidden element in jQuery

I need to get height of an element that is within a div that is hidden. Right now I show the div, get the height, and hide the parent div. This seems a bit silly. Is there a better way? I'm using jQuery 1.4.2: $select.show(); optionHeight = $firstO...

How to interpret "loss" and "accuracy" for a machine learning model

When I trained my neural network with Theano or Tensorflow, they will report a variable called "loss" per epoch. How should I interpret this variable? Higher loss is better or worse, or what does it mean for the final performance (accuracy) of my ne...

Password must have at least one non-alpha character

I need a regular expression for a password. The password has to contain at least 8 characters. At least one character must be a number or a special character (not a letter). [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters ...

Spring Boot without the web server

I have a simple Spring Boot application that gets messages from a JMS queue and saves some data to a log file, but does not need a web server. Is there any way of starting Spring Boot without the web server?...

Importing .py files in Google Colab

Is there any way to upload my code in .py files and import them in colab code cells? The other way I found is to create a local Jupyter notebook then upload it to Colab, is it the only way?...

Order a MySQL table by two columns

How do I sort a MySQL table by two columns? What I want are articles sorted by highest ratings first, then most recent date. As an example, this would be a sample output (left # is the rating, then the article title, then the article date) 50 |...

How to query the permissions on an Oracle directory?

I have a directory in all_directories, but I need to find out what permissions are associated with it, i.e. what has been granted on it?...

Java Compare Two Lists

I have two lists ( not java lists, you can say two columns) For example **List 1** **Lists 2** milan hafil dingo iga iga dingo elpha binga hafil ...

C++ vector of char array

I am trying to write a program that has a vector of char arrays and am have some problems. char test [] = { 'a', 'b', 'c', 'd', 'e' }; vector<char[]> v; v.push_back(test); Sorry this has to be a char array because I need to be able to gene...

Can we open pdf file using UIWebView on iOS?

Can we open the pdf file from UIWebView?...

How to set button click effect in Android?

In Android, when I set background image to Button, I can not see any effect on button. I need some effect on button so user can recognize that button is clicked. Button should be dark while a few second when it clicked, so what should I do for thi...

Number of regex matches

I'm using the finditer function in the re module to match some things and everything is working. Now I need to find out how many matches I've got. Is it possible without looping through the iterator twice? (one to find out the count and then the re...

What is meant with "const" at end of function declaration?

I got a book, where there is written something like: class Foo { public: int Bar(int random_arg) const { // code } }; What does it mean?...

How to Define Callbacks in Android?

During the most recent Google IO, there was a presentation about implementing restful client applications. Unfortunately, it was only a high level discussion with no source code of the implementation. In this diagram, on the return path there are va...

ViewPager and fragments — what's the right way to store fragment's state?

Fragments seem to be very nice for separation of UI logic into some modules. But along with ViewPager its lifecycle is still misty to me. So Guru thoughts are badly needed! Edit See dumb solution below ;-) Scope Main activity has a ViewPager wit...

Pass react component as props

Lets say I have: import Statement from './Statement'; import SchoolDetails from './SchoolDetails'; import AuthorizedStaff from './AuthorizedStaff'; const MultiTab = () => ( <Tabs initialIndex={1} justify="start" className="tablisty"> ...

Disable Chrome strict MIME type checking

Is there any way to disable strict MIME type checking in Chrome. Actually I'm making a JSONP request on cross domain. Its working fine on Firefox but, while using chrome its giving some error in console. Refused to execute script from 'https://e...

Get Wordpress Category from Single Post

I'm finishing up a WP theme, and I'm on the single.php template. I'm having some issues because I need to access the parent category that a post is in in order to display certain images and XML content. Here is an example of what I'm talking about. ...

Sorting arrays in NumPy by column

How can I sort an array in NumPy by the nth column? For example, a = array([[9, 2, 3], [4, 5, 6], [7, 0, 5]]) I'd like to sort rows by the second column, such that I get back: array([[7, 0, 5], [9, 2, 3], [4, ...

How do I exit a while loop in Java?

What is the best way to exit/terminate a while loop in Java? For example, my code is currently as follows: while(true){ if(obj == null){ // I need to exit here } } ...

How can I change the app display name build with Flutter?

I have created the app using Flutter create testapp. Now, I want to change the app name from "testapp" to "My Trips Tracker". How can I do that? I have tried changing from the AndroidManifest.xml, and it got changed, but is there ...

How to update fields in a model without creating a new record in django?

I have a model in django that I want to update only, that is, when I call it and set the data, it will not create a new record, only update the existing one. How can I do this? Here is what I have: class TemperatureData(models.Model): date = ...

ExpressJS - throw er Unhandled error event

I created expressjs application using the following commands: express -e folderName npm install ejs --save npm install When I run the application with: node app.js, I have the following errors: events.js:72 throw er; // Unhandled 'error' even...

Refused to display in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'

I am developing a website that is supposed to be responsive so that people can access it from their phones. The site has got some secured parts that can be logged into using Google, Facebook, ...etc (OAuth). The server backend is developed using ASP...

Image Processing: Algorithm Improvement for 'Coca-Cola Can' Recognition

One of the most interesting projects I've worked on in the past couple of years was a project about image processing. The goal was to develop a system to be able to recognize Coca-Cola 'cans' (note that I'm stressing the word 'cans', you'll see why i...

Loop inside React JSX

I'm trying to do something like the following in React JSX (where ObjectRow is a separate component): <tbody> for (var i=0; i < numrows; i++) { <ObjectRow/> } </tbody> I realize and understand why this isn't val...

Adding text to ImageView in Android

I want to use an ImageView to show some message in a fancy way. How do I add text to an ImageView?...

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 secure MongoDB with username and password

I want to set up user name & password authentication for my MongoDB instance, so that any remote access will ask for the user name & password. I tried the tutorial from the MongoDB site and did following: use admin db.addUser('theadmin', '1...

window.close and self.close do not close the window in Chrome

The issue is that when I invoke window.close() or self.close() it doesn't close the window. Now there seems to be a belief that in Chrome you can't close by script any window that is not script created. That is patently false but regardless it is sup...

How to make HTML element resizable using pure Javascript?

I was wondering how we can make a HTML element like <div> or <p> tag element resizable when clicked using pure JavaScript, not the jQuery library or any other library....

What is the benefit of using "SET XACT_ABORT ON" in a stored procedure?

What is the benefit of using SET XACT_ABORT ON in a stored procedure?...

if statements matching multiple values

Any easier way to write this if statement? if (value==1 || value==2) For example... in SQL you can say where value in (1,2) instead of where value=1 or value=2. I'm looking for something that would work with any basic type... string, int, etc....

jQuery add required to input fields

I have been searching ways to have jQuery automatically write required using html5 validation to my all of my input fields but I am having trouble telling it where to write it. I want to take this <input type="text" name="first_name" value="" i...


How to see the proxy settings on windows?

Our work laptops are configured to use proxy to access external sites and I don't have access to see the proxy information. All our applications like IDEs are configured to use system proxy. Is there a way I can check the proxy settings; For example,...

How do you parse and process HTML/XML in PHP?

How can one parse HTML/XML and extract information from it?...

Illegal mix of collations MySQL Error

I'm getting this strange error while processing a large number of data... Error Number: 1267 Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' SELECT COUNT(*) as num from keywords WHERE campai...

How to parse a JSON object to a TypeScript Object

I am currently trying to convert my received JSON Object into a TypeScript class with the same attributes and I cannot get it to work. What am I doing wrong? Employee Class export class Employee{ firstname: string; lastname: string; bir...

How can we programmatically detect which iOS version is device running on?

I want to check if the user is running the app on iOS less than 5.0 and display a label in the app. How do I detect which iOS is running on user's device programmatically? Thanks!...

PHP Swift mailer: Failed to authenticate on SMTP using 2 possible authenticators

When I send an email with the PHP Swift mailer to this server: smtp.exchange.example.com like this: // Load transport $this->transport = Swift_SmtpTransport::newInstance( self::$config->hostname, self::$config->port ) ...

How to resize JLabel ImageIcon?

I'm making a Java Swing application that has the following layout (MigLayout): [icon][icon][icon][....] where icon = jlabel and the user can add more icons When the user adds or removes icons, the others should shrink or grow. My question is real...

What exactly does Double mean in java?

I'm extremely new to Java and just wanted to confirm what Double is? Is it similar to Float or Int? Any help would be appreciated. I also sometimes see the uppercase Double and other times the lower case double. If someone could clarify what this mea...

Add carriage return to a string

I have a long string. string s1 = "'99024','99050','99070','99143','99173','99191','99201','99202','99203','99204','99211','99212','99213','99214','99215','99217','99218','99219','99221','99222','99231','99232','99238','99239','99356','99357','99371...

Perl regular expression (using a variable as a search string with Perl operator characters included)

$text_to_search = "example text with [foo] and more"; $search_string = "[foo]"; if ($text_to_search =~ m/$search_string/) print "wee"; Please observe the above code. For some reason I would like to find the text "[foo]" in the $text_to_search ...

Line Break in HTML Select Option?

Can I have a two line text in an html select option? How?...

Rotate image with javascript

I need to rotate an image with javascript in 90-degree intervals. I have tried a few libraries like jQuery rotate and Raphaël, but they have the same problem - The image is rotated around its center. I have a bunch of content on all sides of the ima...

Are email addresses case sensitive?

I've read that by standard first part of e-mail is case sensitive, however I've tried to send e-mail to [email protected], [email protected] and [email protected] - it has arrived in each case. How do mail servers handles usernames? Is it possible to m...

Prevent div from moving while resizing the page

I'm quite new to CSS and I'm trying to get a page up and running. I managed to successfully produce what I thought was a nice page until I resized the browser window then everything started to move around. I have no idea why this is happening!! Coul...

How to write new line character to a file in Java

I have a string that contains new lines. I send this string to a function to write the String to a text file as: public static void writeResult(String writeFileName, String text) { try { FileWriter fileWriter = new Fi...

Java enum with multiple value types

Basically what I've done is write an enum for States, and I want to not only be able to access them just as states but also access their abbreviation and whether or not they were an original colony. public enum States { ... MASSACHUS...

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

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

Display date/time in user's locale format and time offset

I want the server to always serve dates in UTC in the HTML, and have JavaScript on the client site convert it to the user's local timezone. Bonus if I can output in the user's locale date format....

How to disable text selection highlighting

For anchors that act like buttons (for example Questions, Tags, Users, etc. which are located on the top of the Stack Overflow page) or tabs, is there a CSS standard way to disable the highlighting effect if the user accidentally selects the text? I...

REST API - Use the "Accept: application/json" HTTP Header

When I make a request, I get a response in XML, but what I need is JSON. In the doc it is stated in order to get a JSON in return: Use the Accept: application/json HTTP Header. Where do I find the HTTP Header to put Accept: application/json inside? ...

"Uncaught TypeError: a.indexOf is not a function" error when opening new foundation project

I've created a new Foundation 5 project through bash, with foundation new my-project. When I open the index.html file in Chrome an Uncaught TypeError: a.indexOf is not a function error is shown in the console, originating in jquery.min.js:4. I creat...

Remove Blank option from Select Option with AngularJS

I am new to AngularJS. I searched a lot, but it does not solve my problem. I am getting a blank option for the first time in select box. Here is my HTML code <div ng-app="MyApp1"> <div ng-controller="MyController"> <inpu...

How to read numbers separated by space using scanf

I want to read numbers(integer type) separated by spaces using scanf() function. I have read the following: C, reading multiple numbers from single input line (scanf?) how to read scanf with spaces It doesn't help me much. How can I read numbers...

Can a Windows batch file determine its own file name?

Can a Windows batch file determine its own file name? For example, if I run the batch file C:\Temp\myScript.bat, is there a command within myScript.bat that can determine the string "myScript.bat"?...

Joining two lists together

If I have two lists of type string (or any other type), what is a quick way of joining the two lists? The order should stay the same. Duplicates should be removed (though every item in both links are unique). I didn't find much on this when googling...

When running WebDriver with Chrome browser, getting message, "Only local connections are allowed" even though browser launches properly

When I run Chrome browser using WebDriver, I am getting following message on console. Please let me know how to resolve it. "Starting ChromeDriver (v2.10.267521) on port 22582 " "Only local connections are allowed." Here is my sample code: ...

How do I mock a service that returns promise in AngularJS Jasmine unit test?

I have myService that uses myOtherService, which makes a remote call, returning promise: angular.module('app.myService', ['app.myOtherService']) .factory('myService', [ myOtherService, function(myOtherService) { function makeRemoteCa...

Asp.net - Add blank item at top of dropdownlist

Why is the dropdown not showing my blank item first? Here is what I have drpList.Items.Add(New ListItem("", "")) With drpList .DataSource = myController.GetList(userid) .DataTextField = "Name" .DataValueField = "ID" .DataBind() End ...

API vs. Webservice

What is the difference between a webservice and an API? Is the difference more than the protocol used to transfer data? thanks. ...

Disable Drag and Drop on HTML elements?

I'm working on a web application for which I'm attempting to implement a full featured windowing system. Right now it's going very well, I'm only running into one minor issue. Sometimes when I go to drag a part of my application (most often the corne...

How to check if a variable is both null and /or undefined in JavaScript

Possible Duplicate: Detecting an undefined object property in JavaScript How to determine if variable is 'undefined' or 'null' Is there a standard function to check for null, undefined, or blank variables in JavaScript? I...

Android: How to get accurate altitude?

I need to get an accurate measurement of altitude using GPS only. I tried Location.getAltitude(), but that is terribly inaccurate. Any advice?...

How to get JSON response from http.Get

I'm trying read JSON data from web, but that code returns empty result. I'm not sure what I'm doing wrong here. package main import "os" import "fmt" import "net/http" import "io/ioutil" import "encoding/json" type Tracks struct { Toptracks []...

Google Spreadsheet, Count IF contains a string

I have a column like this: What devices will you be using? iPad Kindle & iPad No Tablet iPad iPad & Windows How do I count the amount of people that said iPad? This formula does work for exact matches but not if it contains an addition...

Branch from a previous commit using Git

If I have n commits, how can I branch from the n-3 commit? I can see the hash of every commit. ...

How can I open Java .class files in a human-readable way?

I'm trying to figure out what a Java applet's class file is doing under the hood. Opening it up with Notepad or Textpad just shows a bunch of gobbledy-gook. Is there any way to wrangle it back into a somewhat-readable format so I can try to figure o...

NULL vs nullptr (Why was it replaced?)

I know that in C++ 0x or NULL was replaced by nullptr in pointer-based applications. I'm just curious of the exact reason why they made this replacement? In what scenario is using nullptr over NULL beneficial when dealing with pointers?...

Unable to install boto3

I have trouble installing boto3 inside a virtual environment. I have done what the document says. First I activated virtual environment. then I did a: Sudo pip install boto3 Now I enter python >> import boto3 ImportError: No module named ...

spring PropertyPlaceholderConfigurer and context:property-placeholder

I have following bean declaration: <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>WEB-INF/classes/con...

Objective-C and Swift URL encoding

I have a NSString like this: http://www. but I want to transform it to: http%3A%2F%2Fwww. How can I do this?...

Eclipse - Installing a new JRE (Java SE 8 1.8.0)

I am trying to install Java 8. What I have done so far: installed the latest version of Eclipse downloaded and installed Java SE Runtime Environment 8 http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html tried to fo...

PHP string "contains"

What would be the most efficient way to check whether a string contains a "." or not? I know you can do this in many different ways like with regular expressions or loop through the string to see if it contains a dot (".")....

Speed tradeoff of Java's -Xms and -Xmx options

Given these two commands A: $ java -Xms10G -Xmx10G myjavacode input.txt B: $ java -Xms5G -Xmx5G myjavacode input.txt I have two questions: Since command A reserves more memory with its parameters, will A run faster than B? How do -Xmx and -...

MySql Proccesslist filled with "Sleep" Entries leading to "Too many Connections"?

I'd like to ask your help on a longstanding issue with php/mysql connections. Every time I execute a "SHOW PROCESSLIST" command it shows me about 400 idle (Status: Sleep) connections to the database Server emerging from our 5 Webservers. That never...

Rails 2.3.4 Persisting Model on Validation Failure

I have a standard html form post that is being persisted and validated with a rails model on the server side. For the sake of discussion, lets call this a "car" model. When car.save is invoked the validators fire and set a list of fields in er...

Remove multiple objects with rm()

My memory is getting clogged by a bunch of intermediate files (call them temp1, temp2, etc.). and I would like to know if it is possible to remove them from memory without doing repeated rm calls (i.e. rm(temp1), rm(temp2))? I tried rm(list(temp1, te...

Converting milliseconds to minutes and seconds with Javascript

Soundcloud's API gives the duration of it's tracks as milliseconds. JSON looks like this: "duration": 298999 I've tried many functions I found on here to no avail. I'm just looking for something to convert that number to something like looks like ...

Object variable or With block variable not set (Error 91)

I have the following code: Sub AddSources() Dim pubPage As Page Dim pubShape As Shape Dim hprlink As Hyperlink Dim origAddress() As String Dim exportFileName As String exportFileName = "TestResume" Dim linkSource As Strin...

How to manually deploy artifacts in Nexus Repository Manager OSS 3

After installing Nexus Repository Manager OSS 3 I do not see option Artifact Upload to upload artifacts through web page. In Nexus Repository Manager OSS 2.13 there is option to do that operation. Anyone can show me the way how to upload artifacts ...

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

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

Java - sending HTTP parameters via POST method easily

I am successfully using this code to send HTTP requests with some parameters via GET method void sendRequest(String request) { // i.e.: request = "http://example.com/index.php?param1=a&param2=b&param3=c"; URL url = new URL(request);...

How to get the process ID to kill a nohup process?

I'm running a nohup process on the server. When I try to kill it my putty console closes instead. this is how I try to find the process ID: ps -ef |grep nohup this is the command to kill kill -9 1787 787 ...

Remove or adapt border of frame of legend using matplotlib

When plotting a plot using matplotlib: How to remove the box of the legend? How to change the color of the border of the legend box? How to remove only the border of the box of the legend? ...

NOT IN vs NOT EXISTS

Which of these queries is the faster? NOT EXISTS: SELECT ProductID, ProductName FROM Northwind..Products p WHERE NOT EXISTS ( SELECT 1 FROM Northwind..[Order Details] od WHERE p.ProductId = od.ProductId) Or NOT IN: SELECT ProductI...

Best way to update an element in a generic List

Suppose we have a class called Dog with two strings "Name" and "Id". Now suppose we have a list with 4 dogs in it. If you wanted to change the name of the Dog with the "Id" of "2" what would be the best way to do it? Dog d1 = new Dog("Fluffy", "1");...

How do I fix the indentation of selected lines in Visual Studio

In vim I can use = to reindent badly indented lines so foo; bar; baz; becomes foo; bar; baz; Is there an equivalent keyboard-shortcut for visual studio? Where can I find a list of such shortcuts for future reference? Edit: Is there a way ...

How to add 30 minutes to a JavaScript Date object?

I'd like to get a Date object which is 30 minutes later than another Date object. How do I do it with JavaScript?...

Change package name for Android in React Native

I used react-native init MyApp to initialise a new React Native app. This created among others an Android project with the package com.myapp. What's the best way to change this package name, for example to: com.mycompany.myapp? I tried changing it ...

How to return JSON with ASP.NET & jQuery

I cannot get how I can return JSON data with my code. JS $(function () { $.ajax({ type: "POST", url: "Default.aspx/GetProducts", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", ...

Getting a better understanding of callback functions in JavaScript

I understand passing in a function to another function as a callback and having it execute, but I'm not understanding the best implementation to do that. I'm looking for a very basic example, like this: var myCallBackExample = { myFirstFunction ...

How to combine two byte arrays

I have two byte arrays and I am wondering how I would go about adding one to the other or combining them to form a new byte array. ...

PHP/MySQL: How to create a comment section in your website

Instead of asking 'how to use PHP/MySQL to let users affect webpages' I'll ask this, because I learn better from projects and examples. So how would I incorporate a VERY basic comment feature using PHP and MySQL? ...

Update React component every second

I have been playing around with React and have the following time component that just renders Date.now() to the screen: import React, { Component } from 'react'; class TimeComponent extends Component { constructor(props){ super(props); th...

How to clear the entire array?

I have an array like this: Dim aFirstArray() As Variant How do I clear the entire array? What about a collection?...

Prepare for Segue in Swift

I'm facing the error message: "UIStoryboardSegue does not have a member named 'identifier'" Here's the code causing the error if (segue.identifier == "Load View") { // pass data to next view } On Obj-C it's fine using like this: if ([segue...

PLS-00201 - identifier must be declared

I executed a PL/SQL script that created the following table TABLE_NAME VARCHAR2(30) := 'B2BOWNER.SSC_Page_Map'; I made an insert function for this table using arguments CREATE OR REPLACE FUNCTION F_SSC_Page_Map_Insert( p_page_id IN B2...

$on and $broadcast in angular

I have a footerController and codeScannerController with different views. angular.module('myApp').controller('footerController', ["$scope", function($scope) {}]); angular.module('myApp').controller('codeScannerController', ["$scope", function($scop...

PHP: Show yes/no confirmation dialog

My PHP page has a link to delete one MySQL table datum. I want it to be in such a way that when I click the 'delete' link a confirmation box should appear and it should ask "are you sure, you want to delete?", with two buttons: 'yes' and 'no'. When ...

How to force Laravel Project to use HTTPS for all routes?

I am working on a project that requires a secure connection. I can set the route, uri, asset to use 'https' via: Route::get('order/details/{id}', ['uses' => 'OrderController@details', 'as' => 'order.details', 'https']); url($language.'/index...

pinpointing "conditional jump or move depends on uninitialized value(s)" valgrind message

So I've been getting some mysterious uninitialized values message from valgrind and it's been quite the mystery as of where the bad value originated from. Seems that valgrind shows the place where the unitialised value ends up being used, but not th...

How to add line breaks to an HTML textarea?

I’m editing a <textarea> with JavaScript. The problem is that when I make line breaks in it, they won’t display. How can I do this? I’m getting the value to write a function, but it won’t give line breaks....

Getting the "real" Facebook profile picture URL from graph API

Facebook graph API tells me I can get a profile picture of a user using http://graph.facebook.com/517267866/picture?type=large which works fine. However, when you type above URL into a browser, the actual address of the image is http://profile.ak....

How can I delete a file from a Git repository?

I have added a file named "file1.txt" to a Git repository. After that, I committed it, added a couple of directories called dir1 and dir2, and committed them to the Git repository. Now the current repository has "file1.txt", dir1, and dir2. How can ...

Find everything between two XML tags with RegEx

In RegEx, I want to find the tag and everything between two XML tags, like the following: <primaryAddress> <addressLine>280 Flinders Mall</addressLine> <geoCodeGranularity>PROPERTY</geoCodeGranularity> <l...

Can't open and lock privilege tables: Table 'mysql.user' doesn't exist

I installed MySQL community server 5.7.10 using binary zip. I extracted the zip in c:\mysql and created the data folder in c:\mysql\data. I created the config file as my.ini and placed it in c:\mysql (root folder of extracted zip). Below is the conte...

Git Cherry-pick vs Merge Workflow

Assuming I am the maintainer of a repo, and I want to pull in changes from a contributor, there are a few possible workflows: I cherry-pick each commit from the remote (in order). In this case git records the commit as unrelated to the remote branc...

Can't install any packages in Node.js using "npm install"

I'm new to Node.js, and I'm going through a few tutorials. For some reason, I can't install any new node modules. I am using: Mac OSX 10.7.4, Node v. 0.8.6, NPM v. 1.1.48. I run npm install X and I always get a npm ERR! fetch failed https://regist...

How to delete a workspace in Perforce (using p4v)?

I'm new to Perforce and have created a few workspaces as exercises for getting familiar with it. Now I would like to delete some of the workspaces. I just want to get rid of the workspaces so that they do not appear on the drop-down in the workspaces...

How can I control the width of a label tag?

The label tag doesn't have the property 'width', so how should I control the width of a label tag?...

Renaming a directory in C#

I couldn't find a DirectoryInfo.Rename(To) or FileInfo.Rename(To) method anywhere. So, I wrote my own and I'm posting it here for anybody to use if they need it, because let's face it : the MoveTo methods are overkill and will always require extra l...

What's the best visual merge tool for Git?

What's the best tool for viewing and editing a merge in Git? I'd like to get a 3-way merge view, with "mine", "theirs" and "ancestor" in separate panels, and a fourth "output" panel. Also, instructions for invoking said tool would be great. (I still...

How to loop through all but the last item of a list?

I would like to loop through a list checking each item against the one following it. Is there a way I can loop through all but the last item using for x in y? I would prefer to do it without using indexes if I can. Note freespace answered my actua...

java.util.Date and getYear()

I am having the following problem in Java (I see some people are having a similar problem in JavaScript but I'm using Java) System.out.println(new Date().getYear()); System.out.println(new GregorianCalendar().getTime().getYear()); System.out.println...

Convert timestamp to date in Oracle SQL

How can we convert timestamp to date? The table has a field, start_ts which is of the timestamp format: '05/13/2016 4:58:11.123456 PM' I need to query the table and find the maximum and min timestamp in the table but I'm not able to. Select max(...

@Value annotation type casting to Integer from String

I'm trying to cast the output of a value to an integer: @Value("${api.orders.pingFrequency}") private Integer pingFrequency; The above throws the error org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.l...

Username and password in command for git push

It's possible to clone down a git repository, specifying username and password in the command. Example: git clone https://username:[email protected]/file.git Is it is possible to also specify the username and password when pushing? So that,...

Java for loop multiple variables

I'm not sure why my Java code wont compile, any suggestions would be appreciated. String rank = card.substring(0,1); String suit = card.substring(1); String cards = "A23456789TJQKDHSCl"; String[] name = {"Ace","Two","Three","Four","Fi...

Jquery Smooth Scroll To DIV - Using ID value from Link

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

System.Timers.Timer vs System.Threading.Timer

I have been checking out some of the possible timers lately, and System.Threading.Timer and System.Timers.Timer are the ones that look needful to me (since they support thread pooling). I am making a game, and I plan on using all types of events, w...

Why is there no SortedList in Java?

In Java there are the SortedSet and SortedMap interfaces. Both belong to the Java Collections framework and provide a sorted way to access the elements. However, in my understanding there is no SortedList in Java. You can use java.util.Collections....

How to remove empty cells in UITableView?

i am trying to display a simple UITableView with some data. I wish to set the static height of the UITableView so that it doesn't displays empty cells at the end of the table. how do I do that? code: - (NSInteger)tableView:(UITableView *)tableView ...

How to concatenate strings of a string field in a PostgreSQL 'group by' query?

I am looking for a way to concatenate the strings of a field within a group by query. So for example, I have a table: ID COMPANY_ID EMPLOYEE 1 1 Anna 2 1 Bill 3 2 Carol 4 2 Dave and I wan...

jQuery '.each' and attaching '.click' event

I am not a programer but I enjoy building prototypes. All of my experience comes from actionScript2. Here is my question. To simplify my code I would like to figure out how to attach '.click' events to div's that are already existing in the HTML bod...

What is the difference between new/delete and malloc/free?

What is the difference between new/delete and malloc/free? Related (duplicate?): In what cases do I use malloc vs new?...

How to hash some string with sha256 in Java?

How can I hash some string with sha256 in Java? Does anybody know of any free library for this?...

Detect if an input has text in it using CSS -- on a page I am visiting and do not control?

Is there a way to detect whether or not an input has text in it via CSS? I've tried using the :empty pseudo-class, and I've tried using [value=""], neither of which worked. I can't seem to find a single solution to this. I imagine this must be possi...

jQuery Validate - Enable validation for hidden fields

In the new version of jQuery validation plugin 1.9 by default validation of hidden fields ignored. I'm using CKEditor for textarea input field and it hides the field and replace it with iframe. The field is there, but validation disabled for hidden f...

Groovy / grails how to determine a data type?

What is the best way to determine the data type in groovy? I'd like to format the output differently if it's a date, etc. ...

Android Studio-No Module

I am new to Android Studio.This is my project screenshot.My project builds successfully but when i run it only Build Successful is shown. By what I understand I think where build is written in the toolbar there should be my project name.When I go to ...

How to make the background DIV only transparent using CSS

I am using CSS attrubutes : filter: alpha(opacity=90); opacity: .9; to make the DIV transparent, but when I add another DIV inside this DIV it makes it transparent also. I want to make the outer(background) DIV only transparent. How ?...

Can I write a CSS selector selecting elements NOT having a certain class or attribute?

I would like to write a CSS selector rule that selects all elements that don't have a certain class. For example, given the following HTML: <html class="printable"> <body class="printable"> <h1 class="printable">Example...

Stop floating divs from wrapping

I want to have a row of divs (cells) that don't wrap if the browser is too narrow to fit them. I've searched Stack, and couldn't find a working answer to what I think should be a simple css question. The cells have specified width. However I don't ...

Which is the best Linux C/C++ debugger (or front-end to gdb) to help teaching programming?

I teach a sort of "lite" C++ programming course to novices ("lite" meaning no pointers, no classes, just plain old C, plus references and STL string and vectors). Students have no previous experience in programming, so I believe that using an interac...

Synchronously waiting for an async operation, and why does Wait() freeze the program here

Preface: I'm looking for an explanation, not just a solution. I already know the solution. Despite having spent several days studying MSDN articles about the Task-based Asynchronous Pattern (TAP), async and await, I'm still a bit confused about some...

Adding options to a <select> using jQuery?

What's the easiest way to add an option to a dropdown using jQuery? Will this work? $("#mySelect").append('<option value=1>My option</option>'); ...

How to make a gui in python

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

Aligning label and textbox on same line (left and right)

I have an ASP.NET control. I want to align the textbox to the right and the label to the left. I have this code so far: <td colspan="2"> <asp:Label ID="Label6" runat="server" Text="Label"></asp:Label> ...

How do I set up HttpContent for my HttpClient PostAsync second parameter?

public static async Task<string> GetData(string url, string data) { UriBuilder fullUri = new UriBuilder(url); if (!string.IsNullOrEmpty(data)) fullUri.Query = data; HttpClient client = new HttpClient(); HttpResponseMe...

Apply style ONLY on IE

Here is my block of CSS: .actual-form table { padding: 5px 0 15px 15px; margin: 0 0 30px 0; display: block; width: 100%; background: #f9f9f9; border-top: 1px solid #d0d0d0; border-bottom: 1px solid #d0d0d0; } I only want IE 7, 8, and...

Can you call ko.applyBindings to bind a partial view?

I'm using KnockoutJS and have a main view and view model. I want a dialog (the jQuery UI one) to popup with another view which a separate child view model to be bound to. The HTML for the dialog content is retrieved using AJAX so I want to be able t...

How to wait in bash for several subprocesses to finish and return exit code !=0 when any subprocess ends with code !=0?

How to wait in a bash script for several subprocesses spawned from that script to finish and return exit code !=0 when any of the subprocesses ends with code !=0 ? Simple script: #!/bin/bash for i in `seq 0 9`; do doCalculations $i & done wai...

JPA Criteria API - How to add JOIN clause (as general sentence as possible)

I am trying to construct queries dynamically, and my next target is add JOIN clauses (I don't know how can I use the API). By now, for example, this code work for me : ... Class baseClass; ... CriteriaBuilder cb = JpaHandle.get().getCriteriaBuil...

How to get the type of a variable in MATLAB?

Does MATLAB have a function/operator that indicates the type of a variable (similar to the typeof operator in JavaScript)?...

How to create correct JSONArray in Java using JSONObject

how can I create a JSON Object like the following, in Java using JSONObject ? { "employees": [ {"firstName": "John", "lastName": "Doe"}, {"firstName": "Anna", "lastName": "Smith"}, {"firstName": "Peter", "lastName": "Jo...

PATH issue with pytest 'ImportError: No module named YadaYadaYada'

I used easy_install to install pytest on a mac and started writing tests for a project with a file structure likes so: repo/ repo/app.py repo/settings.py repo/models.py repo/tests/ repo/tests/test_app.py run py.test while in the repo directory, ev...

Root element is missing

I am reading xml from xxx URl but i am getting error as Root element is missing. My code to read xml response is as follows: XmlDocument doc = new XmlDocument(); doc.Load("URL from which i am reading xml"); XmlNodeList nodes = doc.GetElements...

How to get json key and value in javascript?

I am returning a json as shown below {"name": "", "skills": "", "jobtitel": "Entwickler", "res_linkedin": "GwebSearch"} I am trying to get each element key and value: .. }).done(function(data){ alert(data['jobtitel']); }); I am getting und...

find without recursion

Is it possible to use the find command in some way that it will not recurse into the sub-directories? For example, DirsRoot |-->SubDir1 | |-OtherFile1 |-->SubDir2 | |-OtherFile2 |-File1 |-File2 And the result of something lik...

What's the difference between emulation and simulation?

Possible Duplicate: Simulator or Emulator? What is the difference? In simple understandable terms, what is the difference between the two terms? [I have already looked at this, this and this]...

Setting user agent of a java URLConnection

I'm trying to parse a webpage using Java with URLConnection. I try to set up the user-agent like this: java.net.URLConnection c = url.openConnection(); c.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9...

What processes are using which ports on unix?

I need to find out what ports are attached to which processes on a Unix machine (HP Itanium). Unfortunately, lsof is not installed and I have no way of installing it. Does anyone know an alternative method? A fairly lengthy Googling session hasn't ...

What is difference between functional and imperative programming languages?

Most of the mainstream languages, including object-oriented programming (OOP) languages such as C#, Visual Basic, C++, and Java were designed to primarily support imperative (procedural) programming, whereas Haskell/gofer like languages are purely fu...

Not Able To Debug App In Android Studio

I am making an app in Android Studio, now trying to debug it through adb. When I click on the word Android and the logo on the bottom bar, logcat comes up and recognizes my device. Then I see this: What do I need to do to my app to make it "debug...

Terminal Commands: For loop with echo

I've never used commands in terminal like this before but I know its possible. How would I for instance write: for (int i = 0; i <=1000; i++) { echo "http://example.com/%i.jpg",i } ...

How to find when a web page was last updated

Is there a way to find out how much time has passed since a web page was changed? For example, I have a page hosted at: www.mywebsitenotupdated.com Is there a way to find out when this HTML page was uploaded to the server? I have no access to se...

PHP XML Extension: Not installed

So i'm currently installing mybb and went through a very long tutorial on how to do it. The problem is when I get to the requirements check this shows up How does one go about fixing this? I read that I may need to do sudo apt-get install php-xm...

StringUtils.isBlank() vs String.isEmpty()

I ran into some code that has the following: String foo = getvalue("foo"); if (StringUtils.isBlank(foo)) doStuff(); else doOtherStuff(); This appears to be functionally equivalent to the following: String foo = getvalue("foo"); if (foo.i...

Angular 5 Scroll to top on every Route click

I am using angular 5. I have a dashboard where I have few sections with small content and few sections with so large content that I am facing a problem when changing router while going to top. Every time I need to scroll to go to top. Can anyone help...

How to pause in C?

I am a beginner of C. I run the C program, but the window closes too fast before I can see anything. How can I pause the window?...

Select multiple elements from a list

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

Change Color of Fonts in DIV (CSS)

I am trying to change the color and size of H2 font and H2 link fonts based on the div they are in but have not been successful. What am I doing wrong? <style> h2 { color:fff; font-size: 20px; } social.h2 { color:pink; font-size: 14px; } soc...

Count all occurrences of a string in lots of files with grep

I have a bunch of log files. I need to find out how many times a string occurs in all files. grep -c string * returns ... file1:1 file2:0 file3:0 ... Using a pipe I was able to get only files that have one or more occurrences: grep -c string *...

Override back button to act like home button

On pressing the back button, I'd like my application to go into the stopped state, rather than the destroyed state. In the Android docs it states: ...not all activities have the behavior that they are destroyed when BACK is pressed. When the use...

Show git diff on file in staging area

Is there a way I can see the changes that were made to a file after I have done git add file? That is, when I do: git add file git diff file no diff is shown. I guess there's a way to see the differences since the last commit but I don't know wh...

How to apply a function to two columns of Pandas dataframe

Suppose I have a df which has columns of 'ID', 'col_1', 'col_2'. And I define a function : f = lambda x, y : my_function_expression. Now I want to apply the f to df's two columns 'col_1', 'col_2' to element-wise calculate a new column 'col_3' , som...

Why does Git tell me "No such remote 'origin'" when I try to push to origin?

I am very new to Git; I only recently created a GitHub account. I've just tried to push my very first repository (a sample project), but I'm getting the following error: No such remote 'origin' I ran the following commands: git init git commit -...

Shell Script Syntax Error: Unexpected End of File

In the following script I get an error: syntax error: unexpected end of file What is this error how can I resove it? It is pointing at the line whee the function is called. #!/bin/sh expected_diskusage="264" expected_dbconn="25" expected_htt...

How can I provide multiple conditions for data trigger in WPF?

How can I provide multiple conditions for data trigger in WPF?...

Connection refused to MongoDB errno 111

I have a Linode server running Ubuntu 12.04 LTS and MongoDB instance (service is running and CAN connect locally) that I can't connect to from an outside source. I have added these two rules to my IP tables, where < ip address > is the server I w...

Where is a log file with logs from a container?

I am running several containers using docker-compose. I can see application logs with command docker-compose logs. However I would like to access raw log file to send it somewhere for example? Where is it located? I guess it's separate log per each c...

Bulk Insertion in Laravel using eloquent ORM

How can we perform bulk database insertions in Laravel using Eloquent ORM? I want to accomplish this in Laravel: https://stackoverflow.com/a/10615821/600516 but I am getting the following error. SQLSTATE[HY093]: Invalid parameter number: mixed n...

Collectors.toMap() keyMapper -- more succinct expression?

I'm trying to come up with a more succinct expression for the "keyMapper" function parameter in the following Collectors.toMap() call: List<Person> roster = ...; Map<String, Person> map = roster .stream() .collect(...

Extract digits from a string in Java

I have a Java String object. I need to extract only digits from it. I'll give an example: "123-456-789" I want "123456789" Is there a library function that extracts only digits? Thanks for the answers. Before I try these I need to know if I have t...

How can I declare and define multiple variables in one line using C++?

I always though that if I declare these three variables that they will all have the value 0 int column, row, index = 0; But I find that only index equals zero & the others are junk like 844553 & 2423445. How can I initialise all these var...

Javascript use variable as object name

I want to use the value of a variable to access an object. Let's say I have an object named myobject. I want to fill a variable with this name and use the variable to access the object. Example: var objname = 'myobject'; {objname}.value = 'value'...

Free Online Team Foundation Server

Can anybody recommend a good free online Team Foundation Server repository? I found CodePlex but it's only for open source projects....

jQuery UI autocomplete with item and id

I have the following script which works with a 1 dimensional array. Is it possible to get this to work with a 2 dimensional array? Then whichever item is selected, by clicking on a second button on the page, should display the id of whichever item ...

What causes the error "_pickle.UnpicklingError: invalid load key, ' '."?

I'm trying to storage 5000 data elements on an array. This 5000 elements are storage on an existent file (therefore it's not empty). But I'm getting an error and I don't know what is causing it. IN: def array(): name = 'puntos.df4' m =...

java.io.FileNotFoundException: (Access is denied)

I am trying to read the files inside a folder, but when I run the program it throws this exception. I tried with some other folders also. It throws the same exception. Exception in thread "main" java.io.FileNotFoundException: C:\backup (Access is de...

WARNING: Can't verify CSRF token authenticity rails

I am sending data from view to controller with AJAXand I got this error: WARNING: Can't verify CSRF token authenticity I think I have to send this token with data. Does anyone know how can I do this ? Edit: My solution I did this by putting ...

Easiest way to convert int to string in C++

What is the easiest way to convert from int to equivalent string in C++. I am aware of two methods. Is there any easier way? (1) int a = 10; char *intStr = itoa(a); string str = string(intStr); (2) int a = 10; stringstream ss; ss << a; st...

Prevent content from expanding grid items

TL;DR: Is there anything like table-layout: fixed for CSS grids? I tried to create a year-view calendar with a big 4x3 grid for the months and therein nested 7x6 grids for the days. The calendar should fill the page, so the year grid container ge...

Javascript search inside a JSON object

I had a JSON string / object in my application. {"list": [ {"name":"my Name","id":12,"type":"car owner"}, {"name":"my Name2","id":13,"type":"car owner2"}, {"name":"my Name4","id":14,"type":"car owner3"}, {"name":"my Name4","id":15,"...

'App not Installed' Error on Android

I have a program working in the Android Emulator. Every now and again I have been creating a signed .apk and exporting it to my HTC Desire to test. It has all been fine. On my latest exported .apk I get the error message 'App not installed' when I t...

How can I resize an image dynamically with CSS as the browser width/height changes?

I wonder how I could make an image resize along with the browser window, here is what I have done so far (or download the whole site in a ZIP). This works okay in Firefox, but it has problems in Chrome: the image does not always resize, it somehow d...

How to set up Automapper in ASP.NET Core

I'm relatively new at .NET, and I decided to tackle .NET Core instead of learning the "old ways". I found a detailed article about setting up AutoMapper for .NET Core here, but is there a more simple walkthrough for a newbie?...

remote rejected master -> master (pre-receive hook declined)

I'm working in rails 3.2 and I receive an error when I try to push to heroku: git push heroku master Counting objects: 496, done. Delta compression using up to 8 threads. Compressing objects: 100% (435/435), done. Writing objects: 100% (496/496), 5...

How to convert List<string> to List<int>?

My question is part of this problem: I recieve a collection of id's from a form. I need to get the keys, convert them to integers and select the matching records from the DB. [HttpPost] public ActionResult Report(FormCollection collection) { ...

Is there a way to change the spacing between legend items in ggplot2?

Is there a way to change the spacing between legend items in ggplot2? I currently have legend.position ="top" which automatically produces a horizontal legend. However, the spacing of the items is very close together and I am wondering how to spa...

Streaming video from Android camera to server

I've seen plenty of info about how to stream video from the server to an android device, but not much about the other way, ala Qik. Could someone point me in the right direction here, or give me some advice on how to approach this?...

Java Minimum and Maximum values in Array

My code does not give errors, however it is not displaying the minimum and maximum values. The code is: Scanner input = new Scanner(System.in); int array[] = new int[10]; System.out.println("Enter the numbers now."); for (int i = 0; i < array....

Cannot import XSSF in Apache POI

I am referencing the version 3.7 of the Apache POI and I am getting a "cannot be resolved" error when I do: import org.apache.poi.xssf.usermodel.XSSFWorkbook; Other import statements that reference POI DO NOT give me errors, such as: import org.a...

Using Java 8's Optional with Stream::flatMap

The new Java 8 stream framework and friends make for some very concise java code, but I have come across a seemingly-simple situation that is tricky to do concisely. Consider a List<Thing> things and method Optional<Other> resolve(Thing ...

.NET NewtonSoft JSON deserialize map to a different property name

I have following JSON string which is received from an external party. { "team":[ { "v1":"", "attributes":{ "eighty_min_score":"", "home_or_away":"home", "score":"22", "team_...

Why does 'git commit' not save my changes?

I did a git commit -m "message" like this: > git commit -m "save arezzo files" # On branch master # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to ...

Update Item to Revision vs Revert to Revision

I've started to use Subversion with TortoiseSVN. If I open up the log and right click on an old revision I see two options that sound like they roll back to an older version: "Update item to revision" and "Revert to this revision". I understand that...

How can I measure the similarity between two images?

I would like to compare a screenshot of one application (could be a Web page) with a previously taken screenshot to determine whether the application is displaying itself correctly. I don't want an exact match comparison, because the aspect could be ...

LinkButton Send Value to Code Behind OnClick

I have a ASP LinkButton Control and I was wondering how to send a value to the code behind when it is clicked? Is that possible with this event? <asp:LinkButton ID="ENameLinkBtn" runat="server" style="font-weight: 700; font-size: 8pt;" o...

Error sending json in POST to web API service

I'm creating a web service using Web API. I implemented a simple class public class ActivityResult { public String code; public int indexValue; public int primaryCodeReference; } And then I have implemented inside my controller [HttpP...

Is there a template engine for Node.js?

I'm experimenting with building an entire web application using Node.js. Is there a template engine similar to (for example) the Django template engine or the like that at least allows you to extend base templates?...

How to make a <div> or <a href="#"> to align center

I'm using the following code in body section. <center><a href="contact.html" class="button large hpbottom">Get Started</a></center> Is there any alternative for <center> tag? How can I make it center without using <...

How do I get the APK of an installed app without root access?

I'm trying to extract the APK file of an installed Android app WITHOUT root permissions. I thought that this was impossible, because all APK files for non-system-apps are located in /data/app, and accessing this folder requires root permission. Then...

Understanding Chrome network log "Stalled" state

I've a following network log in chrome: I don't understand one thing in it: what's the difference between filled gray bars and transparent gray bars....

How to use bitmask?

How do i use it in C++ ? when is it useful to use ? Please give me an example of a problem where bitmask is used , how it actually works . Thanks!...

Apache: Restrict access to specific source IP inside virtual host

I have several named virtual hosts on the same apache server, for one of the virtual host I need to ensure only a specific set of IP addresses are allowed to access. Please suggest the best way to do this. I have looked at mod_authz_hosts module bu...

Side-by-side list items as icons within a div (css)

I am looking for a way to create a <ul> of items that I can put within a <div> and have them show up side-by-side and wrap to the next line as the browser window is resized. For example, if we have 10 items in the list that currently s...

what exactly is device pixel ratio?

this is mentioned every article about mobile web, but nowhere I can found an explanation of what exactly does this attribute measure. Can anyone please elaborate what does queries like this check? @media only screen and (-webkit-min-device-pixel-rat...

Run exe file with parameters in a batch file

Please have a look at my batch file. echo off start "c:\program files\php\php.exe D:\mydocs\mp\index.php param1 param2" but it isn't working. Any ideas how do I get it working?...

Google maps responsive resize

I'm trying to get google maps responsive and resize while keeping its center when windows resizes. I read other stack questions in regards such as: Responsive Google Map? and Center Google Maps (V3) on browser resize (responsive) from the second st...

Comparing double values in C#

I've a double variable called x. In the code, x gets assigned a value of 0.1 and I check it in an 'if' statement comparing x and 0.1 if (x==0.1) { ---- } Unfortunately it does not enter the if statement Should I use Double or double? What's the ...

How to check if a service is running on Android?

How do I check if a background service is running? I want an Android activity that toggles the state of the service -- it lets me turn it on if it is off and off if it is on....

Java converting Image to BufferedImage

There is already question like this link on StackOverflow and the accepted answer is "casting": Image image = ImageIO.read(new File(file)); BufferedImage buffered = (BufferedImage) image; In my program I try: final float FACTOR = 4f; BufferedIma...

$watch'ing for data changes in an Angular directive

How can I trigger a $watch variable in an Angular directive when manipulating the data inside (e.g., inserting or removing data), but not assign a new object to that variable? I have a simple dataset currently being loaded from a JSON file. My Angu...

How to get dictionary values as a generic list

I just want get a list from Dictionary values but it's not so simple as it appears ! here the code : Dictionary<string, List<MyType>> myDico = GetDictionary(); List<MyType> items = ??? I try : List<MyType> items = new Lis...

How do I retrieve the number of columns in a Pandas data frame?

How do you programmatically retrieve the number of columns in a pandas dataframe? I was hoping for something like: df.num_columns ...

console.log showing contents of array object

I have tried using console.log so I can see the content of my array that contains multiple objects. However I get an error saying console.log is not an object etc. I'm using jquery 1.6.2 and my array is like this: filters = {dvals:[{'brand':'1', 'co...

Linq to Sql: Multiple left outer joins

I'm having some trouble figuring out how to use more than one left outer join using LINQ to SQL. I understand how to use one left outer join. I'm using VB.NET. Below is my SQL syntax. T-SQL SELECT o.OrderNumber, v.VendorName, s.Statu...

How to use code to open a modal in Angular 2?

Usually we use data-target="#myModal" in the <button> to open a modal. Right now I need use codes to control when to open the modal. If I use [hidden] or *ngIf to show it, I need remove class="modal fade", otherwise, the modal will never show....

Angular2: custom pipe could not be found

The built-in pipe is work,but all custom pipes that i wanna use are the same error: the pipe 'actStatusPipe' could not be found [ERROR ->]{{data.actStatus | actStatusPipe}} I have tried two ways,declare it in app.module's declarations: app.modul...

Using Linq to get the last N elements of a collection?

Given a collection, is there a way to get the last N elements of that collection? If there isn't a method in the framework, what would be the best way to write an extension method to do this?...

What are enums and why are they useful?

Today I was browsing through some questions on this site and I found a mention of an enum being used in singleton pattern about purported thread safety benefits to such solution. I have never used enums and I have been programing in Java for more tha...

How to unescape a Java string literal in Java?

I'm processing some Java source code using Java. I'm extracting the string literals and feeding them to a function taking a String. The problem is that I need to pass the unescaped version of the String to the function (i.e. this means converting \n ...

Unresolved reference issue in PyCharm

I have a directory structure +-- simulate.py +-- src ¦   +-- networkAlgorithm.py ¦   +-- ... And I can access the network module with sys.path.insert(). import sys import os.path sys.path.insert(0, "./src") from networkAlgorithm import ...

HTML5 Video Autoplay not working correctly

Im using this code: <video width="440px" loop="true" autoplay="true" controls> <source src="http://www.example.com/CorporateVideo.mp4" type="video/mp4" /> <source src="http://www.example.com/CorporateVideo.ogv" type="video/ogv" /> ...