Examples On Programing Languages

Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1

using System; using System.Collections.Generic; using System.Linq; using System.Text; using Facebook; using Newtonsoft.Json; namespace facebook { class Program { static void Main(string[] args) { var client = new ...

How to convert enum value to int?

I have a function which return a type int. However, I only have a value of the TAX enumeration. How can I cast the TAX enumeration value to an int? public enum TAX { NOTAX(0),SALESTAX(10),IMPORTEDTAX(5); private int value; private TAX(...

How to parse XML and count instances of a particular node attribute?

I have many rows in a database that contains XML and I'm trying to write a Python script to count instances of a particular node attribute. My tree looks like: <foo> <bar> <type foobar="1"/> <type foobar=...

How to return XML in ASP.NET?

I have encountered many half-solutions to the task of returning XML in ASP.NET. I don't want to blindly copy & paste some code that happens to work most of the time, though; I want the right code, and I want to know why it's right. I want critici...

Using jQuery to compare two arrays of Javascript objects

I have two arrays of JavaScript Objects that I'd like to compare to see if they are the same. The objects may not (and most likely will not) be in the same order in each array. Each array shouldn't have any more than 10 objects. I thought jQuery migh...

How to write a Python module/package?

I've been making Python scripts for simple tasks at work and never really bothered packaging them for others to use. Now I have been assigned to make a Python wrapper for a REST API. I have absolutely no idea on how to start and I need help. What I ...

Printing newlines with print() in R

I am trying to print a multiline message in R. For example, print("File not supplied.\nUsage: ./program F=filename",quote=0) I get the output File not supplied.\nUsage: ./program F=filename instead of the desired File not supplied. Usage: ./pr...

Fragments within Fragments

I'm wondering if this is actually a bug in the Android API: I have a setup like so: +--------------+ | | | | 1 | 2 | | |+-------+| | || || | || 3 || +--------------+ Is a menu which loads fragment #2 (A searc...

UPDATE with CASE and IN - Oracle

I wrote a query that works like a charm in SQL Server. Unfortunately it needs to be run on an Oracle db. I have been searching the web inside out for a solution on how to convert it, without any success :/ The query looks like this i SQL: UPDATE ta...

How to capitalize the first letter of word in a string using Java?

Example strings one thousand only two hundred twenty seven How do I change the first character of a string in capital letter and not change the case of any of the other letters? After the change it should be: One thousand only Two hundred Twenty...

Convert a space delimited string to list

i have a string like this : states = "Alaska Alabama Arkansas American Samoa Arizona California Colorado" and I want to split it into a list like this states = {Alaska, Alabama, Arkansas, American, Samoa, ....} I am new in python. Help me, ple...

The view didn't return an HttpResponse object. It returned None instead

I have the following simple view. Why is it resulting in this error? The view auth_lifecycle.views.user_profile didn't return an HttpResponse object. It returned None instead. """Renders web pages for the user-authentication-lifecycle project.""" f...

javac: file not found: first.java Usage: javac <options> <source files>

I have a filename named "first.java" saved on my desktop in notepad++. When I run the cmd command "javac first.java" it gives me this error. javac: file not found: first.java Usage: javac <options> <source files> I know you are requir...

Class is inaccessible due to its protection level

I have three classes. all are part of the same namespace. here are the basics of the three classes. //FBlock.cs namespace StubGenerator.PropGenerator { class FBlock : IDesignRegionInserts, IFormRegionInserts, IAPIRegionInserts, IConfigurationIn...

Request string without GET arguments

Is there a simple way to get the requested file or directory without the GET arguments? For example, if the URL is http://example.com/directory/file.php?paramater=value I would like to return just http://example.com/directory/file.php. I was surprise...

Removing an item from a select box

How do I remove items from, or add items to, a select box? I'm running jQuery, should that make the task easier. Below is an example select box. <select name="selectBox" id="selectBox"> <option value="option1">option1</option> ...

Get length of array?

I'm trying to get the length of an array, yet I keep getting this error: Object required Am I doing something wrong? Dim columns As Variant columns = Array( _ "A", "ID", _ "D", "Name") Debug.Print columns.Length ' Error: Object required ...

span with onclick event inside a tag

Sample code <a href="page" style="text-decoration:none;display:block;"> <span onclick="hide()">Hide me</span> </a> Since the a tag is over the span is not possible to click it. I try z-index but that didnt work...

How to set time zone of a java.util.Date?

I have parsed a java.util.Date from a String but it is setting the local time zone as the time zone of the date object. The time zone is not specified in the String from which Date is parsed. I want to set a specific time zone of the date object. H...

.Net: How do I find the .NET version?

How do I find out which version of .NET is installed? I'm looking for something as simple as "java -version" that I can type at the command prompt and that tells me the current version(s) installed. I better add that Visual Studio may not be instal...

What is 0x10 in decimal?

I have the following code: SN.get_Chars(5) SN is a string so this should give the 5th Char. Ok! Now I have another code but: SN.get_Chars(0x10) I wonder what 0x10 is? Is it a number? If it's so, then what is it in decimal notation?...

Ajax Upload image

Q.1 I would like to convert this form to ajax but it seems like my ajax code lacks something. On submit doesn't do anything at all. Q2. I also want the function to fire on change when the file has been selected not to wait for a submit. Here is JS...

Convert string to Python class object?

Given a string as user input to a Python function, I'd like to get a class object out of it if there's a class with that name in the currently defined namespace. Essentially, I want the implementation for a function which will produce this kind of re...

Setting the correct encoding when piping stdout in Python

When piping the output of a Python program, the Python interpreter gets confused about encoding and sets it to None. This means a program like this: # -*- coding: utf-8 -*- print u"åäö" will work fine when run normally, but fail with: Unico...

How to get file creation & modification date/times in Python?

I have a script that needs to do some stuff based on file creation & modification dates but has to run on Linux & Windows. What's the best cross-platform way to get file creation & modification date/times in Python?...

Extracting text OpenCV

I am trying to find the bounding boxes of text in an image and am currently using this approach: // calculate the local variances of the grayscale image Mat t_mean, t_mean_2; Mat grayF; outImg_gray.convertTo(grayF, CV_32F); int winSize = 35; blur(gr...

How do I remove repeated elements from ArrayList?

I have an ArrayList<String>, and I want to remove repeated strings from it. How can I do this?...

Use async await with Array.map

Given the following code: var arr = [1,2,3,4,5]; var results: number[] = await arr.map(async (item): Promise<number> => { await callAsynchronousOperation(item); return item + 1; }); which produces the following error:...

Printing a java map Map<String, Object> - How?

How to I print information from a map that has the object as the value? I have created the following map: Map<String, Object> objectSet = new HashMap<>(); The object has its own class with its own instance variables I have already po...

Refused to execute script, strict MIME type checking is enabled?

Why am I getting this error in console? Refused to execute script from 'https://www.googleapis.com/customsearch/v1?key=API_KEY&q=flower&searchType=image&fileType=jpg&imgSize=small&alt=json' because its MIME type ('applicat...

Sequelize OR condition object

By creating object like this var condition= { where: { LastName:"Doe", FirstName:["John","Jane"], Age:{ gt:18 } } } and pass it in Student.findAll(condition) .success(function(students){ }) It could beautif...

Get each line from textarea

<textarea> put returns between paragraphs for linebreak add 2 spaces at end indent code by 4 spaces quote by placing > at start of line </textarea> $text = value from this textarea; How to: 1) Get each line from this textarea ($tex...

Using awk to print all columns from the nth to the last

This line worked until I had whitespace in the second field. svn status | grep '\!' | gawk '{print $2;}' > removedProjs is there a way to have awk print everything in $2 or greater? ($3, $4.. until we don't have anymore columns?) I suppose I ...

Why do we always prefer using parameters in SQL statements?

I am very new to working with databases. Now I can write SELECT, UPDATE, DELETE, and INSERT commands. But I have seen many forums where we prefer to write: SELECT empSalary from employee where salary = @salary ...instead of: SELECT empSalary from...

Use of PUT vs PATCH methods in REST API real life scenarios

First of all, some definitions: PUT is defined in Section 9.6 RFC 2616: The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHO...

Functions that return a function

I'm stuck with this concept of 'Functions that return functions'. I'm referring the book 'Object Oriented Javascript' by Stoyan Stefanov. Snippet One: _x000D_ _x000D_ function a() {_x000D_ _x000D_ alert('A!');_x000D_ _x000D_...

How to read a file byte by byte in Python and how to print a bytelist as a binary?

I'm trying to read a file byte by byte, but I'm not sure how to do that. I'm trying to do it like that: file = open(filename, 'rb') while 1: byte = file.read(8) # Do something... So does that make the variable byte to contain 8 next bits at ...

AngularJS: ng-show / ng-hide not working with `{{ }}` interpolation

I am trying to show / hide some HTML using the ng-show and ng-hide functions provided by AngularJS. According to the documentation, the respective usage for these functions are as follows: ngHide – {expression} - If the expression truthy then ...

how to git commit a whole folder?

Here is a folder, which contains a lot of .java files. How can I git commit this folder ? If I do the following commands git add foldername git commit foldername -m "commit operation" I will see the messages nothing added to commit but untracked...

how to add a day to a date using jquery datepicker

I have 2 textboxes on my site for pickup date and drop off date both using the jquery date picker. I am having trouble setting the drop off date value to be one day ahead of the pickup date that was selected. Here is what I have: $('.pickupDate')....

How to identify platform/compiler from preprocessor macros?

I'm writing a cross-platform code, which should compile at linux, windows, Mac OS. On windows, I must support visual studio and mingw. There are some pieces of platform-specific code, which I should place in #ifdef .. #endif environment. For example...

Get Android Phone Model programmatically

I would like to know if there is a way for reading the Phone Model programmatically in Android. I would like to get a string like HTC Dream, Milestone, Sapphire or whatever......

jQuery - Detecting if a file has been selected in the file input

Possible Duplicate: jQuery: get the file name selected from <input type=“file” /> I have a standard file input box <input type="file" name="imafile"> I also have a bit of text down the page like so <span clas...

CS0234: Mvc does not exist in the System.Web namespace

I converted a ASP.net 4 webform project to Asp.net MVC4 according to Chapter 13 of the Professional ASP.NET 3.5 MVC, by Scott Hanselmen, Phil Haack, and Rob Conery, Published by Wiley Publishing, Inc. (ISBN: 978-0-470-38461-9). I also followed this ...

How to run multiple SQL commands in a single SQL connection?

I am creating a project in which I need to run 2-3 SQL commands in a single SQL connection. Here is the code I have written: SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\project.mdf;Integrated...

Simple CSS Animation Loop – Fading In & Out "Loading" Text

Without Javascript, I'd like to make a simple looping CSS animation class that fades text in and out, infinitely. I don't know a lot about CSS animations, so I haven't figured it out yet, but here's how far I've gotten: @keyframes flickerAnimation ...

Android map v2 zoom to show all the markers

I have 10 markers in the GoogleMap. I want to zoom in as much as possible and keep all markers in view? In the earlier version this can be achieved from zoomToSpan() but in v2 I have no idea how about doing that. Further, I know the radius of the cir...

How can I remove "\r\n" from a string in C#? Can I use a regular expression?

I am trying to persist string from an ASP.NET textarea. I need to strip out the carriage return line feeds and then break up whatever is left into a string array of 50 character pieces. I have this so far var commentTxt = new string[] { }; var cmtT...

How to Delete Session Cookie?

How to dynamically, via javascript, delete a session cookie, without manually restarting the browser? I read somewhere that session cookie is retained in browser memory and will be removed when the browser is closed. // sessionFooCookie is session ...

How to order results with findBy() in Doctrine

I am using the findBy() method on a Doctrine repository: $entities = $repository->findBy(array('type'=> 'C12')); How can I order the results?...

How to get date in BAT file

I need to get today date in Window *.bat file. After it I would like to get day, month and year. How can I do this? I can't use PowerShell...

How to communicate between iframe and the parent site?

The website in the iframe isn't located in the same domain, but both are mine, and I would like to communicate between the iframe and the parent site. Is it possible?...

Why do access tokens expire?

I am just getting started working with Google API and OAuth2. When the client authorizes my app I am given a "refresh token" and a short lived "access token". Now every time the access token expires, I can POST my refresh token to Google and they wil...

How to continue a Docker container which has exited

Consider: docker run -it centos /bin/bash I pressed Ctrl+D to exit it. I want to continue to run this container, but I found I can't. The only method is docker commit `docker ps -q -l` my_image docker run -it my_image /bin/bash Am I right? Is...

How do I make a stored procedure in MS Access?

How do I make a stored procedure in MS Access?...

notifyDataSetChanged example

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

Controller 'ngModel', required by directive '...', can't be found

What's going on here? Here is my directive: app.directive('submitRequired', function (objSvc) { return { require: 'ngModel', link: function (scope, elm, attrs, ctrl) { // do something } }; }); Here is an...

Detect Close windows event by jQuery

Could you please give me the best way to detect only window close event for all browsers by jQuery? I mean clicking X button on the browser or window.close(), not meaning F5, form submission, window.location or link. I was looking for many threads b...

Java 32-bit vs 64-bit compatibility

Will Java code built and compiled against a 32-bit JDK into 32-bit byte code work in a 64-bit JVM? Or does a 64-bit JVM require 64-bit byte code? To give a little more detail, I have code that was working in a Solaris environment running a 32-bit J...

How to add multiple values to a dictionary key in python?

I want to add multiple values to a specific key in a python dictionary. How can I do that? a = {} a["abc"] = 1 a["abc"] = 2 This will replace the value of a["abc"] from 1 to 2. What I want instead is for a["abc&quo...

How can I assign an ID to a view programmatically?

In an XML file, we can assign an ID to a view like android:id="@+id/something" and then call findViewById(), but when creating a view programmatically, how do I assign an ID? I think setId() is not the same as default assignment. setId() is extra. ...

Executing <script> injected by innerHTML after AJAX call

There's a div called "Content": <div id="content"></div> It should be filled with data from a PHP file, by AJAX, including a <script> tag. However, the script inside this tag is not being executed. <div id="content"><!-...

How to move files using FTP commands

Path of source file is : /public_html/upload/64/SomeMusic.mp3 And I want to move it to this path : /public_html/archive/2011/05/64/SomeMusic.mp3 How can i do this using FTP commands?...

How to preview an image before and after upload?

I am going to preview an image or photo in a form, but it doesn't work and the HTML code looks like this as below: <form action="" method="post" enctype="multipart/form-data" name="personal_image" id="newHotnessForm"> <p><label fo...

Reading and writing value from a textfile by using vbscript code

i have a variable named 'data' i need to write in to a textfile named "listfile.txt".Can you tell me the vbscript code to do that..And i need vbscript code for reading value from textfile "listfile.txt" also...

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

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

How can I run a windows batch file but hide the command window?

How can I run a windows batch file but hiding the command window? I dont want cmd.exe to be visible on screen when the file is being executed. Is this possible?...

How to render an ASP.NET MVC view as a string?

I want to output two different views (one as a string that will be sent as an email), and the other the page displayed to a user. Is this possible in ASP.NET MVC beta? I've tried multiple examples: 1. RenderPartial to String in ASP.NET MVC Beta ...

How to obtain Telegram chat_id for a specific user?

How to obtain user chat_id in Telegram bot API? The documentation says: Integer | Unique identifier for the message recipient — User or GroupChat id ...

Good tool to visualise database schema?

Are there any good tools for visualising a pre-existing database schema? I'm using MySQL if it matters. I'm currently using MySQL Workbench to process an SQL create script dump, but it's clunky, slow and a manual process to drag all the tables about...

Regex: Specify "space or start of string" and "space or end of string"

Imagine you are trying to pattern match "stackoverflow". You want the following: this is stackoverflow and it rocks [MATCH] stackoverflow is the best [MATCH] i love stackoverflow [MATCH] typostackoverflow rules [NO MATCH] i love stackoverf...

How to set css style to asp.net button?

I have a asp:Button, I used css styles with cssClass property in asp:Button, but those styles are not working. When I use asp:LinkButton those styles are working well.I don't want any themes or skins for styles. This is my asp page: <asp:Button...

Parse time of format hh:mm:ss

How can I parse a time of format hh:mm:ss , inputted as a string to obtain only the integer values (ignoring the colons) in java?...

python NameError: global name '__file__' is not defined

When I run this code in python 2.7, I get this error: Traceback (most recent call last): File "C:\Python26\Lib\site-packages\pyutilib.subprocess-3.5.4\setup.py", line 30, in <module> long_description = read('README.txt'), File "C:\Python...

Comparison of Android Web Service and Networking libraries: OKHTTP, Retrofit and Volley

Two-part question from an iOS developer learning Android, working on an Android project that will make a variety of requests from JSON to image to streaming download of audio and video: On iOS I have used the AFNetworking project extensively. Is th...

how to implement Pagination in reactJs

I am new to ReactJS and am creating a simple TODO application in it. Actually, it is a very basic app with no db connection, tasks are stored in an array. I added Edit and Delete functionality to it now I want to add pagination. How do I implement it...

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

This has to be simple, but I can't seem to find an answer.... I have a generic stdClass object $foo with no properties. I want to add a new property $bar to it that's not already defined. If I do this: $foo = new StdClass(); $foo->bar = '1234';...

Visual Studio Code compile on save

How can I configure Visual Studio Code to compile typescript files on save? I see it is possible to configure a task to build the file in focus using the ${file} as an argument. But I would like this to be done when a file is saved....

MessageBox with YesNoCancel - No & Cancel triggers same event

I have a message box with the YesNoCancel buttons... Pressing Yes will do some action and close the application - works fine Pressing No will do nothing and close the application - (see below) Pressing Cancel will do nothing and keep the applicatio...

CSS width of a <span> tag

I use <span> tags in my module titles, e.g. <span>Categories</span>. I specify the span's background color/image, width and height in css. But the span's width depends on its content/text. So, if I do <span></span>,...

How do I disable TextBox using JavaScript?

earlier I asked for help disabling a Button when a drop down menu item was selected. I was given some code that did the trick but now I need the same with a Textbox and for some odd reason its not working can you have a look for me... HTML: <for...

Error LNK2019: Unresolved External Symbol in Visual Studio

I've downloaded this C++ code from the SBIG website in order to control (take pictures and save them) the camera (model ST-401ME) which I purchased from them. I have a Matlab program which needs to call this so I'm trying to compile (with Visual Stud...

Shortcut for creating single item list in C#

In C#, is there an inline shortcut to instantiate a List<T> with only one item. I'm currently doing: new List<string>( new string[] { "title" } )) Having this code everywhere reduces readability. I've thought of using a utility metho...

Disable button in WPF?

I have a Button and a TextBox in my WPF app. How can I make the Button not enabled until the user enters some text in the TextBox?...

What is the backslash character (\\)?

What is the string literal \\ backslash? What does it do? I have thought about it but I do not understand it. I also read it on wikipedia. When I try to print the following: System.out.println("Mango \\ Nightangle"); the output is: Mango \ Nightan...

Can not deserialize instance of java.util.ArrayList out of VALUE_STRING

I have a REST service built with Jersey and deployed in the AppEngine. The REST service implements the verb PUT that consumes an application/json media type. The data binding is performed by Jackson. The verb consumes an enterprise-departments relat...

Convert a JSON string to object in Java ME?

Is there a way in Java/J2ME to convert a string, such as: {name:"MyNode", width:200, height:100} to an internal Object representation of the same, in one line of code? Because the current method is too tedious: Object n = create("new"); setStri...

Is there a NumPy function to return the first index of something in an array?

I know there is a method for a Python list to return the first index of something: >>> l = [1, 2, 3] >>> l.index(2) 1 Is there something like that for NumPy arrays?...

How can I remove all text after a character in bash?

How can I remove all text after a character, in this case a colon (":"), in bash? Can I remove the colon, too? I have no idea how to. ...

Remove all the children DOM elements in div

I have the following dojo codes to create a surface graphics element under a div: .... <script type=text/javascript> .... function drawRec(){ var node = dojo.byId("surface"); // remove all the children graphics var surfa...

Using ping in c#

When I Ping a remote system with windows it says there is no reply, but when I ping with c# it says success. Windows is correct, the device is not connected. Why is my code able to successfully ping when Windows is not? Here is my code : Ping p1 = ...

ASP.NET postback with JavaScript

I have several small divs which are utilizing jQuery draggable. These divs are placed in an UpdatePanel, and on dragstop I use the _doPostBack() JavaScript function, where I extract necessary information from the page's form. My problem is that when ...

Python str vs unicode types

Working with Python 2.7, I'm wondering what real advantage there is in using the type unicode instead of str, as both of them seem to be able to hold Unicode strings. Is there any special reason apart from being able to set Unicode codes in unicode s...

git diff between two different files

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

How to add new elements to an array?

I have the following code: String[] where; where.append(ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1"); where.append(ContactsContract.Contacts.IN_VISIBLE_GROUP + "=1"); Those two appends are not compiling. How would that work correctly?...

How to send a POST request from node.js Express?

Could someone show me the simplest way to send a post request from node.js Express, including how to pass and retrieve some data? I am expecting something similar to cURL in PHP....

How to read specific lines from a file (by line number)?

I'm using a for loop to read a file, but I only want to read specific lines, say line #26 and #30. Is there any built-in feature to achieve this?...

Where to put a textfile I want to use in eclipse?

I need to read a text file when I start my program. I'm using eclipse and started a new java project. In my project folder I got the "src" folder and the standard "JRE System Library" + staedteliste.txt... I just don't know where to put the text file...

How to check whether particular port is open or closed on UNIX?

I am very new to unix. How can I check that a particular port is free or used right now ? ...

I can't delete a remote master branch on git

I need to delete a master branch, but it's proving to be hard. I just want to clean that branch out and start new. I am deleting from the dev branch. I want master on GitHub to be clean. # git push origin --delete master > To https://github....

OS X cp command in Terminal - No such file or directory

this might be one of those days my brain just does not work, or i'm incredibly dumb. i've been trying to copy files (which are actually directories .app, .bundle, etc.) but consistently get an error 'No such file or directory'. i've tried every possi...

How to verify that a specific method was not called using Mockito?

How to verify that a method is not called on an object's dependency? For example: public interface Dependency { void someMethod(); } public class Foo { public bar(final Dependency d) { ... } } With the Foo test: public class...

Go build: "Cannot find package" (even though GOPATH is set)

Even though I have GOPATH properly set, I still can't get "go build" or "go run" to find my own packages. What am I doing wrong? $ echo $GOROOT /usr/local/go $ echo $GOPATH /home/mitchell/go $ cat ~/main.go package main import "foobar" func main()...

UTC Date/Time String to Timezone

How do I convert a date/time string (e.g. 2011-01-01 15:00:00) that is UTC to any given timezone php supports, such as America/New_York, or Europe/San_Marino....

Confirm deletion in modal / dialog using Twitter Bootstrap?

I have an HTML table of rows tied to database rows. I'd like to have a "delete row" link for each row, but I would like to confirm with the user beforehand. Is there any way to do this using the Twitter Bootstrap modal dialog?...

Difference between shared objects (.so), static libraries (.a), and DLL's (.so)?

I have been involved in some debate with respect to libraries in Linux, and would like to confirm some things. It is to my understanding (please correct me if I am wrong and I will edit my post later), that there are two ways of using libraries when ...

Is it possible to iterate through JSONArray?

Possible Duplicates: JSON Array iteration in Android/Java JSONArray with Java Is it possible to iterate through JSONArray object using Iterator?...

isset PHP isset($_GET['something']) ? $_GET['something'] : ''

I am looking to expand on my PHP knowledge, and I came across something I am not sure what it is or how to even search for it. I am looking at php.net isset code, and I see isset($_GET['something']) ? $_GET['something'] : '' I understand normal iss...

How to match any non white space character except a particular one?

In Perl \S matches any non-whitespace character. How can I match any non-whitespace character except a backslash \?...

node.js string.replace doesn't work?

var variableABC = "A B C"; variableABC.replace('B', 'D') //wanted output: 'A D C' but 'variableABC' didn't change : variableABC = 'A B C' when I want it to be 'A D C'....

Same Navigation Drawer in different Activities

I made a working navigation drawer like it's shown in the tutorial on the developer.android.com website. But now, I want to use one Navigation Drawer, i created in the NavigationDrawer.class for multiple Activities in my Application. My question is, ...

How do I share a global variable between c files?

If i define a global variable in a .c file, how can i use the value of the same variable in another .c file? file1.c #include<stdio.h> int i=10; int main() { printf("%d",i); return 0; } file2.c #include<stdio.h> int main() { //so...

Element implicitly has an 'any' type because expression of type 'string' can't be used to index

Trying out TypeScript for a React project and I'm stuck on this error: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ train_1: boolean; train_2: boolean; train_3: boolean; train_4: boolean; }'...

Get path to execution directory of Windows Forms application

I would like to get the path to the execution directory of a Windows Forms application. (That is, the directory in which the executable is located.) Does anyone know of a built-in method in .NET to do this?...

NSURLSession/NSURLConnection HTTP load failed on iOS 9

Tried to run my existing app on iOS9 but getting failure while using AFURLSessionManager. __block NSURLSessionDataTask *task = [self.sessionManager dataTaskWithRequest:request completionHandler:^(NSURLResponse * __unused response, id responseObject,...

jQuery UI Dialog OnBeforeUnload

I have a small problem. I'm attempting to catch the OnUnLoad Event of the Window and ask a confirmation question and if the user decides they want to stay then fine, and if they want to leave the page then they'll lose all unsaved data. Here's the ...

How to sort with a lambda?

sort(mMyClassVector.begin(), mMyClassVector.end(), [](const MyClass & a, const MyClass & b) { return a.mProperty > b.mProperty; }); I'd like to use a lambda function to sort custom classes in place of binding an instance metho...

Response::json() - Laravel 5.1

I am trying to return Response::json('data', $request); however, I am getting an error: FatalErrorException in ProjectsController.php line 74: Call to undefined method Illuminate\Http\Response::json() Where is the Response::json() is located?...

Relative instead of Absolute paths in Excel VBA

I have written an Excel VBA macro which imports data from a HTML file (stored locally) before performing calculations on the data. At the moment the HTML file is referred to with an absolute path: Workbooks.Open FileName:="C:\Documents and Settings...

The most sophisticated way for creating comma-separated Strings from a Collection/Array/List?

During my work with databases I noticed that I write query strings and in this strings I have to put several restrictions in the where-clause from a list/array/collection. Should look like this: select * from customer where customer.id in (34, 26, ...

How to add text to a WPF Label in code?

I feel stupid but cannot find out how to add a text to a WPF Label control in code. Like following for a TextBlock: DesrTextBlock.Text = "some text"; What is equivalent property in Label for doing it? DesrLabel.??? = "some text"; //something like...

Open a URL in a new tab (and not a new window)

I'm trying to open a URL in a new tab, as opposed to a popup window. I've seen related questions where the responses would look something like: window.open(url,'_blank'); window.open(url); But none of them worked for me, the browser still tried t...

Tkinter example code for multiple windows, why won't buttons load correctly?

I am writing a program which should: Open a window with the press of a button. Close the newly opened window with the press of another button. I'm using classes so I can insert the code into a larger program later. However, I can't get my buttons...

MySQL OPTIMIZE all tables?

MySQL has an OPTIMIZE TABLE command which can be used to reclaim unused space in a MySQL install. Is there a way (built-in command or common stored procedure) to run this optimization for every table in the database and/or server install, or is this...

Display calendar to pick a date in java

In other languages like VB, C#, in occasions where you want the user to enter a date, say in a text box,we can make a calendar to appear once you click on it. So the user can click on the corresponding date and that date will be put to the text box. ...

Hide password with "•••••••" in a textField

In my app there is a textField where the user have to put is password in and i want that when he enter a character it change it to '•' how can i do this?...

Altering column size in SQL Server

How to change the column size of the salary column in the employee table from numeric(18,0) to numeric(22,5)...

How to identify unused CSS definitions from multiple CSS files in a project

A bunch of CSS files were pulled in and now I'm trying to clean things up a bit. How can I efficiently identify unused CSS definitions in a whole project?...

C# Select elements in list as List of string

In C# i need to get all values of a particular property from an object list into list of string List<Employee> emplist = new List<Employee>() { new Employee{ EID=10, Ename...

check if "it's a number" function in Oracle

I'm trying to check if a value from a column in an oracle (10g) query is a number in order to compare it. Something like: select case when ( is_number(myTable.id) and (myTable.id >0) ) then 'Is a number greater than 0' e...

PHP: Call to undefined function: simplexml_load_string()

I am implementing facebook count function using cron file. In which cron runs every 10 minutes and counts the total likes of a page. for($i=0;$i<3;$i++){ $source_url =$cars[$i]; $rest_url = "http://api.facebook.com/restserver.php?method=l...

Returning a boolean from a Bash function

I want to write a bash function that check if a file has certain properties and returns true or false. Then I can use it in my scripts in the "if". But what should I return? function myfun(){ ... return 0; else return 1; fi;} then I use it like th...

laravel Eloquent ORM delete() method

Hi I am studying laravel. I use Eloquent ORM delete method but I get a different result.Not true or false but null. I set an resource route and there is a destroy method in UsersController. public function destroy($id){ $res=User::find($id)->d...

momentJS date string add 5 days

i have a start date string "20.03.2014" and i want to add 5 days to this with moment.js but i don't get the new date "25.03.2014" in the alert window. here my javascript Code: startdate = "20.03.2014"; var new_date = moment(startdate, "DD-MM-YYYY")...

MySQL string replace

I have a column containing urls (id, url): http://www.example.com/articles/updates/43 http://www.example.com/articles/updates/866 http://www.example.com/articles/updates/323 http://www.example.com/articles/updates/seo-url http://www.example.com/arti...

Deserialize JSON string to c# object

My Application is in Asp.Net MVC3 coded in C#. This is what my requirement is. I want an object which is in the following format.This object should be achieved when I deserialize the Json string. var obj1 = new { arg1=1,arg2=2 }; After using the...

How to update attributes without validation

I've got a model with its validations, and I found out that I can't update an attribute without validating the object before. I already tried to add on => :create syntax at the end of each validation line, but I got the same results. My announce...

Exception : AAPT2 error: check logs for details

Task :processDebugResources Failed to execute aapt com.android.ide.common.process.ProcessException: Failed to execute aapt at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:796) at com.android.build.gradle.tasks....

Best way to get application folder path

I see that there are some ways to get the application folder path: Application.StartupPath System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location) AppDomain.CurrentDomain.BaseDirectory System.IO.Directory.GetCur...

"Use the new keyword if hiding was intended" warning

I have a warning at the bottom of my screen: Warning 1 'WindowsFormsApplication2.EventControlDataSet.Events' hides inherited member 'System.ComponentModel.MarshalByValueComponent.Events'. Use the new keyword if hiding was intended. C...

Angular 2 - How to navigate to another route using this.router.parent.navigate('/about')?

Angular 2 - How to navigate to another route using this.router.parent.navigate('/about'). It doesnt seem to work. I tried location.go("/about"); as that didnt work. Basically once a user has logged in I want to redirect them to another page. Here ...

Gulp command not found after install

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

Presto SQL - Converting a date string to date format

I'm on presto and have a date formatted as varchar that looks like - 7/14/2015 8:22:39 AM I've looked the presto docs and tried various things(cast, date_format, using split_part to parse and then cast) and am not getting this to convert to a dat...

Please explain about insertable=false and updatable=false in reference to the JPA @Column annotation

If a field is annotated insertable=false, updatable=false, doesn't it mean that you cannot insert value nor change the existing value? Why would you want to do that? @Entity public class Person { @Id @GeneratedValue(strategy = GenerationTyp...

CSS hide scroll bar, but have element scrollable

I have this element called items and the content inside the element is longer than the element height, I want to make it scrollable but hide the scroll bar, how would I do that? <div class="left-side"> <div class="items" style="display:...

How to fix curl: (60) SSL certificate: Invalid certificate chain

I get the following error running curl https://npmjs.org/install.sh | sh on Mac OSX 10.9 (Mavericks): install npm@latest curl: (60) SSL certificate problem: Invalid certificate chain More details here: http://curl.haxx.se/docs/sslcerts.html How do...

Open an html page in default browser with VBA?

How do I open an HTML page in the default browser with VBA? I know it's something like: Shell "http://myHtmlPage.com" But I think I have to reference the program which will open the page....

find vs find_by vs where

I am new to rails. What I see that there are a lot of ways to find a record: find_by_<columnname>(<columnvalue>) find(:first, :conditions => { <columnname> => <columnvalue> } where(<columnname> => <columnva...

beyond top level package error in relative import

It seems there are already quite some questions here about relative import in python 3, but after going through many of them I still didn't find the answer for my issue. so here is the question. I have a package shown below package/ __init__.p...

How can I display an RTSP video stream in a web page?

I have an ip camera which provides a live RTSP video stream. I can use VLC media player to view the feed by providing it with the URL: rtsp://cameraipaddress But I need to display the feed on a web page. The camera provider supplied an ActiveX con...

How to deal with the URISyntaxException

I got this error message : java.net.URISyntaxException: Illegal character in query at index 31: http://finance.yahoo.com/q/h?s=^IXIC My_Url = http://finance.yahoo.com/q/h?s=^IXIC When I copied it into a browser address field, it showed the correc...

Convert AM/PM time to 24 hours format?

I need to convert 12 hours format time (am/pm) to 24 hours format time, e.g. 01:00 PM to 13:00 using C#. How can I convert it?...

How to use orderby with 2 fields in linq?

Say I have these values in a database table id = 1 StartDate = 1/3/2010 EndDate = 1/3/2010 id = 2 StartDate = 1/3/2010 EndDate = 1/9/2010 Now I have so far this orderby for my linq var hold = MyList.OrderBy(x => x.StartDate).ToList(); I wa...

symbol(s) not found for architecture i386

When trying to compile with Xcode, I am getting the following error: **Ld /Users/doronkatz/Library/Developer/Xcode/DerivedData/iKosher-bphnihrngmqtkqfgievrrumzmyce/Build/Products/Debug-iphonesimulator/iKosher.app/iKosher normal i386 cd /Users/...

document.getElementById('btnid').disabled is not working in firefox and chrome

I'm using JavaScript for disabling a button. Works fine in IE but not in FireFox and chrome, here is the script what I'm working on: function disbtn(e) { if ( someCondition == true ) { document.getElementById('btn1').disabled = true; ...

String or binary data would be truncated. The statement has been terminated

I have met some problem with the SQL server, this is the function I created: ALTER FUNCTION [dbo].[testing1](@price int) RETURNS @trackingItems1 TABLE ( item nvarchar NULL, warehouse nvarchar NULL, price int NULL ) AS BEGIN I...

How to get the next auto-increment id in mysql

How to get the next id in mysql to insert it in the table INSERT INTO payments (date, item, method, payment_code) VALUES (NOW(), '1 Month', 'paypal', CONCAT("sahf4d2fdd45", id)) ...

Convert String into a Class Object

I am storing a class object into a string using toString() method. Now, I want to convert the string into that class object. How to do that? Please help me with source code....

How to run shell script file using nodejs?

I need to run a shell script file using nodeJS that executes a set of Cassandra DB commands. Can anybody please help me on this. inside db.sh file: create keyspace dummy with replication = {'class':'SimpleStrategy','replication_factor':3} creat...

Saving an Excel sheet in a current directory with VBA

I have created a sheet in vba Excel. I would like to save it the current directory, but not in absolute path, then, when this is executed somewhere else, there won't be problem. Can somebody help ?...

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

The Angular docs provide an example for creating an attribute directive that changes the background color of an element: https://angular.io/docs/ts/latest/guide/attribute-directives.html <p myHighlight>Highlight me!</p> import { Direc...

Invoke JSF managed bean action on page load

Is there a way to execute a JSF managed bean action when a page is loaded? If that's relevant, I'm currently using JSF 1.2....

How do I solve this error, "error while trying to deserialize parameter"

I have a web service that is working fine in one environment but not in another. The web service gets document meta data from SharePoint, it running on a server where I cant debug but with logging I confirmed that the method enters and exits success...

_tkinter.TclError: no display name and no $DISPLAY environment variable

I am running a simple python script in the server: import matplotlib.pyplot as plt import numpy as np x = np.random.randn(60) y = np.random.randn(60) plt.scatter(x, y, s=20) out_png = 'path/to/store/out_file.png' plt.savefig(out_png, dpi=150) I...

Fetch: reject promise and catch the error if status is not OK?

Here's what I have going: import 'whatwg-fetch'; function fetchVehicle(id) { return dispatch => { return dispatch({ type: 'FETCH_VEHICLE', payload: fetch(`http://swapi.co/api/vehicles/${id}/`) ...

Why my regexp for hyphenated words doesn't work?

I'm writting a regular expression for match with simple words and single hyphenated words using re module of python, so for example in: test_case_input = """the wide-field infrared survey explorer is a nasa infrared-wavelength space telescope in an ...

What's the difference between subprocess Popen and call (how can I use them)?

I want to call an external program from Python. I have used both Popen() and call() to do that. What's the difference between the two? My specific goal is to run the following command from Python. I am not sure how redirects work. ./my_script.sh ...

Create GUI using Eclipse (Java)

Possible Duplicate: Best GUI designer for eclipse? Is there any Eclipse Plugin tool(s) who can help to create Graphical User Interface for (swing, awt or swt), because I'm tired of writing everytime the code of Panels, Labels, ... Thanks...

wget command to download a file and save as a different filename

I am downloading a file using the wget command. But when it downloads to my local machine, I want it to be saved as a different filename. For example: I am downloading a file from www.examplesite.com/textfile.txt I want to use wget to save the file...

EL access a map value by Integer key

I have a Map keyed by Integer. Using EL, how can I access a value by its key? Map<Integer, String> map = new HashMap<Integer, String>(); map.put(1, "One"); map.put(2, "Two"); map.put(3, "Three"); I thought this would work but it doesn'...

Change Default branch in gitlab

I accidentally pushed my local master to a branch called origin on gitlab and now it is the default. Is there a way to rename this branch or set a new master branch to master?...

What is reflection and why is it useful?

What is reflection, and why is it useful? I'm particularly interested in Java, but I assume the principles are the same in any language....

MYSQL order by both Ascending and Descending sorting

I have a mysql table with products. The products have a category ID and a name. What I'd like to do is order by category id first descending order and then order by product name ascending order. SELECT * FROM `products` ORDER BY `products`.`produc...

Remove duplicated rows using dplyr

I have a data.frame like this - set.seed(123) df = data.frame(x=sample(0:1,10,replace=T),y=sample(0:1,10,replace=T),z=1:10) > df x y z 1 0 1 1 2 1 0 2 3 0 1 3 4 1 1 4 5 1 0 5 6 0 1 6 7 1 0 7 8 1 0 8 9 1 0 9 10 0 1 10 I wo...

How to setup FTP on xampp

i want to make a server using xampp. i have already installed xampp and setting port 8080. php and mysql work fine but i can't access ftp from internet. Can you please suggest way how can I do this?...

How to start MySQL with --skip-grant-tables?

I locked my root user out from our database. I need to get all privileges back to the root user. I have my password and I can log in to MySQL. But the root user has no all privileges....

Conversion failed when converting date and/or time from character string in SQL SERVER 2008

I have below SQL. UPDATE student_queues SET Deleted=0, last_accessed_by='raja', last_accessed_on=CONVERT(VARCHAR(24),'23-07-2014 09:37:00',113) WHERE std_id IN ('2144-384-11564') AND reject_details='REJECT' when I ran the a...

Create a batch file to copy and rename file

I need to write a batch file that copies a file to a new folder and renames it. At the moment, my batch file consists of only this command: COPY ABC.PDF \\Documents As you can see, it only copies the file ABC.pdf to the network folder Documents....

How do I generate random number for each row in a TSQL Select?

I need a different random number for each row in my table. The following seemingly obvious code uses the same random value for each row. SELECT table_name, RAND() magic_number FROM information_schema.tables I'd like to get an INT or a FLOAT out...

Replace transparency in PNG images with white background

I've got some PNG images with transparency, and I need to create versions with the image layer composed onto a white background. I've tried various things with Image Magick "convert" operations, but either nothing happens at all or I get an error. ...

How to install JDBC driver in Eclipse web project without facing java.lang.ClassNotFoundexception

There is a VERY similar question to mine but in my case I don't have any duplicate jars in my build path, so the solution does not work for me. I've searched google for a couple of hours now, but none of the solutions I've found there actually resol...

"Too many characters in character literal error"

I'm struggling with a piece of code and getting the error: Too many characters in character literal error Using C# and switch statement to iterate through a string buffer and reading tokens, but getting the error in this line: case '&&': c...

Given the lat/long coordinates, how can we find out the city/country?

For example if we have these set of coordinates "latitude": 48.858844300000001, "longitude": 2.2943506, How can we find out the city/country?...

How to deal with floating point number precision in JavaScript?

I have the following dummy test script: _x000D_ _x000D_ function test() {_x000D_ var x = 0.1 * 0.2;_x000D_ document.write(x);_x000D_ }_x000D_ test();_x000D_ _x000D_ _x000D_ This will print the result 0.020000000000000004 while it should just p...

How to frame two for loops in list comprehension python

I have two lists as below tags = [u'man', u'you', u'are', u'awesome'] entries = [[u'man', u'thats'],[ u'right',u'awesome']] I want to extract entries from entries when they are in tags: result = [] for tag in tags: for entry in entries: ...

tooltips for Button

Is it possible to create a tooltip for an html button. Its the normal HTML button and there is no Title attribute as it is there for some html controls. Any thoughts or comments?...

How can I use threading in Python?

I am trying to understand threading in Python. I've looked at the documentation and examples, but quite frankly, many examples are overly sophisticated and I'm having trouble understanding them. How do you clearly show tasks being divided for multi-...

How to copy to clipboard using Access/VBA?

Using VBA inside Access2003/2007. How to copy the contents of a string variable to the clipboard? This site recommends a creating a zero length TextBox, copying the string to the TextBox, then running DoCmd.RunCommand acCmdCopy. Ugh. I mean, we may...

Remove secure warnings (_CRT_SECURE_NO_WARNINGS) from projects by default in Visual Studio

Is there a way to set by default for all projects removing the precompiler secure warnings that come up when using functions like scanf(). I found that you can do it by adding a line in the project option or a #define _CRT_SECURE_NO_WARNINGS in the b...

Difference between add(), replace(), and addToBackStack()

What is the main difference between calling these methods: fragmentTransaction.addToBackStack(name); fragmentTransaction.replace(containerViewId, fragment, tag); fragmentTransaction.add(containerViewId, fragment, tag); What does it mean to replace...

how to set width for PdfPCell in ItextSharp

i want set width for PdfpCell in Table, i want design this i Write this code PdfPCell cell; PdfGrid tableHeader; PdfGrid tmpTable; PdfGrid table = new PdfGrid(numColumns: 1) { WidthPercentage = 100, RunDirec...

Android refresh current activity

I want to program my android app to refresh its current activity on ButtonClick. I have one button on the top of the activity layout which will do the job. When I click on button the current activity should reload again - just like a device restart. ...

Asynchronous Requests with Python requests

I tried the sample provided within the documentation of the requests library for python. With async.map(rs), I get the response codes, but I want to get the content of each page requested. This, for example, does not work: out = async.map(rs) print...

Adding a Time to a DateTime in C#

I have a calendar and a textbox that contains a time of day. I want to create a datetime that is the combination of the two. I know I can do it by looking at the hours and mintues and then adding these to the calendar DateTime, but this seems rather ...

How do a send an HTTPS request through a proxy in Java?

I am trying to send a request to a server using the HttpsUrlConnection class. The server has certificate issues, so I set up a TrustManager that trusts everything, as well as a hostname verifier that is equally lenient. This manager works just fine...

Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel

I'm running my Web Project in IIS. It is a 4.0 Framework APP. I have a Service.svc and I get this error when I run my Application. "Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3....

Bin size in Matplotlib (Histogram)

I'm using matplotlib to make a histogram. Is there any way to manually set the size of the bins as opposed to the number of bins?...

What is the preferred syntax for defining enums in JavaScript?

What is the preferred syntax for defining enums in JavaScript? Something like: my.namespace.ColorEnum = { RED : 0, GREEN : 1, BLUE : 2 } // later on if(currentColor == my.namespace.ColorEnum.RED) { // whatever } Or is there a more...

SQL JOIN and different types of JOINs

What is a SQL JOIN and what are different types?...

How to set the context path of a web application in Tomcat 7.0

I know that I can rename my webapp (or it's WAR file) to ROOT but this is a terrible way to do it, IMHO. Now I checked out the tomcat doc & it says It is NOT recommended to place elements directly in the server.xml file So I tried doing...

How is returning the output of a function different from printing it?

In my previous question, Andrew Jaffe writes: In addition to all of the other hints and tips, I think you're missing something crucial: your functions actually need to return something. When you create autoparts() or splittext(), the idea is t...

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

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

How do I select elements of an array given condition?

Suppose I have a numpy array x = [5, 2, 3, 1, 4, 5], y = ['f', 'o', 'o', 'b', 'a', 'r']. I want to select the elements in y corresponding to elements in x that are greater than 1 and less than 5. I tried x = array([5, 2, 3, 1, 4, 5]) y = array(['f'...

MySQL: is a SELECT statement case sensitive?

Can anyone tell me if a MySQL SELECT query is case sensitive or case insensitive by default? And if not, what query would I have to send so that I can do something like: SELECT * FROM `table` WHERE `Value` = "iaresavage" Where in actuality, the re...

datatable jquery - table header width not aligned with body width

I am using jQuery datatables. When running the application, the header width is not aligned with the body width. But when I click on the header, it is getting aligned with the body width but even then there is some light misalignment. This problem oc...

Change fill color on vector asset in Android Studio

Android Studio now supports vector assets on 21+ and will generate pngs for lower versions at compile time. I have a vector asset (from the Material Icons) that I want to change the fill color. This works on 21+, but the generated pngs do not chang...

Check whether values in one data frame column exist in a second data frame

I have two data frames (A and B), both with a column 'C'. I want to check if values in column 'C' in data frame A exists in data frame B. A = data.frame(C = c(1,2,3,4)) B = data.frame(C = c(1,3,4,7)) ...

Laravel 5.4 redirection to custom url after login

I am using Laravel Framework 5.4.10, and I am using the regular authentication that php artisan make:auth provides. I want to protect the entire app, and to redirect users to /themes after login. I have 4 controllers: ForgotPasswordController.ph...

Convert varchar dd/mm/yyyy to dd/mm/yyyy datetime

I'm trying to convert a date in a varchar column in the dd/mm/yyyy format into the datetime dd/mm/yyyy format, so then I can run date range queries on the data. So far I have the following which is not working CONVERT(varchar, CAST(date_started AS ...

Is there a typescript List<> and/or Map<> class/library?

Did they add a runtime List<> and/or Map<> type class to typepad 1.0? And if not, is there a solid library out there someone wrote that provides this functionality? And in the case of List<>, is there a linked list where the elements in the...

How to loop through Excel files and load them into a database using SSIS package?

I need to create an SSIS package for importing data from multiple Excel files into an SQL database. I plan on using nested Foreach Loop containers to achieve this. One Foreach File Enumerator and nested within that, a Foreach ADO.net Schema Rowset En...

How to create a hidden <img> in JavaScript?

How can you make a simple tag like <img src="a.gif"> hidden programmatically using JavaScript?...

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

How can I schedule a daily backup with SQL Server Express?

I'm running a small web application with SQL server express (2005) as backend. I can create a backup with a SQL script, however, I'd like to schedule this on a daily basis. As extra option (should-have) I'd like to keep only the last X backups (for ...

LINK : fatal error LNK1104: cannot open file 'D:\...\MyProj.exe'

Using Visual Studio 2010, when I build + run my application in short intervals I often get the following error. If I just wait a minute or two and try again it works fine. Unlocker claims no handle is locking the executable file. How can I discover w...

How to properly create composite primary keys - MYSQL

Here is a gross oversimplification of an intense setup I am working with. table_1 and table_2 both have auto-increment surrogate primary keys as the ID. info is a table that contains information about both table_1 and table_2. table_1 (id, field) ...

Common xlabel/ylabel for matplotlib subplots

I have the following plot: fig,ax = plt.subplots(5,2,sharex=True,sharey=True,figsize=fig_size) and now I would like to give this plot common x-axis labels and y-axis labels. With "common", I mean that there should be one big x-axis label below the...

Is it possible to pass parameters programmatically in a Microsoft Access update query?

I have a query that's rather large, joining over a dozen tables, and I want to pull back records based on an id field (e.g.: between nStartID and nEndID). I created two parameters and tested them as criteria and they work fine. The issue is, I need...

python save image from url

I got a problem when I am using python to save an image from url either by urllib2 request or urllib.urlretrieve. That is the url of the image is valid. I could download it manually using the explorer. However, when I use python to download the image...

How to keep a VMWare VM's clock in sync?

I have noticed that our VMWare VMs often have the incorrect time on them. No matter how many times I reset the time they keep on desyncing. Has anyone else noticed this? What do other people do to keep their VM time in sync? Edit: These are CLI lin...

Up, Down, Left and Right arrow keys do not trigger KeyDown event

I am building an application where all the key input must be handled by the windows itself. I set tabstop to false for each control witch could grab the focus except a panel (but I don't know if it has effect). I set KeyPreview to true and I am han...

jQuery - Uncaught RangeError: Maximum call stack size exceeded

The following code (see Fiddle here) throws the stack overflow referred to in the question title. I'm trying to get a box shadow to display around a circular image in a pulse effect. Can anyone point out the recursion, please? I'm very much a Javascr...

Increase max_execution_time in PHP?

I'm trying to upload large files to my server (my server support post_max_size 192mb and max_execution_time 600 sec). When I upload 100mb files execution will stop after 600 sec so files are not uploaded to the server. How can I increase max_executio...

Why can't Python import Image from PIL?

The single line that I am trying to run is the following: from PIL import Image However simple this may seem, it gives an error: Traceback (most recent call last): File "C:\...\2014-10-22_12-49.py", line 1, in <module> from PIL import...

Why does comparing strings using either '==' or 'is' sometimes produce a different result?

I've got a Python program where two variables are set to the value 'public'. In a conditional expression I have the comparison var1 is var2 which fails, but if I change it to var1 == var2 it returns True. Now if I open my Python interpreter and do t...

Find duplicate records in MySQL

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

What is a NullReferenceException, and how do I fix it?

I have some code and when it executes, it throws a NullReferenceException, saying: Object reference not set to an instance of an object. What does this mean, and what can I do to fix this error?...

Unable to install pyodbc on Linux

I am running Linux (2.6.18-164.15.1.el5.centos.plus) and trying to install pyodbc. I am doing pip install pyodbc and get a very long list of errors, which end in error: command 'gcc' failed with exit status 1 I looked in /root/.pip/pip.log a...

How to find the mysql data directory from command line in windows

In linux I could find the mysql installation directory with the command which mysql. But I could not find any in windows. I tried echo %path% and it resulted many paths along with path to mysql bin. I wanted to find the mysql data directory from co...

How to change spinner text size and text color?

In my Android application, I am using spinner, and I have loaded data from the SQLite database into the spinner, and it's working properly. Here is the code for that. Spinner spinner = (Spinner) this.findViewById(R.id.spinner1); List<String> l...

What does the "yield" keyword do?

What is the use of the yield keyword in Python, and what does it do? For example, I'm trying to understand this code1: def _get_child_candidates(self, distance, min_dist, max_dist): if self._leftchild and distance - max_dist < self._median: ...

Page unload event in asp.net

Is it possible to call a write a Page_Unload event in code behind similar to Page_Load event? I wanted to call a method on Page Unload. How do I achieve that?...

Code for a simple JavaScript countdown timer?

I want to use a simple countdown timer starting at 30 seconds from when the function is run and ending at 0. No milliseconds. How can it be coded?...

What is the precise meaning of "ours" and "theirs" in git?

This might sound like too basic of a question, but I have searched for answers and I am more confused now than before. What does "ours" and "theirs" mean in git when merging my branch into my other branch? Both branches are "ours". In a merge conf...

Read each line of txt file to new array element

I am trying to read every line of a text file into an array and have each line in a new element. My code so far. <?php $file = fopen("members.txt", "r"); while (!feof($file)) { $line_of_text = fgets($file); $members = explode(...

What is the difference between HTML tags <div> and <span>?

I would like to ask for some simple examples showing the uses of <div> and <span>. I've seen them both used to mark a section of a page with an id or class, but I'm interested in knowing if there are times when one is preferred over the...

How do I convert a float number to a whole number in JavaScript?

I'd like to convert a float to a whole number in JavaScript. Actually, I'd like to know how to do BOTH of the standard conversions: by truncating and by rounding. And efficiently, not via converting to a string and parsing....

TSQL PIVOT MULTIPLE COLUMNS

I have the following table but unsure of whether it is possible to pivot this and retain all the labels. RATIO RESULT SCORE GRADE Current Ratio 1.294 60 Good Gearing Ratio 0.3384 70 Good Performance Ratio...

How to make the python interpreter correctly handle non-ASCII characters in string operations?

I have a string that looks like so: 6 918 417 712 The clear cut way to trim this string (as I understand Python) is simply to say the string is in a variable called s, we get: s.replace(' ', '') That should do the trick. But of cours...

How to clear radio button in Javascript?

I have a radio button named "Choose" with the options yes and no. If I select any one of the options and click the button labeled "clear", I need to clear the selected option, using javascript. How can I accomplish that?...

MySQLDump one INSERT statement for each data row

with the following statement: mysqldump --complete-insert --lock-all-tables --no-create-db --no-create-info --extended-insert --password=XXX -u XXX --dump-date yyy > yyy_dataOnly.sql I get INSERT statements like the following: INSERT INTO `t...

clearInterval() not working

Possible Duplicate: JS - How to clear interval after using setInterval() I have a function that changes the font-family of some text every 500 ms using setInterval (I made it just to practice JavaScript.) The function is called by clicking...

How to center div vertically inside of absolutely positioned parent div

I am trying to get blue container in the middle of pink one, however seems vertical-align: middle; doesn't do the job in that case. <div style="display: block; position: absolute; left: 50px; top: 50px;"> <div style="text-align: left; p...

How can I create a Java 8 LocalDate from a long Epoch time in Milliseconds?

I have an external API that returns me dates as longs, represented as milliseconds since the beginning of the Epoch. With the old style Java API, I would simply construct a Date from it with Date myDate = new Date(startDateLong) What is the equiv...

Programmatically scroll to a specific position in an Android ListView

How can I programmatically scroll to a specific position in a ListView? For example, I have a String[] {A,B,C,D....}, and I need to set the top visible item of the ListView to the index 21 of my String[]....

Is it possible to use jQuery .on and hover?

I have a <ul> that is populated with javascript after the initial page load. I'm currently using .bind with mouseover and mouseout. The project just updated to jQuery 1.7 so I have the option to use .on, but I can't seem to get it to work wit...

How to write a test which expects an Error to be thrown in Jasmine?

I'm trying to write a test for the Jasmine Test Framework which expects an error. At the moment I'm using a Jasmine Node.js integration from GitHub. In my Node module I have the following code: throw new Error("Parsing is not possible"); Now I tr...

What is the difference between substr and substring?

What is the difference between alert("abc".substr(0,2)); and alert("abc".substring(0,2)); They both seem to output “ab”....

CMake error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found

I'm trying make a Visual Studio solution with CMake to compile the latest version of aseprite and CMake keeps giving me the: No CMAKE_C_COMPILER could be found. No CMAKE_CXX_COMPILER could be found. I've already downloaded GCC, and I'm using Visua...

How to run JUnit tests with Gradle?

Currently I have the following build.gradle file: apply plugin: 'java' sourceSets { main { java { srcDir 'src/model' } } } dependencies { compile files('libs/mnist-tools.jar', 'libs/gson-2.2.4.jar') runt...

How to upgrade glibc from version 2.13 to 2.15 on Debian?

I heard I can do it using apt-get install libc6, but I need to add something to /etc/apt/sources.list to receive the newest glibc version. What should I do?...

How to center icon and text in a android button with width set to "fill parent"

I want to have an Android Button with icon+text centered inside it. I'm using the drawableLeft attribute to set the image, this works well if the button has a width of "wrap_content" but I need to stretch to max width so I use width "fill_parent". Th...

How to get row count in sqlite using Android?

I am creating task manager. I have tasklist and I want when I click on particular tasklist name if it empty then it goes on Add Task activity but if it has 2 or 3 tasks then it shows me those tasks into it in list form. I am trying to get count in l...

Python - Count elements in list

I am trying to find a simple way of getting a count of the number of elements in a list: MyList = ["a", "b", "c"] I want to know there are 3 elements in this list....

batch script - read line by line

I have a log file which I need to read in, line by line and pipe the line to a next loop. Firstly I grep the logfile for the "main" word (like "error") in a separate file - to keep it small. Now I need to take the seperate file and read it in line ...

Query to count the number of tables I have in MySQL

I am growing the number of tables I have and I am sometimes curious just to do a quick command line query to count the number of tables in my database. Is that possible? If so, what is the query?...

Undefined symbols for architecture x86_64 on Xcode 6.1

All of a sudden Xcode threw me this error at compilation time: Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_Format", referenced from: objc-class-ref in WOExerciseListViewController.o ld: symbol(s) not found for architecture x86_64 cla...

LIKE vs CONTAINS on SQL Server

Which one of the following queries is faster (LIKE vs CONTAINS)? SELECT * FROM table WHERE Column LIKE '%test%'; or SELECT * FROM table WHERE Contains(Column, "test"); ...

MySQL order by before group by

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

Error Code: 1005. Can't create table '...' (errno: 150)

I searched for a solution to this problem on the Internet and checked the Stack Overflow questions, but none of the solutions worked for my case. I want to create a foreign key from table sira_no to metal_kod. ALTER TABLE sira_no ADD CONST...

How to get indices of a sorted array in Python

I have a numerical list: myList = [1, 2, 3, 100, 5] Now if I sort this list to obtain [1, 2, 3, 5, 100]. What I want is the indices of the elements from the original list in the sorted order i.e. [0, 1, 2, 4, 3] --- ala MATLAB's sort function t...

Powershell: A positional parameter cannot be found that accepts argument "xxx"

I am trying to understand what this error actually means. So far a search of similar help requests for this error range from missing parameters, missing pipes, use of single or multi-lines, and also concatenation issues but none of the answers seem t...

password for postgres

In the short version of postgres' installing it tell me to do the following ./configure gmake su gmake install adduser postgres mkdir /usr/local/pgsql/data chown postgres /usr/local/pgsql/data su - postgres /usr/local/pgsql/bin/initdb -D /usr/local/...

Animate a custom Dialog

I'm trying to have a custom dialog appear as though it's sliding down from a text view. Is this possible? I can't seem to apply any animation to dialog class. I've tried this line in the constructor, but it has no effect: this.getWindow().setWindowA...

How do you disable viewport zooming on Mobile Safari?

I've tried all three of these to no avail: <meta name=”viewport” content=”width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;” /> <meta name=”viewport” content=”width=device-width; initial-scale=1.0; ma...

Generate a sequence of numbers in Python

How can I generate the sequence of numbers "1,2,5,6,9,10......" and so until 100 in Python? I even need the comma (',') included, but this is not the main problem. The sequence: every number from 1..100, divisible by 4 with remainder 1 or 2....

NavigationBar bar, tint, and title text color in iOS 8

The background text in the status bar is still black. How do I change the color to white? // io8, swift, Xcode 6.0.1 override func viewDidLoad() { super.viewDidLoad() self.navigationController?.navigationBar.barTintColor = UIColor.blackColo...

PHP shell_exec() vs exec()

I'm struggling to understand the difference between shell_exec() and exec()... I've always used exec() to execute server side commands, when would I use shell_exec()? Is shell_exec() just a shorthand for exec()? It seems to be the same thing with ...

Android Percentage Layout Height

I know that it is impossible to set percentages and that you can set a weight of certain images to scale their heights. What I am trying to do though is specify the height of a layout relative to the layout it is within. Basicly I have something like...

Accessing private member variables from prototype-defined functions

Is there any way to make “private” variables (those defined in the constructor), available to prototype-defined methods? TestClass = function(){ var privateField = "hello"; this.nonProtoHello = function(){alert(privateField)}; }; TestCla...

How To Change DataType of a DataColumn in a DataTable?

I have: DataTable Table = new DataTable; SqlConnection = new System.Data.SqlClient.SqlConnection("Data Source=" + ServerName + ";Initial Catalog=" + DatabaseName + ";Integrated Security=SSPI; Connect Timeout=120"); SqlDataAdapter adapter = new SqlD...

Check if value is zero or not null in python

Often I am checking if a number variable number has a value with if number but sometimes the number could be zero. So I solve this by if number or number == 0. Can I do this in a smarter way? I think it's a bit ugly to check if value is zero separat...

Java: How to convert List to Map

Recently I have conversation with a colleague about what would be the optimal way to convert List to Map in Java and if there any specific benefits of doing so. I want to know optimal conversion approach and would really appreciate if any one can gu...

SQL Server: Is it possible to insert into two tables at the same time?

My database contains three tables called Object_Table, Data_Table and Link_Table. The link table just contains two columns, the identity of an object record and an identity of a data record. I want to copy the data from DATA_TABLE where it is linked...

Simplest way to form a union of two lists

What is the easiest way to compare the elements of two lists say A and B with one another, and add the elements which are present in B to A only if they are not present in A? To illustrate, Take list A = {1,2,3} list B = {3,4,5} So after the operat...

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

Capitalize the first letter of string in AngularJs

I want capitalize first character of string in angularjs As i used {{ uppercase_expression | uppercase}} it convert whole string to upper case....

Replace \n with <br />

I'm parsing text from file with Python. I have to replace all newlines (\n) with cause this text will build html-content. For example, here is some line from file: 'title\n' Now I do: thatLine.replace('\n', '<br />') print thatLine And I...

Java 8 forEach with index

Is there a way to build a forEach method in Java 8 that iterates with an index? Ideally I'd like something like this: params.forEach((idx, e) -> query.bind(idx, e)); The best I could do right now is: int idx = 0; params.forEach(e -> { que...

AngularJS custom filter function

Inside my controller, I would like to filter an array of objects. Each of these objects is a map which can contain strings as well as lists I tried using $filter('filter')(array, function) format but I do not know how to access the individual elemen...

Use nginx to serve static files from subdirectories of a given directory

I have several sets of static .html files on my server, and I would like use nginx to serve them directly. For example, nginx should serve an URI of the following pattern: www.mysite.com/public/doc/foo/bar.html with the .html file that is located ...

Adding a caption to an equation in LaTeX

Well, it seems simple enough, but I can't find a way to add a caption to an equation. The caption is needed to explain the variables used in the equation, so some kind of table-like structure to keep it all aligned and pretty would be great....

How to sort a List of objects by their date (java collections, List<Object>)

private List<Movie> movieItems = null; public List<Movie> getMovieItems() { final int first = 0; if (movieItems == null) { getPagingInfo(); movieItems = jpaController.findRange(new int[]{pagingInfo.getFirstItem(), ...

Is it possible to use std::string in a constexpr?

Using C++11, Ubuntu 14.04, GCC default toolchain. This code fails: constexpr std::string constString = "constString"; error: the type ‘const string {aka const std::basic_string}’ of constexpr variable ‘constString’ is not literal... ...

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

Basically, I like the way that <input type="submit"> is styled, with the clickable button when you add a little CSS. However, regular buttons are not styled as such, they have no such clickability without some major CSS or JS, and you have to u...

Certificate has either expired or has been revoked

A while ago I started coding a new ios app, after a long break from it, I'm working on it again and have it almost complete. I test it on the simulator but when I tried to install it on my iphone 6 (something I have already done in the past) I got a...

Spring schemaLocation fails when there is no internet connection

I am using Spring and in application-context.xml I have the following definitions: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ...

Convert string to integer type in Go?

I'm trying to convert a string returned from flag.Arg(n) to an int. What is the idiomatic way to do this in Go?...

SecurityError: The operation is insecure - window.history.pushState()

I'm getting this error in Firefox's Console: SecurityError: The operation is insecure and the guilty is HTML5 feature: window.history.pushState() when I try to load something with AJAX. It is supposed to load some data but Javascript stops executing ...

CSS background image alt attribute

This is one I have not had to tackle before. I need to use alt tags on all images in a site including those used by CSS background-image attribute. There is no CSS property like this as far as I know, so what is the best way to do this please?...

Setting "checked" for a checkbox with jQuery

I'd like to do something like this to tick a checkbox using jQuery: $(".myCheckBox").checked(true); or $(".myCheckBox").selected(true); Does such a thing exist?...

PHP: How to remove all non printable characters in a string?

I imagine I need to remove chars 0-31 and 127, Is there a function or piece of code to do this efficiently....

Using iText to convert HTML to PDF

Does anyone know if it is possible to convert a HTML page (url) to a PDF using iText? If the answer is 'no' than that is OK as well since I will stop wasting my time trying to work it out and just spend some money on one of a number of components wh...

Reading PDF content with itextsharp dll in VB.NET or C#

How can I read PDF content with the itextsharp with the Pdfreader class. My PDF may include Plain text or Images of the text....

How do I use setsockopt(SO_REUSEADDR)?

I am running my own http server on a raspberry pi. The problem is when I stop the program and restart it, the port is no longer available. Sometimes I get the same issue when receiving lots of requests. I want to use SO_REUSEADDR so that I can keep u...

The easiest way to transform collection to array?

Suppose we have a Collection<Foo>. What is the best (shortest in LoC in current context) way to transform it to Foo[]? Any well-known libraries are allowed. UPD: (one more case in this section; leave comments if you think it's worth to create ...

How do I check two or more conditions in one <c:if>?

How do I check two conditions in one <c:if>? I tried this, but it raises an error: <c:if test="${ISAJAX == 0} && ${ISDATE == 0}"> ...

Android ListView with Checkbox and all clickable

Possible Duplicate: Android: Binding data from a database to a CheckBox in a ListView? i want to use a ListView with the items having following layout ------------------------- [CB] TV TV ------------------------- CB is ...

getString Outside of a Context or Activity

I've found the R.string pretty awesome for keeping hardcoded strings out of my code, and I'd like to keep using it in a utility class that works with models in my application to generate output. For instance, in this case I am generating an email fro...

How to check if a double value has no decimal part

I have a double value which I have to display at my UI. Now the condition is that the decimal value of double = 0 eg. - 14.0 In that case I have to show only 14 on my UI. Also, the max limit for characters is 5 here. eg.- 12.34 the integer value ca...

How do you write to a folder on an SD card in Android?

I am using the following code to download a file from my server then write it to the root directory of the SD card, it all works fine: package com.downloader; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import j...

Retrieve data from website in android app

How can we retrieve data from a website and parse it into a readable format in the Android application? This means I want to extract data from website and use it in my android application, formatted in my way. It could be any website....

Read a XML (from a string) and get some fields - Problems reading XML

I have this XML (stored in a C# string called myXML) <?xml version="1.0" encoding="utf-16"?> <myDataz xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <listS> <sog> ...


How to access the first property of a Javascript object?

Is there an elegant way to access the first property of an object... where you don't know the name of your properties without using a loop like for .. in or jQuery's $.each For example, I need to access foo1 object without knowing the name of foo...

Sorting a Dictionary in place with respect to keys

I have a dictionary in C# like Dictionary<Person, int> and I want to sort that dictionary in place with respect to keys (a field in class Person). How can I do it? Every available help on the internet is that of lists with no particular exam...

No 'Access-Control-Allow-Origin' header is present on the requested resource- AngularJS

XMLHttpRequest cannot load http://mywebservice. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access. I get this error when I try to run my web-service from ins...

How do you use "git --bare init" repository?

I need to create a central Git repository but I'm a little confused... I have created a bare repository (in my git server, machine 2) with: $ mkdir test_repo $ git --bare init Now I need to push files from my local repository (machine 1) to the b...

PHP Sort a multidimensional array by element containing date

I have an array such as: Array ( [0] => Array ( [id] => 2 [type] => comment [text] => hey [datetime] => 2010-05-15 11:29:45 ) [1] => Array ( [id] => 3 [type] => sta...

How to tell which commit a tag points to in Git?

I have a bunch of unannotated tags in the repository and I want to work out which commit they point to. Is there a command that that will just list the tags and their commit SHAs? Checking out the tag and looking at the HEAD seems a bit too laborious...

How to get text with Selenium WebDriver in Python

I'm trying to get text using Selenium WebDriver and here is my code. Please note that I don't want to use XPath, because in my case the ID gets changed on every relaunch of the web page. My code: text = driver.find_element_by_class_name("current...

jquery: get value of custom attribute

html5 supports the placeholder attribute on input[type=text] elements, but I need to handle non-compliant browsers. I know there are a thousand plugins out there for placeholder but I'd like to create the 1001st. I am able to get a handle on the i...

How to view the SQL queries issued by JPA?

When my code issues a call like this: entityManager.find(Customer.class, customerID); How can I see the SQL query for this call? Assuming I don't have access to database server to profile/monitor the calls, is there way to log or view within my ...

How do I remove a single breakpoint with GDB?

I can add a breakpoint in GDB with: b <filename>:<line no> How can I remove an existing breakpoint at a particular location?...

Split string into individual words Java

I would like to know how to split up a large string into a series of smaller strings or words. For example: I want to walk my dog. I want to have a string: "I", another string:"want", etc. How would I do this?...

phpmyadmin.pma_table_uiprefs doesn't exist

I searched the internet but cannot find anything related to this specific error/table. It pops up when I try to view a table in phpMyAdmin. I am logged in as root and the installation (under ubuntu 13.10) of phpMyAdmin is fresh and untouched so far. ...

How to change plot background color?

I am making a scatter plot in matplotlib and need to change the background of the actual plot to black. I know how to change the face color of the plot using: fig = plt.figure() fig.patch.set_facecolor('xkcd:mint green') My issue is that this c...

Maven: Non-resolvable parent POM

I have my maven project setup as 1 shell projects and 4 children modules. When I try to build the shell. I get: [INFO] Scanning for projects... [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project module1:1.0_A0 (...

Open a folder using Process.Start

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

How do I draw a set of vertical lines in gnuplot?

E.g. if I have a graph and want to add vertical lines at every 10 units along the X-axis....

Reactjs - setting inline styles correctly

I am trying to use Reactjs with a kendo splitter. The splitter has a style attribute like style="height: 100%" With Reactjs, if I have understood things correctly, this can be implemented using an inline style var style = { height: 100 } Howe...

Check if xdebug is working

Without installing a texteditor or an IDE, is it possible to test if xdebug is working, i.e. if it can debug php code? The only part xdebug comes up in phpinfo() is the following: Additional .ini files parsed /etc/php5/apache2/conf.d/mysql.ini,...

VBA - If a cell in column A is not blank the column B equals

I'm looking for some code that will look at Column A and as long as the cell in Column A is not blank, then the corresponding cell in Column B will equal a specific value. So if Cell A1 <> "" then Cell B1.Value = "MyText" And repeat until a cell ...

TypeError: 'in <string>' requires string as left operand, not int

Why am I getting this error in the very basic Python script? What does the error mean? Error: Traceback (most recent call last): File "cab.py", line 16, in <module> if cab in line: TypeError: 'in <string>' requires string as left...

Set TextView text from html-formatted string resource in XML

I have some fixed strings inside my strings.xml, something like: <resources> <string name="somestring"> <B>Title</B><BR/> Content </string> </resources> and in my layout I've got a ...

Type converting slices of interfaces

I'm curious why Go does't implicitly convert []T to []interface{} when it will implicitly convert T to interface{}. Is there something non-trivial about this conversion that I'm missing? Example: func foo([]interface{}) { /* do something */ } f...

How to find the socket connection state in C?

I have a TCP connection. Server just reads data from the client. Now, if the connection is lost, the client will get an error while writing the data to the pipe (broken pipe), but the server still listens on that pipe. Is there any way I can find if ...

Reverse engineering from an APK file to a project

I accidently erased my project from Eclipse, and all I have left is the APK file which I transferred to my phone. Is there a way to reverse the process of exporting an application to the .apk file, so I can get my project back?...

Run command on the Ansible host

Is it possible to run commands on the Ansible host? My scenario is that I want to take a checkout from a git server that is hosted internally (and isn't accessible outside the company firewall). Then I want to upload the checkout (tarballed) to the ...

Service located in another namespace

I have been trying to find a way to define a service in one namespace that links to a Pod running in another namespace. I know that containers in a Pod running in namespaceA can access serviceX defined in namespaceB by referencing it in the cluster ...

Get Cell Value from a DataTable in C#

Here is a DataTable dt, which has lots of data. I want to get the specific Cell Value from the DataTable, say Cell[i,j]. Where, i -> Rows and j -> Columns. I will iterate i,j's value with two forloops. But I can't figure out how I can call a cell...

Hidden features of Windows batch files

What are some of the lesser know, but important and useful features of Windows batch files? Guidelines: One feature per answer Give both a short description of the feature and an example, not just a link to documentation Limit answers to native fu...

When to use extern in C++

I'm reading "Think in C++" and it just introduced the extern declaration. For example: extern int x; extern float y; I think I understand the meaning (declaration without definition), but I wonder when it proves useful. Can someone provide an e...

I don't understand -Wl,-rpath -Wl,

For convenience I added the relevant manpages below. My (mis)understanding first: If I need to separate options with ,, that means that the second -Wl is not another option because it comes before , which means it is an argument to the -rpath optio...

javascript change background color on click

Can you show me Javascript that allows you to change the background color of the page to another color. For example, I have a blue background color and I want to change it to green. The color must be changed when the user presses a button that trigge...

Constructor overloading in Java - best practice

There are a few topics similar to this, but I couldn't find one with a sufficient answer. I would like to know what is the best practice for constructor overloading in Java. I already have my own thoughts on the subject, but I'd like to hear more ad...

Git reset --hard and push to remote repository

I had a repository that had some bad commits on it (D, E and F for this example). A-B-C-D-E-F master and origin/master I've modified the local repository specifically with a git reset --hard. I took a branch before the reset so now I have a re...

Sequence contains more than one element

I'm having some issues with grabbing a list of type "RhsTruck" through Linq and getting them to display. RhsTruck just has properites Make, Model, Serial etc... RhsCustomer has properties CustomerName, CustomerAddress, etc... I keep getting the er...

How do I add 24 hours to a unix timestamp in php?

I would like to add 24 hours to the timestamp for now. How do I find the unix timestamp number for 24 hours so I can add it to the timestamp for right now? I also would like to know how to add 48 hours or multiple days to the current timestamp. H...

How do you uninstall the package manager "pip", if installed from source?

I was unaware that pip could be installed via my operating system's package manager, so I compiled and installed pip via source with the following command: wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | sudo python I w...

Splitting a string into chunks of a certain size

Suppose I had a string: string str = "1111222233334444"; How can I break this string into chunks of some size? e.g., breaking this into sizes of 4 would return strings: "1111" "2222" "3333" "4444" ...

Removing white space around a saved image in matplotlib

I need to take an image and save it after some process. The figure looks fine when I display it, but after saving the figure, I got some white space around the saved image. I have tried the 'tight' option for savefig method, did not work either. The ...

python: urllib2 how to send cookie with urlopen request

I am trying to use urllib2 to open url and to send specific cookie text to the server. E.g. I want to open site Solve chess problems, with a specific cookie, e.g. search=1. How do I do it? I am trying to do the following: import urllib2 (need to a...

How do I perform the SQL Join equivalent in MongoDB?

How do I perform the SQL Join equivalent in MongoDB? For example say you have two collections (users and comments) and I want to pull all the comments with pid=444 along with the user info for each. comments { uid:12345, pid:444, comment="blah" ...

How can I initialise a static Map?

How would you initialise a static Map in Java? Method one: static initialiser Method two: instance initialiser (anonymous subclass) or some other method? What are the pros and cons of each? Here is an example illustrating the two methods: import...

Get the time difference between two datetimes

I know I can do anything and some more envolving Dates with momentjs. But embarrassingly, I'm having a hard time trying to do something that seems simple: geting the difference between 2 times. Example: var now = "04/09/2013 15:00:00"; var then = ...

how to split the ng-repeat data with three columns using bootstrap

I am using ng-repeat with my code I have 'n' number of text box based on ng-repeat. I want to align the textbox with three columns. this is my code <div class="control-group" ng-repeat="oneExt in configAddr.ext"> {{$index+1}}. <in...

How to generate a unique hash code for string input in android...?

I wanted to generate a unique hash code for a string in put in android. Is there any predefined library is there or we have to generate manually. Please any body if knows please present a link or a code stuff....

Get first key in a (possibly) associative array?

What's the best way to determine the first key in a possibly associative array? My first thought it to just foreach the array and then immediately breaking it, like this: foreach ($an_array as $key => $val) break; Thus having $key contain the f...

Calculate the execution time of a method

Possible Duplicate: How do I measure how long a function is running? I have an I/O time-taking method which copies data from a location to another. What's the best and most real way of calculating the execution time? Thread? Timer? Stopwatc...

Checking for #N/A in Excel cell from VBA code

I'm iterating through a range of cells which hold numbers with 2 decimal places. I need to check if the cell holds '#N/A', and if it does, I need to skip it. The problem is, when a cell holds a valid number, my if condition below throws a 'Type misma...

pandas dataframe columns scaling with sklearn

I have a pandas dataframe with mixed type columns, and I'd like to apply sklearn's min_max_scaler to some of the columns. Ideally, I'd like to do these transformations in place, but haven't figured out a way to do that yet. I've written the followi...

How to insert array of data into mysql using php

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

How to use foreach with a hash reference?

I have this code foreach my $key (keys %ad_grp) { # Do something } which works. How would the same look like, if I don't have %ad_grp, but a reference, $ad_grp_ref, to the hash?...

ORA-28000: the account is locked error getting frequently

I am getting the error : ORA-28000: the account is locked Is this a DB Issue? When I unlock user account using the command ALTER USER username ACCOUNT UNLOCK temporarily it will be OK. Then after some time the same account lock happens again. T...

Get current date in Swift 3?

How can I set label.text current date in Swift 3? I want to print just today to the screen. I did not find how to do that. In c# is very simple: var date = DateTime.Now I need to write 15.09.2016 in swift 3. thanks...

Activity, AppCompatActivity, FragmentActivity, and ActionBarActivity: When to Use Which?

I'm coming from iOS where it's easy and you simply use a UIViewController. However, in Android things seem much more complicated, with certain UIComponents for specific API Levels. I'm reading BigNerdRanch for Android (the book is roughly 2 years old...

Parser Error: '_Default' is not allowed here because it does not extend class 'System.Web.UI.Page' & MasterType declaration

I recently converted a website project to a web application project in Visual Studio 2008. I finally got it to compile, and the first page (the login screen) displayed as normal, but then when it redirected to the Default.aspx page, I received an er...

Get ID from URL with jQuery

I've got a url like this: http://www.site.com/234234234 I need to grab the Id after /, so in this case 234234234 How can i do this easily?...

Git merge develop into feature branch outputs "Already up-to-date" while it's not

I checked out a feature branch from develop called branch-x. After a while other people pushed changes to the develop branch. I want to merge those changes into my branch-x. However if I do git merge develop it says "Already up-to-date" and do...

Of Countries and their Cities

I need a database of Countries and their Cities. Any idea where I can get such a list?...

How to use basic authorization in PHP curl

I am having problem with PHP curl request with basic authorization. Here is the command line curl: curl -H "Accept: application/product+xml" "https://{id}:{api_key}@api.domain.com/products?limit=1&offset=0" I have tried by setting curl header...

using nth-child in tables tr td

<table> <tr> <th>&nbsp;</th> <td>$</td> <td>&nbsp;</td> </tr> <tr> <th>&nbsp;</th> <td>$</td> <td>&nbsp;</td>...

How to asynchronously call a method in Java

I've been looking at Go's goroutines lately and thought it would be nice to have something similar in Java. As far as I've searched the common way to parallelize a method call is to do something like: final String x = "somethingelse"; new Thread(new...

Send HTTP POST message in ASP.NET Core using HttpClient PostAsJsonAsync

I want to send dynamic object like new { x = 1, y = 2 }; as body of HTTP POST message. So I try to write var client = new HttpClient(); but I can't find method client.PostAsJsonAsync() So I tried to add Microsoft.AspNetCore.Http.Extensions ...

Multiple file extensions in OpenFileDialog

How can I use multiple file extensions within one group using OpenFileDialog? I have Filter = "BMP|*.bmp|GIF|*.gif|JPG|*.jpg|PNG|*.png|TIFF|*.tiff" and I want to create groups so JPG are *.jpg and *.jpeg, TIFF are *.tif and *.tiff and also 'All graph...

Use jQuery to navigate away from page

I will only have a relative link available to me but I want to use jQuery to navigate to this rel link. I only see AJAX functionality in jQuery. How can I do this using jQuery or just pure HTML/JavaScript?...

Git 'fatal: Unable to write new index file'

I've seen many of the other threads about this and they don't help. I have a very simple repo - two JavaScript files. I have 100+ GB on Macbook. When I try to move the files into a subdirectory and stage locally the changes I get ... fatal: Unab...

application/x-www-form-urlencoded or multipart/form-data?

In HTTP there are two ways to POST data: application/x-www-form-urlencoded and multipart/form-data. I understand that most browsers are only able to upload files if multipart/form-data is used. Is there any additional guidance when to use one of the ...

How can I add a variable to console.log?

I'm making a simple game in JavaScript but in the story I need it to say the players name. so what I have so far is: var name = prompt("what is your name?"); console.log("story" name "story); how do I do the second line? or there is another way I...

Maximum value of maxRequestLength?

If we are using IIS 7 and .Net Framework 4, what will be the maximum value of maxRequestLength?...

PHP random string generator

I'm trying to create a randomized string in PHP, and I get absolutely no output with this: <?php function RandomString() { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $randstring = ''; ...

How to encode a URL in Swift

This is my URL. The problem is, that the address field is not being appended to urlpath. Does anyone know why that is? var address:string address = "American Tourister, Abids Road, Bogulkunta, Hyderabad, Andhra Pradesh, India" let urlpath = NSStr...

Express.js Response Timeout

PROBLEM I've been looking for request/response timeouts for Express.js but everything seems to be related to the connection rather than the request/response itself. If a request is taking a long time, it should be timed out. Obviously this shouldn'...

can't start MySql in Mac OS 10.6 Snow Leopard

I've googled this and could'nt find anything new and useful for Apple's new OS SnowLeopard. I wonder if this is my mistake or I do need to do something? this is what I did: Downloaded from mysql site: http://dev.mysql.com/downloads/mysql/5.1.html#m...

How can I execute PHP code from the command line?

I would like to execute a single PHP statement like if(function_exists("my_func")) echo 'function exists'; directly with the command line without having to use a separate PHP file. How is it possible?...

Generate random numbers with a given (numerical) distribution

I have a file with some probabilities for different values e.g.: 1 0.1 2 0.05 3 0.05 4 0.2 5 0.4 6 0.2 I would like to generate random numbers using this distribution. Does an existing module that handles this exist? It's fairly simple to code on ...

Get specific ArrayList item

public static ArrayList mainList = someList; How can I get a specific item from this ArrayList? mainList[3]?...

In Javascript, how do I check if an array has duplicate values?

Possible Duplicate: Easiest way to find duplicate values in a javascript array How do I check if an array has duplicate values? If some elements in the array are the same, then return true. Otherwise, return false. ['hello','goodbye','he...

Regex find word in the string

In general terms I want to find in the string some substring but only if it is contained there. I had expression : ^.*(\bpass\b)?.*$ And test string: high pass h3 When I test the string via expression I see that whole string is found (but gro...

How do I call a non-static method from a static method in C#?

I have the following code, I want to call data1() from data2(). Is this possible in C#? If so, how? private void data1() { } private static void data2() { data1(); //generates error } ...

Copying formula to the next row when inserting a new row

I have a row in which there are formulas using values of the same row. The next row is empty, just with a different background color. Now, if I insert a new row (by right-clicking on the empty row and "insert"), I get a new row with NO background co...

TypeScript, Looping through a dictionary

In my code, I have a couple of dictionaries (as suggested here) which is String indexed. Due to this being a bit of an improvised type, I was wondering if there any suggestions on how I would be able to loop through each key (or value, all I need the...

Re-ordering factor levels in data frame

I have a data.frame as shown below: task measure right m1 left m2 up m3 down m4 front m5 back m6 . . . The task column takes only six different values, which are treated as factors, and are ordered by R as: "back", "down", "fr...

Make function wait until element exists

I'm trying to add a canvas over another canvas – how can I make this function wait to start until the first canvas is created? function PaintObject(brush) { this.started = false; // get handle of the main canvas, as a DOM object, not as ...

how to check for datatype in node js- specifically for integer

I tried the following to check for the datatype (specifically for integer), but not working. var i = "5"; if(Number(i) = 'NaN') { console.log('This is not number')); } ...

Test if a string contains any of the strings from an array

How do I test a string to see if it contains any of the strings from an array? Instead of using if (string.contains(item1) || string.contains(item2) || string.contains(item3)) ...

How do you create a foreign key relationship in a SQL Server CE (Compact Edition) Database?

Visual Studio 2005 doesn't provide an interface for creating relationships between tables in a SQL Server CE database (I'm using version 3.0) and you can't open a Compact Edition DB using Management Studio as far as I know. Any ideas?...

How to determine CPU and memory consumption from inside a process?

I once had the task of determining the following performance parameters from inside a running application: Total virtual memory available Virtual memory currently used Virtual memory currently used by my process Total RAM available RAM currently us...

Batch file to run a command in cmd within a directory

I want to have a batch file(must be placed on desktop) which does the following; opens cmd navigates to a directory, e.g. C:\activiti-5.9\setup runs a command within the directory, e.g. ant demo.start (this command runs the activiti server) I tri...

Batch file to copy directories recursively

Is there a way to copy directories recursively inside a .bat file? If so, an example would be great. thanks....

Maven:Non-resolvable parent POM and 'parent.relativePath' points at wrong local POM

I am using maven 3 to run the application but I am getting the following error: [ERROR] The build could not read 1 project -> [Help 1] org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs: [F...

Can you target <br /> with css?

Is it possible to target the line-break <br/> tag with CSS? I would like to have a 1px dashed line every time there is a line-break. I am customising a site with my own CSS and cannot change the set HTML, otherwise I would use some other way....

Add default value of datetime field in SQL Server to a timestamp

I've got a table that collects forms submitted from our website, but for some reason, when they created the table, they didn't put a timestamp in the table. I want it to enter the exact date and time that the record was entered. I know it's in there...

Do HTTP POST methods send data as a QueryString?

I'd like to know if the POST method on HTTP sends data as a QueryString, or if it use a special structure to pass the data to the server. In fact, when I analyze the communication with POST method from client to server (with Fiddler for example), I...

C# Threading - How to start and stop a thread

Can anyone give me a headstart on the topic of threading? I think I know how to do a few things but I need to know how to do the following: Setup a main thread that will stay active until I signal it to stop(in case you wonder, it will terminate whe...

PHP Parse error: syntax error, unexpected '?' in helpers.php 233

When I create a new Laravel project, the browser displays an error 500. I found this in the log: PHP Parse error: syntax error, unexpected '?' in vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 233 the code in 233 is: r...

Creating a Shopping Cart using only HTML/JavaScript

I'm not sure what to do in order to complete this project. I need to create a shopping cart that uses only one HTML page. I have the table set up showing what is being sold but where I am lost is the JavaScript. I don't know how to link the "Add t...

Detecting a mobile browser

I'm looking for a function which return boolean value if user has mobile browser or not. I know that I can use navigator.userAgent and write that function by using regex, but user-agents are too various for different platforms. I doubt that match al...

Syntax of for-loop in SQL Server

What is the syntax of a for loop in TSQL?...

Java Currency Number format

Is there a way to format a decimal as following: 100 -> "100" 100.1 -> "100.10" If it is a round number, omit the decimal part. Otherwise format with two decimal places....

Inline labels in Matplotlib

In Matplotlib, it's not too tough to make a legend (example_legend(), below), but I think it's better style to put labels right on the curves being plotted (as in example_inline(), below). This can be very fiddly, because I have to specify coordinate...

How to push files to an emulator instance using Android Studio

How am I able to push .txt files to the emulator using Android Studio?...

extract the date part from DateTime in C#

The line of code DateTime d = DateTime.Today; results in 10/12/2011 12:00:00 AM. How can I get only the date part.I need to ignore the time part when I compare two dates. ...

Unable to connect to mongodb Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112

When ever I try to connect to mongo db I always get this error as below. MongoDB shell version: 2.4.3 connecting to: test Fri Apr 26 14:31:46.941 JavaScript execution failed: Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mong...

What is the purpose of the return statement?

What is the simple basic explanation of what the return statement is, how to use it in Python? And what is the difference between it and the print statement?...

Build tree array from flat array in javascript

I have a complex json file that I have to handle with javascript to make it hierarchical, in order to later build a tree. Every entry of the json has : id : a unique id, parentId : the id of the parent node (which is 0 if the node is a root of the t...

Use xml.etree.ElementTree to print nicely formatted xml files

I am trying to use xml.etree.ElementTree to write out xml files with Python. The issue is that they keep getting generated in a single line. I want to be able to easily reference them so if it's possible I would really like to be able to have the fil...

How to install cron

I want to run PHP scripts automatically on a schedule. I learned about CRON recently. But I don't know how to install and use it. I'm using PHP, CSS, HTML, and running on XAMP apache server on localhost. How do I install and use Cron?...

How to drop a unique constraint from table column?

I have a table 'users' with 'login' column defined as: [login] VARCHAR(50) UNIQUE NOT NULL Now I want to remove this unique constraint/index using SQL script. I found its name UQ_users_7D78A4E7 in my local database but I suppose it has a different...

How to create virtual column using MySQL SELECT?

If I do SELECT a AS b and b is not a column in the table, would query create the "virtual" column? in fact, I need to incorporate some virtual column into the query and process some information into the query so I can use it with each item later on....

How to read and write into file using JavaScript?

Can anybody give some sample code to read and write a file using JavaScript?...

How to make <a href=""> link look like a button?

I have this button image: I was wondering whether it would be possible to make a simple <a href="">some words</a> and style that link to appear as that button? If it is possible, how do I do that?...

How can I have same rule for two locations in NGINX config?

How can I have same rule for two locations in NGINX config? I have tried the following server { location /first/location/ | /second/location/ { .. .. } } but nginx reload threw this error: nginx: [emerg] invalid number of arguments in "l...

How to add background image for input type="button"?

i've been trying to change the background image of the input button through css, but it doesn't work. search.html: <body> <form name="myform" class="wrapper"> <input type="text" name="q" onkeyup="showUser()" /> ...

AngularJS : Custom filters and ng-repeat

I'm an AngularJS newbie and I'm building up a small proof-of-concept car hire listings app that pulls in some JSON and renders out various bits of that data via an ng-repeat, with a couple of filters: <article data-ng-repeat="result in results...

Phonegap Cordova installation Windows

The documentation for phonegap/cordova is absolutely horrible. All I'm trying to do is install PhoneGap 3.0 on my Windows environment but having no success. Below are my steps and points of failure. Can anyone advise on solutions? According to th...

How to write text on a image in windows using python opencv2

I want to put some text on an Image. I am writing the code as: cv2.putText(image,"Hello World!!!", (x,y), cv2.CV_FONT_HERSHEY_SIMPLEX, 2, 255) It gives ERROR, saying 'module' object has no attribute 'CV_FONT_HERSHEY_SIMPLEX' Query Can't I use the...

Laravel - Route::resource vs Route::controller

I read the docs on the Laravel website, Stack Overflow, and Google but still don't understand the difference between Route::resource and Route::controller. One of the answers said Route::resource was for crud. However, with Route::controller we can...

How to open Form in Add record

I have a form to input records to a table. I would like it to open on an empty add (New) instead of displaying the first record of the table. To be used by a Navigation Form which opens the input form from a button....

Get Maven artifact version at runtime

I have noticed that in a Maven artifact's JAR, the project.version attribute is included in two files: META-INF/maven/${groupId}/${artifactId}/pom.properties META-INF/maven/${groupId}/${artifactId}/pom.xml Is there a recommended way to read this v...

Internet Explorer 11 disable "display intranet sites in compatibility view" via meta tag not working

I have been working on an intranet website for over 6 months were I have been using the below html5 doctype and edge compatibility meta tag to force Internet Explorer to not emulate an older browser version, and this has worked ok. <!DOCTYPE html...

Validating input using java.util.Scanner

I'm taking user input from System.in using a java.util.Scanner. I need to validate the input for things like: It must be a non-negative number It must be an alphabetical letter ... etc What's the best way to do this?...

Using PHP Replace SPACES in URLS with %20

I'm looking to replace all instances of spaces in urls with %20. How would I do that with regex? Thank you!...

How to read first N lines of a file?

We have a large raw data file that we would like to trim to a specified size. I am experienced in .net c#, however would like to do this in python to simplify things and out of interest. How would I go about getting the first N lines of a text file i...

How to get UTC timestamp in Ruby?

How to get UTC timestamp in Ruby?...

req.query and req.param in ExpressJS

Main differences between req.query and req.param in Express How are Both different from each other When to use then in what cases Suppose a client sends say Android (Key,value) pair in the request ........ which one to use ? [EDIT] Suppose and...

How to add minutes to my Date

I have this date object: SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd HH:mm"); Date d1 = df.parse(interviewList.get(37).getTime()); value of d1 is Fri Jan 07 17:40:00 PKT 2011 Now I am trying to add 10 minutes to the date above. Calend...

bootstrap datepicker today as default

I am using this bootstrap-datepicker for my datepicker. I'd like the datepicker to choose "today" for start day or default day. I cannot figure out how to set "today" automatically, so I did an inefficient way HTML: <input type="text" value ="...

Inline IF Statement in C#

How will I write an Inline IF Statement in my C# Service class when setting my enum value according to what the database returned? For example: When the database value returned is 1 then set the enum value to VariablePeriods, when 2 then FixedPeriod...

Remove Style on Element

I was wondering if this is possible. There's this element <div id="sample_id" style="width:100px; height:100px; color:red;"> So I want to remove width:100px; and height:100px; the result would be <div id="sample_id" style="color:red;"...

Why does 2 mod 4 = 2?

I'm embarrassed to ask such a simple question. My term does not start for two more weeks so I can't ask a professor, and the suspense would kill me. Why does 2 mod 4 = 2?...

CSS Select box arrow style

I want to remove the default arrow from the select box and want to use custom icon. From the previous answers on SO, I have found out that it is not possible (to make it work with major browsers). Only possibility is to wrap the select inside a div, ...

How to print from Flask @app.route to python console

I would like to simply print a "hello world" to the python console after /button is called by the user. This is my naive approach: @app.route('/button/') def button_clicked(): print 'Hello world!' return redirect('/') Background: I would ...

Eclipse CDT: no rule to make target all

My Eclipse CDT keeps complaining "make: *** no rule to make target all" when I am trying to compile the piece of code below: #include <iostream> using namespace std; int main() { cout << "Hello World!!!" << endl; // prints Hel...

How to handle ETIMEDOUT error?

How to handle etimedout error on this call ? var remotePath = "myremoteurltocopy" var localStream = fs.createWriteStream("myfil");; var out = request({ uri: remotePath }); out.on('response', function (resp) { if (resp.s...

How can I create a dropdown menu from a List in Tkinter?

I am creating a GUI that builds information about a person. I want the user to select their birth month using a drop down bar, with the months configured earlier as a list format. from tkinter import * birth_month = [ 'Jan', 'Feb', 'Ma...

Sound effects in JavaScript / HTML5

I'm using HTML5 to program games; the obstacle I've run into now is how to play sound effects. The specific requirements are few in number: Play and mix multiple sounds, Play the same sample multiple times, possibly overlapping playbacks, Interrup...

How to get Linux console window width in Python

Is there a way in python to programmatically determine the width of the console? I mean the number of characters that fits in one line without wrapping, not the pixel width of the window. Edit Looking for a solution that works on Linux...

scp via java

What is the best method of performing an scp transfer via the Java programming language? It seems I may be able to perform this via JSSE, JSch or the bouncy castle java libraries. None of these solutions seem to have an easy answer....

How to use GROUP_CONCAT in a CONCAT in MySQL

If I have a table with the following data in MySQL: id Name Value 1 A 4 1 A 5 1 B 8 2 C 9 how do I get it into the following format? id Column 1 ...

Callback function for JSONP with jQuery AJAX

I didn't quite understand how to work with the callback for the ajax function of jQuery. I have the following code in the JavaScript: try { $.ajax({ url: 'http://url.of.my.server/submit?callback=?', cache: false, type: '...

ExecuteReader requires an open and available Connection. The connection's current state is Connecting

When attempting to connect to MSSQL database via ASP.NET online, I will get the following when two or more people connect simultaneously: ExecuteReader requires an open and available Connection. The connection's current state is Connecting. The...

PHP array value passes to next row

I have an array building multiple instances of the following fields: <div class="checkbox_vm"> <input type="hidden" name="fk_row[]" value="<?php echo $i; ?>"> <input type="hidden" name="fk_id[]" value="<?php echo $veh...

How to stretch the background image to fill a div

I want to set a background image to different divs, but my problems are: The size of image is fixed(60px). Varying div's size How can I stretch the background-image to fill the whole background of the div? #div2{ background-image:url(htt...

Calling a stored procedure in Oracle with IN and OUT parameters

I have this procedure: CREATE OR REPLACE PROCEDURE PROC1(invoicenr IN NUMBER, amnt OUT NUMBER) AS BEGIN SELECT AMOUNT INTO amnt FROM INVOICE WHERE INVOICE_NR = invoicenr; END; So when I run it like this it returns absolutely nothing: DECLARE ...

Get yesterday's date using Date

The following function produces today's date; how can I make it produce only yesterday's date? private String toDate() { DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); Date date = new Date(); return ...

Disable EditText blinking cursor

Does anyone know how to disable the blinking cursor in an EditText view?...

Reading a registry key in C#

I have developed an application and installed it on a client computer. In my application I need to get its installation path. My application has a registry entry at: HKEY_LOCAL_MACHINE\SOFTWARE\MyApplication\[AppPath] How can I read AppPath using...

Execute external program

I tried to make an application that calls an external program that I have to pass two parameters. It doesn't give any errors. The program.exe, written in C++, takes a picture and modifies the content of a .txt file. The Java program runs but it does ...

How to print binary tree diagram?

How can I print a binary tree in Java so that the output is like: 4 / \ 2 5 My node: public class Node<A extends Comparable> { Node<A> left, right; A data; public Node(A data){ this.data = data; } }...

Parsing JSON from XmlHttpRequest.responseJSON

I'm trying to parse a bit.ly JSON response in javascript. I get the JSON via XmlHttpRequest. var req = new XMLHttpRequest; req.overrideMimeType("application/json"); req.open('GET', BITLY_CREATE_API + encodeURIComponent(url) + BITLY_AP...

When is a timestamp (auto) updated?

If I have a column in a table of type TIMESTAMP and has as default: CURRENT_TIMESTAMP does this column get updated to the current timestamp if I update the value of any other column in the the same row? It seems that it does not but I am not sure if ...

What is a good way to handle exceptions when trying to read a file in python?

I want to read a .csv file in python. I don't know if the file exists. My current solution is below. It feels sloppy to me because the two separate exception tests are awkwardly juxtaposed. Is there a prettier way to do it? import csv fName = &...

How do I raise the same Exception with a custom message in Python?

I have this try block in my code: try: do_something_that_might_raise_an_exception() except ValueError as err: errmsg = 'My custom error message.' raise ValueError(errmsg) Strictly speaking, I am actually raising another ValueError, not...

Input and output numpy arrays to h5py

I have a Python code whose output is a sized matrix, whose entries are all of the type float. If I save it with the extension .dat the file size is of the order of 500 MB. I read that using h5py reduces the file size considerably. So, let's say I ha...

Is there a format code shortcut for Visual Studio?

In Eclipse there is a shortcut, Ctrl+Shift+F, that re-indents code and fixes comments and blank lines. Is there an equivalent for Visual Studio 2010?...

difference between @size(max = value ) and @min(value) @max(value)

I want to do some domain validation in my object I am having one integer, now my question is: if I write @Min(SEQ_MIN_VALUE) @Max(SEQ_MAX_VALUE) private Integer sequence; and @Size(min = 1, max = NAME_MAX_LENGTH) private Integer sequence; If it's...

SVG fill color transparency / alpha?

Is it possible to set a transparency or alpha level on SVG fill colours? I've tried adding two values to the fill tag (changing it from fill="#044B94" to fill="#044B9466"), but this doesn't work....

What's the meaning of System.out.println in Java?

Is this static println function in out class from System namespace? namespace System { class out { static println ... } How can I interpret this name? And where in JRE this function is defined? In java.lang.System/java.lang.Object?...

static constructors in C++? I need to initialize private static objects

I want to have a class with a private static data member (a vector that contains all the characters a-z). In java or C#, I can just make a "static constructor" that will run before I make any instances of the class, and sets up the static data member...

initialize a vector to zeros C++/C++11

I know in C++11 they added the feature to initialize a variable to zero as such double number = {}; // number = 0 int data{}; // data = 0 Is there a similar way to initialize a std::vector of a fixed length to all zero's?...

Scala check if element is present in a list

I need to check if a string is present in a list, and call a function which accepts a boolean accordingly. Is it possible to achieve this with a one liner? The code below is the best I could get: val strings = List("a", "b", "c") val myString = "a...

Visual Studio 2012 Web Publish doesn't copy files

I have a Web Application project in VS 2012 and when I use the web publishing tool it builds successfully but doesn't copy any files to the publish target (File System in this case). If I look at the build output I can see everything gets copied ove...

WampServer: php-win.exe The program can't start because MSVCR110.dll is missing

if I try to install WampServer the above error appears. I already tried to install all the programs which were recommended, for example here: WAMP shows error 'MSVCR100.dll' is missing when install But nothing helps. What can I do to install...

Bash if statement with multiple conditions throws an error

I'm trying to write a script that will check two error flags, and in case one flag (or both) are changed it'll echo-- error happened. My script: my_error_flag=0 my_error_flag_o=0 do something..... if [[ "$my_error_flag"=="1" || "$my_error_flag_o"=="...

Cannot drop database because it is currently in use

I want to drop a database. I have used the following code, but to no avail. public void DropDataBase(string DBName,SqlConnection scon) { try { SqlConnection.ClearAllPools(); SqlCommand cmd = new SqlCommand("ALTER DATABASE " +...

How to get client's IP address using JavaScript?

I need to somehow retrieve the client's IP address using JavaScript; no server side code, not even SSI. However, I'm not against using a free 3rd party script/service....

How can get the text of a div tag using only javascript (no jQuery)

I tried this but showing "undefined". function test() { var t = document.getElementById('superman').value; alert(t); } Is there any way to get the value using simple Javascript no jQuery Please!...

Retrieving a random item from ArrayList

I'm learning Java and I'm having a problem with ArrayList and Random. I have an object called catalogue which has an array list of objects created from another class called item. I need a method in catalogue which returns all the information on one...

Intellij IDEA Java classes not auto compiling on save

Yesterday I switched to IntelliJ IDEA from Eclipse. I am using JRebel with WebSphere Server 7 as well. Everything now seems to be working somewhat fine, except that when I modify a Java file, and hit save, IntelliJ does not re-compile the file, in...

Convert an integer to a float number

How do I convert an integer value to float64 type? I tried float(integer_value) But this does not work. And can't find any package that does this on Golang.org How do I get float64 values from integer values?...

Remote debugging Tomcat with Eclipse

I can't seem to debug the tomcat application through Eclipse. I've set CATALINA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n and then I run bin/catalina.sh, where I see output saying it's listening for dt_socket on p...

How to make a <svg> element expand or contract to its parent container?

The goal is to have the <svg> element expand to the size of its parent container, in this case a <div>, no matter how big or small that container may be. The code: <style> svg, #container{ height: 100%; width: ...

Disable Auto Zoom in Input "Text" tag - Safari on iPhone

I made an HTML page that has an <input> tag with type="text". When I click on it using Safari on iPhone, the page becomes larger (auto zoom). Does anybody know how to disable this?...

String "true" and "false" to boolean

I have a Rails application and I'm using jQuery to query my search view in the background. There are fields q (search term), start_date, end_date and internal. The internal field is a checkbox and I'm using the is(:checked) method to build the url th...

Visual Studio breakpoints not being hit

I'm working with an ASP.NET MVC project that seems to be having some issues when attaching to the IIS process (w3wp.exe). I'm running the solution and IIS 8.5 on my own local machine so I wouldn't think that this has anything to do with our network. ...

Correct way to import lodash

I had a pull request feedback below, just wondering which way is the correct way to import lodash? You'd better do import has from 'lodash/has'.. For the earlier version of lodash (v3) which by itself is pretty heavy, we should only import a ...

How to make shadow on border-bottom?

I need to apply the border shadow on border-bottom by CSS3. I just want to apply CSS3 shadow on bottom. Is this possible?...

AttributeError: module 'cv2.cv2' has no attribute 'createLBPHFaceRecognizer'

I am facing some attribute error while running face recognizing the code. My face detects code run perfectly.But while I try to run the face recognizing code it shows some attribute error. I googled and tried to follow all the steps. But still, it sh...

Make JQuery UI Dialog automatically grow or shrink to fit its contents

I have a JQuery UI dialog popup that displays a form. By selecting certain options on the form new options will appear in the form causing it to grow taller. This can lead to a scenario where the main page has a scrollbar and the JQuery UI dialog h...

Switching to a TabBar tab view programmatically?

Let's say I have a UIButton in one tab view in my iPhone app, and I want to have it open a different tab in the tab bar of the TabBarController. How would I write the code to do this? I'm assuming I unload the existing view and load a specific ta...

Permission denied: /var/www/abc/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable?

Hi all I'm using PHP for my website and ubuntu linux on my system. I got the above error in error.log file of apache, even after configurating everything properly. I did a lot of research on this but couldn't be able to resolve the issue. Can anyone ...

Property 'json' does not exist on type 'Object'

I'm trying fetch data via REST with angular 2 HttpClient. I'm following the angular tutorial here https://angular.io/tutorial/toh-pt6 and under the Heroes and HTTP section you'll see this snippet of code used to fetch hero data via http. getHeroes()...

Store output of subprocess.Popen call in a string

I'm trying to make a system call in Python and store the output to a string that I can manipulate in the Python program. #!/usr/bin/python import subprocess p2 = subprocess.Popen("ntpq -p") I've tried a few things including some of the suggestions...

XPath to return only elements containing the text, and not its parents

In this xml, I want to match, the element containing 'match' (random2 element) <root> <random1> <random2>match</random2> <random3>nomatch</random3> </random1> </root> ok, so far I have: //[re:...

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

When to use %r instead of %s in Python?

On Learn Python the Hard Way page 21, I see this code example: x = "There are %d types of people." % 10 ... print "I said: %r." % x Why is %r used here instead of %s? When would you use %r, and when would you use %s?...

How to create a service running a .exe file on Windows 2012 Server?

I have created .exe in .net and want to use as a service, run all time on my local machine. I am using windows server 2012. how to setup a service on my local computer. **You can use windows shell script for create service with commands ** The sc c...

Trying to start a service on boot on Android

I've been trying to start a service when a device boots up on android, but I cannot get it to work. I've looked at a number of links online but none of the code works. Am I forgetting something? AndroidManifest.xml <receiver android:name="....

command to remove row from a data frame

Possible Duplicate: How to delete a row in R I can't figure out how to simply remove row (n) from a dataframe in R. R's documentation and intro manual are so horribly written, they are virtually zero help on this very simple problem. Also,...

Apply global variable to Vuejs

I have a javascript variable which I want to pass globally to Vue components upon instantiation thus either each registered component has it as a property or it can be accessed globally. Note:: I need to set this global variable for vuejs as a READ ...

What is the first character in the sort order used by Windows Explorer?

For example, in a Windows folder, if we create some files and name them 1.html, 2.txt, 3.txt, photo.jpg, zen.png the order will be as is. But if we create another file with the name _file.doc it will be placed at the top. (considering we sort by name...

Converting String array to java.util.List

How do I convert a String array to a java.util.List?...

C char array initialization

I'm not sure what will be in the char array after initialization in the following ways. 1.char buf[10] = ""; 2. char buf[10] = " "; 3. char buf[10] = "a"; For case 2, I think buf[0] should be ' ', buf[1] should be '\0', and from buf[2] to buf...

How do I see the current encoding of a file in Sublime Text?

How do I see the current encoding of a file in Sublime Text? This seems like a pretty simple thing to do but searching has not yielded much. Any pointers would be appreciated!...

Greyscale Background Css Images

I've searched a lot on the web but I cannot find a cross browser solution to fade a css backgrund image to greyscale and back. The only working solution is to apply CSS3 filter greyscale: -webkit-filter: grayscale(100%); but this works just with ...

youtube: link to display HD video by default

Is there a way to link a youtube video so that it plays automatically in HD? I've tried several things (adding &hd=1, &vq=hd720) but none of them works For example: https://www.youtube.com/v/BH_lZSTYFHs&hd=1 It starts always as 480p, ...

How to playback MKV video in web browser?

I am trying to make a MKV video with a MPEG4 video codec and AC3 audio codec available to be played online using Mozilla or Chrome. I have tried multiple methods including native HTML5, which plays back the video but no audio and from what I've read ...

selenium get current url after loading a page

I'm using Selenium Webdriver in Java. I want to get the current url after clicking the "next" button to move from page 1 to page 2. Here's the code I have: WebDriver driver = new FirefoxDriver(); String startURL = //a starting url; Strin...