Examples On Programing Languages

How to create named and latest tag in Docker?

Supposed I have an image that I want to tag as 0.10.24 (in my case it's an image containing Node.js 0.10.24). I built that image using a Dockerfile and executing docker build and by providing a tag using the -t parameter. I expect that one day I wil...

Create an Excel file using vbscripts

How do I create an excel file using VBScript? I searched the net but it just mentions opening an existing file. This is the extraction from the Internet shown below Set objExcel = CreateObject("Excel.Application") Set objWorkbook = objExcel.Workboo...

How to set .net Framework 4.5 version in IIS 7 application pool

I installed the Visual Studio 11 Beta and suddenly all the async action methods I had created under the VS 11 Developer preview started hanging (apparently this issue: http://blogs.msdn.com/b/pfxteam/archive/2012/03/03/10277166.aspx). My app is usin...

Inline onclick JavaScript variable

I have a JavaScript above this html is there any way to pass it inside EditBanner(JS Variable Here) in code below ? //EditBanner to be changed to pass a Js variable. <input id="EditBanner" type="button" value="Edit Image" onclick="EditBanner();"/...

How to browse localhost on Android device?

I try to browse localhost on my HTC Magic. I have connected my device with Eclipse via USB. When browsing http://10.0.2.2 I get "Page not available". I remember, some days ago it worked. But on the emulator I am able to browse localhost Any ideas?...

What is the "assert" function?

I've been studying OpenCV tutorials and came across the assert function; what does it do?...

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

How to manipulate arrays. Find the average. Beginner Java

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

Changing the child element's CSS when the parent is hovered

First of all, I'm assuming this is too complex for CSS3, but if there's a solution in there somewhere, I'd love to go with that instead. The HTML is pretty straightforward. <div class="parent"> <div class="child"> Text Block...

Want to make Font Awesome icons clickable

So I am new to web development and I am trying to link font awesome icons to my social profiles but am unsure of how to do that. I tried using an a href tag but it made all of the icons take me to one site instead of the one I wanted. Here is the cod...

Mockito: Trying to spy on method is calling the original method

I'm using Mockito 1.9.0. I want mock the behaviour for a single method of a class in a JUnit test, so I have final MyClass myClassSpy = Mockito.spy(myInstance); Mockito.when(myClassSpy.method1()).thenReturn(myResults); The problem is, in the seco...

target="_blank" vs. target="_new"

What's the difference between <a target="_new"> and <a target="_blank"> and which should I use if I just want to open a link in a new tab/window?...

Factorial using Recursion in Java

I am learning Java using the book Java: The Complete Reference. Currently I am working on the topic Recursion. Please Note: There are similar questions on stackoverflow. I searched them but I didn't find the solution to my question. I am confused wi...

How to connect access database in c#

I have access database file with 7 tables in it but I don't know how to connect and show all tables, If some one can help me? this is my code but it doesn't show anything private void button1_Click(object sender, EventArgs e) { OleDbConnection...

c# datagridview doubleclick on row with FullRowSelect

I have a datagridview in my C# application and the user should only be able to click on full rows. So I set the SelectionMode to FullRowSelect. But now I want to have an Event which is fired when the user double clicks on a row. I want to have the r...

Dump all documents of Elasticsearch

Is there any way to create a dump file that contains all the data of an index among with its settings and mappings? A Similar way as mongoDB does with mongodump or as in Solr its data folder is copied to a backup location. Cheers!...

Spring data JPA query with parameter properties

What is the simplest way of declaring a Spring data JPA query that uses properties of an input parameter as query parameters? For example, suppose I have an entity class: public class Person { @Id private long id; @Column private S...

SQL injection that gets around mysql_real_escape_string()

Is there an SQL injection possibility even when using mysql_real_escape_string() function? Consider this sample situation. SQL is constructed in PHP like this: $login = mysql_real_escape_string(GetFromPost('login')); $password = mysql_real_escape_s...

Executing "SELECT ... WHERE ... IN ..." using MySQLdb

I'm having a problem executing some SQL from within Python, despite similar SQL working fine from the mysql command-line. The table looks like this: mysql> SELECT * FROM foo; +-------+-----+ | fooid | bar | +-------+-----+ | 1 | A | | ...

Extract a subset of a dataframe based on a condition involving a field

I have a large CSV with the results of a medical survey from different locations (the location is a factor present in the data). As some analyses are specific to a location and for convenience, I'd like to extract subframes with the rows only from th...

What is wrong with this code that uses the mysql extension to fetch data from a database in PHP?

I want to fetch data from a mysql table using php. Please, can anyone tell me what is wrong with this code? What is the correct code to fetch data from a mysql database: <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; ...

restart mysql server on windows 7

How do I restart MySQL on Windows 7? I'm using HeidiSql as a front end and there's no option in there. The only other things I have is the MySQL 5.5 command line client....

How can I remove an entry in global configuration with git config?

I ran a global configuration command in git to exclude certain files using a .gitignore_global file: git config --global core.excludesfile ~/.gitignore_global Is there a way to undo the creation of this setting globally?...

Passing a varchar full of comma delimited values to a SQL Server IN function

Duplicate of Dynamic SQL Comma Delimited Value Query Parameterized Queries with Like and In I have a SQL Server Stored Procedure where I would like to pass a varchar full of comma delimited values to an IN function. For example: DECLARE @I...

Fatal error: Call to undefined function mb_strlen()

I'm trying to make a donation center which I use the source code from Totorialzine. Everything works fine for me at this moment so far but the only problem I was struggling on and trying to look at for the whole day and can't figure what is actually...

How to parse JSON Array (Not Json Object) in Android

I have a trouble finding a way how to parse JSONArray. It looks like this: [{"name":"name1","url":"url1"},{"name":"name2","url":"url2"},...] I know how to parse it if the JSON was written differently (In other words, if I had json object returned...

Python xticks in subplots

If I plot a single imshow plot I can use fig, ax = plt.subplots() ax.imshow(data) plt.xticks( [4, 14, 24], [5, 15, 25] ) to replace my xtick labels. Now, I am plotting 12 imshow plots using f, axarr = plt.subplots(4, 3) axarr[i, j].imshow(data...

How to get the range of occupied cells in excel sheet

I use C# to automate an excel file. I was able to get the workbook and the sheets it contains. If for example I have in sheet1 two cols and 5 rows. I wanted o get the range for the occupied cells as A1:B5. I tried the following code but it did not gi...

Github: error cloning my private repository

I'm trying to clone my GitHub project using the https-URL, but it fails with an error: $ git clone https://[email protected]/foo/foo-private.git Cloning into foo-private... Password: error: error setting certificate verify locations: CAfile: /bin/cur...

Warning - Build path specifies execution environment J2SE-1.4

I create a Maven project in Eclipse Helios. It works fine for a day, but then this warning shows up: Build path specifies execution environment J2SE-1.4. There are no JREs installed in the workspace that are strictly compatible with this environm...

How to check whether a string contains a substring in Ruby

I have a string variable with content: varMessage = "hi/thsid/sdfhsjdf/dfjsd/sdjfsdn\n" "/my/name/is/balaji.so\n" "call::myFunction(int const&)\n" "void::secondFunction(char const&)\n" ...

Loop code for each file in a directory

I have a directory of pictures that I want to loop through and do some file calculations on. It might just be lack of sleep, but how would I use PHP to look in a given directory, and loop through each file using some sort of for loop? Thanks!...

How do I add a bullet symbol in TextView?

I have a TextView and I want to add a bullet symbol in my text through XML. Is it possible?...

Xcode is not currently available from the Software Update server

I have problems with my macport after update to OS X 10.9. I try to follow this manual https://trac.macports.org/wiki/Migration to fix them. But when I install Command Line Tools: xcode-select --install I get message Can't install the s...

How do check if a parameter is empty or null in Sql Server stored procedure in IF statement?

I read this: How do I check if a Sql server string is null or empty but it not helped me in this situation. The piece of code from my stored procedure: IF (@item1 IS NOT NULL) OR (LEN(@item1) > 0) SELECT @sql = 'SELECT * FROM TEST1' ...

Setting PayPal return URL and making it auto return?

This is a follow up question to: PHP: Easy way to start PayPal checkout? So, my problem is that I am specifying the return url. However, after paying with PayPal, I end up at a a screen that says: You just completed your payment. XXXX, you just ...

How do I tokenize a string sentence in NLTK?

I am using nltk, so I want to create my own custom texts just like the default ones on nltk.books. However, I've just got up to the method like my_text = ['This', 'is', 'my', 'text'] I'd like to discover any way to input my "text" as: my_text = "...

ls command: how can I get a recursive full-path listing, one line per file?

How can I get ls to spit out a flat list of recursive one-per-line paths? For example, I just want a flat listing of files with their full paths: /home/dreftymac/. /home/dreftymac/foo.txt /home/dreftymac/bar.txt /home/dreftymac/stackoverflow /home/...

How to use data-binding with Fragment

I'm trying to follow data-binding example from official google doc https://developer.android.com/tools/data-binding/guide.html except that I'm trying to apply data-biding to a fragment, not an activity. the error I'm currently getting when compilin...

Least common multiple for 3 or more numbers

How do you calculate the least common multiple of multiple numbers? So far I've only been able to calculate it between two numbers. But have no idea how to expand it to calculate 3 or more numbers. So far this is how I did it LCM = num1 * num2 /...

What does the error "arguments imply differing number of rows: x, y" mean?

I'm trying to create a plot from elements of csv file which looks like this: h1,h2,h3,h4 a,1,0,1,0 b,1,1,0,1 c,0,0,1,0 I tried the following code but am receiving an error saying Error in data.frame(id = varieties, attr(mat, "row.names"),...

Using Mockito to test abstract classes

I'd like to test an abstract class. Sure, I can manually write a mock that inherits from the class. Can I do this using a mocking framework (I'm using Mockito) instead of hand-crafting my mock? How?...

scrollIntoView Scrolls just too far

I have a page where a scroll bar containing table rows with divs in them is dynamically generated from the database. Each table row acts like a link, sort of like you'd see on a YouTube playlist next to the video player. When a user visits the page,...

Difference between Node object and Element object?

I am totally confused between Node object and Element object. document.getElementById() returns Element object while document.getElementsByClassName() returns NodeList object(Collection of Elements or Nodes?) If a div is an Element Object then what ...

How do I update Homebrew?

When I ran: brew update I got a message saying it initialized an empty repository in /usr/local/.git/, then I got this error: ...

How to use goto statement correctly

I am taking my high school AP Computer Science class. I decided to throw a goto statement into a one of our labs just to play around, but I got this error. Exception in thread "main" java.lang.Error: Unresolved compilation problems: Syntax e...

Make hibernate ignore class variables that are not mapped

I thought hibernate takes into consideration only class variables that are annotated with @Column. But strangely today when I added a variable (that is not mapped to any column, just a variable i need in the class), it is trying to include that vari...

shared global variables in C

How can I create global variables that are shared in C? If I put it in a header file, then the linker complains that the variables are already defined. Is the only way to declare the variable in one of my C files and to manually put in externs at the...

TypeError: 'dict' object is not callable

I'm trying to loop over elements of an input string, and get them from a dictionary. What am I doing wrong? number_map = { 1: -3, 2: -2, 3: -1, 4: 1, 5: 2, 6: 3 } input_str = raw_input("Enter something: ") strikes = [number_map(int(x)) for x in inpu...

Python can't find module in the same folder

My python somehow can't find any modules in the same directory. What am I doing wrong? (python2.7) So I have one directory '2014_07_13_test', with two files in it: test.py hello.py where hello.py: # !/usr/local/bin/python # -*- coding: utf-8 -...

Howto: Clean a mysql InnoDB storage engine?

Is it possible to clean a mysql innodb storage engine so it is not storing data from deleted tables? Or do I have to rebuild a fresh database every time?...

Calculate distance in meters when you know longitude and latitude in java

Possible Duplicate: Working with latitude/longitude values in Java Duplicate: Working with latitude/longitude values in Java How do I calculate distance between two latitude longitude points? I need to calculate the distance between two points g...

How do I get the current date in Cocoa

I'm getting started developing for the iPhone and as such I am looking at different tutorials online as well as trying some different things out myself. Currently, I'm trying to create a countdown until midnight. To get the number of hour, minutes, a...

Integrating Dropzone.js into existing HTML form with other fields

I currently have a HTML form which users fill in details of an advert they wish to post. I now want to be able to add a dropzone for uploading images of the item for sale. I have found Dropzone.js which seems to do most of what I need. However, when...

Oracle: what is the situation to use RAISE_APPLICATION_ERROR?

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

How to read a file and write into a text file?

I want to open mis file, copy all the data and write into a text file. My mis file. File name – 1.mis M3;3395;44;0;1;;20090404;094144;8193;3;0;;;; M3;3397;155;0;2;;20090404;105941;8193;3;0;;;; M3;3396;160;0;1;;20090404;100825;8193;3;0;;;; M3;339...

HTTP response code for POST when resource already exists

I'm building a server that allows clients to store objects. Those objects are fully constructed at client side, complete with object IDs that are permanent for the whole lifetime of the object. I have defined the API so that clients can create or m...

Does Python have a toString() equivalent, and can I convert a db.Model element to String?

I'm writing a ToDo list app to help myself get started with Python. The app is running on GAE and I'm storing todo items in the Data Store. I want to display everyone's items to them, and them alone. The problem is that the app currently displays all...

How to specify an element after which to wrap in css flexbox?

I don't think this is part of the flexbox standard yet, but is there maybe a trick to suggest or force wrapping after a certain element? I'd like to respond to different page sizes and wrap a list differently without extra markup, so that rather than...

How to get the path of the batch script in Windows?

I know that %0 contains the full path of the batch script, e.g. c:\path\to\my\file\abc.bat I would path to be equal to c:\path\to\my\file How could I achieve that ?...

Scroll to element on click in Angular 4

I want to be able to scroll to a target when a button is pressed. I was thinking something like this. <button (click)="scroll(#target)">Button</button> And in my component.ts a method like. scroll(element) { window.scrollTo...

Checking session if empty or not

I want to check that session is null or empty i.e. some thing like this: if(Session["emp_num"] != null) { if (!string.IsNullOrEmpty(Session["emp_num"].ToString())) { //The code } } Or just if(Session...

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

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

How to test if a string is JSON or not?

I have a simple AJAX call, and the server will return either a JSON string with useful data or an error message string produced by the PHP function mysql_error(). How can I test whether this data is a JSON string or the error message. It would be...

NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle

In my AppDelegate there is a problem I do not understand. RootViewController initially called ViewController and I changed it name. The application is formed by many ViewController then I have introduced a UINavigationController. Why this error comes...

Get div's offsetTop positions in React

I am trying to implement a List view in React. What I am trying to achieve is that to store the list headers informations and register the components and register the scroll event. every time when user scroll the window, I'd like to take out the sto...

javascript variable reference/alias

Is it possible in javascript to assign an alias/reference to a local var someway? I mean something C-like: function foo() { var x = 1; var y = &x; y++; alert(x); // prints 2 } = EDIT = Is it possible to alias arguments.callee in thi...

Regular expression for not allowing spaces in the input field

I have a username field in my form. I want to not allow spaces anywhere in the string. I have used this regex: var regexp = /^\S/; This works for me if there are spaces between the characters. That is if username is ABC DEF. It doesn't work if a s...

C# Convert string from UTF-8 to ISO-8859-1 (Latin1) H

I have googled on this topic and I have looked at every answer, but I still don't get it. Basically I need to convert UTF-8 string to ISO-8859-1 and I do it using following code: Encoding iso = Encoding.GetEncoding("ISO-8859-1"); Encoding utf8 = En...

How to fix Error: laravel.log could not be opened?

I'm pretty new at laravel, in fact and I'm trying to create my very first project. for some reason I keep getting this error (I haven't even started coding yet) Error in exception handler: The stream or file "/var/www/laravel/app/storage/logs/larave...

Equivalent of Oracle's RowID in SQL Server

What's the equivalent of Oracle's RowID in SQL Server?...

What's the best three-way merge tool?

Subversion, Git, Mercurial and others support three-way merges (combining mine, theirs, and the "base" revision) and support graphical tools to resolve conflicts. What tool do you use? Windows, Mac OS X, Linux, free or commercial, you name...

Best practice for using assert?

Is there a performance or code maintenance issue with using assert as part of the standard code instead of using it just for debugging purposes? Is assert x >= 0, 'x is less than zero' better or worse than if x < 0: raise Exception, ...

VBA (Excel) Initialize Entire Array without Looping

I am fairly new to VBA, so this may be a simple question but here goes. I would like to initialize an entire array myArray, say of integers, in VBA. I know that I can do this by a simple initialization like so: Dim myArray myArray = Array(1, 2, 4, ...

What are the benefits of using C# vs F# or F# vs C#?

I work for a tech company that does more prototyping than product shipment. I just got asked what's the difference between C# and F#, why did MS create F# and what scenarios would it be better than C#. I've been using the language for a while now a...

Case Statement Equivalent in R

I have a variable in a dataframe where one of the fields typically has 7-8 values. I want to collpase them 3 or 4 new categories within a new variable within the dataframe. What is the best approach? I would use a CASE statement if I were in a SQ...

How do I pass a string into subprocess.Popen (using the stdin argument)?

If I do the following: import subprocess from cStringIO import StringIO subprocess.Popen(['grep','f'],stdout=subprocess.PIPE,stdin=StringIO('one\ntwo\nthree\nfour\nfive\nsix\n')).communicate()[0] I get: Traceback (most recent call last): File "...

How to alter a column's data type in a PostgreSQL table?

Entering the following command into a PostgreSQL interactive terminal results in an error: ALTER TABLE tbl_name ALTER COLUMN col_name varchar (11); What is the correct command to alter the data type of a column?...

How to access full source of old commit in BitBucket?

I can't figure out or find the documentation on how to access the source of an old commit in the new Bit Bucket format. Is this even possible anymore?...

Disable vertical sync for glxgears

Sometimes you need to check whether you Linux 3D acceleration is really working (besides the glxinfo output). This can be quickly done by the glxgears tool. However, the FPS are often limited to the displays vertical refresh rate (i.e. 60 fps). So th...

How to solve “Microsoft Visual Studio (VS)” error “Unable to connect to the configured development Web server”

PROBLEM If you start using "Microsoft Internet Information Services Express (IIS)" from "Microsoft Visual Studio (VS)" you may get when you run Build this error message Unable to connect to the configured development Web server. Failed to registe...

How to automatically generate getters and setters in Android Studio

Is there a shortcut in Android Studio for automatically generating the getters and setters in a given class?...

How to tell if browser/tab is active

Possible Duplicate: Is there a way to detect if a browser window is not currently active? I have a function that is called every second that I only want to run if the current page is in the foreground, i.e. the user hasn't minimized the br...

Active Menu Highlight CSS

I want to highlight the current menu you have click. I'm using CSS, but it is now working. here is my css code: #sub-header ul li:hover{ background-color: #000;} #sub-header ul li:hover a{ color: #fff; } #sub-header ul li.active{ background-color: ...

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

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

Using Predicate in Swift

I'm working through the tutorial here (learning Swift) for my first app: http://www.appcoda.com/search-bar-tutorial-ios7/ I'm stuck on this part (Objective-C code): - (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope { ...

Use success() or complete() in AJAX call

I want to understand the AJAX call below, in terms of the complete() method; When I replace complete() with success(), I get an empty responseText just as with the AJAX error() method. On the other hand, when I leave the complete() method there as...

How can I share Jupyter notebooks with non-programmers?

I am trying to wrap my head around what I can/cannot do with Jupyter. I have a Jupyter server running on our internal server, accessible via VPN and password protected. I am the only one actually creating notebooks but I would like to make some no...

Add bottom line to view in SwiftUI / Swift / Objective-C / Xamarin

I would like to keep the border at the bottom part only in UITextField. But I don't know how we can keep it on the bottom side. Can you please advise me?...

How can I use a batch file to write to a text file?

I need to make a script that can write one line of text to a text file in the same directory as the batch file....

jquery change div text

'<div id="'+div_id+'" class="widget" style="height:60px;width:110px">\n\ <div class="widget-head ui-widget-header" style="cursor:move;height:20px;width:130px">'+ '<span id="'+span_id+'" style="float:right; cursor:p...

spark submit add multiple jars in classpath

I am trying to run a spark program where i have multiple jar files, if I had only one jar I am not able run. I want to add both the jar files which are in same location. I have tried the below but it shows a dependency error spark-submit \ --class...

Managing jQuery plugin dependency in webpack

I'm using Webpack in my application, in which I create two entry points - bundle.js for all my JavaScript files/codes, and vendors.js for all libraries like jQuery and React. What do I do in order to use plugins which have jQuery as their dependencie...

How can I read user input from the console?

I want to get a number from the user, and then multiply that number with Pi. my attempt at this is below. But a contains gibberish. For example, if I insert 22, then a contains 50. What am I doing wrong? I don't get any compiler errors. double a,b; ...

process.waitFor() never returns

Process process = Runtime.getRuntime().exec("tasklist"); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); process.waitFor(); ...

How to draw circle by canvas in Android?

I want to draw circle by canvas. Here is my code: [MyActivity.java]: public class MyActivity extends Activity { public void onCreate(Bundle savedInstanceState) { ... setContentView(new View(this,w,h)); } } [View.java]: ...

Proxy setting for R

I am facing problem while conecting R with internet in my office. May be this due to LAN settings. I tried the almost all possible ways I come across in the web (see below) but still in vain. Method1: Invoking R using --internet2 Method2: Invoking...

Opening a folder in explorer and selecting a file

I'm trying to open a folder in explorer with a file selected. The following code produces a file not found exception: System.Diagnostics.Process.Start( "explorer.exe /select," + listView1.SelectedItems[0].SubItems[1].Text + "\\" + li...

Could not find default endpoint element

I've added a proxy to a webservice to a VS2008/.NET 3.5 solution. When constructing the client .NET throws this error: Could not find default endpoint element that references contract 'IMySOAPWebService' in the ServiceModel client configuration s...

Where does MySQL store database files on Windows and what are the names of the files?

So I accidentally formatted my hard drive and re-installed Windows and forgot to backup an important database I had in my MySQL server. I'm trying to salvage files now using some software, but I don't know what to look for. What is the path that the...

What is "X-Content-Type-Options=nosniff"?

I am doing some penetration testing on my localhost with OWASP ZAP, and it keeps reporting this message: The Anti-MIME-Sniffing header X-Content-Type-Options was not set to 'nosniff' This check is specific to Internet Explorer 8 and Google...

Filter LogCat to get only the messages from My Application in Android?

I observed that when i use Logcat with Eclipse with ADT for Android, I get messages from many other applications as well. Is there a way to filter this and show only messages from my own application only....

Bootstrap onClick button event

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

Truncate number to two decimal places without rounding

Suppose I have a value of 15.7784514, I want to display it 15.77 with no rounding. var num = parseFloat(15.7784514); document.write(num.toFixed(1)+"<br />"); document.write(num.toFixed(2)+"<br />"); document.write(num.toFixed(3)+"<br ...

what does mysql_real_escape_string() really do?

One thing that I hate about documentation at times (when you're a beginner) is how it doesn't really describe things in english. Would anyone mind translating this documentation for me? I'd like to know how exactly this makes things harder for a hack...

Java for loop syntax: "for (T obj : objects)"

I came across some Java syntax that I haven't seen before. I was wondering if someone could tell me what's going on here. for (ObjectType objectName : collectionName.getObjects()) ...

Could not load NIB in bundle

I am trying to integrate Janrain Engage as custom module with Appcelerator Titanium. I have created a sample module and dragged the JREngage folder to the sample module xcodeproj as indicated in the Jainrain's documentation. Now I give build comman...

check if array is empty (vba excel)

These if ... then statements are getting the wrong results in my opinion. The first is returning the value 'false' when it should be 'true'. The fourth returns the right value. The second and third return an error. Sub empty_array() Dim arr1(...

Upgrade to python 3.8 using conda

Python 3.8.0 is out, but I haven't been able to find any post on how to update to python 3.8 using conda - maybe they will wait for the official release? Any suggestions?...

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

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

How to set HTTP header to UTF-8 using PHP which is valid in W3C validator?

I have several PHP pages echoing out various things into HTML pages with the following code. <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> However, when I validate using the W3C validator it comes up with: The cha...

MVC3 EditorFor readOnly

I want to make readOnly with EditorFor in edit page. I tried to put readonly and disabled as: <div class="editor-field"> @Html.EditorFor(model => model.userName, new { disabled = "disabled", @readonly = "readonly" }) </div&g...

Disable JavaScript error in WebBrowser control

I am developing a windows application with a WebBrowser control that navigates to a sharepoint site. My problem is that i am getting JavaScript error. How can i disable the JavaScript error? I don't want them to pop up....

MySQL show status - active or total connections?

When I run show status like 'Con%' it shows the number of connections, which is 9972 and constantly growing. Is this an active number of connections or connections made in total?...

How do I move files in node.js?

How can I move files (like mv command shell) on node.js? Is there any method for that or should I read a file, write to a new file and remove older file?...

Convert XML to JSON (and back) using Javascript

How would you convert from XML to JSON and then back to XML? The following tools work quite well, but aren't completely consistent: xml2json Has anyone encountered this situation before?...

Text editor to open big (giant, huge, large) text files

I mean 100+ MB big; such text files can push the envelope of editors. I need to look through a large XML file, but cannot if the editor is buggy. Any suggestions?...

How do I force detach Screen from another SSH session?

I had Screen running inside an SSH session. Terminal froze. After restarting Terminal, that Screen session still thinks it's attached. Maybe it is. Perhaps I don't really know what that means. I'd like to attach to that Screen session from a fre...

How do I include a pipe | in my linux find -exec command?

This isn't working. Can this be done in find? Or do I need to xargs? find -name 'file_*' -follow -type f -exec zcat {} \| agrep -dEOE 'grep' \; ...

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

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

Angular HTML binding

I am writing an Angular application and I have an HTML response I want to display. How do I do that? If I simply use the binding syntax {{myVal}} it encodes all HTML characters (of course). I need somehow to bind the innerHTML of a div to the vari...

Replace String in all files in Eclipse

How can I search and replace a String in all files of my current project? Let's say I have the string "/sites/default/" now I want it to be "/public/sites/default/", but there are almost 1000 files....

Division in Python 2.7. and 3.3

How can I divide two numbers in Python 2.7 and get the result with decimals? I don't get it why there is difference: in Python 3: >>> 20/15 1.3333333333333333 in Python 2: >>> 20/15 1 Isn't this a modulo actually?...

HTTP redirect: 301 (permanent) vs. 302 (temporary)

Is the client supposed to behave differently? How?...

Android: Internet connectivity change listener

I already have this code which listens to connectivity change - public class NetworkStateReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { Log.d("app","Network connectivity change"); if(intent....

Ruby: How to get the first character of a string

How can I get the first character in a string using Ruby? Ultimately what I'm doing is taking someone's last name and just creating an initial out of it. So if the string was "Smith" I just want "S"....

How to insert a SQLite record with a datetime set to 'now' in Android application?

Say, we have a table created as: create table notes (_id integer primary key autoincrement, created_date date) To insert a record, I'd use ContentValues initialValues = new ContentValues(); initialValues.put("date_created", ""); long rowId = m...

Force "git push" to overwrite remote files

I want to push my local files, and have them on a remote repo, without having to deal with merge conflicts. I just want my local version to have priority over the remote one. How can I do this with Git?...

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

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

Microsoft Advertising SDK doesn't deliverer ads

So I have a Windows Phone solution that has an ad in it. When my Solution References Microsoft.Advertising.SDK Advertising.Mobile Advertising.Mobile.UI Everything works fine and I get ads. Unfortunately this has multiple references to the same DL...

Raw SQL Query without DbSet - Entity Framework Core

With Entity Framework Core removing dbData.Database.SqlQuery<SomeModel> I can't find a solution to build a raw SQL Query for my full-text search query that will return the tables data and also the rank. The only method I've seen to build a ra...

How to echo (or print) to the js console with php

In javascript, I can print to the debug console using console.log("Message here"); I'm now writing a php script, and would like to print to the debug console. Using the above code doesn't work in php. It seems I need to use either echo or some oth...

How to get an array of unique values from an array containing duplicates in JavaScript?

Given a ['0','1','1','2','3','3','3'] array, the result should be ['0','1','2','3']....

No Network Security Config specified, using platform default - Android Log

I am trying to make a database via 000webhost.com. I keep getting this message showing in the event log whenever I run the app from android studio. Does anyone knows how to solve this problem? Much appreciated! ...

to_string not declared in scope

I am trying to make the to_string(NUMBER) function work in my Ubuntu computer for weeks but it never ever works in the QT environment or anywhere else. My code works perfectly on my Mac osx, but when I try running it in Ubuntu it complains that to_st...

How to remove focus from input field in jQuery?

I am setting the focus on a certain input field when loading a page using the following line: $('#myInputID').focus(); Is there a way that I can undo or remove this focus when hovering over a certain element? (The focus does not have to be reset ...

Select top 2 rows in Hive

I'm trying to retrieve top 2 tables from my employee list based on salary in hive (version 0.11). Since it doesn't support TOP function, is there any alternatives? Or do we have define a UDF?...

'adb' is not recognized as an internal or external command, operable program or batch file

I am trying to run google map v2 on emulator, I am following this tutorial. When I was trying to install required apk file on emulator, I am getting below error. I tried to solve this using this tutorial.Followed all steps, added the path to paltfor...

How to get root view controller?

I need an instance of root view controller. I tried those approaches: UIViewController *rootViewController = (UIViewController*)[[[UIApplication sharedApplication] keyWindow] rootViewController]; Returns: null: Also when I try to get an array ...

PHP expects T_PAAMAYIM_NEKUDOTAYIM?

Does anyone have a T_PAAMAYIM_NEKUDOTAYIM?...

Return content with IHttpActionResult for non-OK response

For returning from a Web API 2 controller, I can return content with the response if the response is OK (status 200) like this: public IHttpActionResult Get() { string myResult = ... return Ok(myResult); } If possible, ...

Angular 2: Get Values of Multiple Checked Checkboxes

My problem is really simple: I have a list of checkboxes like this: <div class="form-group"> <label for="options">Options :</label> <label *ngFor="#option of options" class="form-control"> <input type="chec...

jQuery Form Validation before Ajax submit

JavaScript bit: $(document).ready(function() { $('#form').submit(function(e) { e.preventDefault(); var $form = $(this); // check if the input is valid ...

Excel VBA - Pass a Row of Cell Values to an Array and then Paste that Array to a Relative Reference of Cells

Using Excel (2010) VBA, I am trying to copy (pass) a constant range of cells (whose values recalculate) to an array. Then I am trying to pass that array to a new range of cells, directly below it. After I have done this, I want to again copy (pass)...

How do I turn off Unicode in a VC++ project?

I have a VC++ project in Visual Studio 2008. It is defining the symbols for unicode on the compiler command line (/D "_UNICODE" /D "UNICODE"), even though I do not have this symbol turned on in the preprocessor section for the project. As a r...

setBackground vs setBackgroundDrawable (Android)

I want to set background drawable of a view. There are two methods for this (as far as I see): setBackground and setBackgroundDrawable. When I use setBackground, it says it has been added in API level 16 but my project's min SDK version is 7. I ass...

How to prevent XSS with HTML/PHP?

How do I prevent XSS (cross-site scripting) using just HTML and PHP? I've seen numerous other posts on this topic but I have not found an article that clear and concisely states how to actually prevent XSS....

Simple JavaScript login form validation

Just a really simple login and redirect, but the script doesn't fire since I changed the button input type to 'submit' and the onClick event to onSubmit. All is does now is just add the username and password as a string to the url. <form name...

Where does application data file actually stored on android device?

I have developed an Android app using Appcelerator Titanium. This app will create a file in applicationDataDirectory and install a database as well. If run on emulator, I can locate those files using "adb" command. But how about on Android device? C...

How do I convert dmesg timestamp to custom date format?

I am trying to understand the dmesg timestamp and find it hard to convert that to change it to java date/custom date format. Sample dmesg log: [14614.647880] airo(eth1): link lost (missed beacons) So how do I convert 14614.647880 to a standard date?...

How to enable curl in Wamp server

I try 30 combination of answer and forum topic but did not find the right answer. I do all but how I can enable the curl int wamp server becouse I need that? is there any solution? I try to uncomment - dont work? I try to chech into wamp task bar...

Compare 2 arrays which returns difference

What's the fastest/best way to compare two arrays and return the difference? Much like array_diff in PHP. Is there an easy function or am I going to have to create one via each()? or a foreach loop?...

T-SQL: Opposite to string concatenation - how to split string into multiple records

Possible Duplicate: Split string in SQL I have seen a couple of questions related to string concatenation in SQL. I wonder how would you approach the opposite problem: splitting coma delimited string into rows of data: Lets say I have tab...

Java program to connect to Sql Server and running the sample query From Eclipse

package sqlselection; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class Sqlselection { public static void main(String[] args) { try ...

SQLSTATE[42S22]: Column not found: 1054 Unknown column - Laravel

I'm using the framework Laravel. I have 2 tables (Users and Members). When I want to login, I get the error message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user_email' in 'where clause' (SQL: select * from members where user_e...

How do I load an HTTP URL with App Transport Security enabled in iOS 9?

So, the new beta SDK of iOS released last night has "App Transport Security" which encourages developers to use https instead of http. In principle, this is a great idea, and I already use https in our staging/production environments. However, I don'...

Convert named list to vector with values only

I have a list of named values: myList <- list('A' = 1, 'B' = 2, 'C' = 3) I want a vector with the value 1:3 I can't figure out how to extract the values without defining a function. Is there a simpler way that I'm unaware of? library(plyr) myvect...

Vue v-on:click does not work on component

I'm trying to use the on click directive inside a component but it does not seem to work. When I click the component nothings happens when I should get a 'test clicked' in the console. I don't see any errors in the console, so I don't know what am I ...

Converting a PDF to PNG

I'm trying to convert a PDF to a PNG image (at least the cover of one). I'm successfully extracting the first page of the PDF with pdftk. I'm using imagemagick to do the conversion: convert cover.pdf cover.png This works, but unfortunately the cov...

How can I generate a unique ID in Python?

I need to generate a unique ID based on a random value....

PHP: cannot declare class because the name is already in use

I have 5 scripts: database.php parent.php child1.php child2.php somescript.php parent.php class looks like this: include 'database.php'; class Parent { public $db; function __construct() { $this->db = new Database(); } }...

ValueError: setting an array element with a sequence

This Python code: import numpy as p def firstfunction(): UnFilteredDuringExSummaryOfMeansArray = [] MeanOutputHeader=['TestID','ConditionName','FilterType','RRMean','HRMean', 'dZdtMaxVoltageMean','BZMean','ZXMean','LVE...

Chrome - ERR_CACHE_MISS

Does anybody know what the following Chrome error is? Failed to load resource: net::ERR_CACHE_MISS I have had a look online, but have not found a good answer yet. Somebody said it might be related to the latest Chrome update? What is it and how c...

How to use a App.config file in WPF applications?

I created an App.config file in my WPF application: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appsettings> <add key="xmlDataDirectory" value="c:\testdata"/> </a...

How to split a string into an array in Bash?

In a Bash script, I would like to split a line into pieces and store them in an array. For example, given the line: Paris, France, Europe I would like to have the resulting array to look like so: array[0] = Paris array[1] = France array[2] = Europe ...

How do I remove repeated elements from ArrayList?

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

What is the difference between connection and read timeout for sockets?

3 questions: What is the difference between connection and read timeout for sockets? What does connection timeout set to "infinity" mean? In what situation can it remain in an infinitive loop? and what can trigger that the infinity-loop dies? What ...

Pandas merge two dataframes with different columns

I'm surely missing something simple here. Trying to merge two dataframes in pandas that have mostly the same column names, but the right dataframe has some columns that the left doesn't have, and vice versa. >df_may id quantity attr_1 attr...

How to change options of <select> with jQuery?

Suppose a list of options is available, how do you update the <select> with new <option>s?...

Find and replace strings in vim on multiple lines

I can do :%s/<search_string>/<replace_string>/g for replacing a string across a file, or :s/<search_string>/<replace_string>/ to replace in current line. How can I select and replace words from selective lines in vim? Exampl...

How to group an array of objects by key

Does anyone know of a (lodash if possible too) way to group an array of objects by an object key then create a new array of objects based on the grouping? For example, I have an array of car objects: var cars = [ { 'make': 'audi', ...

How can I open multiple files using "with open" in Python?

I want to change a couple of files at one time, iff I can write to all of them. I'm wondering if I somehow can combine the multiple open calls with the with statement: try: with open('a', 'w') as a and open('b', 'w') as b: do_something() excep...

System.out.println() shortcut on Intellij IDEA

I know I can print System.out.println() with "sout" + tab. Is there a way I can do it with "Syso" + ctrl + space like in eclipse?...

Logcat not displaying my log calls

I'm a total noob at Android programming, and wanted to learn how to debug my apps. I can't seem to have my Log.i|d|v calls displayed in the LogCat. Here's the code that I'm using. As you can see I have defined a LOG_TAG constant, but can't seem ...

How do I use the new computeIfAbsent function?

I very much want to use Map.computeIfAbsent but it has been too long since lambdas in undergrad. Almost directly from the docs: it gives an example of the old way to do things: Map<String, Boolean> whoLetDogsOut = new ConcurrentHashMap<&...

"date(): It is not safe to rely on the system's timezone settings..."

I got this error when I requested to update the PHP version from 5.2.17 to PHP 5.3.21 on the server. <div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"> <h4>A PHP Error was encountered</h4> <p>Severi...

Custom Adapter for List View

I want to create a custom adapter for my list view. Is there any article that can walk me through how to create one and also explain how it works?...

What's the difference between django OneToOneField and ForeignKey?

What's the difference between Django OneToOneField and ForeignKey?...

Assign variable in if condition statement, good practice or not?

I moved one years ago from classic OO languages such like Java to JavaScript. The following code is definitely not recommended (or even not correct) in Java: if(dayNumber = getClickedDayNumber(dayInfo)) { alert("day number found : " + dayNumber)...

Is there a Newline constant defined in Java like Environment.Newline in C#?

In C# there is the static property Environment.Newline that changed depending on the running platform. Is there anything similar in Java?...

How to hide the title bar for an Activity in XML with existing custom theme

I want to hide the titlebar for some of my activities. The problem is that I applied a style to all my activities, therefore I can't simply set the theme to @android:style/Theme.NoTitleBar. Using the NoTitleBar theme as a parent for my style would ...

How to list all installed packages and their versions in Python?

Is there a way in Python to list all installed packages and their versions? I know I can go inside python/Lib/site-packages and see what files and directories exist, but I find this very awkward. What I'm looking for something that is similar to npm...

Jquery, set value of td in a table?

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

Most efficient way to increment a Map value in Java

I hope this question is not considered too basic for this forum, but we'll see. I'm wondering how to refactor some code for better performance that is getting run a bunch of times. Say I'm creating a word frequency list, using a Map (probably a Hash...

XSLT counting elements with a given value

I need to count the number of elements in an XML file that have a particular value (to verify uniqueness). The XML file looks like this: EDIT: I updated the original "simplified" XML with the actual hairy mess someone designed. Unfortunately, this i...

How do I set the classpath in NetBeans?

Can someone tell me where and how I set the classpath in NetBeans? I would like to add a .jar file....

Python - round up to the nearest ten

If I get the number 46 and I want to round up to the nearest ten. How do can I do this in python? 46 goes to 50....

.NET Console Application Exit Event

In .NET, is there a method, such as an event, for detecting when a Console Application is exiting? I need to clean up some threads and COM objects. I am running a message loop, without a form, from the console application. A DCOM component that I a...

Change the background color of a row in a JTable

I have a JTable with 3 columns. I've set the TableCellRenderer for all the 3 columns like this (maybe not very effective?). for (int i = 0; i < 3; i++) { myJTable.getColumnModel().getColumn(i).setCellRenderer(renderer); } The getTableCel...

The shortest possible output from git log containing author and date

How can I show a git log output with (at least) this information: * author * commit date * change I want it compressed to one line per log entry. What's the shortest possible format for that? (tried --format=oneline but that does not show the da...

Node.js Error: Cannot find module express

I wrote my first node.js app, but it can't find express library: C:\ChatServer\Server>node server.js module.js:340 throw err; ^ Error: Cannot find module 'express' at Function.Module._resolveFilename (module.js:338:15) at F...

Why do we use Base64?

Wikipedia says Base64 encoding schemes are commonly used when there is a need to encode binary data that needs be stored and transferred over media that are designed to deal with textual data. This is to ensure that the data remains intact withou...

Styling the arrow on bootstrap tooltips

I'm trying to style tootltips using .tooltip-inner{} But i'm having troubles cause i can't find how to style tooltip small arrow. As shown on screenshot the arrow of the tooltip is black i want to add new color on that: any suggestion?...

Increase heap size in Java

I am working on a Windows 2003 server (64-bit) with 8 GB RAM. How can I increase the heap memory maximum? I am using the -Xmx1500m flag to increase the heap size to 1500 Mb. Can I increase the heap memory to 75% of physical memory (6 GB Heap)?...

Enable/disable buttons with Angular

I'm making an web-app in angular 4 and there is a question i came up with. It's the following: I use a property called currentLesson. This property has a variable number from 1 to 6. In my component I have an list of 6 lessons where each lesson has...

add controls vertically instead of horizontally using flow layout

I am adding checkboxes on JPanel in FlowLayout the checkboxes are being added horizontally. I want to add checkboxes vertically on the Panel. What is the possible solution?...

Reversing a String with Recursion in Java

Here is some Java code to reverse a string recursively. Could someone provide an explanation of how it works? public static String reverse(String str) { if ((null == str) || (str.length() <= 1)) { return str; } return rever...

Unable to connect PostgreSQL to remote database using pgAdmin

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

Reading and writing value from a textfile by using vbscript code

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

for-in statement

TypeScript docs say nothing about loop like for or for-in. From playing with the language it seems that only any or string variables are supported in for loop. Why has this decision been made? Why not use the type information and have strongly-type...

XML shape drawable not rendering desired color

I defined a drawable <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#ffffffff" /> <size android:width="60dp" ...

Using Thymeleaf when the value is null

I have some values in my database which can be null if they have not already been entered. But when I use Thymeleaf in my html, it gives an error when parsing null values. Is there any way to handle this?...

What is the shortest function for reading a cookie by name in JavaScript?

What is the shortest, accurate, and cross-browser compatible method for reading a cookie in JavaScript? Very often, while building stand-alone scripts (where I can't have any outside dependencies), I find myself adding a function for reading cookie...

Spark Dataframe distinguish columns with duplicated name

So as I know in Spark Dataframe, that for multiple columns can have the same name as shown in below dataframe snapshot: [ Row(a=107831, f=SparseVector(5, {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0}), a=107831, f=SparseVector(5, {0: 0.0, 1: 0.0, 2: 0.0,...

org.postgresql.util.PSQLException: FATAL: sorry, too many clients already

I am trying to connect to a Postgresql database, I am getting the following Error: Error:org.postgresql.util.PSQLException: FATAL: sorry, too many clients already What does the error mean and how do I fix it? My server.properties file is follo...

SQL DATEPART(dw,date) need monday = 1 and sunday = 7

I have a Query where I get the WeekDay of a date but by default: Sunday = 1 Moday = 2 etc. The function is: DATEPART(dw,ads.date) as weekday I need the result so: Sunday = 7 Monday = 1 etc. Is there any shortcut to do this? Or I will have...

Ruby on Rails: Where to define global constants?

I'm just getting started with my first Ruby on Rails webapp. I've got a bunch of different models, views, controllers, and so on. I'm wanting to find a good place to stick definitions of truly global constants, that apply across my whole app. In pa...

Gray out image with CSS?

What's the best way (if any) to make an image appear "grayed out" with CSS (i.e., without loading a separate, grayed out version of the image)? My context is that I have rows in a table that all have buttons in the right most cell and some rows need...

Hover and Active only when not disabled

I use hover, active and disabled to style Buttons. But the problem is when the button is disabled the hover and active styles still applies. How to apply hover and active only on enabled buttons?...

MySQL: Get column name or alias from query

I'm not asking for the SHOW COLUMNS command. I want to create an application that works similarly to heidisql, where you can specify an SQL query and when executed, returns a result set with rows and columns representing your query result. The colum...

Get current folder path

I want to create a program that converts files. I would like the user to be able to place the executable file in any directory, and when executing that program (double-clicking on the .exe) I want the program to process all the files within the curre...

Custom Drawable for ProgressBar/ProgressDialog

Reading the limited documentation that Google has provided, I get the feeling that it is possible to change the look (drawable) of a ProgressBar/ProgressDialog by simply creating a new style an assigning it to the style property of the ProgressBar. B...

Disable button in jQuery

My page creates multiple buttons as id = 'rbutton_"+i+"'. Below is my code: <button type='button' id = 'rbutton_"+i+"' onclick=disable(i);>Click me</button> In Javascript function disable(i){ $("#rbutton'+i+'").attr("disabled","di...

Change tab bar tint color on iOS 7

Is there a way to change the tint of a tab bar on iOS 7 from the default white with blue icons to another color tint with different color buttons?...

OS X Framework Library not loaded: 'Image not found'

I am trying to create a basic OS X Framework, right now I just have a test framework created: TestMacFramework.framework and I'm trying to import it into a brand new OS X Application project. I have built the .framework file and imported it into the...

Iterate over values of object

I want to iterate over all values of a map. I know it's possible to iterate over all keys. But is it possible to iterate directly over the values? var map = { key1 : 'value1', key2 : 'value2' } for (var key in map) { ...} // iterates over keys ...

how to remove untracked files in Git?

I'm working on a branch, say "experimental" branch which I branch out from my master branch.Then, I generate a user model in experimental branch, but does not add them to index yet. What do I have to do if I want to discard all the changes of the fi...

Named regular expression group "(?P<group_name>regexp)": what does "P" stand for?

In Python, the (?P<group_name>…) syntax allows one to refer to the matched string through its name: >>> import re >>> match = re.search('(?P<name>.*) (?P<phone>.*)', 'John 123456') >>> match.group('name...

How to restore to a different database in sql server?

I have a backup of Database1 from a week ago. The backup is done weekly in the scheduler and I get a .bak file. Now I want to fiddle with some data so I need to restore it to a different database - Database2. I have seen this question: Restore SQL S...

Number to String in a formula field

I am using a formula field to concatonate 2 decimal values separated by a dash. However, I want the result to trim all unneccesary trailing zeros and decimal points for both values. For example, I want values 10 and 8.5 to be "10 - 8.5". Now it show...

Get specific line from text file using just shell script

I am trying to get a specific line from a text file. So far, online I have only seen stuff like sed, (I can only use the sh -not bash or sed or anything like that). I need to do this only using a basic shell script. cat file | while read line d...

Round up double to 2 decimal places

How do I round up currentRatio to two decimal places? let currentRatio = Double (rxCurrentTextField.text!)! / Double (txCurrentTextField.text!)! railRatioLabelField.text! = "\(currentRatio)" ...

How can I convert an Int to a CString?

I can convert a Double to a CString using _ecvt result_str=_ecvt(int,15,&decimal,&sign); So, is there a method like the one above that converts an int to CString?...

How to insert a blob into a database using sql server management studio

How can I easily insert a blob into a varbinary(MAX) field? As an example: thing I want to insert is: c:\picture.png the table is mytable the column is mypictureblob the place is recid=1...

How to add google-play-services.jar project dependency so my project will run and present map

I have following problem: I try to use SupportMapFragment from com.google.android.gms.maps.SupportMapFragment which is part of Google Maps Android API v2. My first approach was to add project to Eclipse from android-sdk\extras\google\google_play_ser...

mongodb service is not starting up

I've installed the mongodb 2.0.3, using the mongodb-10gen debian package. Everything went well, except the service which is installed by default is not starting up when computer starts. The mongod is running only as root user. maybe this is the reaso...

MySQL - Select the last inserted row easiest way

I simply need to select the last entered row specified by condition, e.g: SELECT ID from bugs WHERE user=Me I need to return only the very last ID entered by user 'Me'. Is there a simple way to do this? Thank you....

Access restriction: Is not accessible due to restriction on required library ..\jre\lib\rt.jar

I am trying to modify some legacy code from while back and getting the following kind of errors: Access restriction: The method create(JAXBRIContext, Object) from the type Headers is not accessible due to restriction on required library ..\jre\lib\r...

How to call execl() in C with the proper arguments?

i have vlc (program to reproduce videos) if i type in a shell: /home/vlc "/home/my movies/the movie i want to see.mkv" it opens up an reproduces the movie. however, when I run the following program: #include <unistd.h> int main(void) { ...

How to write "not in ()" sql query using join

Could some one please provide how to write following sql query using joins. I do not want use not in as well as if possible I would like to replace where condition as well. SELECT d1.Short_Code FROM domain1 d1 WHERE d1.Short_Code NOT IN ( SELECT d...

Int to Char in C#

What is the best way to convert an Int value to the corresponding Char in Utf16, given that the Int is in the range of valid values?...

Pass multiple parameters to rest API - Spring

I am trying to figure out if it is possible to pass a JSON object to rest API, Or pass a multiple parameters to that API ? And how to read these parameters in Spring ? Lets assume that the url looks like the below examples : Ex.1 http://localhost:8...

error: expected declaration or statement at end of input in c

void mi_start_curr_serv(void){ #if 0 //stmt #endif } I'm getting an error as "error: expected declaration or statement at end of input" in my compiler. I could not find any error with the above function. Please help me to understand this error...

Difference between null and empty ("") Java String

What is the difference between null and the "" (empty string)? I have written some simple code: String a = ""; String b = null; System.out.println(a == b); // false System.out.println(a.equals(b)); // false Both statements return false. It seems...

Can anybody tell me details about hs_err_pid.log file generated when Tomcat crashes?

Can anybody tell me details about the hs_err_pid.log file generated when Tomcat crashes? Are any specific settings required on the Java tab of Tomcat configuration tool in order to generate a hs_err_pid.log file? What is the default location of the...

Django optional url parameters

I have a Django URL like this: url( r'^project_config/(?P<product>\w+)/(?P<project_id>\w+)/$', 'tool.views.ProjectConfig', name='project_config' ), views.py: def ProjectConfig(request, product, project_id=None, template_na...

Pass parameter to EventHandler

I have the following EventHandler to which I added a parameter MusicNote music: public void PlayMusicEvent(object sender, EventArgs e,MusicNote music) { music.player.Stop(); System.Timers.Timer myTimer = (System.Timers.Timer)sender; myTi...

Convert command line argument to string

I have a program that reads hard-coded file-path and I want to make it read file-path from command line instead. For that purpose I changed the code like this: #include <iostream> int main(char *argv[]) { ... } but, argv[1] variable exposed...

Start ssh-agent on login

I have a site as a remote Git repo pulling from Bitbucket.com using an SSH alias. I can manually start the ssh-agent on my server but I have to do this every time I login via SSH. I manually start the ssh-agent: eval ssh-agent $SHELL Then I add t...

"code ." Not working in Command Line for Visual Studio Code on OSX/Mac

The command "code ." doesn't work in this manual? All the other steps before that worked. How can I call the Visual Studio Code in OSX terminal? Monas-MacBook-Pro:myExpressApp mona$ pwd /Users/mona/nodejs/myExpressApp Monas-MacBook-Pro:myExpressAp...

TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array

I want to write a function that randomly picks elements from a training set, based on the bin probabilities provided. I divide the set indices to 11 bins, then create custom probabilities for them. bin_probs = [0.5, 0.3, 0.15, 0.04, 0.0025, 0.0025, ...

Convert a string to datetime in PowerShell

I am using PowerShell to try and convert a string to a datetime. It should be easy, right? I am getting the string from a CSV import, and it comes in the format of Jul-16. I have tried multiple ways of getting it into the format I want which is yyyy...

ADB error: cannot connect to daemon

I need help to get ADB working on my PC (win7 64bit) with the Samsung Galaxy S2. I have installed the drivers coming along Kies, I think under sub folder "25_escape". The drivers appear correctly as "Samsung ADB interface" under the device manager. ...

Difference between HttpModule and HttpClientModule

Which one to use to build a mock web service to test the Angular 4 app?...

No operator matches the given name and argument type(s). You might need to add explicit type casts. -- Netbeans, Postgresql 8.4 and Glassfish

I am trying to edit a table in Postgresql using JPA in Glassfish using EclipseLink. When I insert an entity, it runs fine. But, when I try to edit or remove the same entity, it fails with the following error. Any idea? Caused by: Exception [Eclipse...

difference between css height : 100% vs height : auto

I was asked a question in an interview that "what is the difference between the css height:100% and height:auto?" Can any one explain?...

CSS div element - how to show horizontal scroll bars only?

I have a div container and have defined its style as follows: div#tbl-container { width: 600px; overflow: auto; scrollbar-base-color:#ffeaff } This gives me both horizontal and vertical scroll bars automatically once I populate...

how do you pass images (bitmaps) between android activities using bundles?

Suppose I have an activity to select an image from the gallery, and retrieve it as a BitMap, just like the example: here Now, I want to pass this BitMap to be used in an ImageView for another activity. I am aware bundles can be passed between activi...

What tool to use to draw file tree diagram

Given a file tree - a directory with directories in it etc, how would you write a script to create a diagram of the file-tree as a graphic file that I can embed in a word processor document. I prefer vector (SVG, EPS, EMF...) files. The tool must run...

Install mysql-python (Windows)

I've spent hours trying to make Django work on my computer. The problem is that I can't install the mysql-python package. I'm running Windows 7 64bit. This is what I've tried: I have downloaded easy_install I have downloaded Cygwin64 to be able to ...

How to get current SIM card number in Android?

I want to know user mobile number in Android. I used this code but I'm not getting number. TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); String n = tm.getLine1Number(); Permission: <uses-permissi...

print variable and a string in python

Alright, I know how to print variables and strings. But how can I print something like "My string" card.price (it is my variable). I mean, here is my code: print "I have " (and here I would like to print my variable card.price)....

Convert System.Drawing.Color to RGB and Hex Value

Using C# I was trying to develop the following two. The way I am doing it may have some problem and need your kind advice. In addition, I dont know whether there is any existing method to do the same. private static String HexConverter(System.Drawin...

How to increase request timeout in IIS?

How to increase request timeout in IIS 7.0? The same is done under application tab in ASP configuration settngs in IIS 6.0. I am not able to find the asp.net configuration section in IIS 7.0...

Laravel - Eloquent or Fluent random row

How can I select a random row using Eloquent or Fluent in Laravel framework? I know that by using SQL, you can do order by RAND(). However, I would like to get the random row without doing a count on the number of records prior to the initial query....

How to retrieve unique count of a field using Kibana + Elastic Search

Is it possible to query for a distinct/unique count of a field using Kibana? I am using elastic search as my backend to Kibana. If so, what is the syntax of the query? Heres a link to the Kibana interface I would like to make my query: http://demo....

Setting format and value in input type="date"

Is there any way to set the format of <input type="date" /> ? if no then how can i set date in this field using JavaScript in the default format of type="date". how can i get what will be the format of this field? EDIT : Actually i want to sh...

Populating a data frame in R in a loop

I am trying to populate a data frame from within a for loop in R. The names of the columns are generated dynamically within the loop and the value of some of the loop variables is used as the values while populating the data frame. For instance the n...

How can you zip or unzip from the script using ONLY Windows' built-in capabilities?

In Windows you can zip some files by right click → Send to → Compressed (zipped) folder And unzip by double clicking on the .zip file and extract the files. Is there a way to apply those abilities from a script (.bat file) without t...

Invalid hook call. Hooks can only be called inside of the body of a function component

I am new to React and Now I would like to show some record in the table and now I got this error. Help me, please. Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the followin...

How to show all privileges from a user in oracle?

Can someone please tell me how to show all privileges/rules from a specific user in the sql-console?...

Vagrant error : Failed to mount folders in Linux guest

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

Why doesn't Python have a sign function?

I can't understand why Python doesn't have a sign function. It has an abs builtin (which I consider sign's sister), but no sign. In python 2.6 there is even a copysign function (in math), but no sign. Why bother to write a copysign(x,y) when you cou...

Is there a simple way to delete a list element by value?

I want to remove a value from a list if it exists in the list (which it may not). a = [1, 2, 3, 4] b = a.index(6) del a[b] print(a) The above case (in which it does not exist) shows the following error: Traceback (most recent call last): File &qu...

How to identify platform/compiler from preprocessor macros?

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

MySQL Update Column +1?

I was wondering what would be the easiest way to update a column by +1? I will be updating a post count of a category based on when users submits a new post. Thanks....

ADB not responding. You can wait more,or kill "adb.exe" process manually and click 'Restart'

I have installed Android Studio. Then I have updated the Android SDK. Now when I start Android Studio, this message pops up: ADB not responding. You can wait more,or kill "adb.exe" process manually and click 'Restart' The dialog has 3 options: ...

Using the GET parameter of a URL in JavaScript

If I am on a page such as http://somesite.com/somepage.php?param1=asdf In the JavaScript of that page, I would like to set a variable to the value of the parameter in the GET part of the URL. So in JavaScript: <script> param1var = ... ...

Can you append strings to variables in PHP?

Why does the following code output 0? It works with numbers instead of strings just fine. I have similar code in JavaScript that also works. Does PHP not like += with strings? <?php $selectBox = '<select name="number">'; for ($i=1;...

docker run <IMAGE> <MULTIPLE COMMANDS>

I'm trying to run MULTIPLE commands like this. docker run image cd /path/to/somewhere && python a.py But this gives me "No such file or directory" error because it is interpreted as... "docker run image cd /path/to/somewhere" && "...

getting the last item in a javascript object

If I have an object like: { 'a' : 'apple', 'b' : 'banana', 'c' : 'carrot' } If I don't know in advance that the list goes up to 'c', other than looping through the object, is there a way to get the last item in the object (e.g. 'carrot')?...

Whats the CSS to make something go to the next line in the page?

How can I make an element automatically be positioned on a new line in the page? In HTML I could use <br>, but how do I add something like a line-break in CSS? Say I have the following code for example: <p>Lorem ipsum dolor sit amet, ...

Set up an HTTP proxy to insert a header

I need to test some HTTP interaction with a client I'd rather not modify. What I need to test is the behavior of the server when the client's requests include a certain, static header. I'm thinking the easiest way to run this test is to set up an HT...

How to generate a Dockerfile from an image?

Is it possible to generate a Dockerfile from an image? I want to know for two reasons: I can download images from the repository but would like to see the recipe that generated them. I like the idea of saving snapshots, but once I am done it would...

PowerShell: Create Local User Account

I need to create a new local user account, and then add them to the local Administrators group. Can this be done in PowerShell? EDIT: # Create new local Admin user for script purposes $Computer = [ADSI]"WinNT://$Env:COMPUTERNAME,Computer" $LocalA...

lodash: mapping array to object

Is there a built-in lodash function to take this: var params = [ { name: 'foo', input: 'bar' }, { name: 'baz', input: 'zle' } ]; And output this: var output = { foo: 'bar', baz: 'zle' }; Right now I'm just using Array.prototype....

CSS background image to fit height, width should auto-scale in proportion

I want background image fit with the height of the div, there's a way to do that? background-size:cover; fit only with the width and height autoscale (I need the opposite effect). Thanks....

Code for Greatest Common Divisor in Python

The greatest common divisor (GCD) of a and b is the largest number that divides both of them with no remainder. One way to find the GCD of two numbers is Euclid’s algorithm, which is based on the observation that if r is the remainder when a is di...

Greater than and less than in one statement

I was wondering, do you have a neat way of doing this ? if(orderBean.getFiles().size() > 0 && orderBean.getFiles().size() < 5) without declaring a variable that is not needed anywhere else ? int filesCount = orderBean.getFiles().si...

How to call Stored Procedure in a View?

How would I call a Stored Procedure that returns data in a View? Is this even possible? ...

What do hjust and vjust do when making a plot using ggplot?

Every time I make a plot using ggplot, I spend a little while trying different values for hjust and vjust in a line like + opts(axis.text.x = theme_text(hjust = 0.5)) to get the axis labels to line up where the axis labels almost touch the axis, ...

package javax.servlet.http does not exist

I have the jre7 and jdk1.7.0 installed along with the Tomcat 7.0 but it shows this error. servlet.http is not the only one that "does not exist", there are also other (servlet.) components. Can anybody help me with this? UPDATE: This error occurs w...

How to quickly check if folder is empty (.NET)?

I have to check, if directory on disk is empty. It means, that it does not contain any folders/files. I know, that there is a simple method. We get array of FileSystemInfo's and check if count of elements equals to zero. Something like that: public ...

Open a facebook link by native Facebook app on iOS

If the native Facebook app is installed on the iPhone. How do I open a facebook link into the native Facebook app from my app. In the case of opening by Safari, the link is same as: http://www.facebook.com/AlibabaUS Thank you....

Postfix is installed but how do I test it?

I tried everything, I read online to test, and I can't get email to go out: telnet <IP> 25 EHLO MAIL FROM: <from-email> RCPT TO: <recipient-email> DATA Type message here. . <Enter> => I even tried this, and when I type the...

Is there an opposite of include? for Ruby Arrays?

I've got the following logic in my code: if [email protected]?(p.name) ... end @players is an array. Is there a method so I can avoid the !? Ideally, this snippet would be: if @players.does_not_include?(p.name) ... end ...

Copy output of a JavaScript variable to the clipboard

I have no knowledge of JavaScript, but I managed to put this code together using bits and bolts from various Stack Overflow answers. It works OK, and it outputs an array of all selected checkboxes in a document via an alert box. function getSel...

PYTHONPATH on Linux

I'm novice in this, and I have started learning Python, but I have some questions that I'm not be able to understand, What exactly is the PYTHONPATH (on Ubuntu)? Is it a folder? Is Python provided by default on Ubuntu, or does it have to be install...

Facebook page automatic "like" URL (for QR Code)

I was wondering if one could construct a URL for automatically liking a Facebook page. Then this URL could be converted to a QR Code so people can automatically "like" your page by reading it with their smartphone. I have been searching a lot, but...

How to use a variable of one method in another method?

I want to know how can I use the variable a[i][j] in the method Scores() to use it in the methods MD() and sumD() in the following code: In my code, the methods MD() and sumD() can't get the result. public class Test3 { public void Scores() { ...

How to convert 2D float numpy array to 2D int numpy array?

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

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

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

List directory tree structure in python?

I know that we can use os.walk() to list all sub-directories or all files in a directory. However, I would like to list the full directory tree content: - Subdirectory 1: - file11 - file12 - Sub-sub-directory 11: - file111 ...

How to take a first character from the string

Using VB.Net & SQL Server 2005 Dim S as string s = "Rajan" s = "Sajan" I want to take a first character from the string (s) Expected Output R S Need VB.Net Code Help...

Disabling submit button until all fields have values

I want to disable my submit button until all the fields have values.. how can I do that? <html> <head> <title></title> <style type="text/css"> </style> <script type="text/jav...

sklearn plot confusion matrix with labels

I want to plot a confusion matrix to visualize the classifer's performance, but it shows only the numbers of the labels, not the labels themselves: from sklearn.metrics import confusion_matrix import pylab as pl y_test=['business', 'business', 'busi...

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

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

how to setup ssh keys for jenkins to publish via ssh

Jenkins requires a certificate to use the ssh publication and ssh commands. It can be configured under "manage jenkins" -> "Configure System"-> "publish over ssh". The question is: How does one create the certificates? I have two ubuntu serve...

How to build a Debian/Ubuntu package from source?

I have the source of a program (taken from cvs/svn/git/...) and I'd like to build a Debian/Ubuntu package for it. The package is present in the repositories, but: It is an older version (lacking features I need) I need slightly different compile op...

Versioning SQL Server database

I want to get my databases under version control. Does anyone have any advice or recommended articles to get me started? I'll always want to have at least some data in there (as alumb mentions: user types and administrators). I'll also often want ...

Datepicker: How to popup datepicker when click on edittext

I want to show datepicker popup window. I have found some examples but i am not getting it properly. I have one edittext and i want that when i click on edittext the datepicker dialog should popup and after setting the date, the date should show in e...

ORA-12528: TNS Listener: all appropriate instances are blocking new connections. Instance "CLRExtProc", status UNKNOWN

I'm getting this error if i try to login as db user. If lsnrctl status is run i get the below error. DB was working fine all these years and stopped working suddenly. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ABC.LOCAL)(PORT=1521) STAT...

wget/curl large file from google drive

I'm trying to download a file from google drive in a script, and I'm having a little trouble doing so. The files I'm trying to download are here. I've looked online extensively and I finally managed to get one of them to download. I got the UIDs of ...

Changing button text onclick

When I click on myButton1 button, I want the value to change to Close Curtain from Open Curtain.HTML: <input onclick="change()" type="button" value="Open Curtain" id="myButton1"></input> Javascript: function change(); { document.g...

List(of String) or Array or ArrayList

Hopefully a simple question to most programmers with some experience. What is the datatype that lets me do this? Dim lstOfStrings as *IDK* Dim String0 As String = "some value" Dim String1 As String = "some value" Dim String2 As String = "some val...

What is causing this error - "Fatal error: Unable to find local grunt"

I removed the old version of grunt first, then I installed the new grunt version, and then I got this error: D:\www\grunt-test\grunt grunt-cli: The grunt command line interface. (v0.1.4) Fatal error: Unable to find local grunt. If you...

invalid byte sequence for encoding "UTF8"

I'm trying to import some data into my database. So I've created a temporary table, create temporary table tmp(pc varchar(10), lat decimal(18,12), lon decimal(18,12), city varchar(100), prov varchar(2)); And now I'm trying to import the data, co...

How to declare local variables in postgresql?

There is an almost identical, but not really answered question here. I am migrating an application from MS SQL Server to PostgreSQL. In many places in code I use local variables so I would like to go for the change that requires less work, so could ...

How to make a local variable (inside a function) global

Possible Duplicate: Using global variables in a function other than the one that created them I'm using functions so that my program won't be a mess but I don't know how to make a local variable into global....

Using Linq select list inside list

Using LINQ how to select from a List within a List public class Model { public string application { get; set; } public List<Users> users { get; set; } } public class Users { public string name { get; set; } public string sur...

Run / Open VSCode from Mac Terminal

I'd like to run / open Visual Studio Code from the Mac OSX Terminal by running this command code .. I found instructions here: https://code.visualstudio.com/Docs/setup Apparently I need to include this in my .bashrc file, so I did, but to no avail...

Why do I get "'property cannot be assigned" when sending an SMTP email?

I can't understand why this code is not working. I get an error saying property can not be assigned MailMessage mail = new MailMessage(); SmtpClient client = new SmtpClient(); client.Port = 25; client.DeliveryMethod = SmtpDeliveryMethod....

How to use '-prune' option of 'find' in sh?

I don't quite understand the example given from the man find, can anyone give me some examples and explanations? Can I combine regular expression in it? The more detailed question is like this: Write a shell script, changeall, which has an inte...

PHP Composer behind http proxy

I use composer on a network where the only way to access the internet is using HTTP or socks proxy. I have http_proxy and https_proxy environment variables. When compose tries to access HTTPS URLs I get this: file could not be downloaded: failed to...

Sending string via socket (python)

I have two scripts, Server.py and Client.py. I have two objectives in mind: To be able to send data again and again to server from client. To be able to send data from Server to client. here is my Server.py : import socket serversocket = s...

Styling multi-line conditions in 'if' statements?

Sometimes I break long conditions in ifs onto several lines. The most obvious way to do this is: if (cond1 == 'val1' and cond2 == 'val2' and cond3 == 'val3' and cond4 == 'val4'): do_something Isn't very very appealing visually, becau...

How can I clear or empty a StringBuilder?

I'm using a StringBuilder in a loop and every x iterations I want to empty it and start with an empty StringBuilder, but I can't see any method similar to the .NET StringBuilder.Clear in the documentation, just the delete method which seems overly co...

What does this expression language ${pageContext.request.contextPath} exactly do in JSP EL?

I have a web app, where I have different navigation anchor tags such as Home, Profile and etc. What I want: When I press anchor tags like home or profile. I just want to ensure that current user gets its information in that Tags/JSP Page. Sample ...

What is "string[] args" in Main class for?

In C# the Main class has string[] args parameter. What is that for and where does it get used?...

Importing .py files in Google Colab

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

Minimum 6 characters regex expression

I m looking for regex which checks for at least 6 characters, regardless of which type of character....

RuntimeError: module compiled against API version a but this version of numpy is 9

Code: import numpy as np import cv Console: >>> runfile('/Users/isaiahnields/.spyder2/temp.py', wdir='/Users/isaiahnields/.spyder2') RuntimeError: module compiled against API version a but this version of numpy is 9 Traceback (most recen...

Golang read request body

I am writing my own logginMiddleware. Basically, I need to log body of the request and the response. The problem that I faced is that when I read body, it becomes empty and I cannot read it twice. I understand that it happens because it is of type R...

MySQL Job failed to start

I'm on Kubuntu 12.04, and after installing mysql via an apt-get (mysql ver: 5.5.35), i'm trying to start mysql service, but I got this error: sudo service mysql start start: Job failed to start So I googled this problem, it says i have to ...

How can I increase the JVM memory?

HI, I like to know can I increase the memory of the JVM depending on my application.If yes how can I increase the JVM memory? And how can I know the size of JVM?...

How do I get a string format of the current date time, in python?

For example, on July 5, 2010, I would like to calculate the string July 5, 2010 How should this be done?...

convert string to number node.js

I'm trying to convert req.params to Number because that is what I defined in my schema for year param. I have tried req.params.year = parseInt( req.params.year, 10 ); and Number( req.params.year); and 1*req.params.year; but non of them wo...

How to check iOS version?

I want to check if the iOS version of the device is greater than 3.1.3 I tried things like: [[UIDevice currentDevice].systemVersion floatValue] but it does not work, I just want a: if (version > 3.1.3) { } How can I achieve this?...

Int to byte array

I thought .net had some kind of easy conversion method to use for converting an int into a byte array? I did a quick search and all solutions are bit masking/shifting one byte at a time, like "the good ol days". Is there not a ToByteArray() method s...

Border Radius of Table is not working

I want to add a border radius around the entire table. But the following code is not working in both the latest versions of Firefox and Google Chrome. HTML <table class="bordered"> <thead> <tr> <th>&l...

How to Auto-start an Android Application?

I'm not sure how to autostart an android application after the android emulator completes its booting. Does anyone have any code snippets that will help me?...

jQuery Validation plugin: disable validation for specified submit buttons

I have a form with multiple fields that I'm validating (some with methods added for custom validation) with Jörn Zaeffere's excellent jQuery Validation plugin. How do you circumvent validation with specified submit controls (in other words, fire val...

How to request a random row in SQL?

How can I request a random row (or as close to truly random as is possible) in pure SQL?...

Removing empty rows of a data file in R

I have a dataset with empty rows. I would like to remove them: myData<-myData[-which(apply(myData,1,function(x)all(is.na(x)))),] It works OK. But now I would like to add a column in my data and initialize the first value: myData$newCol[1] <...

How to recursively find the latest modified file in a directory?

It seems that ls doesn't sort the files correctly when doing a recursive call: ls -altR . | head -n 3 How can I find the most recently modified file in a directory (including subdirectories)?...

Convert number of minutes into hours & minutes using PHP

I have a variable called $final_time_saving which is just a number of minutes, 250 for example. How can I convert that number of minutes into hours and minutes using PHP in this format: 4 hours 10 minutes...

Including dependencies in a jar with Maven

Is there a way to force maven(2.0.9) to include all the dependencies in a single jar file? I have a project the builds into a single jar file. I want the classes from dependencies to be copied into the jar as well. Update: I know that I cant just i...

Copy or rsync command

The following command is working as expected... cp -ur /home/abc/* /mnt/windowsabc/ Does rsync has any advantage over it? Is there a better way to keep to backup folder in sync every 24 hours?...

How can I get my webapp's base URL in ASP.NET MVC?

How can I quickly determine what the root URL is for my ASP.NET MVC application? I.e., if IIS is set to serve my application at http://example.com/foo/bar, then I'd like to be able to get that URL in a reliable way that doesn't involve getting the c...

virtualbox Raw-mode is unavailable courtesy of Hyper-V windows 10

issues: Failed to open a session for the virtual machine ubuntu. Raw-mode is unavailable courtesy of Hyper-V. (VERR_SUPDRV_NO_RAW_MODE_HYPER_V_ROOT). Result Code: E_FAIL (0x80004005) Component: ConsoleWrap Interface: IConsole {872da645-4a9b-1727-b...

How to do IF NOT EXISTS in SQLite

I am trying to port this line from MS SQL Server to SQLite IF NOT EXISTS(SELECT 1 FROM EVENTTYPE WHERE EventTypeName = 'ANI Received') INSERT INTO EVENTTYPE (EventTypeName) VALUES ('ANI Received'); It seems that SQLite does not support IF NOT...

Multi-dimensional associative arrays in JavaScript

There is the following query results: (key1 and key2 could be any text) id key1 key2 value 1 fred apple 2 2 mary orange 10 3 fred banana 7 4 fred orange 4 5 sarah melon 5 ... and I wish to s...

HTML Input Box - Disable

what is the code to disable an INPUT text box for HTML? Thanks...

Add MIME mapping in web.config for IIS Express

I need to add a new MIME mapping for .woff file extensions to IIS Express. If I add the following snippet to the "applicationhost.config" of IIS Express it works fine: <staticContent lockAttributes="isDocFooterFileName"> <mimeMap fileE...

How to resolve git status "Unmerged paths:"?

I merged branch dog into animal. When I go to commit, I get the following: Unmerged paths: (use "git reset HEAD <file>..." to unstage) (use "git add <file>..." to mark resolution both deleted: ../public/images/o...

How to submit a form when the return key is pressed?

Can someone please tell me how to submit an HTML form when the return key is pressed and if there are no buttons in the form? The submit button is not there. I am using a custom div instead of that....

Difference between signature versions - V1 (Jar Signature) and V2 (Full APK Signature) while generating a signed APK in Android Studio?

Please select at least one of the signature versions to use in Android Studio 2.3 Now while generating a signed APK in Android Studio, it's showing two options (CheckBox) namely 1. V1 (Jar Signature) and 2. V2 (Full APK Signature) as Signature Versi...

Convert a String In C++ To Upper Case

How could one convert a string to upper case. The examples I have found from googling only have to deal with chars....

Sending mass email using PHP

I am currently writing a music blog. The administrator posts a new article every 2-3 days. Once the administrator posts an article, a mass email will be sent to around 5000 subscribers immediately. What is the best way to implement the mass mail fe...

window.location.href not working

My website is http://www.collegeanswerz.com/. I'm using rails. The code is for searching for colleges. I want the user to be able to type in the colleges name, click enter, and be taken to the url, rather than seeing the search results (if the use...

HTML5 form required attribute. Set custom validation message?

I've got the following HTML5 form: http://jsfiddle.net/nfgfP/ _x000D_ _x000D_ <form id="form" onsubmit="return(login())">_x000D_ <input name="username" placeholder="Username" required />_x000D_ <input name="pass" type="password" plac...

Column "invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause"

I would like to display the column B in my below SQL, but when I add it to the query it gives me the following error: Column T2.B' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY claus...

Check string length in PHP

I have a string that is 141 characters in length. Using the following code I have an if statement to return a message if the string is greater or less than 140. libxml_use_internal_errors(TRUE); $dom = new DOMDocument(); $dom->loadHTMLFile($sourc...

Why are unnamed namespaces used and what are their benefits?

I just joined a new C++ software project and I'm trying to understand the design. The project makes frequent use of unnamed namespaces. For example, something like this may occur in a class definition file: // newusertype.cc namespace { const in...

Cannot create a connection to data source Error (rsErrorOpeningConnection) in SSRS

I'm working on integrating a report into a browser, and I get this error: An error has occurred during report processing. (rsProcessingAborted) Cannot create a connection to data source 'dsFederatedSample_SurveyLevel_STG'. (rsErrorOpeningConnection)...

setting y-axis limit in matplotlib

I need help with setting the limits of y-axis on matplotlib. Here is the code that I tried, unsuccessfully. import matplotlib.pyplot as plt plt.figure(1, figsize = (8.5,11)) plt.suptitle('plot title') ax = [] aPlot = plt.subplot(321, axisbg = 'w', ...

How to push a docker image to a private repository

I have a docker image tagged as me/my-image, and I have a private repo on the dockerhub named me-private. When I push my me/my-image, I end up always hitting the public repo. What is the exact syntax to specifically push my image to my private repo?...

How to convert a Datetime string to a current culture datetime string

I have string say "12/1/2011" in English US culture my current machine culture is English Uk which is "dd/mm/yyyy" format. How to convert the 12/1/2011 to 1/12/2011. I have tried the below format. System.DateTime.Parse(result,System.Threading.Thread...

Count number of days between two dates

How do I count the number of days between these two dates? start_date = Date.parse "2012-03-02 14:46:21 +0100" end_date = Date.parse "2012-04-02 14:46:21 +0200" ...

How can I get a file's size in C++?

Let's create a complementary question to this one. What is the most common way to get the file size in C++? Before answering, make sure it is portable (may be executed on Unix, Mac and Windows), reliable, easy to understand and without library depend...

jQuery get text as number

This code doesn't work: var number = $(this).find('.number').text(); var current = 600; if (current > number){ // do something } HTML: <div class="number">400</div> Seems there is some problem with converting text() from tex...

Can a main() method of class be invoked from another class in java

Can a main() method of class be invoked in another class in java? e.g. class class1{ public static void main(String []args){ } } class class2{ public static void main(String []args){ class1.main(); } } ...

Connect multiple devices to one device via Bluetooth

I would like to create a game, where you must connect multiple devices (4+) to a main device (ex. a tablet) via Bluetooth. There would be two apps, a main one to which all data would be send from the phones, and to the phones. Is that even possible?...

Error: The 'brew link' step did not complete successfully

I'm trying to install node.js via Homebrew. Unfortunately, I get this error: ? ~ brew install node ==> Downloading http://nodejs.org/dist/v0.8.10/node-v0.8.10.tar.gz ######################################################################## 100.0...

Populating a database in a Laravel migration file

I'm just learning Laravel, and have a working migration file creating a users table. I am trying to populate a user record as part of the migration: public function up() { Schema::create('users', function($table){ $table->increments(...

How to call an element in a numpy array?

This is a really simple question, but I didnt find the answer. How to call an element in an numpy array? import numpy as np arr = np.array([[1,2,3,4,5],[6,7,8,9,10]]) print arr(0,0) The code above doesn't work....

How to add elements of a Java8 stream into an existing List

Javadoc of Collector shows how to collect elements of a stream into a new List. Is there an one-liner that adds the results into an existing ArrayList?...

Most Pythonic way to provide global configuration variables in config.py?

In my endless quest in over-complicating simple stuff, I am researching the most 'Pythonic' way to provide global configuration variables inside the typical 'config.py' found in Python egg packages. The traditional way (aah, good ol' #define!) is a...

How to pass data using NotificationCenter in swift 3.0 and NSNotificationCenter in swift 2.0?

I'm implementing socket.io in my swift ios app. Currently on several panels I'm listening to the server and wait for incoming messages. I'm doing so by calling the getChatMessage function in each panel: func getChatMessage(){ SocketIOManager.s...

Center text output from Graphics.DrawString()

I'm using the .NETCF (Windows Mobile) Graphics class and the DrawString() method to render a single character to the screen. The problem is that I can't seem to get it centred properly. No matter what I set for the Y coordinate of the location of th...

Assign pandas dataframe column dtypes

I want to set the dtypes of multiple columns in pd.Dataframe (I have a file that I've had to manually parse into a list of lists, as the file was not amenable for pd.read_csv) import pandas as pd print pd.DataFrame([['a','1'],['b','2']], ...

Declaring a custom android UI element using XML

How do I declare an Android UI element using XML?...

IE7 Z-Index Layering Issues

I've isolated a little test case of IE7's z-index bug, but don't know how to fix it. I have been playing with z-index all day long. What is wrong with z-index in IE7? Test CSS: input { border: 1px solid #000; } div { border: 1px solid #0...

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

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

How to get the latest file in a folder?

I need to get the latest file of a folder using python. While using the code: max(files, key = os.path.getctime) I am getting the below error: FileNotFoundError: [WinError 2] The system cannot find the file specified: 'a'...

ORA-00942: table or view does not exist (works when a separate sql, but does not work inside a oracle function)

When I have a sql statement like select * from table1, it works great, but as soon as I put it into a function, I get: ORA-00942: table or view does not exist How to solve this?...

How to register ASP.NET 2.0 to web server(IIS7)?

I have a web-page application already created, but when I open it in visual studio 2008, it says there that: ASP.NET 2.0 has not been registered on the Web Server. You need to manually configure you Web server for ASP.NET 2.0 in order for your ...

How do I horizontally center a span element inside a div

I am trying to center the two links 'view website' and 'view project' inside the surrounding div. Can someone point out what I need to do to make this work? JS Fiddle: http://jsfiddle.net/F6R9C/ HTML <div> <span> <a href="#" t...

Best practice for partial updates in a RESTful service

I am writing a RESTful service for a customer management system and I am trying to find the best practice for updating records partially. For example, I want the caller to be able to read the full record with a GET request. But for updating it only c...

Select something that has more/less than x character

Was wondering if it's possible to select something that has more/less than x characters in SQL. For example, I have an employee table and I want to show all employee names that has more than 4 characters in their name. Here's an example table ID E...

How to make "if not true condition"?

I would like to have the echo command executed when cat /etc/passwd | grep "sysa" is not true. What am I doing wrong? if ! [ $(cat /etc/passwd | grep "sysa") ]; then echo "ERROR - The user sysa could not be looked up" exit 2 fi ...

Call Stored Procedure within Create Trigger in SQL Server

I have a stored procedure named insert2Newsletter with parameters (@sex nvarchar(10), @f_name nvarchar(50), @l_name nvarchar(70), @email nvarchar(75), @ip_address nvarchar(50), @hotelID int, @maArt nchar(2)) I want call this stored procedure in a...

In Java, can you modify a List while iterating through it?

I understand that in Java a Collection<E> should not be modified while iterating through it, such as removing or adding elements. But what about changing the elements in a List? For example, what if we have List<String> letters = new Arr...

Remove a specific string from an array of string

I have an array like this: String n[] = {"google","microsoft","apple"}; What I want to do is to remove "apple". My problem is very basic,however,I searched the website and I found out that java doesn't really support the deleting feature from an...

No grammar constraints (DTD or XML schema) detected for the document

I have this dtd : http://fast-code.sourceforge.net/template.dtd But when I include in an xml I get the warning : No grammar constraints (DTD or XML schema) detected for the document. The xml is : <?xml version="1.0" encoding="UTF-8"?> <!D...

Is it safe to expose Firebase apiKey to the public?

The Firebase Web-App guide states I should put the given apiKey in my Html to initialize Firebase: // TODO: Replace with your project's customized code snippet <script src="https://www.gstatic.com/firebasejs/3.0.2/firebase.js"></script> ...

Remove the complete styling of an HTML button/submit

Is there a way of completely removing the styling of a button in Internet Explorer? I use a css sprite for my button, and everything looks ok. But when I click the button, it moves to the top a little, it makes it look out of shape. Is there a css ...

How to search for file names in Visual Studio?

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

How can I find out if an .EXE has Command-Line Options?

Suppose you have an .EXE and you want to check if it has Command-Line Options. How can one know if the .EXE has this ability. In my case I know that Nir Sofers WebBrowserPassView.exe has the ability to start it via cmd.exe and WebBrowserPassView.exe ...

How do you rebase the current branch's changes on top of changes being merged in?

Okay. If I'm on a branch (say working), and I want to merge in the changes from another branch (say master), then I run the command git-merge master while on the working branch, and the changes get merged in without rebasing the history at all. If I ...

How to get Linux console window width in Python

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

What is going wrong when Visual Studio tells me "xcopy exited with code 4"

I'm not very familiar with post-build events, so I'm a little confused as to what's going wrong with my program. When compiling in visual studio 2010, I get the following: The command "xcopy C:\Users\Me\Path\Foo.bar\Library\dsoframer.ocx C:\Users\Me...

Convert seconds to hh:mm:ss in Python

How do I convert an int (number of seconds) to the formats mm:ss or hh:mm:ss? I need to do this with Python code (and if possible in a Django template)....

Swift performSelector:withObject:afterDelay: is unavailable

I have an app in Objective C that I'm transitioning to Swift. In Objective C, I have this method: [self.view performSelector:@selector(someSelector) withObject:self afterDelay:0.1f]; I'm working with Swift and I can't figure out how to do this. I'v...

How do I serialize an object and save it to a file in Android?

Say I have some simple class and once it's instantiated as an object I want to be able to serialize its contents to a file, and retrieve it by loading that file at some later time... I'm not sure where to start here, what do I need to do to serialize...

How to use onResume()?

Can anyone give me an example that uses onResume() in Android? Also, if I want to restart the activity at the end of the execution of another, which method is executed—onCreate() or onResume()? And if I want to update data, how do I put it in onR...

Is it possible to add an HTML link in the body of a MAILTO link

I have not had to mess with mailto links much. However I now need to add a link in the body of a mailto if it is possible. Is there a way to add a link or to change the email opened to an html email vs a text email? Something like: <a href="...

How to check if field is null or empty in MySQL?

I am trying to figure out how to check if a field is NULL or empty. I have this: SELECT IFNULL(field1, 'empty') as field1 from tablename I need to add an additional check field1 != "" something like: SELECT IFNULL(field1, 'empty') OR field...

How to execute an Oracle stored procedure via a database link

Can I call a stored procedure in Oracle via a database link? The database link is functional so that syntax such as... SELECT * FROM myTable@myRemoteDB is functioning. But is there a syntax for... EXECUTE mySchema.myPackage.myProcedure('somePar...

Multi-character constant warnings

Why is this a warning? I think there are many cases when is more clear to use multi-char int constants instead of "no meaning" numbers or instead of defining const variables with same value. When parsing wave/tiff/other file types is more clear to co...

How do I force Maven to use my local repository rather than going out to remote repos to retrieve artifacts?

I’m using Maven 3.3.3 with Java 8 on Mac Yosemite. I have a multi-module project. <modules> <module>first-module</module> <module>my-module</module> … </modules>...

Current Subversion revision command

Is there a Subversion command to show the current revision number? After svn checkout I want to start a script and need the revision number in a variable. It would be great if there is a command like svn info get_revision_number....

How to connect to a remote MySQL database with Java?

I am trying to create a JSF application using the Eclipse IDE. I am using a remote mySQL server as my database. How do I connect to this remote database for creating tables and accessing them?...

Case vs If Else If: Which is more efficient?

Possible Duplicates: is “else if” faster than “switch() case” ? What is the relative performance of if/else vs. switch in Java? Ive been coding-in-the-run again....when the debugger steps through a case statement ...

SELECT max(x) is returning null; how can I make it return 0?

How do you return 0 instead of null when running the following command: SELECT MAX(X) AS MaxX FROM tbl WHERE XID = 1 (Assuming there is no row where XID=1)...

How to pass html string to webview on android

Hi I am parsing xml and then loading it to web view, after parsing I am creating four strings so that I could append all string to one view. I am able to get two views on the web view but not the first two strings. Pls suggest me with my code, wher...

Error: Microsoft Visual C++ 10.0 is required (Unable to find vcvarsall.bat) when running Python script

Im trying to install numpy with PyCharm but i keep getting this error: error: Microsoft Visual C++ 10.0 is required (Unable to find vcvarsall.bat). Can someone please explain to me exactly what i have to do to fix this error(and as simple an...

Binding an Image in WPF MVVM

I am having some trouble binding in Image to my viewmodel. I finally got rid of the XamlParseException, but the image does not come up. I even hard coded the image in the ViewModel. Can someone see what I am doing wrong? View: <...

How to reset or change the passphrase for a GitHub SSH key?

I have forgoten my passphrase in Git. How do I reset it? I found two solutions on Stack Overflow, but I want to know what process to follow to reset it or to get it....

What jsf component can render a div tag?

Eg: h:inputText will render a "input type='text'". What jsf tag can render a "div" tag?...

Build android release apk on Phonegap 3.x CLI

How can I build an android app locally using the Phonegap 3.x CLI, ready to release? I check the bin folder generated inside the platforms/android directory of the project, and only has .debug APKs. By the way, I use this command: phonegap local bui...

JQuery wait for page to finish loading before starting the slideshow?

I have a site with a rotating header image (you've all seen them). I want to do the following: Load the entire page plus the first header image Start the header image slideshow transitioning every x seconds or when the next image has finished loadi...

How to identify which columns are not "NA" per row in a matrix?

I have a matrix with 12 rows and 77 columns, but to simply lets use: p <- matrix(NA,5,7) p[1,2]<-0.3 p[1,3]<-0.5 p[2,4]<-0.9 p[2,7]<-0.4 p[4,5]<-0.6 I want to know which columns are not "NA" per row, so what I would ...

Convert list to tuple in Python

I'm trying to convert a list to a tuple. Most solutions on Google offer the following code: l = [4,5,6] tuple(l) However, the code results in an error message when I run it: TypeError: 'tuple' object is not callable How can I fix this problem?...

ionic build Android | error: No installed build tools found. Please install the Android build tools

When I run ionic build android command in root of ionic project, I am getting this error: FAILURE: Build failed with an exception. Where: Script '/home/javad/Desktop/javadApp/platforms/android/CordovaLib/cordova.gradle' line: 64 What ...

If hasClass then addClass to parent

Original post: Why doesn't this simple script work? if ($('#navigation > ul > li > ul > li > a').hasClass('.active')) { $(this).parent().parent().parent().addClass(".active"); } EDIT: This won't hide the H1: if ($('#content h1...

How to Batch Rename Files in a macOS Terminal?

I have a folder with a series of files named: prefix_1234_567.png prefix_abcd_efg.png I'd like to batch remove one underscore and the middle content so the output would be: prefix_567.png prefix_efg.png Relevant but not completely explanatory: ...

How to send Request payload to REST API in java?

I want to retrieve the JSON data from the following: https://git.eclipse.org/r/#/c/11376/ Request URL: https://git.eclipse.org/r/gerrit/rpc/ChangeDetailService Request Method: POST Request Headers: Accept:application/json Content-Type:applicatio...

How would I check a string for a certain letter in Python?

How would I tell Python to check the below for the letter x and then print "Yes"? The below is what I have so far... dog = "xdasds" if "x" is in dog: print "Yes!" ...

How to print last two columns using awk

All I want is the last two columns printed....

update to python 3.7 using anaconda

Python 3.7 alpha version is out, but I haven't been able to find any post on how to update to python 3.7 using Anaconda - maybe they will wait for the official release? Any suggestions?...

Android studio logcat nothing to show

I installed Android Studio yesterday, and I tried to use the LogCat to see the logs. But there is nothing to show in the logcat. I used the terminal to run ./adb logcat and it works. Is there someone who can explain to me how to use logcat in Andr...

How do I convert a string to enum in TypeScript?

I have defined the following enum in TypeScript: enum Color{ Red, Green } Now in my function I receive color as a string. I have tried the following code: var green= "Green"; var color : Color = <Color>green; // Error: can't convert str...

Remove the last chars of the Java String variable

A java String variable whose value is String path = "http://cdn.gs.com/new/downloads/Q22010MVR_PressRelease.pdf.null" I want to remove the last four characters i.e., .null. Which method I can use in order to split....

How to set 'X-Frame-Options' on iframe?

If I create an iframe like this: var dialog = $('<div id="' + dialogId + '" align="center"><iframe id="' + frameId + '" src="' + url + '" width="100%" frameborder="0" height="'+frameHeightForIe8+'" data-ssotoken="' + token + '"></ifr...

Getting and removing the first character of a string

I would like to do some 2-dimensional walks using strings of characters by assigning different values to each character. I was planning to 'pop' the first character of a string, use it, and repeat for the rest of the string. How can I achieve somet...

How to filter multiple values (OR operation) in angularJS

I want to use the filter in angular and want to filter for multiple values, if it has either one of the values then it should be displayed. I have for example this structure: An object movie which has the property genres and I want to filter for ...

How to read embedded resource text file

How do I read an embedded resource (text file) using StreamReader and return it as a string? My current script uses a Windows form and textbox that allows the user to find and replace text in a text file that is not embedded. private void button1_...

Django: save() vs update() to update the database?

I'm writing a Django app, and I need a function to update a field in the database. Is there any reason to do one of these methods rather than the other? def save_db_field(name,field,value): obj = MyModel.objects.get(name=name) obj.field = v...

how to delete a specific row in codeigniter?

I am new in codeigniter.In my view page I am showing the data from database in a table where I have two anchor tags for update and delete. I want to delete a specific row from database through id. my view page is <?php foreach($query as $row){...

Assigning the output of a command to a variable

I am new with unix and I am writing a shell script. When I run this line on the command prompt, it prints the total count of the number of processes which matches: ps -ef | awk '/siebsvc –s siebsrvr/ && !/awk/ { a++ } END { print a }' ...

"cannot resolve symbol R" in Android Studio

In every instance in all of my classes where I reference R.id.something, the R is in red and it says "cannot resolve symbol R". Also every time there is R.layout.something it is underlined in red and says "cannot resolve method setContentView(?)". T...

jQuery ajax call to REST service

I'm trying to make an ajax call from jquery to a rest service. The rest service used is right from a tutorial of mkyong's blog, this one: http://www.mkyong.com/webservices/jax-rs/integrate-jackson-with-resteasy/ The service works, but when i try to ...

SELECT INTO USING UNION QUERY

I want to create a new table in SQL Server with the following query. I am unable to understand why this query doesn't work. Query1: Works SELECT * FROM TABLE1 UNION SELECT * FROM TABLE2 Query2: Does not Work. Error: Msg 170, Level 15, State 1, ...

Where should my npm modules be installed on Mac OS X?

I was attempting to upgrade phonegap via npm when I started running into trouble. Long story short, there are two node_modules directories on my computer. /usr/local/lib/node_modules /usr/local/share/npm/lib/node_modules When I run npm upgrade -g ...

Detecting the character encoding of an HTTP POST request

I'm building a web service and have a node that accepts a POST to create a new resource. The resource expects one of two content-types - an XML format I'll be defining, or form-encoded variables. The idea is that consuming applications can POST XML...

How to skip the first n rows in sql query

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

How to autowire RestTemplate using annotations

When I try to autowire Spring RestTemplate, I am getting following error: nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.web.client.RestTemplate] found for depende...

Remove a character at a certain position in a string - javascript

Is there an easy way to remove the character at a certain position in javascript? e.g. if I have the string "Hello World", can I remove the character at position 3? the result I would be looking for would the following: "Helo World&quo...

How do I 'overwrite', rather than 'merge', a branch on another branch in Git?

I have two branches, email and staging. staging is the latest one and I no longer need the old changes in email branch, yet I don't want to delete them. So I just want to dump all the contents of staging into email so that they both point to the sam...

Deny direct access to all .php files except index.php

I want to deny direct access to all .php files except one: index.php The only access to the other .php files should be through php include. If possible I want all files in the same folder. UPDATE: A general rule would be nice, so I don't need to ...

How can I read input from the console using the Scanner class in Java?

How could I read input from the console using the Scanner class? Something like this: System.out.println("Enter your username: "); Scanner = input(); // Or something like this, I don't know the code Basically, all I want is have the scanner read a...

What does FETCH_HEAD in Git mean?

git pull --help says: In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD. What is this FETCH_HEAD and what is actually merged during git pull?...

Determine if variable is defined in Python

How do you know whether a variable has been set at a particular place in the code at runtime? This is not always obvious because (1) the variable could be conditionally set, and (2) the variable could be conditionally deleted. I'm looking for somethi...

Execute a file with arguments in Python shell

I would like to run a command in Python Shell to execute a file with an argument. For example: execfile("abc.py") but how to add 2 arguments?...

How to find the most recent file in a directory using .NET, and without looping?

I need to find the most recently modified file in a directory. I know I can loop through every file in a folder and compare File.GetLastWriteTime, but is there a better way to do this without looping?....

Playing MP4 files in Firefox using HTML5 video

I have searched around quite a bit but have not solved my problem. I have a video tag running as follows: <video class="ne" src="{{ page | video_url }}" muted="true" volume="0" controls width="720" height="480" poster="...

Creating an instance using the class name and calling constructor

Is there a way to create an instance of a particular class given the class name (dynamic) and pass parameters to its constructor. Something like: Object object = createInstance("mypackage.MyClass","MyAttributeValue"); Where "MyAttributeValue" is ...

bash: Bad Substitution

#!/bin/bash jobname="job_201312161447_0003" jobname_pre=${jobname:0:16} jobname_post=${jobname:17} This bash script gives me Bad substitution error on Ubuntu. Any help will be highly appreciated....

Untrack files from git temporarily

I have setup a local git on my machine. When I initialized git, I added pre-compiled libs and binaries. However, now during my development I don't want to check in those files intermittently. I dont want to remove these files from repo. Is there any ...

Is it possible to send a variable number of arguments to a JavaScript function?

Is it possible to send a variable number of arguments to a JavaScript function, from an array? var arr = ['a','b','c'] var func = function() { // debug alert(arguments.length); // for(arg in arguments) alert(arg); } func(...

How to get the instance id from within an ec2 instance?

How can I find out the instance id of an ec2 instance from within the ec2 instance?...

How to add a new object (key-value pair) to an array in javascript?

I have an array as : items=[{'id':1},{'id':2},{'id':3},{'id':4}]; How should I add a new pair {'id':5} to the array?...

CASE (Contains) rather than equal statement

Is there a method to use contain rather than equal in case statement? For example, I am checking a database table has an entry lactulose, Lasix (furosemide), oxazepam, propranolol, rabeprazole, sertraline, Can I use CASE When dbo.Table.Column ...

milliseconds to days

i did some research, but still can't find how to get the days... Here is what I got: int seconds = (int) (milliseconds / 1000) % 60 ; int minutes = (int) ((milliseconds / (1000*60)) % 60); int hours = (int) ((milliseconds / (1000*60*60)) % 24); in...

Sorting by date & time in descending order?

all I want to display last 5 entered data for specific id. My sql query is, SELECT id, name, form_id, DATE(updated_at) as date FROM wp_frm_items WHERE user_id = 11 && form_id=9 ORDER BY updated_at DESC updated_at is DATETIME...

Set Radiobuttonlist Selected from Codebehind

Hey I have a radiobuttonlist and trying to set one of the radiobuttons to selected based on a session variable but proving impossible. <asp:radiobuttonlist id="radio1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList1_Se...

Output PowerShell variables to a text file

I'm new to PowerShell and have a script which loops through Active Directory searching for certain computers. I get several variables and then run functions to check things like WMI and registry settings. In the console, my script runs great and sim...

How do I count a JavaScript object's attributes?

Suppose I have the following object in JavaScript: var object = { "key1": "value1", "key2": "value2", "key3": "value3" }; How do I find out how many values exist in the object?...

How to use both onclick and target="_blank"

Code is as following: <p class="downloadBoks" onclick="location.href='Prosjektplan.pdf'">Prosjektbeskrivelse</p> Works fine like this, but it opens the file in the same window. I want to apply the target="_blank". But after some go...

CSS hover vs. JavaScript mouseover

There are times when I have a choice between using a CSS element:hover or JavaScript onmouseover to control the appearance of html elements on a page. Consider the following scenario where a div wraps an input <div> <input id="input"> &...

How to do a "Save As" in vba code, saving my current Excel workbook with datestamp?

I have an Excel Workbook that on form button click I want to save a copy of the workbook with the filename being the current date. I keep trying the the following ActiveWorkbook.SaveAs ("\\filePath\FormFlow To MSExcel\" & Left(Now(), 10)) but am...

Mockito matcher and array of primitives

With Mockito, I want to verify() a method call with byte[] in its argument list, but I didn't find how to write this. myMethod( byte[] ) I just want something like anyByteArray(), how to do that with Mockito ?...

How do I do a not equal in Django queryset filtering?

In Django model QuerySets, I see that there is a __gt and __lt for comparative values, but is there a __ne or != (not equals)? I want to filter out using a not equals. For example, for Model: bool a; int x; I want to do results = Model.objec...

Correct way to quit a Qt program?

How should I quit a Qt Program, e.g when loading a data file, and discovered file corruption, and user need to quit this app or re-initiate data file? Should I: call exit(EXIT_FAILURE) call QApplication::quit() call QCoreApplication::quit() And ...

How do I align views at the bottom of the screen?

Here's my layout code; <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill...

How to set min-height for bootstrap container

I have some issues with the container in bootstrap. My goal is to have a container which is only as high as the content. For example: <div class="container"> <img src="#.jpg" height="200px" width="300px"> </div> In the example ...

How to find all combinations of coins when given some dollar value

I found a piece of code that I was writing for interview prep few months ago. According to the comment I had, it was trying to solve this problem: Given some dollar value in cents (e.g. 200 = 2 dollars, 1000 = 10 dollars), find all the combinati...

How to convert DateTime? to DateTime

I want to convert a nullable DateTime (DateTime?) to a DateTime, but I am getting an error: Cannot implicitly convert type 'System.DateTime?' to 'System.DateTime'. An explicit conversion exists (are you missing a cast?) I have attempted th...

mongodb/mongoose findMany - find all documents with IDs listed in array

I have an array of _ids and I want to get all docs accordingly, what's the best way to do it ? Something like ... // doesn't work ... of course ... model.find({ '_id' : [ '4ed3ede8844f0f351100000c', '4ed3f117a844e0471100000d', ...

What's the most efficient way to check if a record exists in Oracle?

A) select decode(count(*), 0, 'N', 'Y') rec_exists from (select 'X' from dual where exists (select 'X' from sales where sales_type = 'Accessories')); B) select decode(count(*), 0, 'N', 'Y') rec...

What's the point of the X-Requested-With header?

JQuery and other frameworks add the following header: X-Requested-With: XMLHttpRequest Why is this needed? Why would a server want to treat AJAX requests differently than normal requests? UPDATE: I just found a real-life example using this hea...

Sublime Text 3, convert spaces to tabs

I know there are a lot of posts about this, but I couldn´t get it to work. I use tabs for coding. Is there a way, to convert always spaces to tabs? I.e. on open and on Save files? Anyone got an idea? // edit: My desire is to do this automatically! ...

node.js hash string?

I have a string that I want to hash. What's the easiest way to generate the hash in node.js? The hash is for versioning, not security....

How to create a directory using Ansible

How do you create a directory www at /srv on a Debian-based system using an Ansible playbook?...

What's the best way to add a full screen background image in React Native

I wanted to add a full-screen image to the View so I write this code return ( <View style={styles.container}> <Image source={require('image!egg')} style={styles.backgroundImage}/> </View> ) and defined the style ...

How to read file from relative path in Java project? java.io.File cannot find the path specified

I have a project with 2 packages: tkorg.idrs.core.searchengines tkorg.idrs.core.searchengines In package (2) I have a text file ListStopWords.txt, in package (1) I have a class FileLoadder. Here is code in FileLoader: File file = new File("prop...

The name 'model' does not exist in current context in MVC3

I added a cshtml page in an project. When I tried to add the following declaration to it, I get an error: "The name 'model' does not exist in current context". @model xyz.abc.SomeClass I checked the references, all of them are in place. I added a ...

MySql: is it possible to 'SUM IF' or to 'COUNT IF'?

I have a column 'hour' I have a column 'kind' (it can be 1,2 or 3) I'd like to do something like: SELECT count(id), SUM(hour) as totHour, SUM( IF ( kind = 1, 1, 0 ) ) as countKindOne or SELECT count(id), SUM(hour) as totHour, COUNT( IF ( kind ...

How would I find the second largest salary from the employee table?

How would I go about querying for the second largest salary from all employees in my Employee table?...

how to apply click event listener to image in android

i want to apply an onClickListener event to an imageView, how do I accomplish this? Can anyone provide me with some source code examples...

How do I set the colour of a label (coloured text) in Java?

How do I set the color of the text of a label? myLabel.setText("Text Color: Red"); myLabel.??? Can I have two seperate colors in one label? For example here: The "Text Color:" to be black and the "Red" to be red....

How to get the length of an array in C? Is "sizeof" a solution?

Possible Duplicate: Sizeof an array in the C programming language? Why does a C-Array have a wrong sizeof() value when it's passed to a function? See the below code and suggest me that what is the difference of "sizeof" keyword when I us...

stringstream, string, and char* conversion confusion

My question can be boiled down to, where does the string returned from stringstream.str().c_str() live in memory, and why can't it be assigned to a const char*? This code example will explain it better than I can #include <string> #include &l...

How to append rows to an R data frame

I have looked around StackOverflow, but I cannot find a solution specific to my problem, which involves appending rows to an R data frame. I am initializing an empty 2-column data frame, as follows. df = data.frame(x = numeric(), y = character()) ...

How to hide output of subprocess in Python 2.7

I'm using eSpeak on Ubuntu and have a Python 2.7 script that prints and speaks a message: import subprocess text = 'Hello World.' print text subprocess.call(['espeak', text]) eSpeak produces the desired sounds, but clutters the shell with some err...

What is a magic number, and why is it bad?

What is a magic number? Why should it be avoided? Are there cases where it's appropriate?...

jQuery.getJSON - Access-Control-Allow-Origin Issue

I'm jusing jQuery's $.getJSON() function to return a short set of JSON data. I've got the JSON data sitting on a url such as example.com. I didn't realize it, but as I was accessing that same url, the JSON data couldn't be loaded. I followed throu...

Import existing source code to GitHub

How can I import source code from my computer to my GitHub account?...

Understanding SQL Server LOCKS on SELECT queries

I'm wondering what is the benefit to use SELECT WITH (NOLOCK) on a table if the only other queries affecting that table are SELECT queries. How is that handled by SQL Server? Would a SELECT query block another SELECT query? I'm using SQL Server 201...

@class vs. #import

It is to my understanding that one should use a forward-class declaration in the event ClassA needs to include a ClassB header, and ClassB needs to include a ClassA header to avoid any circular inclusions. I also understand that an #import is a simpl...

CSS Circle with border

Every guide I find has the line and fill the same colour. All I want is a circle with a red line and white fill. I have tried: .circle { border: red; background-color: #FFFFFF; height: 100px; -moz-border-radius:75px; -webkit-bor...

Disable and later enable all table indexes in Oracle

How would I disable and later enable all indexes in a given schema/database in Oracle? Note: This is to make sqlldr run faster....

Remove values from select list based on condition

I have the following in the page <select name="val" size="1" > <option value="A">Apple</option> <option value="C">Cars</option> <option value="H">Honda</option> <option value="F">Fiat</option> &l...

What does 'wb' mean in this code, using Python?

Code: file('pinax/media/a.jpg', 'wb') ...

var.replace is not a function

I'm using the below code to try to trim the string in Javascript but am getting the error mentioned in the title: function trim(str) { return str.replace(/^\s+|\s+$/g,''); } Edit: I fixed the problem.... sorry I should have put the code on ho...

How do JavaScript closures work?

How would you explain JavaScript closures to someone with a knowledge of the concepts they consist of (for example functions, variables and the like), but does not understand closures themselves? I have seen the Scheme example given on Wikipedia, bu...

How to send json data in the Http request using NSURLRequest

I'm new to objective-c and I'm starting to put a great deal of effort into request/response as of recent. I have a working example that can call a url (via http GET) and parse the json returned. The working example of this is below - (void)connect...

Loading/Downloading image from URL on Swift

I'd like to load an image from a URL in my application, so I first tried with Objective-C and it worked, however, with Swift, I've a compilation error: 'imageWithData' is unavailable: use object construction 'UIImage(data:)' My function: @IB...

open resource with relative path in Java

In my Java app I need to get some files and directories. This is the program structure: ./main.java ./package1/guiclass.java ./package1/resources/resourcesloader.java ./package1/resources/repository/modules/ -> this is the dir I need to get ./pa...