Examples On Programing Languages

NSDictionary - Need to check whether dictionary contains key-value pair or not

I just need to ask something as follow. Suppose I am having a dictionary. NSMutableDictionary *xyz=[[NSMutableDictionary alloc] init]; [xyz setValue:@"sagar" forKey:@"s"]; [xyz setValue:@"amit" forKey:@"a"]; [xyz setValue:@"nirav" forKey:@"n"]; [xyz...

UNC path to a folder on my local computer

What's the UNC path to a folder on my local computer, and how can I access it? I have tried: Security for the folder -- set to Everyone Full Control (for now!) Sharing permissions -- set to Everyone Full Control (for now!) I can see the folder in...

How to overwrite the output directory in spark

I have a spark streaming application which produces a dataset for every minute. I need to save/overwrite the results of the processed data. When I tried to overwrite the dataset org.apache.hadoop.mapred.FileAlreadyExistsException stops the execution...

Error: stray '\240' in program

It is wanted of me to implement the following function: void calc ( double* a, double* b, int r, int c, double (*f) (double) ) Parameters a, r, c and f are input and b is output. “a” and “b” are 2d matrices ...

How do I use the conditional operator (? :) in Ruby?

How is the conditional operator (? :) used in Ruby? For example, is this correct? <% question = question.size > 20 ? question.question.slice(0, 20)+"..." : question.question %> ...

Percentage calculation

I am working in progress bar concept in ASP.NET MVC 2. Here i have a DropDownList which has 10 values. i want to calculate the percentage for progress bar, e.g. 10 values from DropDownList and i am having a query which returns the value 2. so, out of...

What's the difference between HEAD^ and HEAD~ in Git?

When I specify an ancestor commit object in Git, I'm confused between HEAD^ and HEAD~. Both have a "numbered" version like HEAD^3 and HEAD~2. They seem very similar or the same to me, but are there any differences between the tilde and the caret?...

Where is shared_ptr?

I am so frustrated right now after several hours trying to find where shared_ptr is located. None of the examples I see show complete code to include the headers for shared_ptr (and working). Simply stating std, tr1 and <memory> is not helping ...

How to replace existing value of ArrayList element in Java

I am still quite new to Java programming and I am trying to update an existing value of an ArrayList by using this code: public static void main(String[] args) { List<String> list = new ArrayList<String>(); list.add( "Zero" ); ...

How to close this ssh tunnel?

I opened a ssh tunnel as described in this post: Zend_Db: How to connect to a MySQL database over SSH tunnel? But now I don't know what I actually did. Does this command affect anything on the server? And how do I close this tunnel, because now I ca...

Creating a ZIP archive in memory using System.IO.Compression

I'm trying to create a ZIP archive with a simple demo text file using a MemoryStream as follows: using (var memoryStream = new MemoryStream()) using (var archive = new ZipArchive(memoryStream , ZipArchiveMode.Create)) { var demoFile = archive.Cr...

finding multiples of a number in Python

I'm trying to write a code that lets me find the first few multiples of a number. This is one of my attempts: def printMultiples(n, m): for m in (n,m): print(n, end = ' ') I figured out that, by putting for m in (n, m):, it would run through t...

What is best way to start and stop hadoop ecosystem, with command line?

I see there are several ways we can start hadoop ecosystem, start-all.sh & stop-all.sh Which say it's deprecated use start-dfs.sh & start-yarn.sh. start-dfs.sh, stop-dfs.sh and start-yarn.sh, stop-yarn.sh hadoop-daemon.sh namenode/datanode...

Simultaneously merge multiple data.frames in a list

I have a list of many data.frames that I want to merge. The issue here is that each data.frame differs in terms of the number of rows and columns, but they all share the key variables (which I've called "var1" and "var2" in the code below). If the da...

How to fix/convert space indentation in Sublime Text?

Example: If I have a document with 2 space indentation, and I want it to have 4 space indentation, how do I automatically convert it by using the Sublime Text editor?...

Android Imagebutton change Image OnClick

I just added a new drawable folder under res folder. In the drawable folder, i copied the ic_launcher.png file from drawable-hdpi folder. I wanna change the standard ImageButton image through the new one when i press the button. I wrote some code, bu...

Cannot connect to repo with TortoiseSVN

I've been running a project for some months now using the same TortoiseSVN repository without much hassle, until now. I need to add another box to the project but it seems to be impossible for TSVN to connect to the repository. This is the stuff I'v...

Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' with pdo

$db = new PDO('mysql:dbname=xnews;host=localhost;port=' . $LOCAL_DB_PORT, $LOCAL_DB_USER, $LOCAL_DB_PASS, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'") ); reports: Undefined class constant ...

What's the difference between ".equals" and "=="?

I switched lecturers today and he stated using a weird code to me. (He said it's better to use .equals and when I asked why, he answered "because it is!") So here's an example: if (o1.equals(o2)) { System.out.println("Both integer objects are the ...

How to start Spyder IDE on Windows

I downloaded spyder using the pip install spyder in my windows 10 32-bit operating system, but i dont see any desktop icons or exe files to start running the IDE. I downloaded spyder 3, any my python is 3.6. I even tried creating a shortcut of spy...

How do you share constants in NodeJS modules?

Currently I'm doing this: foo.js const FOO = 5; module.exports = { FOO: FOO }; And using it in bar.js: var foo = require('foo'); foo.FOO; // 5 Is there a better way to do this? It feels awkward to declare the constant in the exports objec...

git push rejected: error: failed to push some refs

I know people have asked similar questions, but I believe the causes of their problems to be different. I did a hard reset because I had messed up my code pretty bad git reset --hard 41651df8fc9 I've made quite some changes, I've made some commi...

How to use SQL Order By statement to sort results case insensitive?

I have a SQLite database that I am trying to sort by Alphabetical order. The problem is, SQLite doesn't seem to consider A=a during sorting, thus I get results like this: A B C T a b c g I want to get: A a b B C c g T What special SQL thing need...

How to use null in switch

Integer i = ... switch (i){ case null: doSomething0(); break; } In the code above I cant use null in switch case statement. How can I do this differently? I can't use default because then I want to do something else....

How to find whether a number belongs to a particular range in Python?

Suppose I want to check if x belongs to range 0 to 0.5. How can I do it?...

Rotate a div using javascript

I want to click on one div and rotate another div then when the firsts div is clicked again the other div rotates back to its original position. I can reference this library if required http://ricostacruz.com/jquery.transit....

Question mark and colon in statement. What does it mean?

What do the question mark (?) and colon (:) mean? ((OperationURL[1] == "GET") ? GetRequestSignature() : "") It appears in the following statement: string requestUri = _apiURL + "?e=" + OperationURL[0] + ((OperationURL[1...

re.sub erroring with "Expected string or bytes-like object"

I have read multiple posts regarding this error, but I still can't figure it out. When I try to loop through my function: def fix_Plan(location): letters_only = re.sub("[^a-zA-Z]", # Search for all non-letters " ", ...

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 convert 2D float numpy array to 2D int numpy array?

How to convert real numpy array to int numpy array? Tried using map directly to array but it did not work....

Html.Raw() in ASP.NET MVC Razor view

@{int count = 0;} @foreach (var item in Model.Resources) { @(count <= 3 ? Html.Raw("<div class=\"resource-row\">").ToString() : Html.Raw("")) // some code @(count <= 3 ? Html.Raw("</div&g...

Formatting text in a TextBlock

How do I achieve formatting of a text inside a TextBlock control in my WPF application? e.g.: I would like to have certain words in bold, others in italic, and some in different colors, like this example: The reason behind my question is this act...

Comparing two files in linux terminal

There are two files called "a.txt" and "b.txt" both have a list of words. Now I want to check which words are extra in "a.txt" and are not in "b.txt". I need a efficient algorithm as I need to compare two dictionaries....

How do I upgrade the Python installation in Windows 10?

I have a Python 2.7.11 installed on one of my LAB stations. I would like to upgrade Python to at least 3.5. How should I do that ? Should I prefer to completely uninstall 2.7.11 and than install the new one ? Is there a way to update it ? Is an upda...

Uncaught TypeError: .indexOf is not a function

I am new to JavaScript and I'm getting an error as below. Uncaught TypeError: time.indexOf is not a function Gee, I really thought indexOf() really was a function. Here is a snippet of my code: var timeofday = new Date().getHours() + (new...

Microsoft Web API: How do you do a Server.MapPath?

Since Microsoft Web API isn't MVC, you cannot do something like this: var a = Request.MapPath("~"); nor this var b = Server.MapPath("~"); because these are under the System.Web namespace, not the System.Web.Http namespace. So how do you figur...

Display SQL query results in php

I'm tring to diplay results in php from sql database MySQL statement is correct and does what i want in phpMyAdmin but for some reason my code breaks in the webpage here is the code require_once('db.php'); $sql="SELECT * FROM modul1open WHERE...

Get Excel sheet name and use as variable in macro

I'm trying to find a way to use an Excel sheetname as a variable in a macro that I've written. Every month I deal with a workbook that is sent to me with 2 sheets. Part of the macro uses the 'Open File' interface to navigate to the folder and open th...

Query an object array using linq

I would like to know how can I query an array of objects. For example I have an array object like CarList. So CarList[0] would return me the object Car. Car has properties Model and Make. Now, I want to use linq to query the array CarList to get the ...

How to darken an image on mouseover?

My problem.. I have a number of images (inside hyperlinks), and I want each to darken on mouseover (i.e. apply a black mask with high opacity or something), and then go back to normal on mouseout . But I can't figure out the best way to do it. I've...

Getting GET "?" variable in laravel

Hello I'm creating API using REST and Laravel following this article. Everything works well as expected. Now, I want to map GET request to recognise variable using "?". For example: domain/api/v1/todos?start=1&limit=2 Below is the content of ...

Add context path to Spring Boot application

I am trying to set a Spring Boot applications context root programmatically. The reason for the context root is we want the app to be accessed from localhost:port/{app_name} and have all the controller paths append to it. Here is the application co...

Change image in HTML page every few seconds

I want to change images every few seconds, this is my code: <?xml version = "1.0" encoding = "utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns = "ht...

Calling onclick on a radiobutton list using javascript

How do I call onclick on a radiobutton list using javascript?...

How can I get a character in a string by index?

I know that I can return the index of a particular character of a string with the indexof() function, but how can I return the character at a particular index?...

No plot window in matplotlib

I just installed matplotlib in Ubuntu 9.10 using the synaptic package system. However, when I try the following simple example >>> from pylab import plot; >>> plot([1,2,3],[1,2,3]) [<matplotlib.lines.Line2D object at 0x9aa78ec&...

Difference Between One-to-Many, Many-to-One and Many-to-Many?

Ok so this is probably a trivial question but I'm having trouble visualizing and understanding the differences and when to use each. I'm also a little unclear as to how concepts like uni-directional and bi-directional mappings affect the one-to-many/...

How to get the body's content of an iframe in Javascript?

<iframe id="id_description_iframe" class="rte-zone" height="200" frameborder="0" title="description"> <html> <head></head> <body class="frameBody"> test<br/> </body> </html> </i...

How to print the current Stack Trace in .NET without any exception?

I have a regular C# code. I have no exceptions. I want to programmatically log the current stack trace for debugging purpose. Example: public void executeMethod() { logStackTrace(); method(); } ...

Intent from Fragment to Activity

I was trying to go to another page using button, but it always fail. Here is my First Class with its XML: public class FindPeopleFragment extends Fragment { public FindPeopleFragment(){} @Override public View onCreateView(LayoutInflat...

Vagrant error : Failed to mount folders in Linux guest

I have some issues with Vagrant shared folders, my base system is Ubuntu 13.10 desktop. I do not understand why I have this error is something that is not right configured ? Is a NFS issue or Virtualbox Guest Additions ? I have tried with different ...

How to use a calculated column to calculate another column in the same view

I am hoping you can help with this question. I am using Oracle SQL (SQL Developer for this view)... If I have a table with the following columns: ColumnA (Number) ColumnB (Number) ColumnC (Number) In my view I have Select ColumnA, ColumnB...

Ajax post request in laravel 5 return error 500 (Internal Server Error)

This is my test ajax in laravel 5 (refer below) $("#try").click(function(){ var url = $(this).attr("data-link"); $.ajax({ url: "test", type:"POST", data: { testdata : 'testdataco...

In log4j, does checking isDebugEnabled before logging improve performance?

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

MySQL select where column is not empty

In MySQL, can I select columns only where something exists? For example, I have the following query: select phone, phone2 from jewishyellow.users where phone like '813%' and phone2 I'm trying to select only the rows where phone starts with 813 a...

How to compare two floating point numbers in Bash?

I am trying hard to compare two floating point numbers within a bash script. I have to variables, e.g. let num1=3.17648e-22 let num2=1.5 Now, I just want do a simple comparison of these two numbers: st=`echo "$num1 < $num2" | bc` if [ $...

How do I find out which keystore was used to sign an app?

I have an app which is signed and several keystore files. I'd like to update the app, so I need to find out which one of keys was used. How can I match which keystore was used to originally sign my app against various keystores I have on my machine?...

How to overload __init__ method based on argument type?

Let's say I have a class that has a member called data which is a list. I want to be able to initialize the class with, for example, a filename (which contains data to initialize the list) or with an actual list. What's your technique for doing t...

Extracting the last n characters from a string in R

How can I get the last n characters from a string in R? Is there a function like SQL's RIGHT?...

What is difference between Implicit wait and Explicit wait in Selenium WebDriver?

There are Implicit and Explicit wait in Selenium WebDriver. What's the difference between them? Kindly share the knowledge about Selenium WebDriver. Please show the real time example with Implicit & Explicit wait....

Observable.of is not a function

I am having issue with importing Observable.of function in my project. My Intellij sees everything. In my code I have: import {Observable} from 'rxjs/Observable'; and in my code I use it like that: return Observable.of(res); Any ideas?...

Remove portion of a string after a certain character

I'm just wondering how I could remove everything after a certain substring in PHP ex: Posted On April 6th By Some Dude I'd like to have it so that it removes all the text including, and after, the sub string "By" Thanks...

Sending a notification from a service in Android

I have a service running, and would like to send a notification. Too bad, the notification object requires a Context, like an Activity, and not a Service. Do you know any way to by pass that ? I tried to create an Activity for each notification but ...

Update Tkinter Label from variable

I wrote a Python script that does some task to generate, and then keep changing some text stored as a string variable. This works, and I can print the string each time it gets changed. I can get the Label to display the string for the first time, bu...

How can I close a browser window without receiving the "Do you want to close this window" prompt?

How can I close a browser window without receiving the Do you want to close this window prompt? The prompt occurs when I use the window.close(); function....

Oracle query execution time

I would like to get the query execution time in Oracle. I don't want the time Oracle needs to print the results - just the execution time. In MySQL it is easy to get the execution time from the shell. How can I do this in SQL*Plus?...

Compiler error "archive for required library could not be read" - Spring Tool Suite

I am starting to configure my development environment and I am using Spring Tool Suite 2.8.1 along with m2E 1.01. As far as I can tell, since this is a Maven Project (my first), my Maven POM is dictating (along with m2E smarts) my project build conf...

syntax error when using command line in python

I am a beginner to python and am at the moment having trouble using the command line. I have a script test.py (which only contains print("Hello.")), and it is located in the map C:\Python27. In my system variables, I have specified python to be C:\Py...

Query to check index on a table

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

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

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

PL/SQL, how to escape single quote in a string?

In the Oracle PL/SQL, how to escape single quote in a string ? I tried this way, it doesn't work. declare stmt varchar2(2000); begin for i in 1021 .. 6020 loop stmt := 'insert into MY_TBL (Col) values(\'ER0002\')'; dbms_output.put_li...

How do you install GLUT and OpenGL in Visual Studio 2012?

I just installed Visual Studio 2012 today, and I was wondering how can you install GLUT and OpenGL on the platform?...

How to upload files to server using JSP/Servlet?

How can I upload files to server using JSP/Servlet? I tried this: <form action="upload" method="post"> <input type="text" name="description" /> <input type="file" name="file" /> <input type="submit" /> </form&g...

Is there a way to get a list of all current temporary tables in SQL Server?

I realize that temporary tables are session/connection bound and not visible or accessible out of the session/connection. I have a long running stored procedure that creates temporary tables at various stages. Is there a way I can see the list of c...

Flask Python Buttons

I'm trying to create two buttons on a page. Each one I would like to carry out a different Python script on the server. So far I have only managed to get/collect one button using. def contact(): form = ContactForm() if request.method == 'POST': ...

How can I detect when the mouse leaves the window?

I want to be able to detect when the mouse leaves the window so I can stop events from firing while the user's mouse is elsewhere. Any ideas of how to do this?...

Getting the difference between two sets

So if I have two sets: Set<Integer> test1 = new HashSet<Integer>(); test1.add(1); test1.add(2); test1.add(3); Set<Integer> test2 = new HashSet<Integer>(); test2.add(1); test2.add(2); test2.add(3); test2.add(4); test2.add(5);...

How to get the file extension in PHP?

I wish to get the file extension of an image I am uploading, but I just get an array back. $userfile_name = $_FILES['image']['name']; $userfile_extn = explode(".", strtolower($_FILES['image']['name'])); Is there a way to just get the extension it...

How to capitalize the first letter of text in a TextView in an Android Application

I'm not referring to textInput, either. I mean that once you have static text in a TextView (populated from a Database call to user inputted data (that may not be Capitalized)), how can I make sure they are capitalized? Thanks!...

Nested iframes, AKA Iframe Inception

Using jQuery I am trying to access div id="element". <body> <iframe id="uploads"> <iframe> <div id="element">...</div> </iframe> </iframe> </body> All iframes are ...

How to get the current time in milliseconds in C Programming

Possible Duplicate: How to measure time in milliseconds using ANSI C? How can I get the Windows system time with millisecond resolution? We want to calculate the time which a player have taken to finish the game. But with time.h we could...

How to resolve "Error: bad index – Fatal: index file corrupt" when using Git

After git init, I added and committed a few files, made some changes, added and committed. Set up the git daemon (running under Cygwin on WinXP) and cloned the repository once. Now, I get this error with the cloned repository: $ git status error: b...

Adding close button in div to close the box

I have created a URL preview box for the entered URL. Preview is shown in the div box. I want to add a close option on the right top. How could be done so that when users click on its box should be disabled? Here is my fiddle. <a class="fragm...

How to reset the use/password of jenkins on windows?

Maybe a fool question, I installed jenkins on windows by default, have set no user/password, it worked at first, no need to login. But when launch the 8080 webpage now, it hangs the login page, I've tried some normal user/password combinations, none ...

Getting a directory name from a filename

I have a filename (C:\folder\foo.txt) and I need to retrieve the folder name (C:\folder) in unmanaged C++. In C# I would do something like this: string folder = new FileInfo("C:\folder\foo.txt").DirectoryName; Is there a function that can be used ...

How to declare an array inside MS SQL Server Stored Procedure?

I need to declare 12 decimal variables, corresponding to each month's year, with a cursor I sum values to this variables, then later I Update some sales information. I don't know if sql server has this syntax Declare MonthsSale(1 to 12) as decimal...

Edit Crystal report file without Crystal Report software

I need to modify a static text (few words) in 3 rpt files. But I dont have Crystal Reports. How can I do it? Is there a free editor or software to be able to modify a simple text of the report?...

What's the difference between compiled and interpreted language?

After reading some material on this subject I'm still not sure what the difference between a compiled language and an interpreted language is. I was told this is one of the differences between Java and JavaScript. Would someone please help me in unde...

How to read file with space separated values in pandas

I try to read the file into pandas. The file has values separated by space, but with different number of spaces I tried: pd.read_csv('file.csv', delimiter=' ') but it doesn't work...

How to search for file names in Visual Studio?

In Eclipse you can search for a file in the project by pressing CTRL-SHIFT-R. Is there a way to do this in Visual Studio?...

REST - HTTP Post Multipart with JSON

I need to receive an HTTP Post Multipart which contains only 2 parameters: A JSON string A binary file Which is the correct way to set the body? I'm going to test the HTTP call using Chrome REST console, so I'm wondering if the correct solution ...

Find and Replace Inside a Text File from a Bash Command

What's the simplest way to do a find and replace for a given input string, say abc, and replace with another string, say XYZ in file /tmp/file.txt? I am writting an app and using IronPython to execute commands through SSH — but I don't know Un...

SQL: How to to SUM two values from different tables

I have a number of tables with values I need to sum up. They are not linked either, but the order is the same across all the tables. Basically, I would like to take this two tables: CASH TABLE London 540 France 240 Belgium 340 CHEQUE TABLE Lon...

how to create inline style with :before and :after

I generated a bubble chat thingy from http://www.ilikepixels.co.uk/drop/bubbler/ In my page I put a number inside of it .bubble { position: relative; width: 20px; height: 15px; padding: 0; background: #FFF; border: 1px solid #000; bor...

Go to "next" iteration in JavaScript forEach loop

How do I go to the next iteration of a JavaScript Array.forEach() loop? For example: var myArr = [1, 2, 3, 4]; myArr.forEach(function(elem){ if (elem === 3) { // Go to "next" iteration. Or "continue" to next iteration... } console.log(e...

How to compare two vectors for equality element by element in C++?

Is there any way to compare two vectors? if (vector1 == vector2) DoSomething(); Note: Currently, these vectors are not sorted and contain integer values....

invalid use of non-static data member

For a code like this: class foo { protected: int a; public: class bar { public: int getA() {return a;} // ERROR }; foo() : a (p->param) }; I get this error: invalid use of non-static data member 'foo:...

Reduce left and right margins in matplotlib plot

I'm struggling to deal with my plot margins in matplotlib. I've used the code below to produce my chart: plt.imshow(g) c = plt.colorbar() c.set_label("Number of Slabs") plt.savefig("OutputToUse.png") However, I get an output figure with lots of wh...

C++ compiling on Windows and Linux: ifdef switch

I want to run some c++ code on Linux and Windows. There are some pieces of code that I want to include only for one operating system and not the other. Is there a standard #ifdef that once can use? Something like: #ifdef LINUX_KEY_WORD ... ...

DBCC CHECKIDENT Sets Identity to 0

I'm using this code to reset the identity on a table: DBCC CHECKIDENT('TableName', RESEED, 0) This works fine most of the time, with the first insert I do inserting 1 into the Id column. However, if I drop the DB and recreate it (using scripts I've ...

How to check if a file exists in a shell script

I'd like to write a shell script which checks if a certain file, archived_sensor_data.json, exists, and if so, deletes it. Following http://www.cyberciti.biz/tips/find-out-if-file-exists-with-conditional-expressions.html, I've tried the following: [...

Display List in a View MVC

I'm trying to display the list I made in my view but keep getting : "The model item passed into the dictionary is of type 'System.Collections.Generic.List1[System.String]', but this dictionary requires a model item of type 'System.Collections.Generic...

How do I vertically align something inside a span tag?

How do I get the "x" to be vertically-aligned in the middle of the span? .foo { height: 50px; border: solid black 1px; display: inline-block; vertical-align: middle; } <span class="foo"> x </span> ...

How to set the holo dark theme in a Android app?

How can I set the dark holo theme in my app? At this time I got this: <style name="AppTheme" parent="android:Theme.Holo.Light" /> But when I change it to: <style name="AppTheme" parent="android:Theme.Holo.Dark" /> I get an error err...

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

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

How to $http Synchronous call with AngularJS

Is there any way to make a synchronous call with AngularJS? The AngularJS documentation is not very explicit or extensive for figuring out some basic stuff. ON A SERVICE: myService.getByID = function (id) { var retval = null; $http({ ...

Sorting a vector of custom objects

How does one go about sorting a vector containing custom (i.e. user defined) objects. Probably, standard STL algorithm sort along with a predicate (a function or a function object) which would operate on one of the fields (as a key for sorting) in th...

Twitter Bootstrap Multilevel Dropdown Menu

Is it possible to have a multi level dropdown menu by using the elements of twitter bootstrap 2? The original version doesn't have this feature....

After MySQL install via Brew, I get the error - The server quit without updating PID file

Ok, I've searched all over and have spent quite a bit of my time installing, uninstalling, trying various option but without success. I'm on Mac OS X Lion (10.7.3) and am trying to setup a Python, MySQL. I successfully installed Python and MySQL vi...

Perfect 100% width of parent container for a Bootstrap input?

How do I make a Bootstrap input field be exactly 100% as wide as its parent? As steve-obrien wrote in Bootstrap Issue #1058: Setting to 100% does not work when applied directly to an input field as it does not take in to account the padding. So ...

Is it possible to output a SELECT statement from a PL/SQL block?

How can I get a PL/SQL block to output the results of a SELECT statement the same way as if I had done a plain SELECT? For example how to do a SELECT like: SELECT foo, bar FROM foobar; Hint : BEGIN SELECT foo, bar FROM foobar; END; doesn't wor...

Sorting an ArrayList of objects using a custom sorting order

I am looking to implement a sort feature for my address book application. I want to sort an ArrayList<Contact> contactArray. Contact is a class which contains four fields: name, home number, mobile number and address. I want to sort on name. ...

json call with C#

I am trying to make a json call using C#. I made a stab at creating a call, but it did not work: public bool SendAnSMSMessage(string message) { HttpWebRequest request = (HttpWebRequest) WebRequest.Create("http://api...

Differences between Emacs and Vim

Without getting into a religious argument about why one is better than the other, what are the practical differences between Emacs and Vim? I'm looking to learn one or the other, but I realize the learning curve for each is high and I can't decide. I...

jQuery - Follow the cursor with a DIV

How can I use jQuery to follow the cursor with a DIV?...

var self = this?

Using instance methods as callbacks for event handlers changes the scope of this from "My instance" to "Whatever just called the callback". So my code looks like this function MyObject() { this.doSomething = function() { ... } var self = ...

Converting json results to a date

Possible Duplicate: How to format a JSON date? I have the following result from a $getJSON call from JavaScript. How do I convert the start property to a proper date in JavaScript? [ {"id":1,"start":"/Date(1238540400000)/"}, {"id"...

Python script to do something at the same time every day

I have a long running python script that I want to do someting at 01:00 every morning. I have been looking at the sched module and at the Timer object but I can't see how to use these to achieve this....

Switching from zsh to bash on OSX, and back again?

So Im learning to develop in Rails, and have discovered the power of zsh. However, for some of my other tasks, I wish to use normal Bash. Although they are the same, I just feel comfortable with the lay out of bash in some situations. How do I switch...

HTML table with fixed headers and a fixed column?

Is there a CSS/JavaScript technique to display a long HTML table such that the column headers stay fixed on-screen and the first coloumn stay fixed and scroll with the data. I want to be able to scroll through the contents of the table, but to alway...

what is the difference between GROUP BY and ORDER BY in sql

When do you use which in general? Examples are highly encouraged! I am referring so MySql, but can't imagine the concept being different on another DBMS...

gitbash command quick reference

Does anyone know where I can find a quick reference for all commands in gitbash for windows? The help command covers the most important, but I can't find info on basic navigation such as getting the current directory, changing directory etc....

How to detect responsive breakpoints of Twitter Bootstrap 3 using JavaScript?

Currently, Twitter Bootstrap 3 have the following responsive breakpoints: 768px, 992px and 1200px, representing small, medium and large devices respectively. How can I detect these breakpoints using JavaScript? I would like to listen with JavaScrip...

Merge two objects with ES6

I'm sure this question has been asked before but I can't quite find the answer I'm looking for, so here goes: I have two objects, as follows: const response = { lat: -51.3303, lng: 0.39440 } let item = { id: 'qwenhee-9763ae-lenfya', addres...

Granting DBA privileges to user in Oracle

How do I grant a user DBA rights in Oracle? I guess something like: CREATE USER NewDBA IDENTIFIED BY passwd; GRANT DBA TO NewDBA WITH ADMIN OPTION; Is it the right way, or......

How to execute Python code from within Visual Studio Code

Visual Studio Code was recently released and I liked the look of it and the features it offered, so I figured I would give it a go. I downloaded the application from the downloads page, fired it up, messed around a bit with some of the features ... a...

Plot a line graph, error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ

a<- c(2,2) b<- c(3,4) plot(a,b) # It works perfectly here Then I tried: t<-xy.coords(a,b) plot(t) # It also works well here Finally, I tried: plot(t,1) Now it shows me: Error in xy.coords(x, y, xlabel, ylabel, log) : ...

How do you UrlEncode without using System.Web?

I am trying to write a windows client application that calls a web site for data. To keep the install to a minimum I am trying only use dlls in the .NET Framework Client Profile. Trouble is that I need to UrlEncode some parameters, is there an easy w...

using wildcards in LDAP search filters/queries

I have very limited knowledge in AD and LDAP queries so I have a simple question on how to use wildcards. Supposed there is object with a displayName of "ITSM - Problem Management" My current implementation of the filter with a wildcard is as such:...

Removing whitespace between HTML elements when using line breaks

I have a page with a row of about 10 imgs. For readability of the HTML, I want to put a linebreak in between each img tag, but doing so renders whitespace between the images, which I do not want. Is there anything I can do other than break in the mid...

How can I convert a stack trace to a string?

What is the easiest way to convert the result of Throwable.getStackTrace() to a string that depicts the stacktrace?...

File 'app/hero.ts' is not a module error in the console, where to store interfaces files in directory structure with angular2?

I am doing the angular2 tutorial at this address: https://angular.io/docs/ts/latest/tutorial/toh-pt3.html I have put the hero interface in a single file under the app folder, in the console I have this error: app/app.component.ts(2,20): error TS2306...

"Object doesn't support this property or method" error in IE11

I am getting the error Critical Error: Object doesn't support this property or method addeventlistener while accessing the InfoPath form page (using InfoPath enabled list form e.g. displayifs.aspx) in IE 11 browser. This error is specific to ...

How to extract code of .apk file which is not working?

Actually I was trying to extract code of a .apk file called cloudfilz.apk and wanted to manipulate in its source code so I followed the steps given below:- make a new folder and put .apk file (which you want to decode) now rename this .apk file with ...

How to merge two json string in Python?

I recently started working with Python and I am trying to concatenate one of my JSON String with existing JSON String. I am also working with Zookeeper so I get the existing json string from zookeeper node as I am using Python kazoo library. # gets ...

Accessing dict_keys element by index in Python3

I'm trying to access a dict_key's element by its index: test = {'foo': 'bar', 'hello': 'world'} keys = test.keys() # dict_keys object keys.index(0) AttributeError: 'dict_keys' object has no attribute 'index' I want to get foo. same with: keys[...

How to use ES6 Fat Arrow to .filter() an array of objects

I'm trying to use ES6 arrow function with .filter to return adults (Jack & Jill). It appears I cannot use an if statement. What do I need to know in order to do this in ES6? var family = [{"name":"Jack", "age": 26}, {"name":"Jil...

What's the difference between REST & RESTful

What's the difference between a REST system and a system that is RESTful? From a few things I've read most so called REST services are actually RESTful services. So what is the difference between the two. ...

Hiding an Excel worksheet with VBA

I have an Excel spreadsheet with three sheets. One of the sheets contains formulas for one of the other sheets. Is there a programmatic way to hide the sheet which contains these formulas?...

Vertically align text within input field of fixed-height without display: table or padding?

The line-height property usually takes care of vertical alignment, but not with inputs. Is there a way to automatically center text without playing around with padding?...

Viewing root access files/folders of android on windows

I'm trying to view the files and folders at root level on an android device using USB Debugging mode and windows. Is this possible? Phone is rooted. I've downloaded a file explorer app which allows me to view it on the phone itself. My main goal is...

How can I access localhost from another computer in the same network?

I just recently downloaded WAMP Server to view and edit php webpages but now I would also like other people in my network (connected to the same wifi) to be able to access localhost and all the files that I have saved. I have already tried to access ...

How to retrieve data from a SQL Server database in C#?

I have a database table with 3 columns firstname, Lastname and age. In my C# Windows application I have 3 textboxes called textbox1... I made my connectivity to my SQL Server using this code: SqlConnection con = new SqlConnection("Data Source = .; ...

Powershell Multidimensional Arrays

I have a way of doing Arrays in other languagues like this: $x = "David" $arr = @() $arr[$x]["TSHIRTS"]["SIZE"] = "M" This generates an error....

Chrome: console.log, console.debug are not working

Console.log and debug not printing, only return undefined. Why it can be? I've tried to re-install chrome, but it doesn't help. Here is screenshot from chrome's main page, so functions are not redefined in some code ...

ASP.NET MVC on IIS 7.5

I'm running Windows 7 Ultimate (64 bit) using Visual Studio 2010 RC. I recently decided to have VS run/debug my apps on IIS rather than the dev server that comes with it. However, every time I try to run an MVC app, I get the following error: H...

how to activate a textbox if I select an other option in drop down box

suppose I've a 3 options in a drop down box say red , blue, others. If a user select option as an others then below a text box should be visible to wrtie his own favourite color. I can populate the drop down box with colors but do not know ho...

no target device found android studio 2.1.1

i'm using android studio 2.1.1 in ubuntu 14.04.Now my question is,i want to run the program through my phone without emulator. so i chose the target as usb device but whenever i run this,below mentioned error is rasing. Error running app : No target...

How can I label points in this scatterplot?

Can you help me on putting labels on the following graph? The code i use is: valbanks<-scan("banks.txt", what=list(0,0,""), sep="", skip=1, comment.char="#") valbanks valj2007<-valbanks[[1]] valj2009<-valbanks[[2]] namebank<-valban...

Naming threads and thread-pools of ExecutorService

Let's say I have an application that utilizes the Executor framework as such Executors.newSingleThreadExecutor().submit(new Runnable(){ @Override public void run(){ // do stuff } } When I run this application in the debugger, a...

Keep-alive header clarification

I was asked to build a site , and one of the co-developer told me That I would need to include the keep-alive header. Well I read alot about it and still I have questions. msdn -> The open connection improves performance when a client makes mult...

Checking if a collection is null or empty in Groovy

I need to perform a null or empty check on a collection; I think that !members?.empty is incorrect. Is there a groovier way to write the following? if (members && !members.empty) { // Some Work } ...

How to download source in ZIP format from GitHub?

I see something strange like: http://github.com/zoul/Finch.git Now I'm not that CVS, SVN, etc. dude. When I open that in the browser it tells me that I did something wrong. So I bet I need some hacker-style tool? Some client? (I mean... why not j...

How to add Tomcat Server in eclipse

I just installed Java EE plugin in plain eclipse and I am trying to add tomcat server. I opened add new server which showing "Choose the type of server to create" but there is no server list. How can I add tomcat server? Eclipse: Indigo....

CSS Change List Item Background Color with Class

I am trying to change the background color of one list item while there is another background color for other list items. This is what I have: _x000D_ _x000D_ <style type="text/css">_x000D_ _x000D_ ul.nav li_x000D_ {_x000D_ display:inli...

Error ITMS-90717: "Invalid App Store Icon"

When I tried to submit an App to Itunes Connect I got the following error. iTunes Store Operation Failed Error ITMS-90717: "Invalid App Store Icon. The App Store Icon in the asset catalog in 'YourApp.app' can't be transparent nor contain an alpha c...

How to have EditText with border in Android Lollipop

I am developing an Android app. I need to know how we can have a EditText with border. In Lolipop they have completely changed the EditText style. Can we do it without using drawables?...

php artisan migrate throwing [PDO Exception] Could not find driver - Using Laravel

I have a bad experience while installing laravel. However, I was able to do so and move to the next level. I used generators and created my migrations. But when I type the last command php artisan migrate It's throwing a PDOException - could not...

How do I check if an object has a key in JavaScript?

Which is the right thing to do? if (myObj['key'] == undefined) or if (myObj['key'] == null) or if (myObj['key']) ...

Pad a string with leading zeros so it's 3 characters long in SQL Server 2008

I have a string that is up to 3 characters long when it's first created in SQL Server 2008 R2. I would like to pad it with leading zeros, so if its original value was '1' then the new value would be '001'. Or if its original value was '23' the new v...

Why is Android Studio reporting "URI is not registered"?

So I've given Android Studio a try, because I really like Resharper and noticed that the IDE had some of their functionality built into it. Having now created a default new project, I added a new layout file and wanted to change the existing default ...

WebAPI Multiple Put/Post parameters

I am trying to post multiple parameters on a WebAPI controller. One param is from the URL, and the other from the body. Here is the url: /offers/40D5E19D-0CD5-4FBD-92F8-43FDBB475333/prices/ Here is my controller code: public HttpResponseMessage Pu...

CURL to access a page that requires a login from a different page

I have 2 pages: xyz.com/a and xyz.com/b. I can only access xyz.com/b if and only if I login to xyz.com/a first. If accessing xyz.com/b without going through the other, I simply get access denied (no redirect to login) via the browser. Once I login at...

WCF Error - Could not find default endpoint element that references contract 'UserService.UserService'

Any ideas how to fix this? UserService.UserServiceClient userServiceClient = new UserServiceClient(); userServiceClient.GetUsersCompleted += new EventHandler<GetUsersCompletedEventArgs>(userServiceClient_GetUsersCompleted); ...

Failed to load resource: the server responded with a status of 404 (Not Found) css

I'm having trouble getting my browser to display the css for the app I am creating. I have looked at the same question asked by other users but have not found any of the answers to help in my situation. When I goto the page, all that is displayed is ...

Operator overloading in Java

Please can you tell me if it is possible to overload operators in Java? If it is used anywhere in Java could you please tell me about it....

Creating a select box with a search option

I am trying to replicate what you can see here in this image. I want to be able to either type in the text field above the box or just click on the option directly. What would be the best way to go about that? Is there anything bootstrap related ...

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

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

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

How do I correctly use "Not Equal" in MS Access?

Objective: The intent of this query is to select all of the distinct values in one column that don't exist in a similar column in a different table. Current Query: SELECT DISTINCT Table1.Column1 FROM Table2, Table1 WHERE Table1.Column1 <> Ta...

Format Date time in AngularJS

How do I properly display the date and time in AngularJS? The output below shows both the input and the output, with and without the AngularJS date filter: In: {{v.Dt}} AngularJS: {{v.Dt | date:'yyyy-MM-dd HH:mm:ss Z'}} This prints: In: 2012-1...

How to perform grep operation on all files in a directory?

Working with xenserver, and I want to perform a command on each file that is in a directory, grepping some stuff out of the output of the command and appending it in a file. I'm clear on the command I want to use and how to grep out string(s) as nee...

Differences between Microsoft .NET 4.0 full Framework and Client Profile

The Microsoft .NET Framework 4.0 full installer (32- and 64-bit) is 48.1 MB and the Client Profile installer is 41.0 MB. The extracted installation files are 237 MB and 194 MB respectively, and once installed, they are 537 MB...

Set the selected index of a Dropdown using jQuery

How do I set the index of a dropdown in jQuery if the way I'm finding the control is as follows: $("*[id$='" + originalId + "']") I do it this way because I'm creating controls dynamically and since the ids are changed when using Web Forms, I fou...

Assign a login to a user created without login (SQL Server)

I have got a user in my database that hasn't got an associated login. It seems to have been created without login. Whenever I attempt to connect to the database with this user I get the following error: Msg 916, Level 14, State 1, Line 1 The serve...

Back to previous page with header( "Location: " ); in PHP

The title of this question kind of explains my question. How do I redirect the PHP page visitor back to their previous page with the header( "Location: URL of previous page" );...

ASP.NET Web Site or ASP.NET Web Application?

When I start a new ASP.NET project in Visual Studio, I can create an ASP.NET Web Application or I can create an ASP.NET Web Site. What is the difference between ASP.NET Web Application and ASP.NET Web Site? Why would I choose one over other? Is the...

How to find the lowest common ancestor of two nodes in any binary tree?

The Binary Tree here is may not necessarily be a Binary Search Tree. The structure could be taken as - struct node { int data; struct node *left; struct node *right; }; The maximum solution I could work out with a friend was something ...

How can I check if a value is of type Integer?

I need to check if a value is an integer. I found this: How to check whether input value is integer or float?, but if I'm not mistaken, the variable there is still of type double even though the value itself is indeed an integer....

trim left characters in sql server?

I want to write a sql statement to trim a string 'Hello' from the string "Hello World'. Please suggest....

how to list all sub directories in a directory

I'm working on a project and I need to list all sub directories in a directory for example how could I list all the sub directories in c:\...

python numpy ValueError: operands could not be broadcast together with shapes

In numpy, I have two "arrays", X is (m,n) and y is a vector (n,1) using X*y I am getting the error ValueError: operands could not be broadcast together with shapes (97,2) (2,1) When (97,2)x(2,1) is clearly a legal matrix operation and shoul...

Does C# have extension properties?

Does C# have extension properties? For example, can I add an extension property to DateTimeFormatInfo called ShortDateLongTimeFormat which would return ShortDatePattern + " " + LongTimePattern?...

TensorFlow ValueError: Cannot feed value of shape (64, 64, 3) for Tensor u'Placeholder:0', which has shape '(?, 64, 64, 3)'

I am new to TensorFlow and machine learning. I am trying to classify two objects a cup and a pendrive (jpeg images). I have trained and exported a model.ckpt successfully. Now I am trying to restore the saved model.ckpt for prediction. Here is the sc...

Using LINQ to find item in a List but get "Value cannot be null. Parameter name: source"

When using LINQ to get data from a list I encounter this error. How can this be fixed? Value cannot be null. Parameter name: source var nCounts = from sale in sal select new { SaleID = sale.OrderID,...

Java generating non-repeating random numbers

I want to create a set of random numbers without duplicates in Java. For example I have an array to store 10,000 random integers from 0 to 9999. Here is what I have so far: import java.util.Random; public class Sort{ public static void main(S...

Export table data from one SQL Server to another

I have two SQL Servers (both 2005 version). I want to migrate several tables from one to another. I have tried: On source server I have right clicked on the database, selected Tasks/Generate scripts. The problem is that under Table/View options t...

Media Queries - In between two widths

I'm trying to use CSS3 media queries to make a class that only appears when the width is greater than 400px and less than 900px. I know this is probably extremely simple and I am missing something obvious, but I can't figure it out. What I have com...

php var_dump() vs print_r()

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

pip installing in global site-packages instead of virtualenv

Using pip3 to install a package in a virtualenv causes the package to be installed in the global site-packages folder instead of the one in the virtualenv folder. Here's how I set up Python3 and virtualenv on OS X Mavericks (10.9.1): I installed Pyt...

Simplest way to set image as JPanel background

How would I add the backgroung image to my JPanel without creating a new class or method, but simply by inserting it along with the rest of the JPanel's attributes? I am trying to set a JPanel's background using an image, however, every example I f...

Why do I get PLS-00302: component must be declared when it exists?

I am using Oracle 10.2. I am working in some scripts to move some ORACLE Objects from one SCHEMA (S1) to another (S2). I am creating the functions with DBA role. When moved, one of my functions becomes invalid, but I don't understand why. Its code ...

What is Gradle in Android Studio?

Gradle is a bit confusing to me, and also for any new Android developer. Can anyone explain what Gradle in Android Studio is and what its purpose is? Why is it included in Android Studio?...

Nested select statement in SQL Server

Why doesn't the following work? SELECT name FROM (SELECT name FROM agentinformation) I guess my understanding of SQL is wrong, because I would have thought this would return the same thing as SELECT name FROM agentinformation Doesn't the inne...

Python - Module Not Found

I am a beginner with Python. Before I start, here's my Python folder structure -project ----src ------model --------order.py ------hello-world.py Under src I have a folder named model which has a Python file called order.py which contents follow: ...

Regular expressions inside SQL Server

I have stored values in my database that look like 5XXXXXX, where X can be any digit. In other words, I need to match incoming SQL query strings like 5349878. Does anyone have an idea how to do it? I have different cases like XXXX7XX for example, ...

Color picker utility (color pipette) in Ubuntu

I'am looking for a color picker utility on Ubuntu/Debian. Anything simple and easy to use....

Regex to match a 2-digit number (to validate Credit/Debit Card Issue number)

I would like to use regex to match a string of exactly 2 characters, and both of those characters have to be between 0 and 9. The string to match against would be coming from a single-line text input field when an ASP.NET MVC view is rendered So far...

how to count the total number of lines in a text file using python

For example if my text file is: blue green yellow black Here there are four lines and now I want to get the result as four. How can I do that?...

Ping a site in Python?

How do I ping a website or IP address with Python?...

JPA - Persisting a One to Many relationship

Maybe this is a stupid question but it's bugging me. I have a bi-directional one to many relationship of Employee to Vehicles. When I persist an Employee in the database for the first time (i.e. it has no assigned ID) I also want its associated Vehi...

Jquery date picker z-index issue

I have a slideshow div, and I have a datepicker field above that div. When I click in the datepicker field, the datepicker panel show behind slideshow div. And I have put the script as: http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery...

Remove leading or trailing spaces in an entire column of data

How do I remove leading or trailing spaces of all cells in an entire column? The worksheet's conventional Find and Replace (aka Ctrl+H) dialog is not solving the problem....

Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $

What is this error ? How can I fix this? My app is running but can't load data. And this is my Error: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $ This is my fragment : public class news extends Fragment { priv...

How to sort a List<Object> alphabetically using Object name field

I have a List of Objects like List<Object> p.I want to sort this list alphabetically using Object name field. Object contains 10 field and name field is one of them. if (list.size() > 0) { Collections.sort(list, new Comparator<Campai...

How to get the index with the key in Python dictionary?

I have the key of a python dictionary and I want to get the corresponding index in the dictionary. Suppose I have the following dictionary, d = { 'a': 10, 'b': 20, 'c': 30} Is there a combination of python functions so that I can get the index val...

Java generics - get class?

I got a list, programmed like this: public class MyList<T>. Is there any way to use the T variable to get the name of class (so I can, from within MyList, know if T is String, Socket, etc.)? EDIT: Nevermind, found the answer here....

Getting all names in an enum as a String[]

What's the easiest and/or shortest way possible to get the names of enum elements as an array of Strings? What I mean by this is that if, for example, I had the following enum: public enum State { NEW, RUNNABLE, BLOCKED, WAITING, ...

How to detect if CMD is running as Administrator/has elevated privileges?

From inside a batch file, I would like to test whether I'm running with Administrator/elevated privileges. The username doesn't change when "Run as Administrator" is selected, so that doesn't work. If there were a universally available command, whi...

MySQL case sensitive query

This has been asked on this site before but I couldn't find a sufficient answer. If I'm doing a query like: Select Seller from Table where Location = 'San Jose' How can I make it return only Sellers with Location 'San Jose' instead of 'san jose' o...

Returning JSON from a PHP Script

I want to return JSON from a PHP script. Do I just echo the result? Do I have to set the Content-Type header?...

SVN remains in conflict?

How do I get this directory out of conflict? I don't care if it's resolved using "theirs" or "mine" or whatever... PS C:\Users\Mark\Desktop\myproject> svn ci -m "gr" svn: Commit failed (details follow): svn: Aborting commit: 'C:\Users\Mark\Deskt...

Command failed due to signal: Segmentation fault: 11

I'm getting the error ... Command failed due to signal: Segmentation fault: 11 ... when trying to compile my Swift app. I'm using Xcode 6.1, trying to build for an iPhone 5 on iOS 8.1. My Code import UIKit class ViewController: UIViewControl...

Select Row number in postgres

How to select row number in postgres. I tried this: select row_number() over (ORDER BY cgcode_odc_mapping_id)as rownum, cgcode_odc_mapping_id from access_odc.access_odc_mapping_tb order by cgcode_odc_mapping_id and got this error: ERROR...

How can I get the key value in a JSON object?

How do I get the key value in a JSON object and the length of the object using JavaScript? For example: [ { "amount": " 12185", "job": "GAPA", "month": "JANUARY", "yea...

Select data between a date/time range

How do I select data between a date range in MySQL. My datetime column is in 24-hour zulu time format. select * from hockey_stats where game_date between '11/3/2012 00:00:00' and '11/5/2012 23:59:00' order by game_date desc; Returns nothing des...

MySQL Nested Select Query?

Ok, so I have the following query: SELECT MIN(`date`), `player_name` FROM `player_playtime` GROUP BY `player_name` I then need to use this result inside the following query: SELECT DATE(`date`) , COUNT(DISTINCT `player_name`) FROM `player_playt...

What is a good alternative to using an image map generator?

I have a large image and I want to make certain sections of the image clickable. I also want to specify the shape of the clickable area (square, circle, custom). Without relying on Javascript, how can I use CSS and HTML to create an interactive ima...

Extracting zip file contents to specific directory in Python 2.7

This is the code I am currently using to extract a zip file that lives in the same current working directory as the script. How can I specify a different directory to extract to? The code I tried is not extracting it where I want. import zipfile f...

How to save a pandas DataFrame table as a png

I constructed a pandas dataframe of results. This data frame acts as a table. There are MultiIndexed columns and each row represents a name, ie index=['name1','name2',...] when creating the DataFrame. I would like to display this table and save it as...

How to remove all namespaces from XML with C#?

I am looking for the clean, elegant and smart solution to remove namespacees from all XML elements? How would function to do that look like? Defined interface: public interface IXMLUtils { string RemoveAllNamespaces(string xmlDocument); } ...

Add a column with a default value to an existing table in SQL Server

How can I add a column with a default value to an existing table in SQL Server 2000 / SQL Server 2005?...

First letter capitalization for EditText

I'm working on a little personal todo list app and so far everything has been working quite well. There is one little quirk I'd like to figure out. Whenever I go to add a new item, I have a Dialog with an EditText view showing inside. When I select t...

Creating a new empty branch for a new project

We are using a git repository to store our project. We have our branches departing from the original branch. But now we want to create a small new project to track some documentation. For that we would want to create a new empty branch to start stori...

Is there an upper bound to BigInteger?

Possible Duplicate: What does BigInteger having no limit mean? The Javadoc for BigInteger does not define any maximum or minimum. However, it does say: (emphasis added) Immutable arbitrary-precision integers Is there such a maximum...

How to get table list in database, using MS SQL 2008?

I want to verify if a table exists in a database, and if it doesn't exist, to create it. How can I get a list of all the tables in the current database? I could get the database list with a SELECT like this: SELECT * FROM sys.databases What's lef...

Aggregate function in SQL WHERE-Clause

In a test at university there was a question; is it possible to use an aggregate function in the SQL WHERE clause. I always thought this isn't possible and I also can't find any example how it would be possible. But my answer was marked false and n...

Passing variables to the next middleware using next() in Express.js

Well, my question is I want to pass some variable from the first middleware to another middleware, and I tried doing this, but there was "req.somevariable is a given as 'undefined'". //app.js .. app.get('/someurl/', middleware1, middleware2) ... ...

Can I use a min-height for table, tr or td?

I am trying to show some details of a receive in a table. I want that table to have a min height to show the products. So if there is only one product, the table would have at least some white space at the end. In the other hand if there are 5 or mo...

iPhone App Icons - Exact Radius?

I'm trying to create the icon for my iPhone app, but don't know how to get the exact radius that the iPhone's icons use. I've searched and searched for a tutorial or a template but can't find one. I'm sure that I'm just a moron, but how do you get t...

Angularjs simple file download causes router to redirect

HTML: <a href="mysite.com/uploads/asd4a4d5a.pdf" download="foo.pdf"> Uploads get a unique file name while there real name is kept in database. I want to realize a simple file download. But the code above redirects to / because of: $routePro...

Difference between "and" and && in Ruby?

What is the difference between the && and and operators in Ruby?...

MySql server startup error 'The server quit without updating PID file '

On Snow Leopard, starting MySQL gives the following error: The server quit without updating PID file my.cnf [mysqld] port = 3306 socket = /tmp/mysql.sock skip-external-locking key_buffer_size = 16K pid-file=/var/run/mys...

get current url in twig template?

I looked around for the code to get the current path in a Twig template (and not the full URL), i.e. I don't want http://www.sitename.com/page, I only need /page....

Why "net use * /delete" does not work but waits for confirmation in my PowerShell script?

I have a script where I want to disconnect from the mapped drives before I create a new PSDrive. Otherwise I get this error: New-PSDrive : Multiple connections to a server or shared resource by the same user , using more than one user name, a...

Protractor : How to wait for page complete after click a button?

In a test spec, I need to click a button on a web page, and wait for the new page completely loaded. emailEl.sendKeys('jack'); passwordEl.sendKeys('123pwd'); btnLoginEl.click(); // ...Here need to wait for page complete... How? ptor.waitForAngula...

Div with margin-left and width:100% overflowing on the right side

I have 2 nested div's that should be 100% wide. Unfortunately the inner div with the Textbox overflows and is actually larger than the outer div. It has a left margin and overflows by about the size of the margin. How can I fix that? <div style...

lists and arrays in VBA

I am extremely new at writing in VB.NET, and I did not even realise that there was a significant difference between VB.NET and VBA. I have been writing my application in Visual Studio, but I realised that I will need to port it over to VBA in Outlook...

ORA-01438: value larger than specified precision allows for this column

We get sometimes the following error from our partner's database: <i>ORA-01438: value larger than specified precision allows for this column</i> The full response looks like the following: <?xml version="1.0" encoding="windows-1251...

How to manipulate arrays. Find the average. Beginner Java

I have a homework assignment and I was wondering if anyone could help me as I am new to Java and programming and am stuck on a question. The question is: The first method finds the average of the elements of an integer array: public double average...

What's the difference between using CGFloat and float?

I tend to use CGFloat all over the place, but I wonder if I get a senseless "performance hit" with this. CGFloat seems to be something "heavier" than float, right? At which points should I use CGFloat, and what makes really the difference?...

Reading a text file using OpenFileDialog in windows forms

I am new to the OpenFileDialog function, but have the basics figured out. What I need to do is open a text file, read the data from the file (text only) and correctly place the data into separate text boxes in my application. Here's what I have in my...

Extend a java class from one file in another java file

How can I include one java file into another java file? For example: If I have 2 java file one is called Person.java and one is called Student.java. How can I include Person.java into Student.java so that I can extend the class from Person.java in ...

How to manage startActivityForResult on Android?

In my activity, I'm calling a second activity from the main activity by startActivityForResult. In my second activity, there are some methods that finish this activity (maybe without a result), however, just one of them returns a result. For example...

Declaring a variable and setting its value from a SELECT query in Oracle

In SQL Server we can use this: DECLARE @variable INT; SELECT @variable= mycolumn from myTable; How can I do the same in Oracle? I'm currently attempting the following: DECLARE COMPID VARCHAR2(20); SELECT companyid INTO COMPID from app where appid...

Default property value in React component using TypeScript

I can't figure out how to set default property values for my components using Typescript. This is the source code: class PageState { } export class PageProps { foo: string = "bar"; } export class PageComponent extends React.Component<PageP...

Convert HTML5 into standalone Android App

I have a dynamic HTML5 document that does not contain any external resources (no images, css and scripts are coded inside of document). This HTML5 application is working fine with internet browser. I was wondering, if it would be possible to convert ...

How to pass model attributes from one Spring MVC controller to another controller?

I am redirecting from a controller to another controller. But I also need to pass model attributes to the second controller. I don't want to put the model in session. Please help....

Check if an HTML input element is empty or has no value entered by user

Related to this question here. Can I check if an element in the DOM has a value or not? I'm trying to put it into an 'if' statement and not sure if my approach is correct. Here goes: if (document.getElementById('customx')){ //do something } Or...

How can I disable a specific LI element inside a UL?

I have a menu which is a <ul>. Each menu item is a <li> and currently clickable. Based on some conditions, I want to disable (make it not clickable) a particular <li> element. How can I achieve this? I tried using the disabled attri...

Should we pass a shared_ptr by reference or by value?

When a function takes a shared_ptr (from boost or C++11 STL), are you passing it: by const reference: void foo(const shared_ptr<T>& p) or by value: void foo(shared_ptr<T> p) ? I would prefer the first method because I suspect it w...

What is the equivalent of ngShow and ngHide in Angular 2+?

I have a number of elements that I want to be visible under certain conditions. In AngularJS I would write <div ng-show="myVar">stuff</div> How can I do this in Angular 2+?...

Index of Currently Selected Row in DataGridView

It's that simple. How do I get the index of the currently selected Row of a DataGridView? I don't want the Row object, I want the index (0 .. n)....

Setting up connection string in ASP.NET to SQL SERVER

I'm trying to set up a connecting string in my web.config file (Visual Studio 2008/ASP.NET 3.5) to a local server (SQL server 2008). In my web.config, how and where do I place the connection string? Here's what web.config file looks like right now:...

Call of overloaded function is ambiguous

What does this error message mean? error: call of overloaded ‘setval(int)’ is ambiguous huge.cpp:18: note: candidates are: void huge::setval(unsigned int) huge.cpp:28: note: void huge::setval(const char*) My code looks like thi...

Iterating each character in a string using Python

In C++, I can iterate over an std::string like this: std::string str = "Hello World!"; for (int i = 0; i < str.length(); ++i) { std::cout << str[i] << std::endl; } How do I iterate over a string in Python?...

Fastest way to convert a dict's keys & values from `unicode` to `str`?

I'm receiving a dict from one "layer" of code upon which some calculations/modifications are performed before passing it onto another "layer". The original dict's keys & "string" values are unicode, but the layer they're being passed onto only ac...

How do I find the index of a character within a string in C?

Suppose I have a string "qwerty" and I wish to find the index position of the e character in it. (In this case the index would be 2) How do I do it in C? I found the strchr function but it returns a pointer to a character and not the index....

Redirecting to previous page after login? PHP

I've been searching for a solution but it's seem I can't get it right, no matter what I try. After successful login, the user should be redirected to the page he came from, let's say he's been browsing a post and wants to log in so he can leave a ...

Trim to remove white space

jQuery trim not working. I wrote the following command to remove white space. Whats wrong in it? var str = $('input').val(); str = jquery.trim(str); console.log(str); Fiddle example....

Adding a color background and border radius to a Layout

I want to create a layout with rounded corners and a filled color background. This is my layout: <LinearLayout android:layout_width="match_parent" android:layout_height="210dp" android:orientation="vertical" android:layout_margin...

How do I find the number of arguments passed to a Bash script?

How do I find the number of arguments passed to a Bash script? This is what I have currently: #!/bin/bash i=0 for var in "$@" do i=i+1 done Are there other (better) ways of doing this?...

How to give environmental variable path for file appender in configuration file in log4j

I have a log4j.xml config file. and a RollingFileAppender to which I need to provide file path for storing logs. The problem is my code will be deployed on Unix machine as a runnable jar. So if I pass parameter something like this: value=logs/messag...

Terminating a Java Program

I found out ways to terminate (shut-down or stop) my Java programs. I found two solutions for it. using return;When I want to quit or terminate my program execution , I add this. using System.exit() ; Sometimes I used it. I read about Sytem.exit(...

Upload folder with subfolders using S3 and the AWS console

When I try to upload a folder with subfolders to S3 through the AWS console, only the files are uploaded not the subfolders. You also can't select a folder. It always requires opening the folder first before you can select anything. Is this even p...

Shell Script — Get all files modified after <date>

I'd rather not do this in PHP so I'm hoping a someone decent at shell scripting can help. I need a script that runs through directory recursively and finds all files with last modified date is greater than some date. Then, it will tar and zip the f...

Facebook login message: "URL Blocked: This redirect failed because the redirect URI is not whitelisted in the app’s Client OAuth Settings."

Important notice: If you register for testing, go to your profile settings and to your interests add delete profile. Trying to login with Facebook to my website: I get the following error: URL Blocked: This redirect failed because the redirec...

What Language is Used To Develop Using Unity

What language does one need to use when programming with Unity? Or is it an API for many languages? I read through the docs and I guess I missed the point on the language used. It says it has iOS deployment, would this still allow the programmer to...

Oracle: what is the situation to use RAISE_APPLICATION_ERROR?

We can use RAISE to fire an exception. What particular situations do we need to use RAISE_APPLICATION_ERROR? Thanks....

How to display 3 buttons on the same line in css

I want to display 3 buttons on the same line in html. I tried two options: This one: <div style="width:500px;"> <div style="float: left; width: 130px"><button type="submit" class="msgBtn" onClick="return false;" >Save...

Populate a datagridview with sql query results

I'm trying to present query results, but I keep getting a blank data grid. It's like the data itself is not visible Here is my code: private void Employee_Report_Load(object sender, EventArgs e) { string select = "SELECT * FROM tblEmployee"...

Excel VBA code to copy a specific string to clipboard

I'm trying to add a button to a spreadsheet that when clicked will copy a specific URL to my clipboard. I had a bit of knowledge of Excel VBA but it's been a while and I'm struggling....

java - path to trustStore - set property doesn't work?

I've setup a self-signed certificate to test an ssl java connection - however, it is refusing to locate the java trustStore. I've saved copies of it in /Java/jre6/lib/security in addition to the folder where the classes are compiled to (im using netb...

How to delete zero components in a vector in Matlab?

I have a vector for example a = [0 1 0 3] I want to turn a into b which equals b = [1 3]. How do I perform this in general? So I have a vector with some zero components and I want to remove the zeroes and leave just the non-zero numbers?...

Using Java 8's Optional with Stream::flatMap

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

Fuzzy matching using T-SQL

I have a table Persons with personaldata and so on. There are lots of columns but the once of interest here are: addressindex, lastname and firstname where addressindex is a unique address drilled down to the door of the apartment. So if I have 'like...

Transparent background in JPEG image

How can I set a transparent background on JPEG image? This is a doubt of many colleagues of mine. What would be the solution using Paint on Windows? What are the other simple alternatives?...

Hide all elements with class using plain Javascript

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

SSL received a record that exceeded the maximum permissible length. (Error code: ssl_error_rx_record_too_long)

I followed the official docs on https setup located here: https://help.ubuntu.com/6.06/ubuntu/serverguide/C/httpd.html#https-configuration I had to remove the +CompatEnvVars from SSLOptions +FakeBasicAuth +ExportCertData +CompatEnvVars +StrictRequi...

JTable won't show column headers

I have the following code to instantiate a JTable: the table comes up with the right number of rows and columns, but there is no sign of the titles atop the columns. public Panel1() { int nmbrRows; setLayout(null); setBackground(Color...

Populating a dictionary using for loops (python)

I'm trying to create a dictionary using for loops. Here is my code: dicts = {} keys = range(4) values = ["Hi", "I", "am", "John"] for i in keys: for x in values: dicts[i] = x print(dicts) This outputs: {0: 'John', 1: 'John', 2: 'John'...

How do I find the date a video (.AVI .MP4) was actually recorded?

properties> date created... I thought this meant the date the video was created, but finally realized that date changes every time I move, reorganize, even open a file. often, the date modified is earlier than date created. the date a jpeg was ta...

Firing events on CSS class changes in jQuery

How can I fire an event if a CSS class is added or changed using jQuery? Does changing of a CSS class fire the jQuery change() event?...

How to import the class within the same directory or sub directory?

I have a directory that stores all the .py files. bin/ main.py user.py # where class User resides dir.py # where class Dir resides I want to use classes from user.py and dir.py in main.py. How can I import these Python classes into main.p...

How to check if an email address is real or valid using PHP

I found some websites that claim to verify if email addresses are valid. Is it possible to check if an email address is valid using just PHP? <?php if($_POST['email'] != ''){ // The email to validate $email = $_POST['email'];...

Don't change link color when a link is clicked

I have a link in an HTML page: <a href="#foo">foo</a> The color of the link text is originally blue. When the link is clicked, the color of the link text changes to Red first, and then changes back to Blue. I want to the color of the l...

Can't access to HttpContext.Current

I can't access to HttpContext.Current on my project MVC4 with C#4.5 I've added my reference to System.Web in my project and added the using instruction on my controller page... But I can access currentHandler only... var context = HttpContext.Curr...

Why and when to use angular.copy? (Deep Copy)

I've been saving all the data received from services direct to local variable, controller, or scope. What I suppose would be considered a shallow copy, is that correct? Example: DataService.callFunction() .then(function(response) { $scope.example...

reading HttpwebResponse json response, C#

In one of my apps, I am getting the response from a webrequest. The service is Restful service and will return a result similar to the JSON format below: { "id" : "1lad07", "text" : "test", "url" : "http:\/\/twitpic.com\/1lacuz", "wi...

Combining border-top,border-right,border-left,border-bottom in CSS

Is there a way of combining border-top,border-right,border-left,border-bottom in CSS like a super shorthand style. eg: border: (1px solid #ff0) (2px dashed #f0F) (3px dotted #F00) (5px solid #09f); ...

How can I convert a DateTime to an int?

I have the following DateTime 4/25/2011 5:12:13 PM and tried this to convert it to int int result = dateDate.Year * 10000 + dateDate.Month * 100 + dateDate.Day + dateDate.Hour + dateDate.Minute + dateDate.Second; But it still gettin...

Can you run GUI applications in a Docker container?

How can you run GUI applications in a Docker container? Are there any images that set up vncserver or something so that you can - for example - add an extra speedbump sandbox around say Firefox?...

jQuery vs document.querySelectorAll

I heard several times that jQuery's strongest asset is the way it queries and manipulates elements in the DOM: you can use CSS queries to create complex queries that would be very hard to do in regular javascript . However , as far as I know, you ca...

Intercept page exit event

When editing a page within my system, a user might decide to navigate to another website and in doing so could lose all the edits they have not saved. I would like to intercept any attempt to go to another page and prompt the user to be sure they wa...

scp with port number specified

I'm trying to scp a file from a remote server to my local machine. Only port 80 is accessible. I tried: scp -p 80 [email protected]:/root/file.txt . but got this error: cp: 80: No such file or directory How do I specify the port number i...

How do I compare a value to a backslash?

if (message.value[0] == "/" or message.value[0] == "\"): do stuff. I'm sure it's a simple syntax error, but something is wrong with this if statement....

Set drawable size programmatically

The images (icons) come in roughly the same size, but I need to resize them in order for the buttons to remain the same height. How do I do this? Button button = new Button(this); button.setText(apiEventObject.getTitle()); button.setOnClickListener...

how does multiplication differ for NumPy Matrix vs Array classes?

The numpy docs recommend using array instead of matrix for working with matrices. However, unlike octave (which I was using till recently), * doesn't perform matrix multiplication, you need to use the function matrixmultipy(). I feel this makes the c...

How can I show figures separately in matplotlib?

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

Change jsp on button click

I have a question. I have 3 jsp page. The first is a menu with 2 button. When I click the first button I want to open the second jsp page. When I click the second button I want to open the third jsp page. Can you help me? I must use a servlet(it's ...

How can I get the content of CKEditor using JQuery?

I'm using CKEditor. I am saving the form values with ajax using page methods. But the content of CKEditor value cannot be saving into the table. I dont postback the page. What can I do for that?...

How to insert values in table with foreign key using MySQL?

I have these two tables just for example: TAB_TEACHER - id_teacher // primary key, autoincrement - name_teacher // a varchar TAB_STUDENT - id_student // primary key, autoincrement - name_student // a varchar - id_teacher_fk // foreign key ref...

number of values in a list greater than a certain number

I have a list of numbers and I want to get the number of times a number appears in a list that meets a certain criteria. I can use a list comprehension (or a list comprehension in a function) but I am wondering if someone has a shorter way. # list o...

How to print environment variables to the console in PowerShell?

I'm starting to use PowerShell and am trying to figure out how to echo a system environment variable to the console to read it. Neither of the below are working. The first just prints %PATH%, and the second prints nothing. echo %PATH% echo $PATH ...

How to convert integer to decimal in SQL Server query?

A column height is integer type in my SQL Server table. I want to do a division and have the result as decimal in my query: Select (height/10) as HeightDecimal How do I cast so that the HeightDecimal is no longer integer? Thanks....

What's the difference between an element and a node in XML?

I'm working in Java with XML and I'm wondering; what's the difference between an element and a node?...

How to semantically add heading to a list

This has been bothering me for a while, and I'm wondering if there's any consensus on how to do this properly. When I'm using an HTML list, how do I semantically include a header for the list? One option is this: <h3>Fruits I Like:</h3>...

How to capture and save an image using custom camera in Android?

How do I capture an image in custom camera and then save that image in android?...

HTML Table width in percentage, table rows separated equally

When I create a table in html, a table with a width of 100%, if I want all the cells (tds) to be divided in equal parts, do I have to enter the width % for each cell? Am I "obliged" to do it? E.g.: <table cellpadding="0" cellspacing="0" width="1...

How do I get java logging output to appear on a single line?

At the moment a default entry looks something like this: Oct 12, 2008 9:45:18 AM myClassInfoHere INFO: MyLogMessageHere How do I get it to do this? Oct 12, 2008 9:45:18 AM myClassInfoHere - INFO: MyLogMessageHere Clarification I'm using java.ut...

How do I get the name of a Ruby class?

How can I get the class name from an ActiveRecord object? I have: result = User.find(1) I tried: result.class # => User(id: integer, name: string ...) result.to_s # => #<User:0x3d07cdc>" I need only the class name, in a string (Use...

ASP.NET MVC3 Razor - Html.ActionLink style

I'm trying to set the style of an action link like so: <text><p>Signed in as @Html.ActionLink(Context.User.Identity.Name,"Index",new { Controller="Account", @style="text-transform:capitalize;" })</p> I'd expect this to be rende...

Prevent flex items from overflowing a container

How do I make my flex item (article in this example), which has flex-grow: 1; not to overflow it's flex parent/container (main)? In this example article is just text, though it might contains other elements (tables, etc). _x000D_ _x000D_ main, asi...

Filtering Sharepoint Lists on a "Now" or "Today"

I'm trying to find an effective method of filtering Sharepoint lists based on the age of an item. In other words, if I want to find list items that are 7 days old, I should be able to build a filtered view on the data. There is a hack to build a "...

How to set Spinner Default by its Value instead of Position?

I have 1-50 records in the database. I am fetching those data using cursor and set those values to Spinner using Simple Cursor Adapter. Now what i need is i want to set one value say 39th value as default. But not by its position i want to set by its...

How to use TLS 1.2 in Java 6

It seems that Java 6 supports TLS up to v1.0, is there any way to use TLS 1.2 in Java 6? Maybe a patch or a particular update of Java 6 will have support for it?...

How can I find all matches to a regular expression in Python?

In a program I'm writing I have Python use the re.search() function to find matches in a block of text and print the results. However, the program exits once it finds the first match in the block of text. How do I do this repeatedly where the progra...

What is the best way to insert source code examples into a Microsoft Word document?

I have to write some documents that will include source code examples. Some of the examples will be written from the IDE, and others would be written in place. My examples are primarily in Java. As someone who is used to LaTeX, doing this in Word is...

How do Common Names (CN) and Subject Alternative Names (SAN) work together?

Assuming the Subject Alternative Name (SAN) property of an SSL certificate contains two DNS names domain.tld host.domain.tld but the Common Name (CN) is set to only one of both: CN=domain.tld. Does this setup have a special meaning, or any [dis]ad...

How to read XML response from a URL in java?

I need to write a simple function that takes a URL and processes the response which is XML or JSON, I have checked the Sun website https://swingx-ws.dev.java.net/servlets/ProjectDocumentList , but the HttpRequest object is to be found nowhere, is it ...

How do you create a temporary table in an Oracle database?

I would like to create a temporary table in a Oracle database something like Declare table @table (int id) In SQL server And then populate it with a select statement Is it possible? Thanks...

Is it possible to run an .exe or .bat file on 'onclick' in HTML

Is it possible to run bat/executable file using html5 button event? In IE its achievable using Shell object if I am not wrong....

Navigation drawer: How do I set the selected item at startup?

My code works perfectly: every time an item in Navigation Drawer is clicked the item is selected. Of course I want to start the app with a default fragment (home), but Navigation Drawer doesn't have the item selected. How can I select that item prog...

How to copy JavaScript object to new variable NOT by reference?

I wrote a quick jsfiddle here, where I pass a small JSON object to a new variable and modify the data from the original variable (not the new variable), but the new variable's data gets updated as well. This must mean that the JSON object was passed ...

What is the best way to get all the divisors of a number?

Here's the very dumb way: def divisorGenerator(n): for i in xrange(1,n/2+1): if n%i == 0: yield i yield n The result I'd like to get is similar to this one, but I'd like a smarter algorithm (this one it's too much slow and dumb :-)...

Eclipse Bug: Unhandled event loop exception No more handles

I've built a GUI using Swing and the MigLayout. I am using Eclipse 4.2.2 (64-bit) on Windows 7 Ultimate. Every time I click back into the window to edit my code, a popup comes up, then I'm prompted to restart Eclipse, and the Event log says the foll...

PHP Date Time Current Time Add Minutes

Simple question but this is killing my time. Any simple solution to add 30 minutes to current time in php with GMT+8?...

Closing database connections in Java

I am getting a little confused. I was reading the below from Java Database Connectivity: Connection conn = DriverManager.getConnection( "jdbc:somejdbcvendor:other data needed by some jdbc vendor", "myLogin", "m...

How to read a file from jar in Java?

I want to read an XML file that is located inside one of the jars included in my class path. How can I read any file which is included in the jar?...

SQL MAX of multiple columns?

How do you return 1 value per row of the max of several columns: TableName [Number, Date1, Date2, Date3, Cost] I need to return something like this: [Number, Most_Recent_Date, Cost] Query?...

How to create an XML document using XmlDocument?

how to create an XML document like this? <body> <level1> <level2>text</level2> <level2>other text</level2> </level1> </body> using XmlDocument in C#...

Octave/Matlab: Adding new elements to a vector

Having a vector x and I have to add an element (newElem) . Is there any difference between - x(end+1) = newElem; and x = [x newElem]; ?...

Combination of async function + await + setTimeout

I am trying to use the new async features and I hope solving my problem will help others in the future. This is my code which is working: async function asyncGenerator() { // other code while (goOn) { // other code var fileList...

Save and load MemoryStream to/from a file

I am serializing an structure into a MemoryStream and I want to save and load the serialized structure. So, How to Save a MemoryStream into a file and also load it back from file?...

Password Protect a SQLite DB. Is it possible?

I have to face a new little project. It will have about 7 or 9 tables, the biggest of them will grow by a max rate of 1000 rows a month. I thought about SQLite as my db... But i will need to protect the db in case anybody wants to change data from t...

JPA CriteriaBuilder - How to use "IN" comparison operator

Can you please help me how to convert the following codes to using "in" operator of criteria builder? I need to filter by using list/array of usernames using "in". I also tried to search using JPA CriteriaBuilder - "in" method but cannot find good r...

How to make HTML open a hyperlink in another window or tab?

This is a line for a hyperlink in HTML: <a href="http://www.starfall.com/">Starfall</a> Thus, if I click on "Starfall" my browser - I am using FireFox - will take me to that new page and the contents of my window will change. I wonder,...

How to find the 'sizeof' (a pointer pointing to an array)?

First off, here is some code: int main() { int days[] = {1,2,3,4,5}; int *ptr = days; printf("%u\n", sizeof(days)); printf("%u\n", sizeof(ptr)); return 0; } Is there a way to find out the size of the array that ptr is pointin...

Check if a user has scrolled to the bottom

I'm making a pagination system (sort of like Facebook) where the content loads when the user scrolls to the bottom. I imagine the best way to do that is to find when the user is at the bottom of the page and run an ajax query to load more posts. The...

How can I get a channel ID from YouTube?

I'm trying to retrive the data from my channel using the YouTube Data API V3. For that I need my channel ID. I've tried to find my channel ID from my YouTube account, and I failed in every single way. If anyone have a single tip for me, I would be in...

OnClick in Excel VBA

Is there a way to catch a click on a cell in VBA with Excel? I am not referring to the Worksheet_SelectionChange event, as that will not trigger multiple times if the cell is clicked multiple times. BeforeDoubleClick does not solve my problem either,...

how to remove multiple columns in r dataframe?

I am trying to remove some columns in a dataframe. I want to know why it worked for a single column but not with multible columns e.g. this works album2[,5]<- NULL this doesn't work album2[,c(5:7)]<- NULL Error in `[<-.data.frame`(`*tmp...

Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.`

EDIT: After I modified the web.config and I don't get error that's good.... then I add a new page (html) and write this small code to consume the service like this: $("#btn12").click(function (event) { $.getJSON('http://localhost:3...

Bootstrap onClick button event

This seems a silly question but just got bootstrap and it doesn't gives any examples on the website about adding a Javascript callback to a button... Tried setting my button an id flag and then <div class="btn-group"> <button id="rectBut...

How do I remove time part from JavaScript date?

I have a date '12/12/1955 12:00:00 AM' stored in a hidden column. I want to display the date without the time. How do I do this?...

how to wait for first command to finish?

I am writing a script in bash, which is calling two bash scripts internally. Where first script includes different tests which runs in background and second script print results of first script. When I run these two scripts one after other, sometime...

How do I measure request and response times at once using cURL?

I have a web service that receives data in JSON format, processes the data, and then returns the result to the requester. I want to measure the request, response, and total time using cURL. My example request looks like: curl -X POST -d @file serv...

How do the post increment (i++) and pre increment (++i) operators work in Java?

Can you explain to me the output of this Java code? int a=5,i; i=++a + ++a + a++; i=a++ + ++a + ++a; a=++a + ++a + a++; System.out.println(a); System.out.println(i); The output is 20 in both cases...

Sorting a list with stream.sorted() in Java

I'm interested in sorting a list from a stream. This is the code I'm using: list.stream() .sorted((o1, o2)->o1.getItem().getValue().compareTo(o2.getItem().getValue())) .collect(Collectors.toList()); Am I missing something? The list is n...

Is it possible to make a Tree View with Angular?

I'm looking to display data in a tree structure in a web app. I was hoping to use Angular for this task. Looks like ng-repeat will allow me to iterate through a list of nodes, but how can I then do nesting when a given node's depth increases? I tri...

PHP 7 simpleXML

I'm testing PHP7, and have a weird issue after a recent update. SimpleXML should be enabled by default, and my phpinfo page shows that it is available: However, the functions are not available: <?php if (function_exists('simplexml_load_file')...

How do I get the number of elements in a list?

Consider the following: items = [] items.append("apple") items.append("orange") items.append("banana") # FAKE METHOD: items.amount() # Should return 3 How do I get the number of elements in the list items?...

How to format a date using ng-model?

I have an input defined as <input class="datepicker" type="text" ng-model="clientForm.birthDate" /> Which is rigged up to be displayed elsewhere on the page: <tr> <th>Birth Date</th> <td>{{client.birthDate|da...

How to create a new img tag with JQuery, with the src and id from a JavaScript object?

I understand JQuery in the basic sense but am definitely new to it, and suspect this is very easy. I've got my image src and id in a JSON response (converted to an object), and therefore the correct values in responseObject.imgurl and responseObject...

How to vertically center a "div" element for all browsers using CSS?

I want to center a div vertically with CSS. I don't want tables or JavaScript, but only pure CSS. I found some solutions, but all of them are missing Internet Explorer 6 support. <body> <div>Div to be aligned vertically</div> &...

How do I convert a string to a number in PHP?

I want to convert these types of values, '3', '2.34', '0.234343', etc. to a number. In JavaScript we can use Number(), but is there any similar method available in PHP? Input Output '2' 2 '2.34' 2.34 '0.3454545' ...

How to set entire application in portrait mode only?

How do I set it so the application is running in portrait mode only? I want the landscape mode to be disabled while the application is running. How do I do it programmatically?...

WooCommerce: Finding the products in database

I'm creating a website using WooCommerce and I want to restrict the available products to users depending on the postcode that they enter in the search form on my home page. To be able to achieve that I'll have to specify the conditions of each pro...

how to pass this element to javascript onclick function and add a class to that clicked element

I had an html navigation code as below _x000D_ _x000D_ function Data(string) { //1. get some data from server according to month year etc., //2. unactive all the remaining li's and make the current clicked element active by adding "active" class ...

How to overwrite styling in Twitter Bootstrap

How can I overwrite the stylings in Twitter Bootstrap? For instance, I am currently using a .sidebar class that has the CSS rule 'float: left;' How can I change this so that it goes to the right instead? I'm using HAML and SASS but am relatively n...

Extract time from moment js object

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

Simplest way to download and unzip files in Node.js cross-platform?

Just looking for a simple solution to downloading and unzipping .zip or .tar.gz files in Node.js on any operating system. Not sure if this is built in or I have to use a separate library. Any ideas? Looking for just a couple lines of code so when ...

pip install access denied on Windows

I am trying to run pip install mitmproxy on Windows, but I keep getting access denied, even with cmd and PowerShell using the Run as Administrator option. WindowsError: [Error 5] Access is denied: 'c:\\users\\bruno\\appdata\\local\\temp\\easy_instal...

Commenting out code blocks in Atom

I have been moving from Webstorm and RubyMine to Atom and I really miss a feature from the Jetbrains editors where you select a code block and press CMD + - and it adds language specific comment character(s) to the beginning of each line. (# for ruby...

How to dismiss the dialog with click on outside of the dialog?

I have implemented a custom dialog for my application. I want to implement that when the user clicks outside the dialog, the dialog will be dismissed. What do I have to do for this?...

mysqli_select_db() expects parameter 1 to be mysqli, string given

I am new to Mysqli_* and I am getting these errors: Warning: mysqli_select_db() expects parameter 1 to be mysqli, string given in D:\Hosting\9864230\html\includes\connection.php on line 11 Warning: mysqli_error() expects exactly 1 paramete...

How to install PyQt4 in anaconda?

From the PyQt4 website their instructions for installing the package are to download the tarball and use the config file. I have two versions of Python, one is my normal system and the other is within anaconda. I'm not sure how I get this to install ...

Stop/Close webcam stream which is opened by navigator.mediaDevices.getUserMedia

I opened a webcam by using the following JavaScript code: const stream = await navigator.mediaDevices.getUserMedia({ /* ... */ }); Is there any JavaScript code to stop or close the webcam? Thanks everyone....

Fixed Table Cell Width

A lot of people still use tables to layout controls, data etc. - one example of this is the popular jqGrid. However, there is some magic happening that I cant seem to fathom (its tables for crying out loud, how much magic could there possibly be?) H...

Regular Expression to get a string between parentheses in Javascript

I am trying to write a regular expression which returns a string which is between parentheses. For example: I want to get the string which resides between the strings "(" and ")" I expect five hundred dollars ($500). would return $500 Found Reg...

Run a Command Prompt command from Desktop Shortcut

Is it possible to create a desktop shortcut that, when pressed, will open command prompt and run a pre-defined command?...

Subversion ignoring "--password" and "--username" options

When I try to do any svn command and supply the --username and/or --password options, it prompts me for my password anyways, and always will attempt to use my current user instead of the one specified by --username. Neither --no-auth-cache nor --non-...

Odd behavior when Java converts int to byte?

int i =132; byte b =(byte)i; System.out.println(b); Mindboggling. Why is the output -124?...

What is a C++ delegate?

What is the general idea of a delegate in C++? What are they, how are they used and what are they used for? I'd like to first learn about them in a 'black box' way, but a bit of information on the guts of these things would be great too. This is no...

SQL Server : export query as a .txt file

I am trying to export my SQL Server query results into a folder in .txt format (this is for an automated job) I know the equivalent in MySQL works with INTO OUTFILE. Does anyone know the best way to do this in SQL Server 2008 Management Studio? SE...

Compile/run assembler in Linux?

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

Webclient / HttpWebRequest with Basic Authentication returns 404 not found for valid URL

Edit: I wanted to come back to note that the problem wasn't on my end at all, but rather with with code on the other company's side. I'm trying to pull up a page using Basic Authentication. I keep getting a 404 Page not found error. I can copy and p...

Is there a "standard" format for command line/shell help text?

If not, is there a de facto standard? Basically I'm writing a command line help text like so: usage: app_name [options] required_input required_input2 options: -a, --argument Does something -b required Does something with "required...

How to add items to array in nodejs

How do I iterate through an existing array and add the items to a new array. var array = []; forEach( calendars, function (item, index) { array[] = item.id }, done ); function done(){ console.log(array); } The above code would normally wo...

Status bar and navigation bar appear over my view's bounds in iOS 7

I recently downloaded Xcode 5 DP to test my apps in iOS 7. The first thing I noticed and confirmed is that my view's bounds is not always resized to account for the status bar and navigation bar. In viewDidLayoutSubviews, I print the view's bounds: ...

Check if an array contains any element of another array in JavaScript

I have a target array ["apple","banana","orange"], and I want to check if other arrays contain any one of the target array elements. For example: ["apple","grape"] //returns true; ["apple","banana","pineapple"] //returns true; ["grape", "pineap...

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

pretty-print JSON using JavaScript

How can I display JSON in an easy-to-read (for human readers) format? I'm looking primarily for indentation and whitespace, with perhaps even colors / font-styles / etc....

Allow user to select camera or gallery for image

What I'm trying to do seems very simple, but after a few days of searching I can't quite figure it out. I have an application that allows the user to select multiple(up to 5) images. I'm using an ImageView. When the user clicks on the ImageView, I'...

Send raw ZPL to Zebra printer via USB

Typically, when I plug in my Zebra LP 2844-Z to the USB port, the computer sees it as a printer and I can print to it from notepad like any other generic printer. However, my application has some bar code features. My application parses some input an...

Android: Difference between onInterceptTouchEvent and dispatchTouchEvent?

What is the difference between onInterceptTouchEvent and dispatchTouchEvent in Android? According to the android developer guide, both methods can be used to intercept a touch event (MotionEvent), but what is the difference? How do onInterceptTouch...

Extract MSI from EXE

I want to extract the MSI of an EXE setup to publish over a network. For example, using Universal Extractor, but it doesn't work for Java Runtime Environment....

Append an int to a std::string

Why is this code gives an Debug Assertion Fail? std::string query; int ClientID = 666; query = "select logged from login where id = "; query.append((char *)ClientID); ...

How do I create a MessageBox in C#?

I have just installed C# for the first time, and at first glance it appears to be very similar to VB6. I decided to start off by trying to make a 'Hello, World!' UI Edition. I started in the Form Designer and made a button named "Click Me!" proceede...

.htaccess redirect www to non-www with SSL/HTTPS

I've got several domains operating under a single .htaccess file, each having an SSL certificate. I need to force a https prefix on every domain while also ensuring www versions redirect to no-www ones. Below is my code; it doesn't work: RewriteCo...

What is default color for text in textview?

I set the color to red , and after that I want to set the color again back to default, but I do not know what is default color, does anyone knows ?...

Access a URL and read Data with R

Is there a way I can specify and get data from a web site URL on to a CSV file for analysis using R?...

startActivityForResult() from a Fragment and finishing child Activity, doesn't call onActivityResult() in Fragment

FirstActivity.Java has a FragmentA.Java which calls startActivityForResult(). SecondActivity.Java call finish() but onActivityResult never get called which is written in FragmentA.Java. FragmentA.Java code: @Override public void onActivityCrea...

Tool to generate JSON schema from JSON data

We have this json schema draft. I would like to get a sample of my JSON data and generate a skeleton for the JSON schema, that I can rework manually, adding things like description, required, etc, which can not be infered from the specific examples. ...

Django - taking values from POST request

I have the following django template (http://IP/admin/start/ is assigned to a hypothetical view called view): {% for source in sources %} <tr> <td>{{ source }}</td> <td> <form action="/admin/start/" method="...

Returning value from Thread

I have a method with a HandlerThread. A value gets changed inside the Thread and I'd like to return it to the test() method. Is there a way to do this? public void test() { Thread uiThread = new HandlerThread("UIHandler"){ public sync...

How to dynamically add a style for text-align using jQuery

I'm trying to correct the usual IE bugs around CSS 2.1 and need a way to alter an elements style properties to add a custom text-align style. Currently in jQuery you can do something like $(this).width() or $(this).height() but I can't seem to f...

Remove multiple whitespaces

I'm getting $row['message'] from a MySQL database and I need to remove all whitespace like \n \t and so on. $row['message'] = "This is a Text \n and so on \t Text text."; should be formatted to: $row['message'] = 'This is a Text and so on T...

ASP.NET MVC Razor pass model to layout

What I see is a string Layout property. But how can I pass a model to layout explicitly?...

Execute PowerShell Script from C# with Commandline Arguments

I need to execute a PowerShell script from within C#. The script needs commandline arguments. This is what I have done so far: RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create(); Runspace runspace = RunspaceFactory.Create...

Jquery, set value of td in a table?

I create dynamic a table with <tr> and <td> tags. One of the td tags gets the id "detailInfo". I have an onclick function on some button. I would like to set some value in the td "detailInfo" after pressing on the button. So how can I se...

Angular JS - angular.forEach - How to get key of the object?

I have JSON object like below { "txt_inc_Application": { "EWS": true, "EWindow": true }, "txt_inc_IncidentType": { "Brand Damage": true, "Internal failure": true } } And I am using angular.forEach to...

Summing elements in a list

Here is my code, I need to sum an undefined number of elements in the list. How to do this? l = raw_input() l = l.split(' ') l.pop(0) My input: 3 5 4 9 After input I delete first element via l.pop(0). After .split(' ') my list is ['5', '4', '9'] a...

How to decode a QR-code image in (preferably pure) Python?

TL;DR: I need a way to decode a QR-code from an image file using (preferable pure) Python. I've got a jpg file with a QR-code which I want to decode using Python. I've found a couple libraries which claim to do this: PyQRCode (website here) whi...

Request Permission for Camera and Library in iOS 10 - Info.plist

I have implemented a WKWebView in an app. there's a file input in the shown web page where it should import an image from photos. Whenever i press on that input and select either "Take Photo" or "Photo Library" the app suddenly crash, which I believe...

Where is localhost folder located in Mac or Mac OS X?

I just started developing PHP projects on my mac (using PDT) and was wondering where localhost is located? How does Mac OS X serve websites, I haven't changed any settings during the installation of PDT....

PHP simple foreach loop with HTML

I am wondering if it will work best to actually write the following for example: <table> <?php foreach($array as $key=>$value){ ?> <tr> <td><?php echo $key; ?></td> </tr> <?php ...

Subset and ggplot2

I have a problem to plot a subset of a data frame with ggplot2. My df is like: df = data.frame(ID = c('P1', 'P1', 'P2', 'P2', 'P3', 'P3'), Value1 = c(100, 120, 300, 400, 130, 140), Value2 = c(12, 13, 11, 16, 15, 12)) ...

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

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

How to make an executable JAR file?

I have a program which consists of two simple Java Swing files. How do I make an executable JAR file for my program?...

Meaning of Choreographer messages in Logcat

I installed the latest versions of SDK (API 16) and got the latest ADT. I'm now seeing these messages in the logcat, that I'm quite sure, I haven't seen before. Does anyone have an idea about this? 06-29 23:11:17.796: I/Choreographer(691): Skippe...

Adding days to a date in Python

I have a date "10/10/11(m-d-y)" and I want to add 5 days to it using a Python script. Please consider a general solution that works on the month ends also. I am using following code: import re from datetime import datetime StartDate = "10/10/11" ...

What is the default encoding of the JVM?

Is UTF-8 the default encoding in Java? If not, how can I know which encoding is used by default?...

How do I use a third-party DLL file in Visual Studio C++?

I understand that I need to use LoadLibrary(). But what other steps do I need to take in order to use a third-party DLL file? I simply jumped into C++ and this is the only part that I do not get (as a Java programmer). I am just looking into how I c...

CSS media query to target iPad and iPad only?

Hi I am working with multiple tablet devices, iPad, Galaxy Tab, Acer Iconia, LG 3D Pad and so on. iPad - 1024 x 768 LG Pad - 1280 x 768 Galaxy Tab - 1280 x 800 I want to target iPad only using CSS3 media query. Since, device width of LG and iPad ...

Multiple file upload in php

I want to upload multiple files and store them in a folder and get the path and store it in the database... Any good example you looked for doing multiple file upload... Note: Files can be of any type......

New line in Sql Query

How you get new line or line feed in Sql Query ?...

Disable button after click in JQuery

My button uses AJAX to add information to the database and change the button text. However, I wish to have the button disabled after one click (or else the person can spam the information in the dataabase). How do I do this? HTML <button class="...

How to get the seconds since epoch from the time + date output of gmtime()?

How do you do reverse gmtime(), where you put the time + date and get the number of seconds? I have strings like 'Jul 9, 2009 @ 20:02:58 UTC', and I want to get back the number of seconds between the epoch and July 9, 2009. I have tried time.strfti...

How do I resolve "Run-time error '429': ActiveX component can't create object"?

My company has a VB6 application using Crystal Reports 7 which a client has asked to be installed on Windows 7 32 bit. It is currently installed on Windows XP 32bit SP2 machines at the client. Connection to the DB is done via ODBC to SQL Server 2000 ...

Visual Studio Copy Project

I would like to make a copy of my project. I would rather not start doing it from scratch by adding files and references, etc. Please note that I don't mean copy for deployment. Just plain copy. Is there a tool in VS to do this? I am using VS 2008...

String delimiter in string.split method

I have following data: 1||1||Abdul-Jabbar||Karim||1996||1974 I want to delimit the tokens. Here the delimiter is "||". My delimiter setter is: public void setDelimiter(String delimiter) { char[] c = delimiter.toCharArray(); this.delimit...

json and empty array

I have the following json : { "users": [{ "user": { "user_id" :"a11uhk22hsd3jbskj", "username" :"tom", "location" : null } }] } I get this json in response to a request to an api. Lookin...

MD5 hashing in Android

I have a simple android client which needs to 'talk' to a simple C# HTTP listener. I want to provide a basic level of authentication by passing username/password in POST requests. MD5 hashing is trivial in C# and provides enough security for my need...

Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/JDBC_DBO]]

I get this Tomcat Error: Sep 09, 2012 4:16:54 PM org.apache.catalina.core.AprLifecycleListener init Information: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library...

How to convert current date to epoch timestamp?

How to convert current date to epoch timestamp ? Format current date: 29.08.2011 11:05:02 ...

How to set max width of an image in CSS

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

How do I create a master branch in a bare Git repository?

(All done in poshgit on Windows 8): git init --bare test-repo.git cd test-repo.git (Folder is created with git-ish files and folders inside) git status fatal: This operation must be run in a work tree (Okay, so I can't use git status with a bar...

Creating java date object from year,month,day

int day = Integer.parseInt(request.getParameter("day")); // 25 int month = Integer.parseInt(request.getParameter("month")); // 12 int year = Integer.parseInt(request.getParameter("year")); // 1988 System.out.println(year); Calendar c = Calendar.ge...

Docker: unable to prepare context: unable to evaluate symlinks in Dockerfile path: GetFileAttributesEx

I just downloaded Docker Toolbox for Windows 10 64bit today. I'm going through the tutorial. I'm receving the following error when trying to build an image using a Dockerfile. Steps: Launched Docker Quickstart terminal. testdocker after creating...

Android: ProgressDialog.show() crashes with getApplicationContext

I can't seem to grasp why this is happening. This code: mProgressDialog = ProgressDialog.show(this, "", getString(R.string.loading), true); works just fine. However, this code: mProgressDialog = ProgressDialog.show(getApplicationContext(), "", ge...

Java: Get month Integer from Date

How do I get the month as an integer from a Date object (java.util.Date)?...

What's the difference between `raw_input()` and `input()` in Python 3?

What is the difference between raw_input() and input() in Python 3?...

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined raised when starting react app

I'm working on a project in React and ran into a problem that has me stumped. Whenever I run yarn start I get this error: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined I have no idea w...

How to unmount, unrender or remove a component, from itself in a React/Redux/Typescript notification message

I know this question has been asked a couple of times already but most of the time, the solution is to handle this in the parent, as the flow of responsibility is only descending. However, sometimes, you need to kill a component from one of its metho...

Tkinter: How to use threads to preventing main event loop from "freezing"

I have a small GUI test with a "Start" button and a Progress bar. The desired behavior is: Click Start Progressbar oscillates for 5 seconds Progressbar stops The observed behavior is the "Start" button freezes for 5 seconds, then a Progressbar is...

How can I open a website in my web browser using Python?

I want to open a website in my local computer's web browser (Chrome or Internet Explorer) using Python. open("http://google.co.kr") # something like this Is there a module that can do this for me?...

Get a DataTable Columns DataType

DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn(gridColumn1, typeof(bool))); I was expecting the result of the below line to include info about the DataColumns Type (bool): ?dt.Columns[0].GetType() ...

How do I print all POST results when a form is submitted?

I need to see all of the POST results that are submitted to the server for testing. What would be an example of how I can create a new file to submit to that will echo out all of the fields which were submitted with that form? It's dynamic, so some...

How to run or debug php on Visual Studio Code (VSCode)

I can't find a way to run or debug php on Visual studio code, Does anyone know how?...

How can I debug javascript on Android?

I'm working on a project that involves Raphaeljs. Turns out, it doesn't work on Android. It does on the iPhone. How the heck to I go about debugging something on the Android browser? It's WebKit, so if I know the version, will debugging it on that f...

How to properly use unit-testing's assertRaises() with NoneType objects?

I did a simple test case: def setUp(self): self.testListNone = None def testListSlicing(self): self.assertRaises(TypeError, self.testListNone[:1]) and I am expecting test to pass, but I am getting exception: Traceback (most recent call las...

Negative weights using Dijkstra's Algorithm

I am trying to understand why Dijkstra's algorithm will not work with negative weights. Reading an example on Shortest Paths, I am trying to figure out the following scenario: 2 A-------B \ / 3 \ / -2 \ / C From the website: ...

How to fetch FetchType.LAZY associations with JPA and Hibernate in a Spring Controller

I have a Person class: @Entity public class Person { @Id @GeneratedValue private Long id; @ManyToMany(fetch = FetchType.LAZY) private List<Role> roles; // etc } With a many-to-many relation that is lazy. In my cont...

Angular-Material DateTime Picker Component?

I imported a date picker in a project and was wondering if there was any official recent component from angular and material to include time in the calendar as well. I've seen plenty of time pickers in material documentation and researched a lot of t...

How to display databases in Oracle 11g using SQL*Plus

With help of this command show databases; I can see databases in MySQL. How to show the available databases in Oracle?...

Error on line 2 at column 1: Extra content at the end of the document

When I use the below code and parse the xml locally it works fine but when upload the same script at the server it shows error. Note: I retrieved the $lng and $lat from the query string and it works fine locally. $lng=$_GET['lng']; $lat=$_GET['lat...

python numpy machine epsilon

I am trying to understand what is machine epsilon. According to the Wikipedia, it can be calculated as follows: def machineEpsilon(func=float): machine_epsilon = func(1) while func(1)+func(machine_epsilon) != func(1): machine_epsilon...

Context.startForegroundService() did not then call Service.startForeground()

I am using Service Class on the Android O OS. I plan to use the Service in the background. The Android documentation states that If your app targets API level 26 or higher, the system imposes restrictions on using or creating background serv...

Python: instance has no attribute

I have a problem with list within a class in python. Here's my code : class Residues: def setdata(self, name): self.name = name self.atoms = list() a = atom C = Residues() C.atoms.append(a) Something like this. I get an error ...

Any way to Invoke a private method?

I have a class that uses XML and reflection to return Objects to another class. Normally these objects are sub fields of an external object, but occasionally it's something I want to generate on the fly. I've tried something like this but to no avai...

how to get selected row value in the KendoUI

I have a kendoUI grid. @(Html.Kendo().Grid<EntityVM>() .Name("EntitesGrid") .HtmlAttributes(new { style = "height:750px;width:100%;scrollbar-face-color: #eff7fc;" }) ...

How do I get a list of installed CPAN modules?

Aside from trying perldoc <module name> individually for any CPAN module that takes my fancy or going through the file system and looking at the directories I have no idea what modules we have installed. What's the easiest way to just get ...

Open and write data to text file using Bash?

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

ECMAScript 6 class destructor

I know ECMAScript 6 has constructors but is there such a thing as destructors for ECMAScript 6? For example if I register some of my object's methods as event listeners in the constructor, I want to remove them when my object is deleted. One soluti...

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 do I add more members to my ENUM-type column in MySQL?

The MySQL reference manual does not provide a clearcut example on how to do this. I have an ENUM-type column of country names that I need to add more countries to. What is the correct MySQL syntax to achieve this? Here's my attempt: ALTER TABLE ca...

When do you use the "this" keyword?

I was curious about how other people use the this keyword. I tend to use it in constructors, but I may also use it throughout the class in other methods. Some examples: In a constructor: public Light(Vector v) { this.dir = new Vector(v); } El...

awk without printing newline

I want the variable sum/NR to be printed side-by-side in each iteration. How do we avoid awk from printing newline in each iteration ? In my code a newline is printed by default in each iteration for file in cg_c ep_c is_c tau xhpl printf "\n $file"...

How can I format bytes a cell in Excel as KB, MB, GB etc?

I have a value in a cell that's in bytes. But nobody can read 728398112238. I'd rather it say 678.37GB To write a formula to format it relatively easy (here's one: http://www.yonahruss.com/2007/02/format-excel-numbers-as-gb-mb-kb-b.html) But is the...

How to check for the type of a template parameter?

Suppose I have a template function and two classes class animal { } class person { } template<class T> void foo() { if (T is animal) { kill(); } } How do I do the check for T is animal? I don't want to have something that checks dur...

pod has unbound PersistentVolumeClaims

When I push my deployments, for some reason, I'm getting the error on my pods: pod has unbound PersistentVolumeClaims Here are my YAML below: This is running locally, not on any cloud solution. apiVersion: extensions/v1beta1 kind: Deploymen...

Automating running command on Linux from Windows using PuTTY

I have a scenario where I need to run a linux shell command frequently (with different filenames) from windows. I am using PuTTY and WinSCP to do that (requires login name and password). The file is copied to a predefined folder in the linux machine...

"The system cannot find the file specified" when running C++ program

I installed Visual Studio 2010. I wrote a simple code which I'm sure is correct but unfortunately, when I run the code, I get the error below. Here is my code: #include<iostream> using namespace std; int main (){ cout <<"Hello StackO...

Can I apply a CSS style to an element name?

I'm currently working on a project where I have no control over the HTML that I am applying CSS styles to. And the HTML is not very well labelled, in the sense that there are not enough id and class declarations to differentiate between elements. So...

Best way to convert pdf files to tiff files

I have around 1000 pdf filesand I need to convert them to 300 dpi tiff files. What is the best way to do this? If there is an SDK or something or a tool that can be scripted that would be ideal. ...

SQL GROUP BY CASE statement with aggregate function

I have a column that looks something like this: CASE WHEN col1 > col2 THEN SUM(col3*col4) ELSE 0 END AS some_product And I would like to put it in my GROUP BY clause, but this seems to cause problems because there is an aggregate functi...

This page didn't load Google Maps correctly. See the JavaScript console for technical details

I am using this code from Google Map API's and it is not working <!DOCTYPE html> <html> <head> <title>Place Autocomplete</title> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> <meta cha...

Casting a variable using a Type variable

In C# can I cast a variable of type object to a variable of type T where T is defined in a Type variable?...

How to get the current time as datetime

Just started with the playground. I'm trying to create a simple app. I've created a date object like this: var date = NSDate() How can I get the current hour? In other languages I can do something like this: var hour = date.hour But I can't fi...

How to generate random number in Bash?

How to generate a random number within a range in Bash?...

How to get your Netbeans project into Eclipse

I want to get my NetBeans project to Eclipse. It's a web application project. I imported war files into Eclipse but I am not able to get the Java files and the war files are giving me many errors. What is the best way to import the whole project?...

Failed to resolve: com.android.support:appcompat-v7:27.+ (Dependency Error)

I am having this issue in Android studio. Error:Failed to resolve: com.android.support:appcompat-v7:27.+ <a href="install.m2.repo">Install Repository and sync project</a><br><a href="open.dependency.in.project.structure">Show...

Shortcut to Apply a Formula to an Entire Column in Excel

If I select a cell containing a formula, I know I can drag the little box in the right-hand corner downwards to apply the formula to more cells of the column. Unfortunately, I need to do this for 300,000 rows! Is there a shortcut, similar to CTRL+SP...

Connecting to Oracle Database through C#?

I need to connect to a Oracle DB (external) through Visual Studio 2010. But I dont want to install Oracle on my machine. In my project I referenced: System.Data.OracleClient. But its not fulfilling the need. I have an "Oracle SQL Developer IDE" in ...

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

Missing Microsoft RDLC Report Designer in Visual Studio

In Visual Studio 2015, I cannot find the designer for RDLC reports anymore. Does anyone know if this is only a bug and if it is provided later on or if Microsoft wants to kill the RDLC or if they want us to use an external designer and when, which de...

how to call a function from another function in Jquery

<script> $(document).ready(function(){ //Load City by State $('#billing_state_id').live('change', function() { //do something }); $('#click_me').live('click', function() { //do something //need to recal...

Javascript validation: Block special characters

How can I restrict users from entering special characters in the text box. I want only numbers and alphabets to be entered ( Typed / Pasted ). Any samples?...

IllegalArgumentException or NullPointerException for a null parameter?

I have a simple setter method for a property and null is not appropriate for this particular property. I have always been torn in this situation: should I throw an IllegalArgumentException, or a NullPointerException? From the javadocs, both seem appr...

How to make ng-repeat filter out duplicate results

I'm running a simple ng-repeat over a JSON file and want to get category names. There are about 100 objects, each belonging to a category - but there are only about 6 categories. My current code is this: <select ng-model="orderProp" > <...

What should I use to open a url instead of urlopen in urllib3

I wanted to write a piece of code like the following: from bs4 import BeautifulSoup import urllib2 url = 'http://www.thefamouspeople.com/singers.php' html = urllib2.urlopen(url) soup = BeautifulSoup(html) But I found that I have to install urllib...

MySql difference between two timestamps in days?

How can I get the difference between two timestamps in days? Should I be using a datetime column for this? I switched my column to datetime. Simple subtraction doesn't seem to give me a result in days. mysql> SELECT NOW(), last_confirmation_att...

How to verify a method is called two times with mockito verify()

I want to verify if a method is called at least once through mockito verify. I used verify and it complains like this: org.mockito.exceptions.verification.TooManyActualInvocations: Wanted 1 time: But was 2 times. Undesired invocation: ...

How to move or copy files listed by 'find' command in unix?

I have a list of certain files that I see using the command below, but how can I copy those files listed into another folder, say ~/test? find . -mtime 1 -exec du -hc {} + ...

TypeError: cannot perform reduce with flexible type

I have been using the scikit-learn library. I'm trying to use the Gaussian Naive Bayes Module under the scikit-learn library but I'm running into the following error. TypeError: cannot perform reduce with flexible type Below is the code snippet. t...

ExecutorService, how to wait for all tasks to finish

What is the simplest way to to wait for all tasks of ExecutorService to finish? My task is primarily computational, so I just want to run a large number of jobs - one on each core. Right now my setup looks like this: ExecutorService es = Executors...

Add a common Legend for combined ggplots

I have two ggplots which I align horizontally with grid.arrange. I have looked through a lot of forum posts, but everything I try seem to be commands that are now updated and named something else. My data looks like this; # Data plot 1 ...

How to implode array with key and value without foreach in PHP

Without foreach, how can I turn an array like this array("item1"=>"object1", "item2"=>"object2",......."item-n"=>"object-n"); to a string like this item1='object1', item2='object2',.... item-n='object-n' I thought about implode() alre...

npm install hangs

This is my package.json: { "name": "my-example-app", "version": "0.1.0", "dependencies": { "request": "*", "nano": "3.3.x", "async": "~0.2" } } Now, when I open the cmd and run npm install, the install hangs. What am I doing wrong?...

CURL Command Line URL Parameters

I am trying to send a DELETE request with a url parameter using CURL. I am doing: curl -H application/x-www-form-urlencoded -X DELETE http://localhost:5000/locations` -d 'id=3' However, the server is not seeing the parameter id = 3. I tried using ...

Get DOS path instead of Windows path

In a DOS window, how can I get the full DOS name/short name of the directory I am in? For example, if I am in the directory C:\Program Files\Java\jdk1.6.0_22, I want to display it's short name C:\PROGRA~1\Java\JDK16~1.0_2. I know running dir /x wil...

ASP.NET jQuery Ajax Calling Code-Behind Method

I am very new to web development, but have a lot of experience in development in general. I have an ASP page that has a few input fields and a submit button. This submit button purely calls $.ajax, which I intended to have call a method in the code-b...

Connect to docker container as user other than root

BY default when you run docker run -it [myimage] OR docker attach [mycontainer] you connect to the terminal as root user, but I would like to connect as a different user. Is this possible? ...

How can I generate a tsconfig.json file?

How can I generate a tsconfig.json via the command line? I tried command tsc init, but this doesn't work....

What is the difference between user variables and system variables?

What is the difference between user variables such as PATH, TMP, etc. and system variables? I accidentally deleted the user variable PATH. What am I supposed to do?...

What is the difference between an IntentService and a Service?

Can you please help me understand what the difference between an IntentService and a Service is?...

Adding and removing style attribute from div with jquery

I've inherited a project I'm working on and I'm updating some jquery animations (very little practice with jquery). I have a div I need to add and remove the style attribute from. Here is the div: <div id='voltaic_holder'> At one point in t...

error opening trace file: No such file or directory (2)

I am getting the above error: error opening trace file: No such file or directory (2) when I run my android application on the emulator. Can someone tell me what could be the possible reason for this? I am using android-sdk-20 and below line...

matplotlib colorbar for scatter

I'm working with data that has the data has 3 plotting parameters: x,y,c. How do you create a custom color value for a scatter plot? Extending this example I'm trying to do: import matplotlib import matplotlib.pyplot as plt cm = matplotlib.cm.get_...