Questions Tagged with #Collect

Difference between map and collect in Ruby?

I have Googled this and got patchy / contradictory opinions - is there actually any difference between doing a map and doing a collect on an array in Ruby/Rails? The docs don't seem to suggest any, ..

Easy way to use variables of enum types as string in C?

Here's what I am trying to do: typedef enum { ONE, TWO, THREE } Numbers; I am trying to write a function that would do a switch case similar to the following: char num_str[10]; int process_numb..

Calculating and printing the nth prime number

I am trying to calculate prime numbers, which I've already done. But I want to calculate and print ONLY the nth prime number (User input), while calculating the rest (They won't be printed) only the n..

How to change column width in DataGridView?

I have created a database and table using Visual Studio's SQL Server Compact 3.5 with a dataset as my datasource. On my WinForm I have a DataGridView with 3 columns. However, I have been unable to fig..

jQuery .scrollTop(); + animation

I set the page to scroll to top when a button is clicked. But first I used an if statement to see if the top of the page was not set to 0. Then if it's not 0 I animate the page to scroll to the top...

Resize external website content to fit iFrame width

I have a webpage with 2 iFrames in it. Both of them are with fixed width and height. I am loading external websites inside them. How can I resize those external websites width to fit with the iFrame (..

How to pass table value parameters to stored procedure from .net code

I have a SQL Server 2005 database. In a few procedures I have table parameters that I pass to a stored proc as an nvarchar (separated by commas) and internally divide into single values. I add it to t..

How to loop through key/value object in Javascript?

var user = {}; now I want to create a setUsers() method that takes a key/value pair object and initializes the user variable. setUsers = function(data) { // loop and init user } where..

How do I set a program to launch at startup

I have a small application with a CheckBox option that the user can set if they want the app to start with Windows. My question is how do I actually set the app to run at startup. ps: I'm using C# w..

Converting HTML element to string in JavaScript / JQuery

I would like to convert a html element created from a string back to the string after some modifications. But I get an empty string instead. $('<iframe width="854" height="480" src="

How to hide first section header in UITableView (grouped style)

As the design of table views using the grouped style changed considerably with iOS 7, I would like to hide (or remove) the first section header. So far I haven't managed to achieve it. Somewhat simpl..

How can I run MongoDB as a Windows service?

How can I set up MongoDB so it can run as a Windows service?..

Checking the equality of two slices

How can I check if two slices are equal?..

Compile a DLL in C/C++, then call it from another program

I want to make a simple, simple DLL which exports one or two functions, then try to call it from another program... Everywhere I've looked so far, is for complicated matters, different ways of linking..

Run a shell script with an html button

I want to launch a bash script when a button is pressed on a website. This is my first attempt: <button type="button" onclick="/path/to/">Click Me!</button> But no luck. Any sugg..

javascript getting my textbox to display a variable

So I have some basic code in html here, i just have two textbox which u can type numbers in and when you click the button, it adds em both up, and in a perfect world, it would display the answer in th..

Setting Access-Control-Allow-Origin in ASP.Net MVC - simplest possible method

I have a simple actionmethod, that returns some json. It runs on I need to access this from another site If I try to call it, I get the expected...: Origin http:..

Does a valid XML file require an XML declaration?

I am parsing an XML file using Sax Parser of Xerces. Is the XML declaration <?xml version="1.0" encoding="UTF-8"?> required?..

Can not deserialize instance of java.lang.String out of START_ARRAY token

I am very new to the Jackson parser. My code was running fine until today. I am not able to figure out the error. Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: Can n..

Scanner is never closed

I'm working on a game and I came across a little problem with my scanner. I'm getting a resource leak scanner never closed. But I thought my scanner was working before without closing it. But now it ..

Difference between static memory allocation and dynamic memory allocation

I would like to know what is the difference between static memory allocation and dynamic memory allocation? Could you explain this with any example?..

Passing Parameters JavaFX FXML

How can I pass parameters to a secondary window in javafx? Is there a way to communicate with the corresponding controller? For example: The user chooses a customer from a TableView and a new window ..

Check if input value is empty and display an alert

How is it possible to display an alert with jQuery if I click the submit button and the value of the input field is empty? <input type="text" id="myMessage" name="shoutbox_..

How to enable ASP classic in IIS7.5

I am running IIS 7.5 in Windows 7 and have already gone into "Turn Windows features on or off" and enabled ASP in "Internet Information Services/World Wide Web Service/application Development Features..

How can I get the "network" time, (from the "Automatic" setting called "Use network-provided values"), NOT the time on the phone?

I would like in my application to find a way to synch the date and time with something given by an external source. I don't want to use the phone time because I might get a difference of maybe 5 minu..

Regex to match URL end-of-line or "/" character

I have a URL, and I'm trying to match it to a regular expression to pull out some groups. The problem I'm having is that the URL can either end or continue with a "/" and more URL text. I'd like to ma..

&& (AND) and || (OR) in IF statements

I have the following code: if(!partialHits.get(req_nr).containsKey(z) || partialHits.get(req_nr).get(z) < tmpmap.get(z)){ partialHits.get(z).put(z, tmpmap.get(z)); } where partialHits ..

Click in OK button inside an Alert (Selenium IDE)

I need to click the 'Ok' button inside an alert window with a Selenium command. I've tried assertAlert or verifyAlert but they don't do what I want. It's possible the click the 'Ok' button? If so, ca..

async for loop in node.js

I am new to this node.js ..I am little bit confused about this callback..In my app inside a for loop i am calling a asynchronous function call,i think my problem is that before i am getting response o..

Iterating through list of list in Python

I want to iterate through list of list. I want to iterate through irregularly nested lists inside list also. Can anyone let me know how can I do that? x = [u'sam', [['Test', [['one', [], []]], [(u'fi..

How can I make an entire HTML form "readonly"?

I have two pages with HTML forms. The first page has a submission form, and the second page has an acknowledgement form. The first form offers a choice of many controls, while the second page displays..

How to convert QString to std::string?

I am trying to do something like this: QString string; // do things... std::cout << string << std::endl; but the code doesn't compile. How to output the content of qstring into the cons..

Python integer incrementing with ++

I've always laughed to myself when I've looked back at my VB6 days and thought, "What modern language doesn't allow incrementing with double plus signs?": number++ To my surprise, I can't find anyt..

List only stopped Docker containers

Docker gives you a way of listing running containers or all containers including stopped ones. This can be done by: $ docker ps # To list running containers Or by $ docker ps -a # To list running..

How do I get the full path to a Perl script that is executing?

I have Perl script and need to determine the full path and filename of the script during execution. I discovered that depending on how you call the script $0 varies and sometimes contains the fullpath..

CSS - how to make image container width fixed and height auto stretched

I've go some html code like this: <div class="item"> <img src="..."> </div> And css code like this: img { max-width: 100%; height: auto; } .item { width: 120p..

How to select/get drop down option in Selenium 2

I am converting my selenium 1 code to selenium 2 and can't find any easy way to select a label in a drop down menu or get the selected value of a drop down. Do you know how to do that in Selenium 2? ..

How to write connection string in web.config file and read from it?

I'm trying to write Connection string to Web.config like this: <connectionStrings> <add name="Dbconnection" connectionString="Server=localhost; Database=OnlineShopping ; Integrated..

how do you insert null values into sql server

In sql server enterprise manager, how do you write an insert statement and pass in null values?..

sql: check if entry in table A exists in table B

I have a definition table that I know is not being maintained very well, lets call this table A. I have another table (call it table B) that is much smaller and ideally should be a subset of table A b..

PHP FPM - check if running

The documentation on php fpm website says that php fpm is part for coe php as of 5.3.3 I am running 5.3.10, how can i check that it is working correctly? I thought it was a service that ran on a por..

How do I set an ASP.NET Label text from code behind on page load?

I can't seem to find an answer out there for this. Here's the scenario: I have an ASP.NET project using C#. I'm loading data (Username, email, etc...) from a sqlite database with C# (using ADO). I'll ..

Start thread with member function

I am trying to construct a std::thread with a member function that takes no arguments and returns void. I can't figure out any syntax that works - the compiler complains no matter what. What is the co..

What does $1 [QSA,L] mean in my .htaccess file?

I need to change my .htaccess and there are two lines which I don't understand. RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] When I should use these lines ?..

Why does my Eclipse keep not responding?

I'm using Eclipse, and at random times, it will just freeze up and stop responding. Does this happen to anyone else? It usually happens when I click on a line of code, whether it be Java or XML. Any i..

Java AES and using my own Key

I want to encrypt a string using AES with my own key. But I'm having trouble with the bit length of the key. Can you review my code and see what I need to fix/change. public static void main(String[]..

Pass mouse events through absolutely-positioned element

I'm attempting to capture mouse events on an element with another absolutely-positioned element on top of it. Right now, events on the absolutely-positioned element hit it and bubble up to its parent..

Ruby Arrays: select(), collect(), and map()

The syntax for mapping: a = ["a", "b", "c", "d"] #=> ["a", "b", "c", "d"] {|item|"a" == item} #=> [true, false, false, false] {|item|"a" == item} #=> ["a"] Quest..

Is there a method that calculates a factorial in Java?

I didn't find it, yet. Did I miss something? I know a factorial method is a common example program for beginners. But wouldn't it be useful to have a standard implementation for this one to reuse? I ..

Change a Django form field to a hidden field

I have a Django form with a RegexField, which is very similar to a normal text input field. In my view, under certain conditions I want to hide it from the user, and trying to keep the form as simila..

What is the correct way to free memory in C#

I have a timer in C# which executes some code inside it's method. Inside the code I'm using several temporary objects. If I have something like Foo o = new Foo(); inside the method, does that mean t..

jQuery Force set src attribute for iframe

I have a main page (actually a JSP) with an iframe inside it as; <iframe name="abc_frame" id="abc_frame" src="about:blank" frameborder="0" scrolling="no"></iframe> Now there are multipl..

adb doesn't show nexus 5 device

Android Studio 0.3.6 Fedora 18 3.11.7-100.fc18.x86_64 Nexus 5 Kitkat Hello, I have been using my Samsung Galaxy Tab 3 7.0 running Android 4.1.2 everything works fine with adb. However, I have just..

Check if the number is integer

I was surprised to learn that R doesn't come with a handy function to check if the number is integer. is.integer(66) # FALSE The help files warns: is.integer(x) does not test if x contains in..

Learning Ruby on Rails

As it stands now, I'm a Java and C# developer. The more and more I look at Ruby on Rails, the more I really want to learn it. What have you found to be the best route to learn RoR? Would it be eas..

How to apply an XSLT Stylesheet in C#

I want to apply an XSLT Stylesheet to an XML Document using C# and write the output to a File...

Display number with leading zeros

Given: a = 1 b = 10 c = 100 How do I display a leading zero for all numbers with less than two digits? This is the output I'm expecting: 01 10 100 ..

Can't drop table: A foreign key constraint fails

In MySQL I want to drop a table. I tried a lot things but I keep getting the error that the table named bericht can't be dropped. This is the error I'm getting: #1217 - Cannot delete or update a p..

Dynamically Dimensioning A VBA Array?

Why am I unable to set the size of an array based on a variable? What's the best way around this? Dim NumberOfZombies as integer NumberOfZombies = 20000 Dim Zombies(NumberOfZombies) as New Zombie ..

Using "like" wildcard in prepared statement

I am using prepared statements to execute mysql database queries. And I want to implement a search functionality based on a keyword of sorts. For that I need to use LIKE keyword, that much I know. A..

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

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

Take a char input from the Scanner

I am trying to find a way to take a char input from the keyboard. I tried using: Scanner reader = new Scanner(; char c = reader.nextChar(); This method doesn't exist. I tried taking c a..

Android - styling seek bar

I wanted to style a seek bar which looks like the one in the image below. By using default seekbar I will get something like this: So what I need is to only change the color. I need no extra sty..

How to determine if a number is positive or negative?

I was asked in an interview, how to determine whether a number is positive or negative. The rules are that we should not use relational operators such as <, and >, built in java functions (like ..

Python 3 turn range to a list

I'm trying to make a list with numbers 1-1000 in it. Obviously this would be annoying to write/read, so I'm attempting to make a list with a range in it. In Python 2 it seems that: some_list = range(..

Get all column names of a DataTable into string array using (LINQ/Predicate)

I know we can easily do this by a simple loop, but I want to persue this LINQ/Predicate? string[] columnNames = dt.Columns.? or string[] columnNames = from DataColumn dc in dt.Columns select dc.nam..

How to close Browser Tab After Submitting a Form?

<?php /* ... SQL EXECUTION TO UPDATE DB ... */ ?> <form method = "post" action = "<?=$_SERVER['php_self']?>" onSubmit= "window.close();"> ... <input type="..

Raise error in a Bash script

I want to raise an error in a Bash script with message "Test cases Failed !!!". How to do this in Bash? For example: if [ condition ]; then raise error "Test cases failed !!!" fi ..

How to get a Color from hexadecimal Color String

I'd like to use a color from an hexa string such as "#FFFF0000" to (say) change the background color of a Layout. Color.HSVToColor looks like a winner but it takes a float[] as a parameter. Am I any ..

In Swift how to call method with parameters on GCD main thread?

In my app I have a function that makes an NSRURLSession and sends out an NSURLRequest using sesh.dataTaskWithRequest(req, completionHandler: {(data, response, error) In the completion block for thi..

How can I pretty-print JSON in a shell script?

Is there a (Unix) shell script to format JSON in human-readable form? Basically, I want it to transform the following: { "foo": "lorem", "bar": "ipsum" } ... into something like this: { "foo"..

How to create an empty R vector to add new items

I want to use R in Python, as provided by the module Rpy2. I notice that R has very convenient [] operations by which you can extract the specific columns or lines. How could I achieve such a function..

Resync git repo with new .gitignore file

Is it possible to "refresh" a git repository after updating the gitignore file? I just added more ignorations(?) to my gitignore and would like to remove stuff already in the repo matching the new fi..

Difference between left join and right join in SQL Server

I know about joins in SQL Server. For example. There are two tables Table1, Table2. Their table structures are the following. create table Table1 (id int, Name varchar (10)) create table Table2 (..

How to style input and submit button with CSS?

I'm learning CSS. How to style input and submit button with CSS? I'm trying create something like this but I have no idea how to do <form action="#" method="post"> Name <input type="tex..

How to pass parameters to a partial view in ASP.NET MVC?

Suppose that I have this partial view: Your name is <strong>@firstName @lastName</strong> which is accessible through a child only action like: [ChildActionOnly] public ActionResult Fu..

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

Difference between Spring MVC and Spring Boot

I have just started learning Spring. In my next step, I would like to develop bigger web applications. Now I am wondering if I should start with Spring Boot or Spring MVC. I have already read some s..

Does Python support short-circuiting?

Does Python support short-circuiting in boolean expressions?..

What does void do in java?

The return type—the data type of the value returned by the method, or void if the method does not return a value. Okay, then..

Doing a cleanup action just before Node.js exits

I want to tell Node.js to always do something just before it exits, for whatever reason — Ctrl+C, an exception, or any other reason. I tried this: process.on('exit', function (){ console.log('..

Separating class code into a header and cpp file

I am confused on how to separate implementation and declarations code of a simple class into a new header and cpp file. For example, how would I separate the code for the following class? class A2DD ..

fatal error LNK1169: one or more multiply defined symbols found in game programming

I've been training to use object orientated programming in c++ but I keep getting this error: 1>main.obj : error LNK2005: "int WIDTH" (?WIDTH@@3HA) already defined in GameObject.obj 1>main.obj ..

Vertical Alignment of text in a table cell

Here's a portion of my table (it's a form): Those are just two <td>'s in a <tr>. I'm trying to get Description up top, to the top of the table cell, rather than resting on the bottom. ..

Mean filter for smoothing images in Matlab

I need to test some basic image processing techniques in Matlab. I need to test and compare especially two types of filters: mean filter and median filter. To smooth image using median filtering, the..

YYYY-MM-DD format date in shell script

I tried using $(date) in my bash shell script, however, I want the date in YYYY-MM-DD format. How do I get this?..

How might I extract the property values of a JavaScript object into an array?

Given a JavaScript object: var dataObject = { object1: {id: 1, name: "Fred"}, object2: {id: 2, name: "Wilma"}, object3: {id: 3, name: "Pebbles"} }; How do I efficiently extract the inne..

Change Screen Orientation programmatically using a Button

I think this is implementable since screen rotation behaviour can go up to the application level...

For a boolean field, what is the naming convention for its getter/setter?

Eg. boolean isCurrent = false; What do you name its getter and setter?..

Smart way to truncate long strings

Does anyone have a more sophisticated solution/library for truncating strings with JavaScript and putting an ellipsis on the end, than the obvious one: if (string.length > 25) { string = string...

Laravel 5: Retrieve JSON array from $request

I'm a Laravel newbie and I'm converting a php/jquery app to Laravel. The original code used a JSON array with an ajax POST, which was retrieved like this: $json = file_get_contents('php://input'); $d..

Javascript to stop HTML5 video playback on modal window close

I've got a html5 video element on a modal window. When I close the window the video continues to play. I'm a total newbie to JS. Is there an easy way to tie a video playback stop function to the wi..

How to list the properties of a JavaScript object?

Say I create an object thus: var myObject = {"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"}; What is the best way to retrieve a list of the property names? i.e. I would l..

Docker: How to use bash with an Alpine based docker image?

I created a docker image from openjdk:8-jdk-alpine but when I try to execute simple commands I get the following errors: RUN bash /bin/sh: bash: not found RUN ./gradlew build env: can't execute 'bas..

Altering a column: null to not null

I have a table that has several nullable integer columns. This is undesirable for several reasons, so I am looking to update all nulls to 0 and then set these columns to NOT NULL. Aside from changing..

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

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

System.BadImageFormatException: Could not load file or assembly (from installutil.exe)

I am trying to install a Windows service using InstallUtil.exe and am getting the error message System.BadImageFormatException: Could not load file or assembly '{xxx.exe}' or one of its dependenci..

How to drop all tables from a database with one SQL query?

I don't want to type all tables' name to drop all of them. Is it possible with one query?..

SVG support for Internet Explorer 8 and below

I created animation in flash and converted it into HTML5 using Swiffy. I think it's using SVG to render all of it; is there some JavaScript or a trick to make IE8 and below support it? My animation i..

How to use store and use session variables across pages?

When one page is accessed, I would like to start a session and store a session variable: <?php session_start(); $_SESSION['myvar']='myvalue'; ?> Then from another page, I would like to c..

How do I 'svn add' all unversioned files to SVN?

I'm looking for a good way to automatically 'svn add' all unversioned files in a working copy to my SVN repository. I have a live server that can create a few files that should be under source cont..

Should I use int or Int32

In C#, int and Int32 are the same thing, but I've read a number of times that int is preferred over Int32 with no reason given. Is there a reason, and should I care?..

What's a simple way to get a text input popup dialog box on an iPhone

I want to get the user name. A simple text input dialog box. Any simple way to do this?..

CreateElement with id?

I'm trying to modify this code to also give this div item an ID, however I have not found anything on google, and idName does not work. I read something about append, however it seems pretty complicat..

How to make the division of 2 ints produce a float instead of another int?

In another Bruce Eckels exercise in calculating velocity, v = s / t where s and t are integers. How do I make it so the division cranks out a float? class CalcV { float v; float calcV(int s, int..

Why doesn't the height of a container element increase if it contains floated elements?

I would like to ask how height and float work. I have an outer div and an inner div that has content in it. Its height may vary depending on the content of the inner div but it seems that my inner div..

How to re-index all subarray elements of a multidimensional array?

The question is how to reset key e.g. for an array: Array ( [1_Name] => Array ( [1] => leo [4] => NULL ) [1_Phone] => Array ( [1] => 12345 ..

Difference between timestamps with/without time zone in PostgreSQL

Are timestamp values stored differently in PostgreSQL when the data type is WITH TIME ZONE versus WITHOUT TIME ZONE? Can the differences be illustrated with simple test cases?..

C# version of java's synchronized keyword?

Does c# have its own version of the java "synchronized" keyword? I.e. in java it can be specified either to a function, an object or a block of code, like so: public synchronized void doImportantSt..

Using Helvetica Neue in a Website

Normally, I use "Helvetica Neue" for the fonts in some websites although looking at other sites, I've seen some with "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue". Is there any reas..

getString Outside of a Context or Activity

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

GitHub: invalid username or password

I have a project hosted on GitHub. I fail when trying to push my modifications on the master. I always get the following error message Password for 'https://[email protected]': remote: Invalid username..

How to set headers in http get request?

I'm doing a simple http GET in Go: client := &http.Client{} req, _ := http.NewRequest("GET", url, nil) res, _ := client.Do(req) But I can't found a way to customize the request header in the do..

How do I know if jQuery has an Ajax request pending?

I'm having some problems with a jQuery control we made. Suppose you have a dropdownlist that allows you to enter the ID of the item you're looking for, and when you press ENTER or lose focus in a text..

Apache VirtualHost and localhost

I'm working with XAMPP on Mac OS X. I'm trying to run a Symfony website properly for a client, and I really don't know Symfony (yet). I just want to install and launch it. I've changed my /etc/hosts f..

How to enable zoom controls and pinch zoom in a WebView?

The default Browser app for Android shows zoom controls when you're scrolling and also allows for pinch zooming. How can I enable this feature for my own Webview? I've tried: webSettings.setBuiltIn..

SSRS - Checking whether the data is null

I've the following expression in my report. =FormatNumber(MAX(Fields!Reading.Value, "CellReading_Reading"),3) Now when the dataset is empty 'Fields!Reading.Value' becomes empty and finding their ma..

How to iterate through XML in Powershell?

I have this XML document in a text file: <?xml version="1.0"?> <Objects> <Object Type="System.Management.Automation.PSCustomObject"> <Property Name="DisplayName" Type="Syst..

How to force delete a file?

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar ..

Hibernate: Automatically creating/updating the db tables based on entity classes

I have the following entity class (in Groovy): import javax.persistence.Entity import javax.persistence.Id import javax.persistence.GeneratedValue import javax.persistence.GenerationType @Entity pub..

remove objects from array by object property

var listToDelete = ['abc', 'efg']; var arrayOfObjects = [{id:'abc',name:'oh'}, // delete me {id:'efg',name:'em'}, // delete me {id:'hij',name:'ge'}] // all..

How to convert Rows to Columns in Oracle?

I have a table in this form (this is just the partial view, the table contains more than 100 columns). LOAN NUMBER DOCUMENT_TYPE DOCUMENT_ID 992452533663 Voters ID ..

Defining TypeScript callback type

I've got the following class in TypeScript: class CallbackTest { public myCallback; public doWork(): void { //doing some work... this.myCallback(); //calling callback ..

Warn user before leaving web page with unsaved changes

I have some pages with forms in my application. How can I secure the form in such a way that if someone navigates away or closes the browser tab, they should be prompted to to confirm they really wa..

Get Cell Value from a DataTable in C#

Here is a DataTable dt, which has lots of data. I want to get the specific Cell Value from the DataTable, say Cell[i,j]. Where, i -> Rows and j -> Columns. I will iterate i,j's value with two forlo..

mysql update column with value from another table

I have two tables, both looking like id name value =================== 1 Joe 22 2 Derk 30 I need to copy the value of value from tableA to tableB based on check name in each table. An..

Convert negative data into positive data in SQL Server

The current data of the table is: a b --------- -1 5 -11 2 -5 32 My request is to convert every data into a positive value. Unfortunately, I forgot the name of the built-in function of SQL..

Why is "1000000000000000 in range(1000000000000001)" so fast in Python 3?

It is my understanding that the range() function, which is actually an object type in Python 3, generates its contents on the fly, similar to a generator. This being the case, I would have expected ..

How to position a DIV in a specific coordinates?

I want to position a DIV in a specific coordinates ? How can I do that using Javascript ?..

SQL subquery with COUNT help

I have an SQL statement that works SELECT * FROM eventsTable WHERE columnName='Business' I want to add this as a subquery... COUNT(Business) AS row_count How do I do this?..

How to run Maven from another directory (without cd to project dir)?

Supposing my maven project is located in /some/location/project and my current location is /another/location/ how can I run maven build without changing to project location cd /some/location/project?..

How to stop event propagation with inline onclick attribute?

Consider the following: <div onclick="alert('you clicked the header')" class="header"> <span onclick="alert('you clicked inside the header');">something inside the header</span> &..

C++ convert string to hexadecimal and vice versa

What is the best way to convert a string to hex and vice versa in C++? Example: A string like "Hello World" to hex format: 48656C6C6F20576F726C64 And from hex 48656C6C6F20576F726C64 to string: "Hel..

Difference between natural join and inner join

What is the difference between a natural join and an inner join?..

Return HTML from ASP.NET Web API

How to return HTML from ASP.NET MVC Web API controller? I tried the code below but got compile error since Response.Write is not defined: public class MyController : ApiController { [HttpPost] ..

What is the OAuth 2.0 Bearer Token exactly?

According to RFC6750-The OAuth 2.0 Authorization Framework: Bearer Token Usage, the bearer token is: A security token with the property that any party in possession of the token (a "bearer") can u..

Setting maxlength of textbox with JavaScript or jQuery

I want to change the maxlength of a textbox with JavaScript or jQuery: I tried the following but it didn't seem to help: var a = document.getElementsByTagName('input'); for(var i=0; i<a.length; i..

Using Jquery Datatable with AngularJs

I'm trying to use the jquery datatable plugin in my angularjs project. but my question is does it support lazy loading of value for angularjs? i want beacuse i have many row. how to use datatable pip..

How do I compare two hashes?

I am trying to compare two Ruby Hashes using the following code: #!/usr/bin/env ruby require "yaml" require "active_support" file1 = YAML::load('./en_20110207.yml')) file2 = YAML::load(Fi..

Types in MySQL: BigInt(20) vs Int(20)

I was wondering what the difference between BigInt, MediumInt, and Int are... it would seem obvious that they would allow for larger numbers; however, I can make an Int(20) or a BigInt(20) and that wo..

Add element to a JSON file?

I am trying to add an element to a json file in python but I am not able to do it. This is what I tried untill now (with some variation which I deleted): import json data = [ { 'a':'A', 'b':(2, 4),..

Where do I find old versions of Android NDK?

Does anyone know where I can find older versions of the Android NDK? Our code doesn't build with r6. Surely there must be archived versions somewhere...

Opening Android Settings programmatically

How can I open settings programmatically?..

Check if Cell value exists in Column, and then get the value of the NEXT Cell

After checking if a cell value exists in a column, I need to get the value of the cell next to the matching cell. For instance, I check if the value in cell A1 exists in column B, and assuming it matc..

Execute multiple command lines with the same process using .NET

I'm trying to execute multiple commands without create a new process each time. Basically, I want to start the DOS command shell, switch to the MySQL command shell, and execute a command. Here's how I..

Read specific columns with pandas or other python module

I have a csv file from this webpage. I want to read some of the columns in the downloaded file (the csv version can be downloaded in the upper right corner). Let's say I want 2 columns: 59 which in..

Convert or extract TTC font to TTF - how to?

I am already more than 8 hours trying to make the STHeiti font work on Windows. But I can't make it work. Is anybody able to make it work on Windows?..

Why do you need to put #!/bin/bash at the beginning of a script file?

I have made Bash scripts before and they all ran fine without #!/bin/bash at the beginning. What's the point of putting it in? Would things be any different? Also, how do you pronounce #? I know tha..

Load a Bootstrap popover content with AJAX. Is this possible?

The appropriate bits of what I tried are here: <a href="#" data-content="<div id='my_popover'></div>"> Click here </a> $(".button").popover({html: true}) $(".button").click(..

When should I use the new keyword in C++?

I've been using C++ for a short while, and I've been wondering about the new keyword. Simply, should I be using it, or not? 1) With the new keyword... MyClass* myClass = new MyClass(); myClass->M..

Making the Android emulator run faster

The Android emulator is a bit sluggish. For some devices, like the Motorola Droid and the Nexus One, the app runs faster in the actual device than the emulator. This is a problem when testing games an..

In DB2 Display a table's definition

Hello everybody I am learning DB2 and would like to know how to see a table's characteristics after I create one. Similar to the EXPLAIN TABLE command in MySQL. Thank you...

Jquery Ajax Posting json to webservice

I am trying to post a JSON object to a webservice. My json looks like this: var markers = { "markers": [ { "position": "128.3657142857143", "markerPosition": "7" }, { "position": "235.19..

Deploying website: 500 - Internal server error

I am trying to deploy an ASP.NET application. I have deployed the site to IIS, but when visiting it with the browser, it shows me this: Server Error 500 - Internal server error. There is a problem wi..

How to get a path to a resource in a Java JAR file

I am trying to get a path to a Resource but I have had no luck. This works (both in IDE and with the JAR) but this way I can't get a path to a file, only the file contents: ClassLoader classLoader..

How do I get my Python program to sleep for 50 milliseconds?

How do I get my Python program to sleep for 50 milliseconds?..

What is a good Java library to zip/unzip files?

I looked at the default Zip library that comes with the JDK and the Apache compression libs and I am unhappy with them for 3 reasons: They are bloated and have bad API design. I have to write 50 lin..

Vertically center text in a 100% height div?

I am working with a div that is 100% of the parent divs height. The div only contains a single line of text. The div cannot have a fixed height. So my question is. How do I vertically center the l..

Two divs side by side - Fluid display

I am trying to place two divs side by side and using the following CSS for it. #left { float: left; width: 65%; overflow: hidden; } #right { overflow: hidden; } The HTML is simple, two lef..

How to export JSON from MongoDB using Robomongo

So I do not know much about MongoDB. I have RoboMongo using which I connect to a MongoDB. What I need to do is this - there is a collection in that MongoDB. I want to export the data from that collect..

WARNING: Exception encountered during context initialization - cancelling refresh attempt

Error is as shown below. The problem is, occurring as below, this XmlWebApplicationContext need not occur, since it's injecting the bean again. How to avoid it? org.springframework.web.context.suppor..

Shell script to capture Process ID and kill it if exist

I tried this code and it is not working #!/bin/sh #Find the Process ID for syncapp running instance PID=`ps -ef | grep syncapp 'awk {print $2}'` if [[ -z "$PID" ]] then Kill -9 PID fi It is show..

Python Pandas User Warning: Sorting because non-concatenation axis is not aligned

I'm doing some code practice and applying merging of data frames while doing this getting user warning /usr/lib64/python2.7/site-packages/pandas/core/ FutureWarning: Sorting becaus..

How do I get AWS_ACCESS_KEY_ID for Amazon?

I'm totally new to AWS. I downloaded some sample code from Amazon and I need to set a number of constants: AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY MERCHANT_ID MARKETPLACE_ID I just created an AW..

Forgot Oracle username and password, how to retrieve?

I have forgotten my Oracle username and password and hence not able to use it. My Oracle version is I consulted Internet. They asked me to execute commands like ‘SYSDBA’ but I was..


There are 2 tables, spawnlist and npc, and I need to delete data from spawnlsit. npc_templateid = n.idTemplate is the only thing that "connect" the tables. I have tried this script but it doesn't work..

How to order a data frame by one descending and one ascending column?

I have a data frame, which looks like that: P1 P2 P3 T1 T2 T3 I1 I2 1 2 3 5 52 43 61 6 "b" 2 6 4 3 72 NA 59 1 "a" 3 1 5 6 55 48 60 6 "f" 4 2 4 ..

TestNG ERROR Cannot find class in classpath

I'm trying to run testng via command line and I have following things in classpath: testng jar, jar of compiled test case file, and other required jars. testng.xml points to appropriate class in the..

How to alter SQL in "Edit Top 200 Rows" in SSMS 2008

In SQL Server 2008 Management Studio, when I right click on a database table and choose "Select Top 100 Rows", I can then e.g. easily add a "ORDER BY " statement to the SQL. That works fine. But when..

What are the recommendations for html <base> tag?

I've never seen <base> HTML tag actually used anywhere before. Are there pitfalls to its use that means I should avoid it? The fact that I have never noticed it in use on a modern production s..

Hiding and Showing TabPages in tabControl

I am trying to show or hide tabpages as per user choice. If user selects gender male then form for male in a tabpage "male" should be displayed and if user selects female then similar next form should..

node.js - request - How to "emitter.setMaxListeners()"?

When I do a GET on a certain URI using the node.js 'request' module; var options = {uri:"aURI", headers:headerData}; request.get(options, function (error, response, body) { } The error message is: ..

How to horizontally center an unordered list of unknown width?

It is common to have a set of links in a footer represented in a list, such as: <div id="footer"> <ul> <li><a href="#">Home</a></li> <li>..

Spring Boot application in eclipse, the Tomcat connector configured to listen on port XXXX failed to start

I'm developing a REST API using Spring Framework. First I wasn't able to run my application because of the same problem. The port 8080 on my computer is busy. Then I found out that one alternative t..

Linking a UNC / Network drive on an html page

Just a basic html link question. I have an intranet setup, and I need to link to some network drives. They are located on drives such as \server_drive\blahblah\doc.docx Using file:// does not work..

Html.DropdownListFor selected value not being set

How can I set the selected value of a Html.DropDownListFor? I've been having a look online and have seen that it can be achieved by using the fourth parameter so like the below: @Html.DropDownListFor..

What is the best way to clone/deep copy a .NET generic Dictionary<string, T>?

I've got a generic dictionary Dictionary<string, T> that I would like to essentially make a Clone() of ..any suggestions. ..

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

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

using System; using System.Collections.Generic; using System.Linq; using System.Text; using Facebook; using Newtonsoft.Json; namespace facebook { class Program { static void Main(stri..

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

I am trying to send a request to a server using the HttpsUrlConnection class. The server has certificate issues, so I set up a TrustManager that trusts everything, as well as a hostname verifier that..

What is the syntax to insert one list into another list in python?

Given two lists: x = [1,2,3] y = [4,5,6] What is the syntax to: Insert x into y such that y now looks like [1, 2, 3, [4, 5, 6]]? Insert all the items of x into y such that y now looks like [1, 2,..

Change the encoding of a file in Visual Studio Code

Is there any way to change the encoding of a file? For example UTF-8 to ISO 8859-1? Setting Example Sublime Text: "default_encoding": "UTF-8" ..

Python: Pandas pd.read_excel giving ImportError: Install xlrd >= 0.9.0 for Excel support

I am trying to read a .xlsx with pandas, but get the follwing error: data = pd.read_excel(low_memory=False, io="DataAnalysis1/temp1.xlsx").fillna(value=0) Traceback (most recent call last): File ..

Finding three elements in an array whose sum is closest to a given number

Given an array of integers, A1, A2, ..., An, including negatives and positives, and another integer S. Now we need to find three different integers in the array, whose sum is closest to the given inte..

How can I find a specific file from a Linux terminal?

I am trying to find where index.html is located on my linux server, and was wondering if there was a command to do that. Very new to linux and appreciate any help I can get...

TypeError: 'str' does not support the buffer interface

plaintext = input("Please enter the text you want to compress") filename = input("Please enter the desired filename") with + ".gz", "wb") as outfile: outfile.write(plaintext) ..

How can I turn a List of Lists into a List in Java 8?

If I have a List<List<Object>>, how can I turn that into a List<Object> that contains all the objects in the same iteration order by using the features of Java 8?..

How do I terminate a thread in C++11?

I don't need to terminate the thread correctly, or make it respond to a "terminate" command. I am interested in terminating the thread forcefully using pure C++11...

Curl to return http status code along with the response

I use curl to get http headers to find http status code and also return response. I get the http headers with the command curl -I http://localhost To get the response, I use the command cu..

Connect to Oracle DB using sqlplus

I am using below command in Unix environment to connect to Oracle database: sqlplus test/test@'(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)( )(PORT=1521)))(CONNECT_DATA=(SID=my..

capture div into image using html2canvas

I'm trying to capture a div into an image using html2canvas I have read some similar question here like How to upload a screenshot using html2canvas? create screenshot of web page using html2canvas..

how to convert 2d list to 2d numpy array?

I have a 2D list something like a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] and I want to convert it to a 2d numpy array. Can we do it without allocating memory like numpy.zeros((3,3)) and then sto..

How do I properly set the Datetimeindex for a Pandas datetime object in a dataframe?

I have a pandas dataframe: lat lng alt days date time 0 40.003834 116.321462 211 39745.175405 2008-10-24 04:12:35 1 40.003783 116.321431 201 39..

Semi-transparent color layer over background-image?

I have a DIV and I would like to put a pattern as background. This pattern is gray. So to make it a little more nice, I would like to put a light transparent color "layer" over. Below is what I tried ..

Adding click event listener to elements with the same class

I have a list view for delete id. I'd like to add a listener to all elements with a particular class and do a confirm alert. My problem is that this seems to only add the listener to the first elemen..

coercing to Unicode: need string or buffer, NoneType found when rendering in django admin

I have this error since a long time but can't figure it out : Caught TypeError while rendering: coercing to Unicode: need string or buffer, NoneType found It happens in admin when I try to add or mo..

How to import a module given the full path?

How can I load a Python module given its full path? Note that the file can be anywhere in the filesystem, as it is a configuration option...

'JSON' is undefined error in JavaScript in Internet Explorer

We are using jQuery in our application. We have used a jQuery plugin to implement JavaScript session. It is working properly in Firefox and most Internet Explorer 8 browsers. But in some Internet ..

JPA and Hibernate - Criteria vs. JPQL or HQL

What are the pros and cons of using Criteria or HQL? The Criteria API is a nice object-oriented way to express queries in Hibernate, but sometimes Criteria Queries are more difficult to understand/bui..

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

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

Program to find prime numbers

I want to find the prime number between 0 and a long variable but I am not able to get any output. The program is using System; using System.Collections.Generic; using System.Linq; using System.Tex..