Examples On Programing Languages

Get top first record from duplicate records having no unique identity

I need to fetch top first row out of each duplicate set of records from table given below. I need to use this query in view please no temp table as I have already done it by adding identity column and min function and group by. I need solution with...

Convert list or numpy array of single element to float in python

I have a function which can accept either a list or a numpy array. In either case, the list/array has a single element (always). I just need to return a float. So, e.g., I could receive: list_ = [4] or the numpy array: array_ = array([4]) And...

Excel function to make SQL-like queries on worksheet data?

I have a largish table in an Excel worksheet: Column_1 | Column_2 | Column_3 ValueA ValueB ValueC .... What I need is a function that will take as input the range and an SQL-like query String and return a range of rows that match the qu...

How to use boolean datatype in C?

I was just writing code in C and it turns out it doesn't have a boolean/bool datatype. Is there any C library which I can include to give me the ability to return a boolean/bool datatype?...

How to create a css rule for all elements except one class?

I have created a CSS stylesheet for my project. Is there any way I can create a css rule that applies to all table elements EXCEPT table elements belonging to the class "dojoxGrid"? Something like: .not(dojoxGrid) table{ width:100%; border-t...

cannot find module "lodash"

Today I tried to learn more about Google Web Starter Kit so I followed these instructions and after a lot of fight and problem I just tried to start a local server (the first task we’ll look at is: $ gulp serve.) and received this error: C:\gwsk>g...

Output in a table format in Java's System.out

I'm getting results from a database and want to output the data as a table in Java's standard output I've tried using \t but the first column I want is very variable in length. Is there a way to display this in a nice table like output?...

Toolbar navigation icon never set

I'm trying the new Toolbar component and having some trouble with the navigation icon. I want to implement a custom icon for back navigation : In my manifest i set a parent to my activity : <activity android:name=".CardsActivity" android...

Replace comma with newline in sed on MacOS?

I have a file of id's that are comma separated. I'm trying to replace the commas with a new line. I've tried: sed 's/,/\n/g' file but it is not working. What am I missing?...

Can scripts be inserted with innerHTML?

I tried to load some scripts into a page using innerHTML on a <div>. It appears that the script loads into the DOM, but it is never executed (at least in Firefox and Chrome). Is there a way to have scripts execute when inserting them with inner...

How do I write a "tab" in Python?

Let's say I have a file. How do I write "hello" TAB "alex"?...

What does request.getParameter return?

// index.jsp <form method="post" action="backend.jsp"> <input type="text" name="one" /> <input type="submit value="Submit" /> </form> In backend.jsp what does request.getParameter("one"); return? request.getParameter("one"...

How to calculate the number of occurrence of a given character in each row of a column of strings?

I have a data.frame in which certain variables contain a text string. I wish to count the number of occurrences of a given character in each individual string. Example: q.data<-data.frame(number=1:3, string=c("greatgreat", "magic", "not")) I ...

Python - OpenCV - imread - Displaying Image

I am currently working on reading an image and displaying it to a window. I have successfully done this, but upon displaying the image, the window only allows me to see a portion of the full image. I tried saving the image after loading it, and it s...


Converting newline formatting from Mac to Windows

I need a conversion utility/script that will convert a .sql dump file generated on Mac to one readable on Windows. This is a continuation of a problem I had here. The issue seems to be with newline formatting in text files, but I can't find a tool ...

Parse date string and change format

I have a date string with the format 'Mon Feb 15 2010'. I want to change the format to '15/02/2010'. How can I do this?...

Laravel Eloquent ORM Transactions

The Eloquent ORM is quite nice, though I'm wondering if there is an easy way to setup MySQL transactions using innoDB in the same fashion as PDO, or if I would have to extend the ORM to make this possible?...

How to show an empty view with a RecyclerView?

I am used to put an special view inside the layout file as described in the ListActivity documentation to be displayed when there is no data. This view has the id "android:id/empty". <TextView android:id="@android:id/empty" android:layout...

Notify ObservableCollection when Item changes

I found on this link ObservableCollection not noticing when Item in it changes (even with INotifyPropertyChanged) some techniques to notify a Observablecollection that an item has changed. the TrulyObservableCollection in this link seems to be wha...

Getter and Setter of Model object in Angular 4

How can I make getter and setter work in my model class? My goal is to calculate integer value of the selected day when input, containing the date, updated. I was going to do it in setter, but Angular 4 ignores setter and getter of my model. My mod...

CSS: center element within a <div> element

To center an HTML element I can use the CSS left: 50%;. However, this centers the element with respect to the whole window. I have an element which is a child of a <div> element and I want to center the child with respect to this parent <di...

Convert a string to an enum in C#

What's the best way to convert a string to an enumeration value in C#? I have an HTML select tag containing the values of an enumeration. When the page is posted, I want to pick up the value (which will be in the form of a string) and convert it to t...

C#: Waiting for all threads to complete

I'm running into a common pattern in the code that I'm writing, where I need to wait for all threads in a group to complete, with a timeout. The timeout is supposed to be the time required for all threads to complete, so simply doing thread.Join(time...

Git keeps prompting me for a password

I've been using Git for a while now, but the constant requests for a password are starting to drive me up the wall. I'm using Mac OS X and GitHub, and I set up Git and my SSH keys as instructed by GitHub's Set Up Git page. I've also adde...

Removing white space around a saved image in matplotlib

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

How to get the last N records in mongodb?

I can't find anywhere it has been documented this. By default, the find() operation will get the records from beginning. How can I get the last N records in mongodb? Edit: also I want the returned result ordered from less recent to most recent, not ...

Where can I find "make" program for Mac OS X Lion?

Just upgraded my computer to Mac OS X Lion and went to terminal and typed "make" but it says: -bash: make: command not found Where did the "make" command go?...

Can't connect to MySQL server on 'localhost' (10061) after Installation

I installed MySQL using mysql-installer-5.5.20.0.msi on Windows 7. From the cmd window, I run "mysqlshow -u root -p". It asked for a password, then returned this error: "Can't connect to MySQL server on 'localhost' (10061)" This is a bad indication o...

Set custom attribute using JavaScript

I am using The DynaTree (https://code.google.com/p/dynatree) but I am having some problems and hoping someone can help.. I am displaying the tree on the page like below: <div id="tree"> <ul> <li class="folder">...

Adding a background image to a <div> element

Is it possible to make a <div> element contain a background image, and if so, how would I go about doing this?...

Can you blur the content beneath/behind a div?

I'm creating a new web design in Photoshop at the moment, but I'd like to know if it's possible to blur the content beneath a div? I'd like to create a half transparent nav bar on my page that's fixed at the top of your screen. Everything that flows...

How to create a multi line body in C# System.Net.Mail.MailMessage

If create the body property as System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); message.Body ="First Line \n second line"; I also tried message.Body ="First Line" + system.environment + "second line"; Both of these wer...

Android Fragment no view found for ID?

I have a fragment I am trying to add into a view. FragmentManager fragMgr=getSupportFragmentManager(); feed_parser_activity content = (feed_parser_activity)fragMgr .findFragmentById(R.id.feedContentContainer); Fra...

Create the perfect JPA entity

I've been working with JPA (implementation Hibernate) for some time now and each time I need to create entities I find myself struggling with issues as AccessType, immutable properties, equals/hashCode, ... . So I decided to try and find out the gene...

Align an element to bottom with flexbox

I have a div with some children: <div class="content"> <h1>heading 1</h1> <h2>heading 2</h2> <p>Some more or less text</p> <a href="/" class="button">Click me</a> </div> and I wan...

How to disable text selection using jQuery?

Does jQuery or jQuery-UI have any functionality to disable text selection for given document elements?...

How are zlib, gzip and zip related? What do they have in common and how are they different?

The compression algorithm used in zlib is essentially the same as that in gzip and zip. What are gzip and zip? How are they different and how are they same?...

Add new line in text file with Windows batch file

I have a text file which has more than 200 lines in it, and I just want to add a new line before line 4. I'm using Windows XP. Example text file before input: header 1 header 2 header 3 details 1 details 2 After output: header 1 header 2 he...

What's the UIScrollView contentInset property for?

Can someone explain to me what the contentInset property in a UIScrollView instance is used for? And maybe provide an example?...

How/when to use ng-click to call a route?

Suppose you are using routes: // bootstrap myApp.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) { $routeProvider.when('/home', { templateUrl: 'partials/home.html', controller: 'HomeCt...

How to check if a file exists in a folder?

I need to check if an xml file exists in the folder. DirectoryInfo di = new DirectoryInfo(ProcessingDirectory); FileInfo[] TXTFiles = di.GetFiles("*.xml"); if (TXTFiles.Length == 0) { log.Info("no files present") } Is this the best way to chec...

How to left align a fixed width string?

I just want fixed width columns of text but the strings are all padded right, instead of left!!? sys.stdout.write("%6s %50s %25s\n" % (code, name, industry)) produces BGA BEGA CHEESE LIMITED Food Beverage & T...

Linux shell script for database backup

I tried many scripts for database backup but I couldn't make it. I want to backup my database every hour. I added files to "/etc/cron.hourly/" folder, changed its chmod to 755, but it didn't run. At least I write my pseudo code. I would be happy if ...

How to Ignore "Duplicate Key" error in T-SQL (SQL Server)

I have a transaction that contains multiple SQL Statements (INSERT, UPDATE and/or DELETES). When executing, I want to ignore Duplicate Error statements and continue onto the next statement. What's the best way of doing that?...

How do you set the max number of characters for an EditText in Android?

How do you set the max number of characters for an Android EditText input? I see setMaxLines, setMaxEMS, but nothing for the number of characters....

“Error occurred during initialization of VM; Could not reserve enough space for object heap” using -Xmx3G

First of all, I have a box with 8gb of ram, so I doubt total memory is the issue. This application is running fine on machines with 6gb or less. I am trying to reserve 3GB of space using -Xmx3G under "VM Arguments" in Run Configurations in Eclipse. ...

Align a div to center

I want to float a div to center. Is it possible? text-align: center is not working in IE. ...

How to merge a Series and DataFrame

If you came here looking for information on how to merge a DataFrame and Series on the index, please look at this answer. The OP's original intention was to ask how to assign series elements as columns to another DataFrame. If you are i...

Filtering by Multiple Specific Model Properties in AngularJS (in OR relationship)

Take a look at the example here: http://docs.angularjs.org/api/ng.filter:filter You can search by any of the phone properties by using <input ng-model="search"> and you can search by just the name by using <input ng-model="search.name">...

Excel VBA Code: Compile Error in x64 Version ('PtrSafe' attribute required)

I am using Win8 x64 + Office 2013 x64. MY PROBLEM: I have an excel file, which has some modules in it, and works flawlessly in Office (Excel) x86. It uses the Swiss Ephemeris file (swedll32.dll) to do a lot of astronomical calculations. However...

How to center buttons in Twitter Bootstrap 3?

I am building a form in Twitter Bootstrap but I'm having issues with centering the button below the input in the form. I have already tried applying the center-block class to the button but that didn't work. How should I fix this? Here is my code. ...

Unpivot with column name

I have a table StudentMarks with columns Name, Maths, Science, English. Data is like Name, Maths, Science, English Tilak, 90, 40, 60 Raj, 30, 20, 10 I want to get it arranged like the following: Name, Subject, Marks T...

Twitter Bootstrap onclick event on buttons-radio

I have a Twitter Bootstrap buttons-radio and hook an onclick event to it. But how do I check which of the buttons that got triggered? My first thought was to simply check for the class 'active', but this should create a race condition (result depend...

Is this a good way to clone an object in ES6?

Googling for "javascript clone object" brings some really weird results, some of them are hopelessly outdated and some are just too complex, isn't it as easy as just: let clone = {...original}; Is there anything wrong with this?...

Found conflicts between different versions of the same dependent assembly that could not be resolved

When I clean and then build my solution that has several projects, the output window reports that the build succeeded. However, when I view the Error List Window, it shows me this warning: Found conflicts between different versions of the same de...

Select single item from a list

Using LINQ what is the best way to select a single item from a list if the item may not exists in the list? I have come up with two solutions, neither of which I like. I use a where clause to select the list of items (which I know will only be one)...

Setting background-image using jQuery CSS property

I have an image URL in a imageUrl variable and I am trying to set it as CSS style, using jQuery: $('myObject').css('background-image', imageUrl); This seems to be not working, as: console.log($('myObject').css('background-image')); returns none...

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

In Bash, how can I check if a string begins with some value?

I would like to check if a string begins with "node" e.g. "node001". Something like if [ $HOST == user* ] then echo yes fi How can I do it correctly? I further need to combine expressions to check if HOST is either "user1" or begins with "n...

How do I query for all dates greater than a certain date in SQL Server?

I'm trying: SELECT * FROM dbo.March2010 A WHERE A.Date >= 2010-04-01; A.Date looks like: 2010-03-04 00:00:00.000 However, this is not working. Can anyone provide a reference for why?...

How to get Javascript Select box's selected text

This things works perfectly <select name="selectbox" onchange="alert(this.value)"> But I want to select the text. I tried in this way <select name="selectbox" onchange="alert(this.text)"> It shows undefined. I found how to use DOM ...

fatal error C1083: Cannot open include file: 'xyz.h': No such file or directory?

I am using visual studio 2005 to create a project. And I have folder structure in project as: a folder called code. this folder contains all *.cxx files. Now, I have created a class xyz in header file xyz.h. And defined every thing in xyz.cxx which...

Property '...' has no initializer and is not definitely assigned in the constructor

in my Angular app i have a component: import { MakeService } from './../../services/make.service'; import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-vehicle-form', templateUrl: './vehicle-form.component.html', sty...

Specifying width and height as percentages without skewing photo proportions in HTML

I was wondering if in the width and height <img> attributes, I could specify width and height as percentages? Well, I guess that is obvious, because when I try so, it resizes, but it appears to skew the quality of my image. Here is an example...

Is there a color code for transparent in HTML?

I'm building a new website, and I'm looking for a transparent navigation bar so the background is visible....

Is there a way to compile node.js source files?

Is there a way to compile a node.js application?...

Write string to text file and ensure it always overwrites the existing content.

I have a string with a C# program that I want to write to a file and always overwrite the existing content. If the file isn't there, the program should create a new file instead of throwing an exception....

mysql server port number

I've just made a database on mysql on my server. I want to connect to this via my website using php. This is the contents of my connections file: $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'password'; $conn = mysql_connect($dbhost, $dbuser,...

How do I POST an array of objects with $.ajax (jQuery or Zepto)

I'd like to POST an array of objects with $.ajax in Zepto or Jquery. Both exhibit the same odd error, but I can't find what I'm doing wrong. The data saves to the server when sent using a test client like 'RestEasy', and I can see the request gettin...

How to check if a Unix .tar.gz file is a valid file without uncompressing?

I have found the question How to determine if data is valid tar file without a file?, but I was wondering: is there a ready made command line solution?...

Difference between `Optional.orElse()` and `Optional.orElseGet()`

I am trying to understand the difference between the Optional<T>.orElse() and Optional<T>.orElseGet() methods. The description for the orElse() method is "Return the value if present, otherwise return other." While, the description for...

How to print variables in Perl

I have some code that looks like my ($ids,$nIds); while (<myFile>){ chomp; $ids.= $_ . " "; $nIds++; } This should concatenate every line in my myFile, and nIds should be my number of lines. How do I print out my $ids and $nIds? ...

Capture screenshot of active window?

I am making a screen capturing application and everything is going fine. All I need to do is capture the active window and take a screenshot of this active window. Does anyone know how I can do this?...

How do you synchronise projects to GitHub with Android Studio?

I am trying to synchronise a project that I have on in my Android Studio folder to GitHub, but I am not fully sure what to do other than adding my credentials in the options menu. Could someone give me a quick guide, please?...

Latex - Change margins of only a few pages

I have a Latex document where I need to change the margins of only a few pages (the pages where I'm adding a lot of graphics). In particular, I'd like to change the top margins (\voffset). I've tried doing: \addtolength{\voffset}{-4cm} % Insert im...

How to create an empty file at the command line in Windows?

How to create an empty file at the DOS/Windows command-line? I tried: copy nul > file.txt but it always displays that a file was copied. Is there any other method in the standard cmd? It should be a method that does not require the touch com...

When to use margin vs padding in CSS

When writing CSS, is there a particular rule or guideline that should be used in deciding when to use margin and when to use padding?...

ASP.NET MVC: Html.EditorFor and multi-line text boxes

This is my code: <div class="editor-label"> @Html.LabelFor(model => model.Comments[0].Comment) </div> <div class="editor-field"> @Html.EditorFor(model => model.Comments[0].Comment) @Html.Va...

syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

I have been staring at this code for hours now and I cannot figure out where my mistake is. I know this syntax error usually comes up because of some missing or out of place curly brace or some issue with single/double quotes and I'm not sure there i...

How to increase scrollback buffer size in tmux?

How do I increase scrollback buffer size in tmux? If I enter copy mode, the number of available scrollback lines (visible in upper right corner) is always below 2000. I tried to find a list of all tmux commands, but I can't find anything about scr...

How to increment variable under DOS?

I've spent the past 3hrs trying to work this out but just couldn't find a solution. Here's my batch script: if NOT Exist Counter.txt GOTO START Type c:\counter.txt if %COUNTER% EQU %Cycles% goto Pass if NOT %COUNTER% EQU %Cycles% goto Cycle :START ...

How to check if activity is in foreground or in visible background?

I have a splash screen on a timer. My problem is that before I finish() my activity I need to check that the next activity has started because a system dialogue box pops-up and I only want to finish(); once the user has selected an option from the di...

Select multiple rows with the same value(s)

I have a table, sort of like this: ID | Chromosome | Locus | Symbol | Dominance | =============================================== 1 | 10 | 2 | A | Full | 2 | 10 | 2 | a | Rec. | 3 | 10 |...

JavaScript Promises - reject vs. throw

I have read several articles on this subject, but it is still not clear to me if there is a difference between Promise.reject vs. throwing an error. For example, Using Promise.reject return asyncIsPermitted() .then(function(result) { if...

What is the default initialization of an array in Java?

So I'm declaring and initializing an int array: static final int UN = 0; int[] arr = new int[size]; for (int i = 0; i < size; i++) { arr[i] = UN; } Say I do this instead... int[] arr = new int[5]; System.out.println(arr[0]); ... 0 will ...

Switch to selected tab by name in Jquery-UI Tabs

If I have three tabs: <div id="tabs"> <ul> <li><a href="#sample-tab-1"><span>One</span></a></li> <li><a href="#sample-tab-2"><span>Two</span></a></l...

Should I return EXIT_SUCCESS or 0 from main()?

It's a simple question, but I keep seeing conflicting answers: should the main routine of a C++ program return 0 or EXIT_SUCCESS? #include <cstdlib> int main(){return EXIT_SUCCESS;} or int main(){return 0;} Are they the exact same thing? ...

Disable Copy or Paste action for text box?

I have two textboxes, and I want to prevent user from copying the value from the first (email) textbox and pasting it in the second (confirmEmail) textbox. Email: <input type="textbox" id="email"><br/> Confirm Email: <input type="t...

What is the single most influential book every programmer should read?

If you could go back in time and tell yourself to read a specific book at the beginning of your career as a developer, which book would it be? I expect this list to be varied and to cover a wide range of things. To search: Use the search box in the...

Fatal error in launcher: Unable to create process using ""C:\Program Files (x86)\Python33\python.exe" "C:\Program Files (x86)\Python33\pip.exe""

Searching the net this seems to be a problem caused by spaces in the Python installation path. How do I get pip to work without having to reinstall everything in a path without spaces ?...

String.Replace(char, char) method in C#

How do I replace \n with empty space? I get an empty literal error if I do this: string temp = mystring.Replace('\n', ''); ...

Android Studio says "cannot resolve symbol" but project compiles

I'm importing twitter4j in AndroidStudio, using the following in my build.gradle: dependencies { compile 'com.android.support:support-v4:18.0.+' compile files('libs/twitter4j-core-3.0.4.jar') } The project compiles fine, and I can create twitt...

EditText non editable

I'm trying to make an EditText non editable with this code: <EditText android:id="@+id/outputResult" android:inputType="text" android:editable="false" android:layout_width="fill_parent" android:layout_heigh...

How to get element's width/height within directives and component?

_x000D_ _x000D_ @Component({_x000D_ selector: '.donation',_x000D_ template: `_x000D_ <figure id="donation" move>_x000D_ <img src="image/qrcode.png"/>_x000D_ <figcaption>_x000D_ Buy me a cup of cof...

Position a div container on the right side

I want to develop some kind of utility bar. I can position each element in this bar side by side using float:left; But I want the second element to be positioned at the very right of the bar. This is hard for me because the width of the bar is not s...

Remove a JSON attribute

if I have a JSON object say: var myObj = {'test' : {'key1' : 'value', 'key2': 'value'}} can I remove 'key1' so it becomes: {'test' : {'key2': 'value'}} ...

Syntax for an If statement using a boolean

I just recently joined the python3 HypeTrain. However I just wondered how you can use an if statement onto a boolean. Example: RandomBool = True # and now how can I check this in an if statement? Like the following: if RandomBool == True: #DoY...

"pip install json" fails on Ubuntu

Cannot install the json module. As far as I know I shouldn't use sudo. what's the matter? pip install json The directory '/home/snow/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please c...

Putting text in top left corner of matplotlib plot

How can I put text in the top left (or top right) corner of a matplotlib figure, e.g. where a top left legend would be, or on top of the plot but in the top left corner? E.g. if it's a plt.scatter(), then something that would be within the square of...

Declare and Initialize String Array in VBA

This should work according to another stack overflow post but its not: Dim arrWsNames As String() = {"Value1", "Value2"} Can anyone let me know what is wrong?...

insert password into database in md5 format?

can anyone please show me or explain how i can insert a password into a database in md5 format? even if you can just point me in the right direction or something i'd be grateful because I'm only new to mysql thanks. $query="INSERT INTO ptb_users (id...

Can a foreign key refer to a primary key in the same table?

I just think that the answer is false because the foreign key doesn't have uniqueness property. But some people said that it can be in case of self joining the table. I am new to SQL. If its true please explain how and why? Employee table | e_id |...

Where can I find error log files?

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

Sending files using POST with HttpURLConnection

Since the Android developers recommend to use the HttpURLConnection class, I was wondering if anyone can provide me with a good example on how to send a bitmap "file" (actually an in-memory stream) via POST to an Apache HTTP server. I'm not intereste...

Hash Map in Python

I want to implement a HashMap in Python. I want to ask a user for an input. depending on his input I am retrieving some information from the HashMap. If the user enters a key of the HashMap, I would like to retrieve the corresponding value. How do...

How to parse date string to Date?

How do I parse the date string below into a Date object? String target = "Thu Sep 28 20:29:30 JST 2000"; DateFormat df = new SimpleDateFormat("E MM dd kk:mm:ss z yyyy"); Date result = df.parse(target); Throws exception... java.text.ParseExcept...

make: *** [ ] Error 1 error

I am trying to compile a Pro*C file on gcc and I am getting this error : make: *** [MedLib_x.o] Error 1 This is the command printed by make: /usr/bin/gcc -g -fPIC -m64 -DSS_64BIT_SERVER -I/home/med/src/common - I/u01/app/oradb11r2/product/11....

How to parseInt in Angular.js

Probably, it is the simplest thing but I couldn't parse a string to Int in angular.. What I am trying to do: <input type="text" ng-model="num1"> <input type="text" ng-model="num2"> Total: {{num1 + num2}} How can I sum these num1 and ...

How to change option menu icon in the action bar?

How to change the index icon of option menu? I mean icon (3). Here is my code: @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.options, menu); return true;...

'and' (boolean) vs '&' (bitwise) - Why difference in behavior with lists vs numpy arrays?

What explains the difference in behavior of boolean and bitwise operations on lists vs NumPy arrays? I'm confused about the appropriate use of & vs and in Python, illustrated in the following examples. mylist1 = [True, True, True, False, Tr...

Set a Fixed div to 100% width of the parent container

I have a wrapper with some padding, I then have a floating relative div with a percentage width (40%). Inside the floating relative div I have a fixed div which I would like the same size as its parent. I understand that a fixed div is removed from...

Multiplying across in a numpy array

I'm trying to multiply each of the terms in a 2D array by the corresponding terms in a 1D array. This is very easy if I want to multiply every column by the 1D array, as shown in the numpy.multiply function. But I want to do the opposite, multiply ea...

How can I disable the bootstrap hover color for links?

I am using Bootstrap. Bootstrap defines a:hover, a:focus { color: #005580; text-decoration: underline; } I have this links / CSS-classes <a class="green" href="#">green text</a> <a class="yellow" ...

Deploy a project using Git push

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

Pygame mouse clicking detection

I was wondering how to write code that would detect the mouse clicking on a sprite. For example: if #Function that checks for mouse clicked on Sprite: print ("You have opened a chest!") ...

Checking if a field contains a string

I'm looking for an operator, which allows me to check, if the value of a field contains a certain string. Something like: db.users.findOne({$contains:{"username":"son"}}) Is that possible? ...

How to convert a string to character array in c (or) how to extract a single char form string?

I need to convert a string to a char array in C; how can I do this? Or at least, how can I extract single chars from a string incrementally?...

How to get process details from its pid

I have maintained a list of pids of processes currently running on my system(Linux) from this now it would be great if i can get the process details from this pid i have come over syscall.Getrusage() in golang but i am not getting desired results. D...

How to get the height of a body element

Here the total height of all <div>'s are 900 pixels, but the jQuery function returns the height of the body as 577 pixels. (If I remove the body CSS, it's working). Is there a solution for this problem? $j(function() { alert($j("body").he...

How to remove all non-alpha numeric characters from a string in MySQL?

I'm working on a routine that compares strings, but for better efficiency I need to remove all characters that are not letters or numbers. I'm using multiple REPLACE functions now, but maybe there is a faster and nicer solution ?...

How to ignore whitespace in a regular expression subject string?

Is there a simple way to ignore the white space in a target string when searching for matches using a regular expression pattern? For example, if my search is for "cats", I would want "c ats" or "ca ts" to match. I can't strip out the whitespace ...

Python int to binary string?

Are there any canned Python methods to convert an Integer (or Long) into a binary string in Python? There are a myriad of dec2bin() functions out on Google... But I was hoping I could use a built-in function / library....

Add a column in a table in HIVE QL

I'm writing a code in HIVE to create a table consisting of 1300 rows and 6 columns: create table test1 as SELECT cd_screen_function, SUM(access_count) AS max_count, MIN(response_time_min) as response_time_min, AVG(response_time_avg) a...

What is the difference between varchar and nvarchar?

Is it just that nvarchar supports multibyte characters? If that is the case, is there really any point, other than storage concerns, to using varchars?...

How to get index of object by its property in JavaScript?

For example, I have: var Data = [ { id_list: 1, name: 'Nick', token: '312312' }, { id_list: 2, name: 'John', token: '123123' }, ] Then, I want to sort/reverse this object by name, for example. And then I want to get something like this: var D...

How can I close a window with Javascript on Mozilla Firefox 3?

I need to close the tab which displays my webpage, by the click of a button. But firefox does not allow to close the window by javascript as long as it is not opened by javascript. If I set the value of dom.allow_scripts_to_close_windows to be "true"...

Why can't I reference my class library?

I have a solution that contains a website and a class library in Visual Studio 2008. I then have another web site project outside of the solution that needs to reference the class library. I right click the Bin folder or Project and select Add Refe...

Best way to do a split pane in HTML

Is there a good technique to make a resizable split pane in HTML? May it be done using CSS / jQuery / JavaScript or is there a good JavaScript library that have been used? (An example of a split pane is the favorites bar in Internet Explorer which y...

Eclipse change project files location

I have an Eclipse project (Flex Builder) of which the actual files have changed location on the drive. When I start Eclipse I can see the project listed but there are no actual files listed. Right clicking the project and selecting properties will sh...

Android Call an method from another class

I know that this Question is repeated but I can't find the answer in Internet. I want to call a method from another class. I've Class1 and Class2. In Class 2 I've that method: public void UpdateEmployee(){ //some code } I want to call that ...

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

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

How to add image to canvas

I'm experimenting a bit with the new canvas element in HTML. I simply want to add an image to the canvas but it doesn't work for some reason. I have the following code: HTML <canvas id="viewport"></canvas> CSS canvas#viewport { bor...

What is the use of GO in SQL Server Management Studio & Transact SQL?

SQL Server Management Studio always inserts a GO command when I create a query using the right click "Script As" menu. Why? What does GO actually do?...

Stick button to right side of div

http://jsfiddle.net/kn5sH/ What do I need to add in order to stick the button to the right side of the div on the same line as the header? HTML: <div> <h1> Ok </h1> <button type='button'>Button</button> </d...

Computed / calculated / virtual / derived columns in PostgreSQL

Does PostgreSQL support computed / calculated columns, like MS SQL Server? I can't find anything in the docs, but as this feature is included in many other DBMSs I thought I might be missing something. Eg: http://msdn.microsoft.com/en-us/library/ms...

Using SUMIFS with multiple AND OR conditions

I would like to create a succinct Excel formula that SUMS a column based on a set of AND conditions, plus a set of OR conditions. My Excel table contains the following data and I used defined names for the columns. Quote_Value (Worksheet!$A:$A) ho...

How to change Android usb connect mode to charge only?

I've seen HTC android devices have connect mode selection when connected to PC via usb line, while mine always pops up a USB massive storage device dialog with a button turn on massive storage, which is boring, because sometimes my line could be loos...

Remove last character from C++ string

How can I remove last character from a C++ string? I tried st = substr(st.length()-1); But it didn't work....

Volatile vs Static in Java

Is it correct to say that static means one copy of the value for all objects and volatile means one copy of the value for all threads? Anyway a static variable value is also going to be one value for all threads, then why should we go for volatile?...

How do I check if a string contains another string in Swift?

In Objective-C the code to check for a substring in an NSString is: NSString *string = @"hello Swift"; NSRange textRange =[string rangeOfString:@"Swift"]; if(textRange.location != NSNotFound) { NSLog(@"exists"); } But how do I do this in Swif...

What is the difference between Integrated Security = True and Integrated Security = SSPI?

I have two apps that use Integrated Security. One assigns Integrated Security = true in the connection string, and the other sets Integrated Security = SSPI. What is the difference between SSPI and true in the context of Integrated Security?...

php_network_getaddresses: getaddrinfo failed: Name or service not known

Here is a snippet of my code $fp = fsockopen($s['url'], 80, $errno, $errstr, 5); if($fp){ fwrite($fp, $out); fclose($fp); When I run it, it outputs: unable to connect to www.mydomain.net/1/file.php:80 (php_network_getaddresses:...

Java Synchronized list

I have a pre-populated array list. And I have multiple threads which will remove elements from the array list. Each thread calls the remove method below and removes one item from the list. Does the following code give me consistent behavior ? ArrayL...

There is already an object named in the database

Update-Database failed from Package Manager Console. I've used Entity Framework 6.x and code-first approach. Error is "There is already an object named 'AboutUs' in the database." How can I solve this problem? internal sealed class Configuration ...

Truncating a table in a stored procedure

When I run the following in an Oracle shell it works fine truncate table table_name But when I try to put it in a stored procedure CREATE OR REPLACE PROCEDURE test IS BEGIN truncate table table_name; END test; / it fails with ERROR line 3,...

Call a PHP function after onClick HTML event

Purpose: Call a PHP function to read data from a file and rewrite it. I used PHP only for this purpose - FileIO - and I'm new to PHP. Solution? I tried through many forums and knew that we cannot achieve it normal way: onClick event > call function...

Detecting the onload event of a window opened with window.open

window.popup = window.open($(this).attr('href'), 'Ad', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); $(window.popup).onload = function() { alert("Popup has loaded a page"); }; This doesn't work in a...

Integer to hex string in C++

How do I convert an integer to a hex string in C++? I can find some ways to do it, but they mostly seem targeted towards C. It doesn't seem there's a native way to do it in C++. It is a pretty simple problem though; I've got an int which I'd like to...

What is the difference between a Relational and Non-Relational Database?

I know that solutions like MySQL, PostgreSQL and MS SQL Server are relational database systems, and NoSQL, MongoDB, etc. are Non-Relational DBMS. However, what are the differences between the two types of system ? Layman terms are preferable. Than...

Centering text in a table in Twitter Bootstrap

For some reason, The text inside the table still is not centered. Why? How do I center the text inside the table? To make it really Clear: For example, I want "Lorem" to sit in the middle of the four "1". ? _x000D_ _x000D_ @import...

JBoss AS 7: How to clean up tmp?

I noticed that in my JBoss Application Server 7 installation under standalone/tmp I have 400 MB of files related to past deployments, some of them a few months old. How is it cleaned up? Should it happen automatically? Is there a tool for it? Can I ...

How to monitor SQL Server table changes by using c#?

I have more than one application accessing the same DB and I need to get notified if one of these apps change anything (update, insert) in a certain table. Database and apps are not in the same server....

Simulating Key Press C#

I want to simulate F5 key press in my C# program. When IE is open, I want to be able refresh my website automatically. How can I do that?...

Resolve promises one after another (i.e. in sequence)?

Consider the following code that reads an array of files in a serial/sequential manner. readFiles returns a promise, which is resolved only once all files have been read in sequence. var readFile = function(file) { ... // Returns a promise. }; var...

How to query between two dates using Laravel and Eloquent?

I'm trying to create a report page that shows reports from a specific date to a specific date. Here's my current code: $now = date('Y-m-d'); $reservations = Reservation::where('reservation_from', $now)->get(); What this does in plain SQL is sel...

How to trigger event when a variable's value is changed?

I'm currently creating an application in C# using Visual Studio. I want to create some code so that when a variable has a value of 1 then a certain piece of code is carried out. I know that I can use an if statement but the problem is that the value ...

Reverse a string without using reversed() or [::-1]?

I came across a strange Codecademy exercise that required a function that would take a string as input and return it in reverse order. The only problem was you could not use the reversed method or the common answer here on stackoverflow, [::-1]. Obv...

Not Able To Debug App In Android Studio

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

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

What is the difference between public, protected, package-private and private in Java?

In Java, are there clear rules on when to use each of access modifiers, namely the default (package private), public, protected and private, while making class and interface and dealing with inheritance?...

What is the "right" JSON date format?

I've seen so many different standards for the JSON date format: "\"\\/Date(1335205592410)\\/\"" .NET JavaScriptSerializer "\"\\/Date(1335205592410-0500)\\/\"" .NET DataContractJsonSerializer "2012-04-23T18:25:43.511Z" JavaScr...

How can I apply styles to multiple classes at once?

I want two classes with different names to have the same property in CSS. I don't want to repeat the code. _x000D_ _x000D_ .abc {_x000D_ margin-left:20px;_x000D_ } _x000D_ .xyz {_x000D_ margin-left:20px;_x000D_ }_x000D_ <a class="abc">L...

How can I hide a TD tag using inline JavaScript or CSS?

How can I hide a <td> tag using JavaScript or inline CSS?...

How to run Rake tasks from within Rake tasks?

I have a Rakefile that compiles the project in two ways, according to the global variable $build_type, which can be :debug or :release (the results go in separate directories): task :build => [:some_other_tasks] do end I wish to create a task t...

unix sort descending order

I want to sort a tab limited file in descending order according to the 5th field of the records. I tried sort -r -k5n filename But it didn't work....

How to set multiple commands in one yaml file with Kubernetes?

In this official document, it can run command in a yaml config file: https://kubernetes.io/docs/tasks/configure-pod-container/ apiVersion: v1 kind: Pod metadata: name: hello-world spec: # specification of the pod’s contents restartPolicy...

Array from dictionary keys in swift

Trying to fill an array with strings from the keys in a dictionary in swift. var componentArray: [String] let dict = NSDictionary(contentsOfFile: NSBundle.mainBundle().pathForResource("Components", ofType: "plist")!) componentArray = dict.allKeys ...

What does @@variable mean in Ruby?

What are Ruby variables preceded with double at signs (@@)? My understanding of a variable preceded with an at sign is that it is an instance variable, like this in PHP: PHP version class Person { public $name; public function setName($na...

how to convert current date to YYYY-MM-DD format with angular 2

i use this line to get the current date public current_date=new Date(); and i have got this result: Wed Apr 26 2017 10:38:12 GMT+0100 (Afr. centrale Ouest) how can i transform that to this format YYYY-MM-DD ...

typeof !== "undefined" vs. != null

I often see JavaScript code which checks for undefined parameters etc. this way: if (typeof input !== "undefined") { // do stuff } This seems kind of wasteful, since it involves both a type lookup and a string comparison, not to mention its ve...

java comparator, how to sort by integer?

Im trying to learn comparator in java and I have found this great example online, my question is how would this code be changed so that the pet names are ordered by age and in descending order so that the oldest is first and youngest is last? class...

How to fix UITableView separator on iOS 7?

UITableView draws with ragged lines on iOS 7: How to fix it? The line between cells should be on the full width of the screen....

Using regular expressions to do mass replace in Notepad++ and Vim

So I've got a big text file which looks like the following: <option value value='1' >A <option value value='2' >B <option value value='3' >C <option value value='4' >D It's several hundred lines long and I really don't want...

SOAP request in PHP with CURL

Since the SOAP manual on php.net is not very noob friendly and I could not find any good examples I will post my question here. How can I create PHP SOAP request to look like this? POST /MySERVER/myWSDLservice.asmx HTTP/1.1 Host: connection.mywebsi...

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 Alter a table for Identity Specification is identity SQL Server

not working ALTER TABLE ProductInProduct ALTER COLUMN Id KEY IDENTITY (1, 1); Check Image I have a table ProductInProduct is want its id should be Unique.. ...

CSS fill remaining width

I have this header bar. <div id="header"> <div class="container"> <img src="img/logo.png"/> <div id="searchBar"> <input type="text" /> </div> ...

Composer Update Laravel

A developer has sent me his project to work with, but when ever I try to update or install my vendors everything works great until the very end and it outputs the message bellow. C:\xampp\htdocs\BigWaveMedia\davinkit>php artisan migrate { "er...

Convert object to JSON string in C#

Possible Duplicate: Turn C# object into a JSON string in .NET 4 In the Java, I have a code to convert java object to JSON string. How to do the similar in the C# ? which JSON library I should use ? Thanks. JAVA code import net.sf.json.J...

Add Foreign Key relationship between two Databases

I have two tables in two different databases. In table1 (in database1) there is a column called column1 and it is a primary key. Now in table2 (in database2) there is a column called column2 and I want to add it as a foreign key. I tried to add it a...

Fatal error: iostream: No such file or directory in compiling C program using GCC

Why when I wan to compile the following multi thread merge sorting C program, I receive this error: ap@sharifvm:~/forTHE04a$ gcc -g -Wall -o mer mer.c -lpthread mer.c:4:20: fatal error: iostream: No such file or directory #include <iostream>...

Implement an input with a mask

I would like to implement a mask for a text input field which accepts a date. The masked value should display directly inside of the input. Something like this: <input type='text' value='____/__/__'> I wrote the mask as a value in that exam...

Radio button validation in javascript

Need to validate a radio button input, i.e. when submit button is pressed and no radio buttons have been selected, it alerts the user saying 'please select a check box', and if a radio button has been selected then simply submit the form, needs no al...

Print newline in PHP in single quotes

I try to use single quotes as much as possible and I've noticed that I can't use \n in single quotes. I know I can just enter a newline literally by pressing return, but that screws up the indentation of my code. Is there some ASCII character or som...

Running an executable in Mac Terminal

I just made a .c file and compiled it with gcc in the terminal on OS X 10.8.2. My syntax was gcc -o <filename> <sourcefile> and that was fine. Now I see I have an executable and file <filename> tells me as such, but I'm not sure h...

Is there a way to continue broken scp (secure copy) command process in Linux?

I am copying 7.5 GB file to a remote server using scp command. At some point in time file transfer breaks and I have to start all over again. Is the temporary amount of file being transferred completely lost ? Can I somehow restart the transfer from...

Overflow-x:hidden doesn't prevent content from overflowing in mobile browsers

I have a website here. Viewed in a desktop browser, the black menu bar properly extends only to edge of the window, since the body has overflow-x:hidden. In any mobile browser, whether Android or iOS, the black menu bar displays its full width, w...

Create XML file using java

How to create a xml file and save it in some place in my machine using java..there are attributes also include in the xml file? I have found org.w3c.dom.Document but having problems with creating attributes for elements and save the xml file. Thank ...

how can I connect to a remote mongo server from Mac OS terminal

I would like to drop into the mongo shell in the terminal on my MacBook. However, I'm interested in connecting to a Mongo instance that is running in the cloud (compose.io instance via Heroku addon). I have the name, password, host, port, and datab...

Fetching data from MySQL database to html dropdown list

I have a web site that contains a html form, in this form i have a dropdownlist with list of agents that works in the company, i want to fetch data from MySQL database to this dropdownlist so when you add a new agent his name will appear as a option ...

SQL - The conversion of a varchar data type to a datetime data type resulted in an out-of-range value

I have been getting the following error when running a SQL to convert my data type value from varchar to datetime. Msg 242, Level 16, State 3, Line 1 The conversion of a varchar data type to a datetime data type resulted in an out-of-range valu...

Could not load file or assembly Microsoft.SqlServer.management.sdk.sfc version 11.0.0.0

I have installed MS SQL Server 2008 R2 and when I try to update model from database under EDMX file I am facing that error. Could not load file or assembly Microsoft.SqlServer.management.sdk.sfc version 11.0.0.0 I have tried to install Micro...

how to implement Interfaces in C++?

Possible Duplicate: Preferred way to simulate interfaces in C++ I was curious to find out if there are interfaces in C++ because in Java, there is the implementation of the design patterns mostly with decoupling the classes via interfaces....

how to find 2d array size in c++

How do I find the size of a 2D array in C++? Is there any predefined function like sizeof to determine the size of the array? Also, can anyone tell me how to detect an error in the getvalue method for arrays while trying to get a value which is not ...

hash keys / values as array

I cannot find the javascript equivalent of php array_keys() / array_values() For people unfamiliar with php given the following js hash: var myHash = {"apples": 3, "oranges": 4, "bananas": 42} How can I get an array of keys, i.e. ["apples", "ora...

Java : Accessing a class within a package, which is the better way?

If I access a class within a package using fully qualified name, without importing it, whether it saves any memory? Using fully qualified class name : java.lang.Math.sqrt(x); Import package : import java.lang.Math; Math.sqrt(x); which is the...

WCF ServiceHost access rights

I get the following error when going through the WCF tutorial. HTTP could not register URL http://+:8000/ServiceModelSamples/Service/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for d...

Passing a Bundle on startActivity()?

What's the correct way to pass a bundle to the activity that is being launched from the current one? Shared properties?...

iOS 7 status bar overlapping UI

I recently upgraded to xcode 5 and when I run my app in the iOS simulator the splash screen overlaps the status bar and when you are in the app the status bar overlaps onto elements on my app, like a back button I have on the top left hand corner of ...

How to obtain the location of cacerts of the default java installation?

I am looking on how how to obtain the location of cacerts of the default java installation, when you do not have JAVA_HOME or JRE_HOME defined. I need a solution that works at least for OS X and Linux. Yes. java -v is assumed to work :)...

In reactJS, how to copy text to clipboard?

I'm using ReactJS and when a user clicks a link I want to copy some text to the clipboard. I am using Chrome 52 and I do not need to support any other browsers. I can't see why this code does not result in the data being copied to the clipboard. (t...

How to read an http input stream

The code pasted below was taken from java docs on HttpURLConnection. I get the following error: readStream(in) as there is no such method. I see this same thing in the Class Overview for URLConnection at URLConnection.getInputStream() Where...

Redirecting to a page after submitting form in HTML

I'm fairly new to coding in HTML. After hours of searching the internet for a way to do this, I failed and so I'm here. I was setting up a CSRF Proof of concept page here, I want it to redirect to another page which will execute the payload that the ...

Does Python's time.time() return the local or UTC timestamp?

Does time.time() in the Python time module return the system's time or the time in UTC?...

ValueError : I/O operation on closed file

import csv with open('v.csv', 'w') as csvfile: cwriter = csv.writer(csvfile, delimiter=' ', quotechar='|', quoting=csv.QUOTE_MINIMAL) for w, c in p.items(): cwriter.writerow(w + c) Here, p is a dictionary, w and c both are strings. W...

Executing an EXE file using a PowerShell script

I'm trying to execute an EXE file using a PowerShell script. If I use the command line it works without a problem (first I supply the name of the executable and series of parameters to invoke it): "C:\Program Files\Automated QA\TestExecute 8\Bin\Tes...

How can I count the number of elements with same class?

I have a main div in my page with a specific id. Now some input elements of the same class are present in this div. So how can I count the number of these elements of same class in this div using jQuery?...

Stacking DIVs on top of each other?

Is it possible to stack up multiple DIVs like: <div> <div></div> <div></div> <div></div> <div></div> </div> So that all those inner DIVs have the same X and Y position? By default they al...

How can I Convert HTML to Text in C#?

I'm looking for C# code to convert an HTML document to plain text. I'm not looking for simple tag stripping , but something that will output plain text with a reasonable preservation of the original layout. The output should look like this: Html...

Custom bullet symbol for <li> elements in <ul> that is a regular character, and not an image

I realize one can specify a custom graphic to be a replacement bullet character, using CSS attribute: list-style-image And then giving it a URL. However, in my case, I just want to use the '+' symbol. I don't want to have to create a graphic for ...

fatal: Unable to create temporary file '/home/username/git/myrepo.git/./objects/pack/tmp_pack_XXXXXX': Permission denied

I have been having trouble with this error message and I don't understand the proper solution to fix it or go about debugging it. I have googled the error in various forms but no real solution has presented itself. I am assuming it's an issue with pe...

Create URL from a String

It is a very basic question. But i am unable to find an answer in Java documentation and unable to test it as well since i don't know if such method exist or not. I might receive a URL String which could be http://www.example1.com or http://www....

What's the difference between nohup and ampersand

Both nohup myprocess.out & or myprocess.out & set myprocess.out to run in the background. After I shutdown the terminal, the process is still running. What's the difference between them?...

Using multiple arguments for string formatting in Python (e.g., '%s ... %s')

I have a string that looks like '%s in %s' and I want to know how to seperate the arguments so that they are two different %s. My mind coming from Java came up with this: '%s in %s' % unicode(self.author), unicode(self.publication) But this does...

Wait until all jQuery Ajax requests are done?

How do I make a function wait until all jQuery Ajax requests are done inside another function? In short, I need to wait for all Ajax requests to be done before I execute the next. But how?...

Objective-C declared @property attributes (nonatomic, copy, strong, weak)

Can someone explain to me in detail when I must use each attribute: nonatomic, copy, strong, weak, and so on, for a declared property, and explain what each does? Some sort of example would be great also. I am using ARC....

Django Template Variables and Javascript

When I render a page using the Django template renderer, I can pass in a dictionary variable containing various values to manipulate them in the page using {{ myVar }}. Is there a way to access the same variable in Javascript (perhaps using the DOM,...

How to install Flask on Windows?

I have a project to do for after create a webpage that display the latest weather from my CSV file. I would like some details how to do it (don't really get the http://flask.pocoo.org/docs/installation/#installation installation setup) Can anyone m...

How to add a "confirm delete" option in ASP.Net Gridview?

How to add a "confirm delete" option in ASP.Net Gridview ?...

How do I position a div at the bottom center of the screen

I have this css: #manipulate { position:absolute; width:300px; height:300px; background:#063; bottom:0px; right:25%; } I have this html: <div id="manipulate" align="center"> </div> How do we position that div at the bot...

Maven Install on Mac OS X

I'm trying to install maven through the terminal by following these instructions. So far I got this export M2_HOME=/user/apple/apache-maven-3.0.3 export M2=$M2_HOME/bin export PATH=$M2:$PATH export JAVA_HOME=/usr/java/jdk1.6.0_22 This is probably...

How do you replace double quotes with a blank space in Java?

For example: "I don't like these "double" quotes" and I want the output to be I don't like these double quotes ...

Find the max of 3 numbers in Java with different data types

Say I have the following three constants: final static int MY_INT1 = 25; final static int MY_INT2 = -10; final static double MY_DOUBLE1 = 15.5; I want to take the three of them and use Math.max() to find the max of the three but if I pass in more ...

How to check if any Checkbox is checked in Angular

Is there any function or ng-something to check if any of the displayed Checkboxes are checked? I have the values through the ng-click="function()" and pass the values through. I can go by foot and check my array if any value is inside. I want to...

What is the list of supported languages/locales on Android?

I'd like to know what to name my folder for different languages. Where can I find the supported list of languages on Android?...

JDK on OSX 10.7 Lion

I've instaled the Java for Developer package provided from Apple for 10.7 and java apps are running fine but eclipse cannot find the JDK root path and I cant either. Anybody any ideas?...

What's the whole point of "localhost", hosts and ports at all?

I'm totally new to this web development stuff. So I see things like "localhost" all the time and ask myself: What's that? I feel to know what a "host" actually is. Something that executes something. So my mac is the host for everything that runs on...

MySQL pivot table query with dynamic columns

I'm using the following tables for storing product data: mysql> SELECT * FROM product; +---------------+---------------+--------+ | id | name | description | stock | +---------------+---------------+--------+ | 1 | product1 | first produc...

Print text instead of value from C enum

int main() { enum Days{Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday}; Days TheDay; int j = 0; printf("Please enter the day of the week (0 to 6)\n"); scanf("%d",&j); TheDay = Days(j); //how to PRINT THE VALUES stor...

How to find distinct rows with field in list using JPA and Spring?

I am using Spring to connect to the db. I have an interface extending CrudRepository<People, Long> Here is the query I want execute on the db: SELECT DISTINCT name FROM people WHERE name NOT IN UserInputSet. I would prefer to do it without any ...

How can I get LINQ to return the object which has the max value for a given property?

If I have a class that looks like: public class Item { public int ClientID { get; set; } public int ID { get; set; } } And a collection of those items... List<Item> items = getItems(); How can I use LINQ to return the single "Item...

Converting between datetime and Pandas Timestamp objects

I have the following: > date1 Timestamp('2014-01-23 00:00:00', tz=None) > date2 datetime.date(2014, 3, 26) and I read on this answer that I could use pandas.to_datetime() to convert from Timestamps to datetime objects, but it doesn't seem t...

Negation in Python

I'm trying to create a directory if the path doesn't exist, but the ! (not) operator doesn't work. I'm not sure how to negate in Python... What's the correct way to do this? if (!os.path.exists("/usr/share/sounds/blues")): proc = subprocess....

How to create JSON object Node.js

I am trying to create a JSON object in Node.js without any success. For example an object like this: { 'Orientation Sensor': [ { sampleTime: '1450632410296', data: '76.36731:3.4651554:0.5665419' }, { sampleTime: '1450632410296', ...

how to add button click event in android studio

So I have done some research, and after defining you button as an object by the code private Button buttonname; buttonname = (Button) findViewById(R.id.buttonnameinandroid) ; here is my problem buttonname.setOnClickListener(this); //as I understa...

How do I append text to a file?

What is the easiest way to append text to a file in Linux? I had a look at this question, but the accepted answer uses an additional program (sed) I'm sure there should be an easier way with echo or similar....

Maven: Failed to retrieve plugin descriptor error

I configured Maven 3.0.3 and tried to download a sample project using archetypes with this command: mvn archetype:generate -DarchetypeGroupId=org.graniteds.archetypes -DarchetypeArtifactId=graniteds-tide-spring-jpa-hibernate...

C/C++ include header file order

What order should include files be specified, i.e. what are the reasons for including one header before another? For example, do the system files, STL, and Boost go before or after the local include files?...

Class Not Found Exception when running JUnit test

I am getting this error when running JUnit test in Eclipse: Class not found com.myproject.server.MyTest java.lang.ClassNotFoundException: com.myproject.server.MyTest at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLCl...

Why are my PowerShell scripts not running?

I wrote a simple batch file as a PowerShell script, and I am getting errors when they run. It's in a scripts directory in my path. This is the error I get: Cannot be loaded because the execution of scripts is disabled on this system. Please ...

How to close a Tkinter window by pressing a Button?

Write a GUI application with a button labeled "Good-bye". When the Button is clicked, the window closes. This is my code so far, but it is not working. Can anyone help me out with my code? from Tkinter import * window = Tk() def close_window (r...

Plotting a python dict in order of key values

I have a python dictionary that looks like this: In[1]: dict_concentration Out[2] : {0: 0.19849878712984576, 5000: 0.093917341754771386, 10000: 0.075060643507712022, 20000: 0.06673074282575861, 30000: 0.057119318961966224, 50000: 0.0461348345462034...

Why does my favicon not show up?

The following is used to set the favicon in my html code: <link rel="icon" type="img/ico" href="img/favicon.ico"> However, the icon does not show. Why? Note: I have confirmed that the file is on-disk at the correct path....

How to solve error: "Clock skew detected"?

I am uploading my OpenCL and Cuda code to hgpu.org because I don't have a graphics card on my laptop. When I upload my code I get the following error: make: Warning: File `main.cu' has modification time 381 s in the future make: warning: Clock skew...

Facebook login "given URL not allowed by application configuration"

I've added facebook login to my site. However, when I click the button, I get a red box that says: Invalid Argument Given URL is not allowed by the Application configuration. If I continue to login then I get: API Error Code: 100 API Error Desc...

Simplest way to throw an error/exception with a custom message in Swift 2?

I want to do something in Swift 2 that I'm used to doing in multiple other languages: throw a runtime exception with a custom message. For example (in Java): throw new RuntimeException("A custom message here") I understand that I can throw enum ...

How to round up with excel VBA round()?

I have the following data: cell(1,1) = 2878.75 cell(1,2) = $31.10 cell(2,1) = $89,529.13 However, when I tried to use round(cells(1,1).value*cells(1,2).value),2), the result does not match cell(2,1). I figured it has to do with the rounding issue,...

How to send a HTTP OPTIONS request from the command line?

I tried to use cURL but it seems that by default (Debian) is not compiled with HTTPS support and I dont want to build it myself. wget seems to have SSL support but I found no information on how to generate an OPTIONS HTTP request with wget....

Hide keyboard in react-native

If I tap onto a textinput, I want to be able to tap somewhere else in order to dismiss the keyboard again (not the return key though). I haven't found the slightest piece of information concerning this in all the tutorials and blog posts that I read....

MongoDB Data directory /data/db not found

When I try to run Mongod in terminal I got this message : 2015-05-14T17:33:04.554+0700 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating 2015-05-14T17:33:04.554+0700 I CONTROL [initandlisten]...

How to create virtual column using MySQL SELECT?

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

How to declare Global Variables in Excel VBA to be visible across the Workbook

I have a question about global scope and have abstracted the problem into a simple example: In an Excel Workbook: In Sheet1 I have two(2) buttons. The first is labeled SetMe and is linked to a subroutine in Sheet1's module: Sheet1 code: Option Expl...

Create a directory if it doesn't exist

In my app I want to copy a file to the other hard disk so this is my code: #include <windows.h> using namespace std; int main(int argc, char* argv[] ) { string Input = "C:\\Emploi NAm.docx"; string CopiedFile = "Emploi NAm.docx"; ...

C#: How to add subitems in ListView

Creating an item(Under the key) is easy,but how to add subitems(Value)? listView1.Columns.Add("Key"); listView1.Columns.Add("Value"); listView1.Items.Add("sdasdasdasd"); //How to add "asdasdasd" under value? ...

The module ".dll" was loaded but the entry-point was not found

I have a DLL which cause to an error when I run the application. The error says that the service is not registered. So I run command regsvr32 with the name of the DLL. But it gives me an error, now the error is: The module 'mydll.dll' was loaded but...

Item frequency count in Python

Assume I have a list of words, and I want to find the number of times each word appears in that list. An obvious way to do this is: words = "apple banana apple strawberry banana lemon" uniques = set(words.split()) freqs = [(item, words.split().coun...

Regex to check if valid URL that ends in .jpg, .png, or .gif

I would like users to submit a URL that is valid but also is an image, ending with .jpg, .png, or .gif....

Uploading Laravel Project onto Web Server

I am trying to upload my Laravel project onto my web server, but my past two attempts have been unsuccessful. I believe I am not uploading the files to the right location. This is my web server's structure -> Am I correct to say that I need to up...

ant warning: "'includeantruntime' was not set"

I receive the following warning: [javac] build.xml:9: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds What does this mean?...

LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1

LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1 I know "52e" code is when username is valid, but password is invalid. I am using the same user name and password in my apache studio, ...

Definitive way to trigger keypress events with jQuery

I've read all the answers on to this questions and none of the solutions seem to work. Also, I am getting the vibe that triggering keypress with special characters does not work at all. Can someone verify who has done this? ...

AngularJS $resource RESTful example

I would like to use $resource to call my RESTful web service, (which I am still working on) but I would like to find out if I got my AngularJS script correct first. The todo DTO has: {id, order, content, done} :cmd is so I can call api/1/todo/reset...

What is mapDispatchToProps?

I was reading the documentation for the Redux library and it has this example: In addition to reading the state, container components can dispatch actions. In a similar fashion, you can define a function called mapDispatchToProps() that receives ...

How to specify Memory & CPU limit in docker compose version 3

I am unable to specify CPU & memory for services specified in version 3 . With version 2 it works fine with "mem_limit" & "cpu_shares" parameters under the services . But it fails while using version 3 , putting them under deploy section doe...

How do I compute derivative using Numpy?

How do I calculate the derivative of a function, for example y = x2+1 using numpy? Let's say, I want the value of derivative at x = 5... ...

How to convert a string variable containing time to time_t type in c++?

I have a string variable containing time in hh:mm:ss format. How to convert it into time_t type? eg: string time_details = "16:35:12" Also, how to compare two variables containing time so as to decide which is the earliest? eg : string curr_time = "...

How to change an Android app's name?

Is there a way to change the name (Launcher App Label) of an app without creating a new project? Note: Name of the App and The label shown on the Launcher Icon on Home Screen on Mobiles can be different. Example: On the home page in my Mobile where...

how to create and call scalar function in sql server 2008

I have created a Scalar Functions, it was created successfully, but when I call the function using select statement, it says invalid object, I altered the function, I got the message command completed successfully, but when I call the function, I get...

How to remove carriage return and newline from a variable in shell script

I am new to shell script. I am sourcing a file, which is created in Windows and has carriage returns, using the source command. After I source when I append some characters to it, it always comes to the start of the line. test.dat (which has carriag...

IE 8: background-size fix

I've tried to add background size to IE but it's not working at all: HTML <h2 id="news">Notícias <img src="white-marker.png" alt="" /></h2> CSS: div#content h2#news { background: url('../images/news-background.jpg') no-rep...

How to save a data frame as CSV to a user selected location using tcltk

I have a data frame called, Fail. I would like to save Fail as a CSV in a location that the user selects. Below is some example code that I found, but I don't know how to incorporate Fail into it. require(tcltk) fileName <- tclvalue(tkgetSave...

"git pull" or "git merge" between master and development branches

I have my master branch and a develop branch for working on a few changes. I need to merge changes from master into develop, but will eventually merge everything from develop into master. I have two different workflows in mind: git pull origin mas...

Java ArrayList copy

I have an ArrayList l1 of size 10. I assign l1 to new list reference type l2. Will l1 and l2 point to same ArrayList object? Or is a copy of the ArrayList object assigned to l2? When using the l2 reference, if I update the list object, it reflects t...

Adding item to Dictionary within loop

Below data is grasped from webpage and containing entries as below(like a table with many rows): entry1: key1: value1-1, key2: value2-1, key3: value3-1 entry2: key1: value1-2, key2: value2-2, key3: value3-2 entry3: key1: value3-1, key2: value2-3, k...

Removing the remembered login and password list in SQL Server Management Studio

I've recently used our company's spare laptop (that has a general user set up) while mine was being repaired. I've checked the "Remember password" option in SQL Server Management Studio when logging in to the database. I need to clear the login and...

How to generate class diagram from project in Visual Studio 2013?

In Visual Studio 2010 I can generate class diagram from my project with 2 clicks. But now in Visual Studio 2013 I don't see the option "View Class Diagram" in project menu. Where did this item disappear? How can I generate class diagram from project ...

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

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

Make Adobe fonts work with CSS3 @font-face in IE9

I'm in the process of building a small intranet application and try, with no luck, to use Adobe font I purchased lately. As I was informed, in our case it's not a license violation. I converted the .ttf/.otf versions of font to .woff, .eot and .svg,...

How to get 'System.Web.Http, Version=5.2.3.0?

I just created an MVC5 project and added several packages from nuget, but then when I compiled the project, i got this error. It seems one of the packages really depends on system.web.http version 5.2.3.0, which i couldn't find anywhere. I just wond...

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 to ignore a property in class if null, using json.net

I am using Json.NET to serialize a class to JSON. I have the class like this: class Test1 { [JsonProperty("id")] public string ID { get; set; } [JsonProperty("label")] public string Label { get; set; } [JsonProperty("url")] ...

Python: Assign print output to a variable

I would like to know how to assign the output of the print function (or any function) to a variable. To give an example: import eyeD3 tag = eyeD3.Tag() tag.link("/some/file.mp3") print tag.getArtist() How do I assign the output of print tag.getArt...

HTTP 400 (bad request) for logical error, not malformed request syntax

The HTTP/1.1 specification (RFC 2616) has the following to say on the meaning of status code 400, Bad Request (§10.4.1): The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request wi...

How to get all table names from a database?

I'd like to retrieve all table names from a database schema, and, if possible, get all table starting with a specified prefix. I tried using JDBC's connection.getMetaData().getTables() but it didn't work at all. Connection jdbcConnection = DriverM...

How do I change the background color of a plot made with ggplot2

By default, ggplot2 produces plots with a grey background. How do I change the color of the background of the plot? For example, a plot produced by the following code: library(ggplot2) myplot<-ggplot(data=data.frame(a=c(1,2,3), b=c(2,3,4)), aes...

Why does an onclick property set with setAttribute fail to work in IE?

Ran into this problem today, posting in case someone else has the same issue. var execBtn = document.createElement('input'); execBtn.setAttribute("type", "button"); execBtn.setAttribute("id", "execBtn"); execBtn.setAttribute("value", "Execute"); exe...

Setting table row height

I have this code: <table class="topics" > <tr> <td style="white-space: nowrap; padding: 0 5px 0 0; color:#3A5572; font-weight: bold;">Test</td> <td style="padding: 0 4px 0 0;">1.0</td> ...

Easy way to export multiple data.frame to multiple Excel worksheets

I am surprised to find that there is no easy way to export multiple data.frame to multiple worksheets of an Excel file? I tried xlsx package, seems it can only write to one sheet (override old sheet); I also tried WriteXLS package, but it gives me er...

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

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

Difference between TCP and UDP?

What is the difference between TCP and UDP? I know that TCP is used in the case of non-time critical applications, and UDP is used for games or applications that require fast transmission of data. I know that TCP is used for HTTP, HTTPs, FTP, SMTP,...

Java Look and Feel (L&F)

I am developing a desktop application with Java Swing for my personal use.I am in need of some beautiful Look and Feel for my application. How can I do it using Java or a 3rd party API?...

How to calculate 1st and 3rd quartiles?

I have DataFrame: time_diff avg_trips 0 0.450000 1.0 1 0.483333 1.0 2 0.500000 1.0 3 0.516667 1.0 4 0.533333 2.0 I want to get 1st quartile, 3rd quartile and median for the column time_diff. To obtain median, I use n...

Test a weekly cron job

I have a #!/bin/bash file in cron.week directory. Is there a way to test if it works? Can't wait 1 week I am on Debian 6 with root...

LINQ Contains Case Insensitive

This code is case sensitive, how to make it case insensitive? public IQueryable<FACILITY_ITEM> GetFacilityItemRootByDescription(string description) { return this.ObjectContext.FACILITY_ITEM.Where(fi => fi.DESCRIPTION.Contains(descripti...

How to simulate a button click using code?

How can I trigger a button click event using code in Android? I want to trigger the button click programmatically when some other event occurs. Same Problem I am Facing public void onDateSelectedButtonClick(View v){ /*Something Alarm Manageme...

Print time in a batch file (milliseconds)

How do I print the time (in ms) in a Windows batch file? I want to measure the time that passes between lines in my batch file, but Windows's "time /T" does not print milliseconds....

Makefile to compile multiple C programs?

This is an incredibly simple question, but I'm new to makefiles. I am trying to make a makefile that will compile two independent programs: program1: gcc -o prog1 program1.c program2: gcc -o prog2 program2.c All the examples online go int...

JavaScript checking for null vs. undefined and difference between == and ===

How do I check a variable if it's null or undefined and what is the difference between the null and undefined? What is the difference between == and === (it's hard to search Google for "===" )? ...

lvalue required as left operand of assignment error when using C++

int main() { int x[3]={4,5,6}; int *p=x; p +1=p;/*compiler shows error saying lvalue required as left operand of assignment*/ cout<<p 1; getch(); } ...

Configure nginx with multiple locations with different root folders on subdomain

I'm looking to serve the root url of a subdomain and directory of a subdomain to two different folders on my server. Here is the simple set-up that I have and is not working... server { index index.html index.htm; server_name test.example.c...

I keep getting "Uncaught SyntaxError: Unexpected token o"

I'm trying to learn some html/css/javascript, so I'm writing myself a teaching project. The idea was to have some vocabulary contained in a json file which would then be loaded into a table. I managed to load the file in and print out one of its val...

How to write macro for Notepad++?

I would like to write a macro for Notepad++ which should replace char1, char2, char3 with char4, char5, char6, respectively....

how to get files from <input type='file' .../> (Indirect) with javascript

I have problem with "input tag" in non IE browsers <input type="file" ... I'm trying to write my uploader , just using javascript and asp.net. I have no problem uploading files. My problem occured When I wanted to get my files in non IE brows...

HTTP 1.0 vs 1.1

Could somebody give me a brief overview of the differences between HTTP 1.0 and HTTP 1.1? I've spent some time with both of the RFCs, but haven't been able to pull out a lot of difference between them. Wikipedia says this: HTTP/1.1 (1997-1999) Cur...

How to use relative paths without including the context root name?

To working my static file (CSS, JS) I have to write absolute path like /AppName/templates/style/main.css. Is there any solution, that I could write relative path like style/main.css?...

How to run cron once, daily at 10pm

I had entered: * 22 * * * test > /dev/null However, I am being notified via email that this is running every minute. I am confused I guess because I thought this was correct for what I am wanting....

How to style SVG <g> element?

I have some SVG elements grouped together in a <g> element. I just want to style that <g> element to show grouping of elements. Like I want to give some background-color and a border to it. How it would be achieved? I tried fill and stro...

How can I convert string date to NSDate?

I want to convert "2014-07-15 06:55:14.198000+00:00" this string date to NSDate in Swift....

How do I lowercase a string in Python?

Is there a way to convert a string from uppercase, or even part uppercase to lowercase? For example, "Kilometers" ? "kilometers"....

How do I post form data with fetch api?

My code: fetch("api/xxx", { body: new FormData(document.getElementById("form")), headers: { "Content-Type": "application/x-www-form-urlencoded", // "Content-Type": "multipart/form-data", }, method: "post", } I tried...

not None test in Python

Out of these not None tests. if val != None: if not (val is None): if val is not None: Which one is preferable, and why?...

How to POST a JSON object to a JAX-RS service

I am using the Jersey implementation of JAX-RS. I would like to POST a JSON object to this service but I am getting an error code 415 Unsupported Media Type. What am I missing? Here's my code: @Path("/orders") @Consumes(MediaType.APPLICATION_JSON) ...

Android: adbd cannot run as root in production builds

I have an Android-based phone (2.3.6) with unlocked root privileges. Since i'd like to have access to my phone through my computer, today i've installed QtAdb and Android SDK. If i open a command prompt and i do adb shell su i get # And s...

How to find day of week in php in a specific timezone

I am confused while using php to handle date/time. What I am trying to do is this: When a user visits my page I am asking his timezone and then displaying the 'day of week' in his timezone. I don't want to use the browser's day. I want to do this c...

How to create separate AngularJS controller files?

I have all of my AngularJS controllers in one file, controllers.js. This file is structured as follows: angular.module('myApp.controllers', []) .controller('Ctrl1', ['$scope', '$http', function($scope, $http) { }]) .controller('Ctrl2', ['...

Importing modules from parent folder

I am running Python 2.5. This is my folder tree: ptdraft/ nib.py simulations/ life/ life.py (I also have __init__.py in each folder, omitted here for readability) How do I import the nib module from inside the life module? I am hop...

Skip certain tables with mysqldump

Is there a way to restrict certain tables from the mysqldump command? For example, I'd use the following syntax to dump only table1 and table2: mysqldump -u username -p database table1 table2 > database.sql But is there a similar way to dump a...

WebApi's {"message":"an error has occurred"} on IIS7, not in IIS Express

I'm working with ASP.NET MVC 4 WebApi and am having a lot of fun with it running it on my local computer on IIS Express. I've configured IIS Express to serve remote machines too, and so other's in my company are using my computer as our webserver. ...

How to install a node.js module without using npm?

There are quite a few modules which are listed on node's github page but are not published with the npm-registry. These modules can't be installed using npm. What is the correct way to install these nodejs modules after cloning them from Git? ...

How to make a simple image upload using Javascript/HTML

Does any one know how to do a simple image upload and display it on the page. This is what I'm looking for. User(me) will choose a image The page will display the image without refreshing the page or going to another file. multiple <img src>...

Match everything except for specified strings

I know that the following regex will match "red", "green", or "blue". red|green|blue Is there a straightforward way of making it match everything except several specified strings?...

Adding external resources (CSS/JavaScript/images etc) in JSP

I added an external CSS stylesheet to my project and placed in the WEB-CONTENTS folder of my project in Eclipse. When I deployed it on the Tomcat, the stylesheet was not applied. When I debugged it in Chrome and opened it, it gave me 404 file not fou...

Is it possible to use an input value attribute as a CSS selector?

Is it possible to use a CSS selector to target an input that has a specific value? Example: How can I target the input below based on the value="United States" <input type="text" value="United States" /> ...

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

I am trying to feed my Django page with some resource I am getting from somewhere else. Inside the feed, I have YouTube videos with URL like: https://www.youtube.com/watch?v=A6XUVjK9W4o Once I added this into my page, the video does not show up, s...

Editable 'Select' element

I would like to have a select element in the form but besides the options in the dropdown, it would be useful to be able to edit it and add new option but not with another input text, I need all in once. Is it possible? ...

Remove local git tags that are no longer on the remote repository

We use tags in git as part of our deployment process. From time to time, we want to clean up these tags by removing them from our remote repository. This is pretty straightforward. One user deletes the local tag and the remote tag in one set of co...

Combining two lists and removing duplicates, without removing duplicates in original list

I have two lists that i need to combine where the second list has any duplicates of the first list ignored. .. A bit hard to explain, so let me show an example of what the code looks like, and what i want as a result. first_list = [1, 2, 2, 5] seco...

Where does this come from: -*- coding: utf-8 -*-

Python recognizes the following as instruction which defines file's encoding: # -*- coding: utf-8 -*- I definitely saw this kind of instructions before (-*- var: value -*-). Where does it come from? What is the full specification, e.g. can the val...

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

The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead

When I attempt to connect to a MySQL server from PHP, I see the following error: Deprecated: The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /path/to/filename.php on line 123 The code on the ref...

.htaccess or .htpasswd equivalent on IIS?

Does anyone know if there is an equivalent to .htaccess and .htpassword for IIS ? I am being asked to migrate an app to IIS that uses .htaccess to control access to sets of files in various URLs based on the contents of .htaccess files. I did a goo...

Setting Margin Properties in code

MyControl.Margin.Left = 10; Error: Cannot modify the return value of 'System.Windows.FrameworkElement.Margin' because it is not a variable ...

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

Creating a new user and password with Ansible

I have an ansible task which creates a new user on ubuntu 12.04; - name: Add deployment user action: user name=deployer password=mypassword it completes as expected but when I login as that user and try to sudo with the password I set it alway...

Call to undefined function mysql_query() with Login

When i execute my PHP code below i get a Fatal error and i'm not sure how to resolve it. Thank you for your help The Error PHP Fatal error: Uncaught Error: Call to undefined function mysql_query() in /Applications/MAMP/htdocs/lprapp/config.php...

How can I change Mac OS's default Java VM returned from /usr/libexec/java_home

(Wasn't sure if this should go on SU... migration is certainly an option, but more programmers read questions here, so here goes). I am running Mac OS X 10.8.4, and I have Apple's JDK 1.6.0_51 installed as well as Oracle's JDK 1.7.0_25. I recently i...

Get all child elements

In Selenium with Python is it possible to get all the children of a WebElement as a list?...

How do you put an image file in a json object?

I am making a database for video games, each containing elements like name, genre, and and image of the game. Is it possible to put images into a json object for the db? If not is there a way around this?...

How to redirect to another page using PHP

I'm building a website which includes a login page. I need to redirect the user to their profile page once they've logged in successfully, but I don't know how to do that in PHP (It's my first site). I've searched the internet and have been told that...

Tool to monitor HTTP, TCP, etc. Web Service traffic

What's the best tool that you use to monitor Web Service, SOAP, WCF, etc. traffic that's coming and going on the wire? I have seen some tools that made with Java but they seem to be a little crappy. What I want is a tool that sits in the middle as a ...

How to create file object from URL object (image)

I need to create a File object from URL object My requirement is I need to create a file object of a web image (say googles logo) URL url = new URL("http://google.com/pathtoaimage.jpg"); File f = create image from url object ...

Check for column name in a SqlDataReader object

How do I check to see if a column exists in a SqlDataReader object? In my data access layer, I have create a method that builds the same object for multiple stored procedures calls. One of the stored procedures has an additional column that is not ...

Check if an element's content is overflowing?

What's the easiest way to detect if an element has been overflowed? My use case is, I want to limit a certain content box to have a height of 300px. If the inner content is taller than that, I cut it off with an overflow. But if it is overflowed I w...

Python Socket Receive Large Amount of Data

When I try to receive larger amounts of data it gets cut off and I have to press enter to get the rest of the data. At first I was able to increase it a little bit but it still won't receive all of it. As you can see I have increased the buffer on th...

What IDE to use for Python?

What IDEs ("GUIs/editors") do others use for Python coding?...

Qt 5.1.1: Application failed to start because platform plugin "windows" is missing

Edit: Some people started to mark my question as a duplicate. Do not forget that many similar questions existed when I asked this one (see e.g. the list below). However, none of these answers solved my problem. After a long search I found a comment...

Is there a 'box-shadow-color' property?

I have the following CSS: box-shadow: inset 0px 0px 2px #a00; Now I am trying to extract that color to make the page colors 'skinnable'. Is there any way of doing this? Simply removing the color, and then using the same key again later overwrites ...

How can I handle the warning of file_get_contents() function in PHP?

I wrote a PHP code like this $site="http://www.google.com"; $content = file_get_content($site); echo $content; But when I remove "http://" from $site I get the following warning: Warning: file_get_contents(www.google.com) [function.file-ge...

What's the syntax for mod in java

As an example in pseudocode: if ((a mod 2) == 0) { isEven = true; } else { isEven = false; } ...

How to write new line character to a file in Java

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

Find UNC path of a network drive?

I need to be able determine the path of the network Q drive at work for a WEBMethods project. The code that I have before is in my configuration file. I placed single character leters inside of the directories just for security reasons. I am not sure...

How do I get NuGet to install/update all the packages in the packages.config?

I have a solution with multiple projects in it. Most of the third party references are missing, yet there are packages.config file for each project. How do I get NuGet to install/update all the packages needed? Does this need to be done via command ...

Generic deep diff between two objects

I have two objects: oldObj and newObj. The data in oldObj was used to populate a form and newObj is the result of the user changing data in this form and submitting it. Both objects are deep, ie. they have properties that are objects or arrays of obj...

How to concatenate columns in a Postgres SELECT?

I have two string columns a and b in a table foo. select a, b from foo returns values a and b. However, concatenation of a and b does not work. I tried : select a || b from foo and select a||', '||b from foo Update from comments: both column...

Adding link a href to an element using css

Can I add an <a href=""> link to an HTML element using CSS. As I have an image which I want to add a link to a particular page. Can any one help me in doing this?...

How to use npm with node.exe?

I have downloaded Windows Binary (.exe) of nodejs from the main page. How can I install and use npm (Node package manager)?...

jQuery send HTML data through POST

I am using jQuery to make a POST to a PHP file with the HTML content of a div. The HTML content contain tables, inputs, smaller divs and I would like to grab the content of the main DIV and send it to the database. The only option I could think of is...

How to read and write to a text file in C++?

Hey everyone, I have just started to learn C++ and I wanted to know how to read and write to a text file. I have seen many examples but they have all been hard to understand/follow and they have all varied. I was hoping that someone here could help. ...

How do you create a Spring MVC project in Eclipse?

I am trying to follow the basic tutorial for Spring MVC but got lost at creating a new project in Eclipse. It seems to me that most tutorials assume you know how to create a Spring Project in Eclipse. Any advice on where to get started or tutorials w...

Can I limit the length of an array in JavaScript?

I want to display the product browsing history, so I am storing the product ids in a browser cookie. Because the list of history is limited to 5 items, I convert the cookie value to an array, then check the length of it and cut the redundant. The ...

MySQL - UPDATE query with LIMIT

I want to update rows in my table with starting from 1001 to next 1000. I tried with following query: UPDATE `oltp_db`.`users` SET p_id = 3 LIMIT 1001, 1000 This is giving me syntax error. Is this correct? am I doing any mistake here. Can we lim...

Can I start the iPhone simulator without "Build and Run"?

I want to delete an app in the simulator before I "build and run". How can I start the simulator so I can do the deletion? If I start it by "build and run" I get a long log output that takes a while because of a bug I'm trying to fix. I'd like to avo...

Array versus linked-list

Why would someone want to use a linked-list over an array? Coding a linked-list is, no doubt, a bit more work than using an array and one may wonder what would justify the additional effort. I think insertion of new elements is trivial in a linked-...

Given URL is not allowed by the Application configuration Facebook application error

Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains. I have resear...

Capturing window.onbeforeunload

I have a form where the input fields are saved onChange. In Firefox (5) this works even when the window is closed, but for Chrome and IE it doesn't and I need to be sure that I'm saving this data even if they try to close the window after they've typ...

How to stop a vb script running in windows

I'm using windows 7 I wrote a script to check whether My Laptop is running in Battery or AC current. I googled it and succedded in that. dim a a=1 Do While a=1 If IsLaptop( "." ) Then ' WScript.Echo "Laptop" Else ' WScript.Echo "Desktop or s...

Uncaught ReferenceError: <function> is not defined at HTMLButtonElement.onclick

I have created my problem on JSFiddle at https://jsfiddle.net/kgw0x2ng/5/. The code is as follows HTML CODE <div class="loading">Loading&#8230;</div> <button type="submit" onClick="hideButton()">Hide</button> <butto...

Android: How can I validate EditText input?

I need to do form input validation on a series of EditTexts. I'm using OnFocusChangeListeners to trigger the validation after the user types into each one, but this doesn't behave as desired for the last EditText. If I click on the "Done" button whi...

ruby LoadError: cannot load such file

When I require a file, for example (called st.rb): require 'rubygems' require 'mongrel' class TestHandler < Mongrel::HttpHandler def process(request, response) response.start(200) do |head, out| head["Content-Type"] = "text/html" ...

Getting a list of all subdirectories in the current directory

Is there a way to return a list of all the subdirectories in the current directory in Python? I know you can do this with files, but I need to get the list of directories instead....

How to implement "Access-Control-Allow-Origin" header in asp.net

Is it possible to implement "Access-Control-Allow-Origin" header in asp.net...

Send data from activity to fragment in Android

I have two classes. First is activity, second is a fragment where I have some EditText. In activity I have a subclass with async-task and in method doInBackground I get some result, which I save to variable. How can I send this variable from subclass...

Couldn't connect to server 127.0.0.1:27017

I'm getting the following error: alex@alex-K43U:/$ mongo MongoDB shell version: 2.2.0 connecting to: test Thu Oct 11 11:46:53 Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91 exception: connect failed alex@alex-K43U:/$ ...

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

Passing multiple values for same variable in stored procedure

I have a variable that passes multiple values to stored procedure. When I see through fidler I see values being passed correctly like arg1=331 arg1=222 arg1=876 arg1=932 In my stored procedure I am reading as procedure main...

iptables LOG and DROP in one rule

I am trying to log outgoing connections with iptables. What I want is, drop and accept connection while logging them also. I have found that -j option takes DROP/REJECT/ACCEPT/LOG. But I want to do something like DROP and LOG or ACCEPT and LOG. Is t...

Adding simple legend to plot in R

I would like to create a very simple plot. I am using this data: a <- read.table("https://dl.dropbox.com/u/22681355/a.csv", sep=',', header=TRUE) plot(a$X25, type="l",col="red", ylim=c(0,100)) lines(a$X25.1, type="l", col="blue") lines(a$X25.2,...

IF a cell contains a string

How can I assign a value to cells if it's neighbour contains a specific string? For example, fields in column A: dog11 cat22 cow11 chick11 duck22 cat11 horse22 cat33 The syntax in column B would be: =IF(SEARCH("ca...

How to change status bar color in Flutter?

I am trying to change the status bar color to white. I found this pub on flutter. I tried to use the example code on my dart files....

SQL Server: Get data for only the past year

I am writing a query in which I have to get the data for only the last year. What is the best way to do this? SELECT ... FROM ... WHERE date > '8/27/2007 12:00:00 AM' ...

Compare two MySQL databases

I'm currently developing an application using a MySQL database. The database-structure is still in flux and changes while development progresses (I change my local copy, leaving the one on the test-server alone). Is there a way to compare the two i...

Hide axis values but keep axis tick labels in matplotlib

I have this image: plt.plot(sim_1['t'],sim_1['V'],'k') plt.ylabel('V') plt.xlabel('t') plt.show() I want to hide the numbers; if I use: plt.axis('off') ...I get this image: It also hide the labels, V and t. How can I keep the labels while ...

What does the M stand for in C# Decimal literal notation?

In order to work with decimal data types, I have to do this with variable initialization: decimal aValue = 50.0M; What does the M part stand for?...

Send text to specific contact programmatically (whatsapp)

I wanted to know how I can send text to a specific whatsapp contact. I found some code to view a specific contact, but not to send data. Cursor c = getContentResolver().query(ContactsContract.Data.CONTENT_URI, new String[] { ContactsContract.Con...

How to detect page zoom level in all modern browsers?

How can I detect the page zoom level in all modern browsers? While this thread tells how to do it in IE7 and IE8, I can't find a good cross-browser solution. Firefox stores the page zoom level for future access. On the first page load, would I be ab...

Apply CSS Style to child elements

I want to apply styles only to the table inside the DIV with a particular class: Note: I'd rather use a css-selector for children elements. Why does the #1 works and #2 doesn't? 1: div.test th, div.test td, div.test caption {padding:40px 100px 40...

how to pass parameter from @Url.Action to controller function

I have a function CreatePerson(int id) , I want to pass id from @Url.Action. Below is the reference code: public ActionResult CreatePerson(int id) //controller window.location.href = "@Url.Action("CreatePerson", "Person") + id"; the above code ...

Objective-C - Remove last character from string

In Objective-C for iOS, how would I remove the last character of a string using a button action?...

Stupid error: Failed to load resource: net::ERR_CACHE_MISS

I'm developing Web app in Yii framework. I need use AJAX in my some pages. So, when I clicked the button (which I loaded them with AJAX the Google Chrome Developer Tools browser says me: Failed to load resource: net::ERR_CACHE_MISS How to solv...

How to format a float in javascript?

In JavaScript, when converting from a float to a string, how can I get just 2 digits after the decimal point? For example, 0.34 instead of 0.3445434....

How To Create Table with Identity Column

I have an existing table that I am about to blow away because I did not create it with the ID column set to be the table's Identity column. Using SQL Server Management Studio, I scripted a "Create To..." of the existing table and got this: CREATE T...

JavaScript closures vs. anonymous functions

A friend of mine and I are currently discussing what is a closure in JS and what isn't. We just want to make sure we really understand it correctly. Let's take this example. We have a counting loop and want to print the counter variable on the conso...

Java: JSON -> Protobuf & back conversion

I have an existing system, which is using protobuf-based communication protocol between GUI and server. Now I would like to add some persistence, but at the moment protobuf messages are straight converted to a third-party custom objects. Is there a ...

How to downgrade to older version of Gradle

I have in my .gradle folder, a 2.4 folder which is the version of gradle. I want to downgrade to 2.2.1, because I need to use Gradle plugin 1.0.1. I already try to change by: distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all...

Pandas - 'Series' object has no attribute 'colNames' when using apply()

I need to use a lambda function to do a row by row computation. For example create some dataframe import pandas as pd import numpy as np def myfunc(x, y): return x + y colNames = ['A', 'B'] data = np.array([np.arange(10)]*2).T df = pd.DataFra...

Multiple controllers with AngularJS in single page app

I want to know is how to use multiple controllers for a single page application. I have tried to figure it out and I've found questions very similar to mine, but there is just a ton of different answers solving a specific problem where you end up not...

Installing Oracle Instant Client

I can't seem to figure out how to install the Oracle client on Windows Server 2008. I downloaded x64 version (the first file on the list) here. There are installation instructions on the bottom of that page: Step 2 ("instantclient") Which executa...

Disable future dates in jQuery UI Datepicker

Is it possible to disable future date from today? Let say today is 23/10/2010, so 24/10/2010 onwards are disabled. Sorry I am very new in jQuery and JavaScript....

How to save and extract session data in codeigniter

I save some data in session on my verify controller then I extract this session data into user_activity model and insert session data into activity table. My problem is only username data saved in session and I can get and insert only username data a...

How to convert a DataTable to a string in C#?

I'm using Visual Studio 2005 and have a DataTable with two columns and some rows that I want to output to the console. I hoped there would be something like: DataTable results = MyMethod.GetResults(); Console.WriteLine (results.ToString()); What's...

.net Core 2.0 - Package was restored using .NetFramework 4.6.1 instead of target framework .netCore 2.0. The package may not be fully compatible

I have a .net core 2.0 console app. I'm trying to read files from TFS using the following: How to get a file from TFS directly into memory (i.e., don't want to read from file system into memory)? I head over to nuget and install Microsoft.Tea...

What's the difference between xsd:include and xsd:import?

What's the difference between xsd:include and xsd:import? When would you use one instead of the other, and when might it not matter?...

How do I use WPF bindings with RelativeSource?

How do I use RelativeSource with WPF bindings and what are the different use-cases?...

Row numbers in query result using Microsoft Access

I always use this query in sql server to get Row number in a table: SELECT * FROM (SELECT *, Row_number() OVER( ORDER BY [myidentitycolumn]) RowID FROM mytable) sub WHERE rowid = 15 ...

What does --net=host option in Docker command really do?

I'm a little bit beginner to Docker. I couldn't find any clear description of what this option does in docker run command in deep and bit confused about it. Can we use it to access the applications running on docker containers without specifying a p...

How to send a simple email from a Windows batch file?

I'm running Windows 2003 Service Pack 2. I have a batch file that runs on demand. I want to have an email sent every time the batch file runs. The email is simple, just a sentence indicating that the batch file ran; it is the same every time. I've t...

Check image width and height before upload with Javascript

I have a JPS with a form in which a user can put an image: <div class="photo"> <div>Photo (max 240x240 and 100 kb):</div> <input type="file" name="photo" id="photoInput" onchange="checkPhoto(this)"/> </div> I ...

Android Calling JavaScript functions in WebView

I am trying to call some javascript functions sitting in an html page running inside an android webview. Pretty simple what the code tries to do below - from the android app, call a javascript function with a test message, which inturn calls a java ...

Java SecurityException: signer information does not match

I recompiled my classes as usual, and suddenly got the following error message. Why? How can I fix it? java.lang.SecurityException: class "Chinese_English_Dictionary"'s signer information does not match signer information of other classes in the sam...

SQL Query to fetch data from the last 30 days?

Hi I am new to Oracle. How do I do a simple statement, for example get product id from the last 30, or 20 days purchase date? SELECT productid FROM product WHERE purchase_date ? ...

How to append contents of multiple files into one file

I want to copy the contents of five files to one file as is. I tried doing it using cp for each file. But that overwrites the contents copied from the previous file. I also tried paste -d "\n" 1.txt 0.txt and it did not work. I want my script to...

continuous page numbering through section breaks

The page numbering in footer returns to 1 after every section break in my long document. I'm using Word 2013, odd and even page headers and footers. What am I missing?...

How to change current working directory using a batch file

I need some help in writing a batch file. I have a path stored in a variable root as follows: set root=D:\Work\Root Then I am changing my working directory to this root as follows: cd %root% When I execute this batch file from anywhere on the D...

How to $watch multiple variable change in angular

How to $scope.$watch multiple variables in Angular, and trigger callback when one of them has changed. $scope.name = ... $scope.age = ... $scope.$watch('???',function(){ //called when name or age changed }) ...

How to run test methods in specific order in JUnit4?

I want to execute test methods which are annotated by @Test in specific order. For example: public class MyTest { @Test public void test1(){} @Test public void test2(){} } I want to ensure to run test1() before test2() each time I run MyT...

Simplest SOAP example

What is the simplest SOAP example using Javascript? To be as useful as possible, the answer should: Be functional (in other words actually work) Send at least one parameter that can be set elsewhere in the code Process at least one result value th...

c# open file with default application and parameters

The most easy way to open a file with the default application is: System.Diagnostics.Process.Start(@"c:\myPDF.pdf"); However, I would like to know if exists a way to set parameters to the default application, because I would like to open a pdf in ...

Move SQL data from one table to another

I was wondering if it is possible to move all rows of data from one table to another, that match a certain query? For example, I need to move all table rows from Table1 to Table2 where their username = 'X' and password = 'X', so that they will no lo...

How can I issue a single command from the command line through sql plus?

Using SQL Plus, you can run a script with the "@" operator from the command line, as in: c:\>sqlplus username/password@databasename @"c:\my_script.sql" But is it possible to just run a single command with a similar syntax, without a whole separ...

Running a cron job at 2:30 AM everyday

How to configure a cron job to run every night at 2:30? I know how to make it run at 2, but not 2:30....

Uncaught SyntaxError: Unexpected token with JSON.parse

what causes this error on the third line? _x000D_ _x000D_ var products = [{_x000D_ "name": "Pizza",_x000D_ "price": "10",_x000D_ "quantity": "7"_x000D_ }, {_x000D_ "name": "Cerveja",_x000D_ "price": "12",_x000D_ "quantity": "5"_x000D_ },...

Drag and drop menuitems

I want to rearrange menuitems by drag and drop in my firefox addon like the bookmarks in the Bookmarks menu. Specifically, I want the blue insertion marker to appear while dragging a menuitem over valid places. Can someone show me how to do this or t...

Difference between numeric, float and decimal in SQL Server

What are the differences between numeric, float and decimal datatypes and which should be used in which situations? For any kind of financial transaction (e.g. for salary field), which one is preferred and why?...

How to apply a function to two columns of Pandas dataframe

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

Http Get using Android HttpURLConnection

I'm new to Java and Android development and try to create a simple app which should contact a web server and add some data to a database using a http get. When I do the call using the web browser in my computer it works just fine. However, when I do...

Can I set up HTML/Email Templates with ASP.NET?

I'm working on a site that will send out a significant number of emails. I want to set up both header and footer text, or maybe even templates to allow the users to easily edit these emails if they need to. If I embed the HTML inside C# string liter...

Get type name without full namespace

I have the following code: return "[Inserted new " + typeof(T).ToString() + "]"; But typeof(T).ToString() returns the full name including namespace Is there anyway to just get the class name (without any namespace qualifiers?)...

Error - Unable to access the IIS metabase

After installing Visual Studio 2012 and opening my solution I get a series of errors in this form: The Web Application Project Foo is configured to use IIS. Unable to access the IIS Metabase. You do not have sufficient privilege to access IIS w...

Print PHP Call Stack

I'm looking for a way to print the call stack in PHP. Bonus points if the function flushes the IO buffer....

How to open a website when a Button is clicked in Android application?

I am designing an app, with several button for users to click on. Once button is clicked, user is directed to appropriate website. How do I accomplish this?...

Why do I get "a label can only be part of a statement and a declaration is not a statement" if I have a variable that is initialized after a label?

I have the following simplified code: #include <stdio.h> int main () { printf("Hello "); goto Cleanup; Cleanup: char *str = "World\n"; printf("%s\n", str); } I get an error because a new variable is declared after the label....

issue ORA-00001: unique constraint violated coming in INSERT/UPDATE

I am trying to insert some values in table throught the application and get issue ORA-00001: unique constraint violated. I see that sequences are out of sync with the highest id of the table, but even after fixing the sequence number the error still ...

"Adaptive Server is unavailable or does not exist" error connecting to SQL Server from PHP

I'm attempting to connect to a SQL Server 2005 DB from my Mac using unixODBC and FreeTDS as I have outlined here. However, when I try to connect in to a different DB using the same setup, I get: Connection Failed:[FreeTDS][SQL Server]Unable to conne...

Recursive directory listing in DOS

How do we achieve a recursive directory listing in DOS? I'm looking for a command or a script in DOS which can give me the recursive directory listing similar to ls -R command in Unix....

Why is Java Vector (and Stack) class considered obsolete or deprecated?

Why is Java Vector considered a legacy class, obsolete or deprecated? Isn't its use valid when working with concurrency? And if I don't want to manually synchronize objects and just want to use a thread-safe collection without needing to make fresh...

jQuery Ajax File Upload

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

PHP How to fix Notice: Undefined variable:

code: Function ShowDataPatient($idURL) { $query =" select * from cmu_list_insurance,cmu_home,cmu_patient where cmu_home.home_id = (select home_id from cmu_patient where patient_hn like '%$idURL%') AND cmu_patient.patient_hn ...

Replace \n with actual new line in Sublime Text

How can I replace \n in Sublime Text with real in-editor displayed new line so: foo\nbar becomes: foo bar in the editor when I view the file in it....

How to do a deep comparison between 2 objects with lodash?

I have 2 nested objects which are different and I need to know if they have difference in one of their nested properties. var a = {}; var b = {}; a.prop1 = 2; a.prop2 = { prop3: 2 }; b.prop1 = 2; b.prop2 = { prop3: 3 }; The object could be much ...

Can I change the height of an image in CSS :before/:after pseudo-elements?

Suppose I want to decorate links to certain file types using an image. I could declare my links as <a href='foo.pdf' class='pdflink'>A File!</a> then have CSS like .pdflink:after { content: url('/images/pdf.png') } Now, this works ...

Detecting negative numbers

I was wondering if there is any way to detect if a number is negative in PHP? I have the following code: $profitloss = $result->date_sold_price - $result->date_bought_price; I need to find out if $profitloss is negative and if it is, I need...

How to increase heap size of an android application?

I am writing an Android application which uses several 3D models. Such a model with textures can take up a lot of memory. I found out the manufacturer sets a limit on the heap size an application can use. For example my tablet Samsung Galaxy Tab 8.9 ...

How to scale a BufferedImage

Following the javadocs, I have tried to scale a BufferedImage without success here is my code: BufferedImage image = MatrixToImageWriter.getBufferedImage(encoded); Graphics2D grph = image.createGraphics(); grph.scale(2.0, 2.0); grph.dispose(); I c...

git replace local version with remote version

How can I tell git to ignore my local file and take the one from my remote branch without trying to merge and causing conflicts?...

How to insert close button in popover for Bootstrap

JS: $(function(){ $("#example").popover({ placement: 'bottom', html: 'true', title : '<span class="text-info"><strong>title</strong></span> <button type="button" id="close" class="close">&times;</b...

How do I retrieve query parameters in Spring Boot?

I am developing a project using Spring Boot. I've a controller which accepts GET requests. Currently I'm accepting requests to the following kind of URLs: http://localhost:8888/user/data/002 but I want to accept requests using query parameters...

Inheritance and Overriding __init__ in python

I was reading 'Dive Into Python' and in the chapter on classes it gives this example: class FileInfo(UserDict): "store file metadata" def __init__(self, filename=None): UserDict.__init__(self) self["name"] = filename The au...

What does T&& (double ampersand) mean in C++11?

I've been looking into some of the new features of C++11 and one I've noticed is the double ampersand in declaring variables, like T&& var. For a start, what is this beast called? I wish Google would allow us to search for punctuation like t...

How to print exact sql query in zend framework ?

I have the following piece of code which i taken from model, ... $select = $this->_db->select() ->from($this->_name) ->where('shipping=?',$type) ->wh...

Push eclipse project to GitHub with EGit

I am successfully pushing my project to GitHub using EGit. My repository is called HelloWorld. My project in eclipse is also called HelloWorld. My problem is when i push the project it is upload the project under the folder HelloWorld. So the result ...

How to set a primary key in MongoDB?

I want to set one of my fields as primary key. I am using MongoDB as my NoSQL....

In Android EditText, how to force writing uppercase?

In my Android application I have different EditText where the user can enter information. But I need to force user to write in uppercase letters. Do you know a function to do that?...

Does svn have a `revert-all` command?

If I want to throw away all of my changes, and return to the code that is on the repository, I do the following: $ rm -fr * $ svn up This is easy enough, but I'm wondering if there is a single command that will accomplish this, something like: $ ...

ToggleButton in C# WinForms

Is it possible to create a toggle button in C# WinForms? I know that you can use a CheckBox control and set it's Appearance property to "Button", but it doesn't look right. I want it to appear sunken, not flat, when pressed. Any thoughts?...

Is there a simple way to convert C++ enum to string?

Suppose we have some named enums: enum MyEnum { FOO, BAR = 0x50 }; What I googled for is a script (any language) that scans all the headers in my project and generates a header with one function per enum. char* enum_to_string(MyEnum t...

Convert a space delimited string to list

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

Can I pass variable to select statement as column name in SQL Server

Possible Duplicate: SQL: Select dynamic column name based on variable I have the following simple select statement: DECLARE @value varchar(10) SET @value = 'intStep' SELECT @value FROM dbo.tblBatchDetail I have tried SELECT CA...

How to get the month name in C#?

How does one go about finding the month name in C#? I don't want to write a huge switch statement or if statement on the month int. In VB.Net you can use MonthName(), but what about C#?...

The intel x86 emulator accelerator (HAXM installer) revision 6.0.5 is showing not compatible with windows

This a screenshot of the sdk manager message showing the emulator as incompatible with windows: I am using android studio, currently version 2.2.3. Is there an other or older version of the emulator accelerator (HAXM installer) that is compatible ...

What is property in hasOwnProperty in JavaScript?

Consider: if (someVar.hasOwnProperty('someProperty') ) { // Do something(); } else { // Do somethingElse(); } What is the right use/explanation of hasOwnProperty('someProperty')? Why can't we simply use someVar.someProperty to check if an object s...

hardcoded string "row three", should use @string resource

I'm a beginner android developer , I was trying to run this Linear Layout in eclipse : <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" ...

What to do on TransactionTooLargeException

I got a TransactionTooLargeException. Not reproducible. In the docs it says The Binder transaction failed because it was too large. During a remote procedure call, the arguments and the return value of the call are transferred as Parcel objects stor...

Performing Inserts and Updates with Dapper

I am interested in using Dapper - but from what I can tell it only supports Query and Execute. I do not see that Dapper includes a way of Inserting and Updating objects. Given that our project (most projects?) need to do inserts and updates, what i...

Insert some string into given string at given index in Python

I am newbie in Python facing a problem: How to insert some fields in already existing string? For example, suppose I have read one line from any file which contains: line = "Name Age Group Class Profession" Now I have to insert 3rd Field(Group) 3...

Slick Carousel Uncaught TypeError: $(...).slick is not a function

Somehow I'm unable to use slick carousel (http://kenwheeler.github.io/slick/) correctly. I'm getting the following error: Uncaught TypeError: $(...).slick is not a function I'm running the following code in my javascript file: function initSli...

Bring a window to the front in WPF

How can I bring my WPF application to the front of the desktop? So far I've tried: SwitchToThisWindow(new WindowInteropHelper(Application.Current.MainWindow).Handle, true); SetWindowPos(new WindowInteropHelper(Application.Current.MainWindow).Handle...

Setting up MySQL and importing dump within Dockerfile

I'm trying to setup a Dockerfile for my LAMP project, but i'm having a few problems when starting MySQL. I have the folowing lines on my Dockerfile: VOLUME ["/etc/mysql", "/var/lib/mysql"] ADD dump.sql /tmp/dump.sql RUN /usr/bin/mysqld_safe & sl...

Postman: How to make multiple requests at the same time

I want to POST data from Postman Google Chrome extension. I want to make 10 requests with different data and it should be at the same time. Is it possible to do such in Postman? If yes, can anyone explain to me how can this be achieved?...

How do I get list of methods in a Python class?

I want to iterate through the methods in a class, or handle class or instance objects differently based on the methods present. How do I get a list of class methods? Also see: How can I list the methods in a Python 2.5 module? Looping over a Pyth...

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

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

Playing m3u8 Files with HTML Video Tag

I am trying to use HTTP Live Streaming (HLS) to stream video to my computers and my iPhone. After reading through the Apple 'HTTP Live Streaming Overview' as well as 'Best Practices for Creating and Deploying HTTP Live Streaming Media for the iPhone...

How do I change the string representation of a Python class?

In Java, I can override the toString() method of my class. Then Java's print function prints the string representation of the object defined by its toString(). Is there a Python equivalent to Java's toString()? For example, I have a PlayCard class. ...

How do I drop a MongoDB database from the command line?

What's the easiest way to do this from my bash prompt?...

Android Studio rendering problems

I'm using Android Studio 0.2.3 and when opened an activity layout normally, the preview should appear on the right side, so that I can switch between Text and Design mode, which should again show the preview of the layout. But no preview is shown n...

Vim clear last search highlighting

After doing a search in Vim, I get all the occurrences highlighted. How can I disable that? I now do another search for something gibberish that can't be found. Is there a way to just temporarily disable the highlight and then re-enable it when nee...

python-pandas and databases like mysql

The documentation for Pandas has numerous examples of best practices for working with data stored in various formats. However, I am unable to find any good examples for working with databases like MySQL for example. Can anyone point me to links or ...

How to connect to remote Redis server?

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

What is the string length of a GUID?

I want to create a varchar column in SQL that should contain N'guid' while guid is a generated GUID by .NET (Guid.NewGuid) - class System.Guid. What is the length of the varchar I should expect from a GUID? Is it a static length? Should I use nvarc...

Can a local variable's memory be accessed outside its scope?

I have the following code. #include <iostream> int * foo() { int a = 5; return &a; } int main() { int* p = foo(); std::cout << *p; *p = 8; std::cout << *p; } And the code is just running with no runt...

Library not loaded: libmysqlclient.16.dylib error when trying to run 'rails server' on OS X 10.6 with mysql2 gem

I've been struggling with this for some time. I've installed Rails 3, gem, mysql on my Snow Leopard machine. All was going well until I created my first project and tried to run rails server Upon running this I get: jontybrook$ rails server /Li...

Programmatically get height of navigation bar

I know that the presence of the more view controller (navigation bar) pushes down the UIView by its height. I also know that this height = 44px. I have also discovered that this push down maintains the [self.view].frame.origin.y = 0. So how do I d...

Play a Sound with Python

What's the easiest way to play a sound file (.wav) in Python? By easiest I mean both most platform independent and requiring the least dependencies. pygame is certainly an option, but it seems overkill for just sound....

Combining two sorted lists in Python

I have two lists of objects. Each list is already sorted by a property of the object that is of the datetime type. I would like to combine the two lists into one sorted list. Is the best way just to do a sort or is there a smarter way to do this in P...

Properties order in Margin

If I have such string in XAML: Storyboard.TargetProperty="Margin" From="1,2,3,4" To="0,0,0,0" What is Top Bottom Right and Left? 1- right 2- top 3- left 4 - bottom Is that right?...

Initialize a long in Java

Primitive Data Types - oracle doc says the range of long in Java is -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. But when I do something like this in my eclipse long i = 12345678910; it shows me "The literal 12345678910 of type int is ...

Turning multi-line string into single comma-separated

Let's say I have the following string: something1: +12.0 (some unnecessary trailing data (this must go)) something2: +15.5 (some more unnecessary trailing data) something4: +9.0 (some other unnecessary data) something1: +13.5 (bla...

Simple regular expression for a decimal with a precision of 2

What is the regular expression for a decimal with a precision of 2? Valid examples: 123.12 2 56754 92929292929292.12 0.21 3.1 Invalid examples: 12.1232 2.23332 e666.76 The decimal point may be optional, and integers may also be included....

How can I align all elements to the left in JPanel?

I would like to have all elements in my JPanel to be aligned to the left. I try to do it in the following way: JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.setAlignmentX(Component.LEFT_ALIGNMENT); As ...

Make a dictionary with duplicate keys in Python

I have the following list which contains duplicate car registration numbers with different values. I want to convert it into a dictionary which accepts this multiple keys of car registration numbers. So far when I try to convert list to dictionary i...

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

All inclusive Charset to avoid "java.nio.charset.MalformedInputException: Input length = 1"?

I'm creating a simple wordcount program in Java that reads through a directory's text-based files. However, I keep on getting the error: java.nio.charset.MalformedInputException: Input length = 1 from this line of code: BufferedReader reader = F...

How to Convert Excel Numeric Cell Value into Words

I am working with Microsoft Excel 2007 and I have one Numeric Column in my Sheet. Is there any solution that I can convert it's Words equivalent? I am attaching Excel Sheet's Screen Shot. ...

How to fix: fatal error: openssl/opensslv.h: No such file or directory in RedHat 7

I have RedHat Enterprise Linux Server 7, and I downloaded the linux kernel version 4.12.10 which I am trying to compile but when I execute the following command: make modules I get the following error: scripts/sign-file.c:25:30: fatal error: ope...

Android getResources().getDrawable() deprecated API 22

With new android API 22 getResources().getDrawable() is now deprecated. Now the best approach is to use only getDrawable(). What changed? ...

IntelliJ cannot find any declarations

I completely uninstalled IntelliJ and have now reinstalled and imported my project. I imported using gradle and can see all of the files in my project present. However, when I open a file I can't find any declaration to go to by doing cmd + click. I ...

Math functions in AngularJS bindings

Is there a way to use math functions in AngularJS bindings? e.g. <p>The percentage is {{Math.round(100*count/total)}}%</p> This fiddle shows the problem http://jsfiddle.net/ricick/jtA99/1/...

How to clear memory to prevent "out of memory error" in excel vba?

I am running VBA code on a large spreadsheet. How do I clear the memory between procedures/calls to prevent an "out of memory" issue occurring? Thanks...

React Checkbox not sending onChange

TLDR: Use defaultChecked instead of checked, working jsbin. Trying to setup a simple checkbox that will cross out its label text when it is checked. For some reason handleChange is not getting fired when I use the component. Can anyone explain wha...

SOAP or REST for Web Services?

Is REST a better approach to doing Web Services or is SOAP? Or are they different tools for different problems? Or is it a nuanced issue - that is, is one slightly better in certain arenas than another, etc? I would especially appreciate informat...