Examples On Programing Languages

Call parent method from child class c#

This is a slightly different question from previous answers I have seen or I am not getting it. I have a parent class with a method named MyMethod() and a variable public Int32 CurrentRow; public void MyMethod() { this.UpdateProgressBar(); ...

Activate a virtualenv with a Python script

I want to activate a virtualenv instance from a Python script. I know it's quite easy to do, but all the examples I've seen use it to run commands within the env and then close the subprocess. I simply want to activate the virtualenv and return to ...

How to format column to number format in Excel sheet?

Below is the VBA code. Sheet2 contains all of the values in general format. After running the code, values in column 'C' of Sheet3 contain exponential values for numbers which are 13 or more digits. What should be done so that column 'C' of Sheet3...

Matplotlib: Specify format of floats for tick labels

I am trying to set the format to two decimal numbers in a matplotlib subplot environment. Unfortunately, I do not have any idea how to solve this task. To prevent using scientific notation on the y-axis I used ScalarFormatter(useOffset=False) as you...

Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project

When creating a new Java project in IntelliJ IDEA, the following directories and files are created: ./projectname.iml ./projectname.ipr ./projectname.iws ./src/ I want to configure IntelliJ IDEA to include my dependency JARs in ./lib/*.jar to the ...

How can I save a screenshot directly to a file in Windows?

Is there a one button way to save a screenshot directly to a file in Windows? TheSoftwareJedi accurately answered above question for Windows 8 and 10. Below original extra material remains for posterity. This is a very important question as the 31...

Python Save to file

I would like to save a string to a file with a python program named Failed.py Here is what I have so far: myFile = open('today','r') ips = {} for line in myFile: parts = line.split(' ') if parts[1] == 'Failure': if parts[0] in ips...

Calculating distance between two points (Latitude, Longitude)

I am trying to calculate the distance between two positions on a map. I have stored in my data: Longitude, Latitude, X POS, Y POS. I have been previously using the below snippet. DECLARE @orig_lat DECIMAL DECLARE @orig_lng DECIMAL SET @orig_lat=53....

Date only from TextBoxFor()

I'm having trouble displaying the only date part of a DateTime into a textbox using TextBoxFor<,>(expression, htmlAttributes). The model is based on Linq2SQL, field is a DateTime on SQL and in the Entity model. Failed: <%= Html.TextBoxFor(mo...

Closing pyplot windows

Final Edit: What I found on the subject of closing pyplot windows is that it really probably shouldn't be done using pyplot. SRK gives a great example on how to handle plots that will be updated in his answer below. Also I have stumbled across ho...

TypeError: $(...).autocomplete is not a function

I am getting the above error using the following code inside a Drupal module. jQuery(document).ready(function($) { $("#search_text").autocomplete({ source:results, minLength:2, position: { offset:'-30 0' }...

Access IP Camera in Python OpenCV

How do I access my IP Camera stream? Code for displaying a standard webcam stream is import cv2 import numpy as np cap = cv2.VideoCapture(0) while(True): ret, frame = cap.read() cv2.imshow('frame',frame) if cv2.waitKey(1) & 0xFF == ...

Best Free Text Editor Supporting *More Than* 4GB Files?

I am looking for a text editor that will be able to load a 4+ Gigabyte file into it. Textpad doesn't work. I own a copy of it and have been to its support site, it just doesn't do it. Maybe I need new hardware, but that's a different question. T...

java SSL and cert keystore

How does my java program know where my keystore containing the certificate is? Or alternatively how do I tell my java program where to look for the keystore? After specifying the keystore in some way, how to specify the certificate to use for authen...

data.table vs dplyr: can one do something well the other can't or does poorly?

Overview I'm relatively familiar with data.table, not so much with dplyr. I've read through some dplyr vignettes and examples that have popped up on SO, and so far my conclusions are that: data.table and dplyr are comparable in speed, except when...

How to properly overload the << operator for an ostream?

I am writing a small matrix library in C++ for matrix operations. However my compiler complains, where before it did not. This code was left on a shelf for 6 months and in between I upgraded my computer from debian etch to lenny (g++ (Debian 4.3.2-1....

Popup window in winform c#

I'm working on a project where I need a popup window. But the thing is I also want to be able to add textboxes etc in this popup window thru the form designer. So basically I have a button and when you click on it it will open another window that I'...

How to copy a file to another path?

I need to copy a file to another path, leaving the original where it is. I also want to be able to rename the file. Will FileInfo's CopyTo method work?...

how to get the ipaddress of a virtual box running on local machine

I need to connect to my virtual box running on my local machine to transfer files from my local system to VM by using WinSCP. How do I find the IP address? When I go to the settings and network tab, there I find something related to IP, but when I u...

How prevent CPU usage 100% because of worker process in iis

My CPU usage is 100% most of the the time in Windows Server 2008-R2 with my own vps, vmware, quad core, and 4GB Ram. When I open windows Task Manager and go to the resource monitor I see that 100% usage is because of workerprocess.exe. I have 3 webs...

Switch in Laravel 5 - Blade

How can I use switch in blade templates? When I used: @switch($login_error) @case(1) `E-mail` input is empty! @break @case(2) `Password` input is empty! @break @endswitch in result I see this text as plainte...

How to correctly implement custom iterators and const_iterators?

I have a custom container class for which I'd like to write the iterator and const_iterator classes. I never did this before and I failed to find an appropriate how-to. What are the guidelines regarding iterator creation, and what should I be aware ...

Check if specific input file is empty

In my form I have 3 input fields for file upload: <input type=file name="cover_image"> <input type=file name="image1"> <input type=file name="image2"> How can I check if cover_image is empty - no file is put for upload?...

What's the simplest way of detecting keyboard input in a script from the terminal?

I have a simple python script, that has some functions that run in a loop (I'm taking sensor readings). while True: print "Doing a function" If the keyboard is pressed I'd like to print "key pressed". What's the simplest way of doing this in ...

"Are you missing an assembly reference?" compile error - Visual Studio

I am currently working on a server control for other applications in our company to interface with a WCF service. Every time I make a change code change and recompile the control, I increment the the AssemblyVerison and AssemblyFileVersion class in...

Difference between System.DateTime.Now and System.DateTime.Today

Can anyone explain the difference between System.DateTime.Now and System.DateTime.Today in C#.NET? Pros and cons of each if possible....

How to restart adb from root to user mode?

Basic question on ADB. adb root restarts adb as root. But what i want is to restart it back to user after some time. I tried the following : adb kill-server adb start-server doesnt work.. ps -A -> noted the process number of adb and killed it.....

Styling an anchor tag to look like a submit button

I have a form where there's a "Submit" button and a "Cancel" anchor. The HTML is this: <input type="submit" value="Submit" /> <a href="some_url">Cancel</a> I'd like for the two to look and act the same. Nothing fancy, just some...

Python-equivalent of short-form "if" in C++

Possible Duplicate: Python Ternary Operator Is there a way to write this C/C++ code in Python? a = (b == true ? "123" : "456" )...

Make more than one chart in same IPython Notebook cell

I have started my IPython Notebook with ipython notebook --pylab inline This is my code in one cell df['korisnika'].plot() df['osiguranika'].plot() This is working fine, it will draw two lines, but on the same chart. I would like to draw each...

Close Android Application

Please suggest how I may close my whole Android Application with one line code....

How to fix Error: this class is not key value coding-compliant for the key tableView.'

I made an app with Table View and Segmented Control, and this is my first time. I'm using some code and some tutorials, but It's not working. When I run my app It's crashing and it's showing this Error in logs: MyApplication[4928:336085] * Termin...

C#: how to get first char of a string?

Can the first char of a string be retrieved by doing the following? MyString.ToCharArray[0] ...

Telegram Bot - how to get a group chat id?

I've been using telegram_bot, and trying to get groupChat id to send notifications to group chat, but don't know which methods I have to use for it. For getting chat id I use to message.chat.id when the bot participated in the chat but which I have ...

String replacement in java, similar to a velocity template

Is there any String replacement mechanism in Java, where I can pass objects with a text, and it replaces the string as it occurs. For example, the text is : Hello ${user.name}, Welcome to ${site.name}. The objects I have are "user" and "site"...

String "true" and "false" to boolean

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

Difference between _self, _top, and _parent in the anchor tag target attribute

I know _blank opens a new tab when used with the anchor tag and also, there are self-defined targets I use when using framesets but I will like to know the difference between _parent, _self and _top....

How can I plot with 2 different y-axes?

I would like superimpose two scatter plots in R so that each set of points has its own (different) y-axis (i.e., in positions 2 and 4 on the figure) but the points appear superimposed on the same figure. Is it possible to do this with plot? Edit Ex...

How to show uncommitted changes in Git and some Git diffs in detail

How do I show uncommitted changes in Git? I STFW'ed, and these commands are not working: teyan@TEYAN-THINK MINGW64 /d/nano/repos/PSTools/psservice (teyan/psservice) $ git status On branch teyan/psservice Your branch is up-to-date with 'origin/teyan...

Batch file to split .csv file

I have a very large .csv file (>500mb) and I wish to break this up into into smaller .csv files in command prompt. (Basically trying to find a linux "split" function in Windows". This has to be a batch script as my machine only has windows installed...

Initialize empty vector in structure - c++

I have a struct: typedef struct user { string username; vector<unsigned char> userpassword; } user_t; I need to initialize userpassword with an empty vector: struct user r={"",?}; What should I put instead of ??...

How to send image to PHP file using Ajax?

my question is that is it possible to upload an image to a server using ajax(jquery) below is my ajax script to send text without page reload $(function() { //this submits a form $('#post_submit').click(function(event) { event.preventDefault(); var...

Can we open pdf file using UIWebView on iOS?

Can we open the pdf file from UIWebView?...

Multidimensional arrays in Swift

Edit: As Adam Washington points out, as from Beta 6, this code works as is, so the question is no longer relevant. I am trying to create and iterate through a two dimensional array: var array = Array(count:NumColumns, repeatedValue:Array(count:Num...

How to update Xcode from command line

I am trying to update Xcode from the command line. Initially I tried running: xcode-select --install which resulted in this message: xcode-select: error: command line tools are already installed, use "Software Update" to install updates So th...

How to read from a file or STDIN in Bash?

The following Perl script (my.pl) can read from either the file on the command line args or from STDIN: while (<>) { print($_); } perl my.pl will read from STDIN, while perl my.pl a.txt will read from a.txt. This is very handy. Wondering is...

Pytorch tensor to numpy array

I have a pytorch Tensor of size torch.Size([4, 3, 966, 1296]) I want to convert it to numpy array using the following code: imgs = imgs.numpy()[:, ::-1, :, :] Can anyone please explain what this code is doing ?...

Change GitHub Account username

I want to change my account's user name on GitHub, but I can't find how to do it. Is this possible at all? To clarify, I'm not talking about the user.name parameter in a git repository, but the username of the actual GitHub account....

How to get the background color code of an element in hex?

How do I get the background color code of an element? _x000D_ _x000D_ console.log($(".div").css("background-color"));_x000D_ <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>_x000D_ <div class="...

What does 'x packages are looking for funding' mean when running `npm install`?

I usually get "x packages are looking for funding." when running npm install on a react project. Any idea what that means?...

How to edit my Excel dropdown list?

How to edit my Excel dropdown list ? I went to Data -> Validation -> Settings, and in that I found the values as =Attribute_Brands. What I have to do to edit this?...

Excel VBA App stops spontaneously with message "Code execution has been halted"

From what I can see on the web, this is a fairly common complaint, but answers seem to be rarer. The problem is this: We have a number of Excel VBA apps which work perfectly on a number of users' machines. However on one machine they stop on certain...

sass --watch with automatic minify?

Is there a way to run: sass --watch a.scss:a.css but have a.css end up being minified? How would I avoid having to run a separate minification step as I compile my stylesheet?...

Python module for converting PDF to text

Is there any python module to convert PDF files into text? I tried one piece of code found in Activestate which uses pypdf but the text generated had no space between and was of no use. ...

postgresql - replace all instances of a string within text field

In postgresql, how do I replace all instances of a string within a database column? Say I want to replace all instances of cat with dog, for example. What's the best way to do this?...

What are the differences between a superkey and a candidate key?

What are the differences between a super key and a candidate key? I have already referred to wiki,dotnet spider and also Database Concepts 4th edition book. But I am unable to understand the concept. Can anyone please explain it with proper example?...

How to autosize and right-align GridViewColumn data in WPF?

How can I: right-align the text in the ID column make each of the columns auto size according to the text length of the cell with the longest visible data? Here is the code: <ListView Name="lstCustomers" ItemsSource="{Binding Path=Collection...

Where are static methods and static variables stored in Java?

For example: class A { static int i=0; static int j; static void method() { // static k=0; can't use static for local variables only final is permitted // static int L; } } Where will these variables be stored in Java...

Some projects cannot be imported because they already exist in the workspace error in Eclipse

I am trying to import a project that me and my co-worker have been working on.. and keep getting this error after I select-- "import" then "import existing project" then click archive file, and then I click next, and this error comes up: "Some proje...

Get/pick an image from Android's built-in Gallery app programmatically

I am trying to open an image / picture in the Gallery built-in app from inside my application. I have a URI of the picture (the picture is located on the SD card). Do you have any suggestions?...

React Native Responsive Font Size

I would like to ask how react native handle or do the responsive font. For example in iphone 4s i Have fontSize: 14, while in iphone 6 I have fontSize: 18....

does linux shell support list data structure?

this question is not the same as Does the shell support sets? i know lots of script language support list structure, such as python, python, ruby, and javascript, so what about linux shell? does shell support such syntax? for i in list: do pr...

Cross domain POST request is not sending cookie Ajax Jquery

Seems that something similar already has been discussed on stackoverflow, but i could not find exactly the same. I am trying to send Cookie with CORS(Cross-origin resource sharing), but it is not working. This is my code. $.ajax( { typ...

System.loadLibrary(...) couldn't find native library in my case

I want to use a existing native library from another Android project, so I just copied the NDK built library (libcalculate.so) to my new Android project. In my new Android project I created a folder libs/armeabi/ and put libcalculate.so there. There ...

Setting up SSL on a local xampp/apache server

I'm trying to access a Active Directory from my local webserver. To do this I'm using the latest version of xampp and a PHP script called adLDAP. If I understand things right, I need to enable SSL to access https URLs. I've tried to google it but wit...

How to center a (background) image within a div?

Is it possible to center a background image in a div? I have tried just about everything - but no success: <div id="doit"> Lorem Ipsum ... </div> //CSS #doit { background-image: url(images/pic.png); background-repeat: none; text-align...

Can I have a video with transparent background using HTML5 video tag?

We filmed a spokesperson on a green screen and have the video files ready in multiple formats. With Flash we could use the wmode transparent within the param and embed tags, but is there something similar to this with the video and source tags in H...

DateTime.ToString() format that can be used in a filename or extension?

I want to add a timestamp to filenames as files are created but most of the DateTime methods I've tried output something with spaces and slashes. For instance: Debug.WriteLine(DateTime.Now.ToString()); // <-- 9/19/2012 1:41:46 PM Debug.WriteLine(...

How to define static property in TypeScript interface

I just want to declare a static property in typescript interface? I have not found anywhere regarding this. interface myInterface { static Name:string; } Is it possible?...

The "backspace" escape character '\b': unexpected behavior?

So I'm finally reading through K&R, and I learned something within the first few pages, that there is a backspace escape character, \b. So I go to test it out, and there is some very odd behavior: #include <stdio.h> main () { printf(...

OnChange event handler for radio button (INPUT type="radio") doesn't work as one value

I'm looking for a generalized solution for this. Consider 2 radio type inputs with the same name. When submitted, the one that is checked determines the value that gets sent with the form: <input type="radio" name="myRadios" onchange="handleChan...

How can I make a CSS glass/blur effect work for an overlay?

I am having trouble applying a blur effect on a semi-transparent overlay div. I'd like everything behind the div the be blurred, like this: Here is a jsfiddle which doesn't work: http://jsfiddle.net/u2y2091z/ Any ideas how to make this work? I'd ...

Div Background Image Z-Index Issue

I am trying to get the background image of my content to appear behind the header and footer. Currently, the top of the content's background is sticking out onto the header, and you can see that the bottom has slightly covered the footer (notice the ...

Can't access object property, even though it shows up in a console log

Below, you can see the output from these two logs. The first clearly shows the full object with the property I'm trying to access, but on the very next line of code, I can't access it with config.col_id_3 (see the "undefined" in the screenshot?). Can...

Separators for Navigation

I need to add separators between elements of navigation. Separators are images. My HTML structure is like: ol > li > a > img. Here I come to two possible solutions: To add more li tags for separation (boo!), Include separator in image of e...

how to set start page in webconfig file in asp.net c#

how to set start page using webconfig file .I have tried this code <system.webServer> <defaultDocument enabled="true"> <files> <clear /> <add value="index.aspx"/> ...

ASP.NET Core Web API Authentication

I'm struggling with how to set up authentication in my web service. The service is build with the ASP.NET Core web api. All my clients (WPF applications) should use the same credentials to call the web service operations. After some research, I c...

Quicker way to get all unique values of a column in VBA?

Is there a faster way to do this? Set data = ws.UsedRange Set unique = CreateObject("Scripting.Dictionary") On Error Resume Next For x = 1 To data.Rows.Count unique.Add data(x, some_column_number).Value, 1 Next x On Error GoTo 0 At this poin...

Android refresh current activity

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

Two-way SSL clarification

I am somewhat confused as to how two-way SSL works. How does the client create its certificate to send to the server? Is it generated from the server and distributed to the client? Also, what is the advantage of two-way SSL over one-way SSL?...

How can I get the class name from a C++ object?

Is it possible to get the object name too? #include<cstdio> class one { public: int no_of_students; one() { no_of_students = 0; } void new_admission() { no_of_students++; } }; int main() { one A; for(int i = 0; i < 99;...

segmentation fault : 11

I'm having a problem with some program, I have searched about segmentation faults, by I don't understand them quite well, the only thing I know is that presumably I am trying to access some memory I shouldn't. The problem is that I see my code and do...

Java - removing first character of a string

In Java, I have a String: Jamaica I would like to remove the first character of the string and then return amaica How would I do this?...

ImageView - have height match width?

I have an imageview. I want its width to be fill_parent. I want its height to be whatever the width ends up being. For example: <ImageView android:layout_width="fill_parent" android:layout_height="whatever the width ends up being" /> Is ...

Java Error: illegal start of expression

I'm basically refining, completing and trying to compile a test code from a reference book for java beginners. The objective is to create a guessing game wherein the target is located in 3 continuous cells (I'm holding the locations in an array) and ...

How to check a string for a special character?

I can only use a string in my program if it contains no special characters except underscore _. How can I check this? I tried using unicodedata library. But the special characters just got replaced by standard characters....

How to download/checkout a project from Google Code in Windows?

How do I download a ZIP file of an entire project from Google Code when there are no prepared downloads available? This is what I see on the checkout page: Command-line access Use this command to anonymously check out the latest project sourc...

Delete file from internal storage

I'm trying to delete images stored in internal storage. I've come up with this so far: File dir = getFilesDir(); File file = new File(dir, id+".jpg"); boolean deleted = file.delete(); And this is from another question, which was answered with: Fi...

Can I change the name of `nohup.out`?

When I run nohup some_command &, the output goes to nohup.out; man nohup says to look at info nohup which in turn says: If standard output is a terminal, the command's standard output is appended to the file 'nohup.out'; if that cannot ...

How can I create a UIColor from a hex string?

How can I create a UIColor from a hexadecimal string format, such as #00FF00?...

How to find the logs on android studio?

I have tried to import my project in to android studio.The error will be shown.I need to know where do I get logs? Consult IDE log for more details (Help | Show Log) ...

How to access iOS simulator camera

Hi friends i am doing camera app. i need to test the app in simulator but i can't able to access the iOS simulator camera. Any help for my problem. If not possible in simulator means i need to access my system camera. Whether it is possible?I tried ...

How can I read large text files in Python, line by line, without loading it into memory?

I need to read a large file, line by line. Lets say that file has more than 5GB and I need to read each line, but obviously I do not want to use readlines() because it will create a very large list in the memory. How will the code below work for thi...

enum Values to NSString (iOS)

I have an enum holding several values: enum {value1, value2, value3} myValue; In a certain point in my app, I wish to check which value of the enum is now active. I'm using NSLog but I'm not clear on how to display the current value of the enum (v...

"inconsistent use of tabs and spaces in indentation"

I'm trying to create an application in Python 3.2 and I use tabs all the time for indentation, but even the editor changes some of them into spaces and then print out "inconsistent use of tabs and spaces in indentation" when I try to run the program....

What does Visual Studio mean by normalize inconsistent line endings?

Visual Studio occasionally tells me: The line endings in the following files are not consistent. Do you want to normalize the line endings? It then gives me a drop down with different standards or something, such as Windows, Mac, Unix, and a co...

How does database indexing work?

Given that indexing is so important as your data set increases in size, can someone explain how indexing works at a database-agnostic level? For information on queries to index a field, check out How do I index a database column....

Android YouTube app Play Video Intent

I have created a app where you can download YouTube videos for android. Now, I want it so that if you play a video in the YouTube native app you can download it too. To do this, I need to know the Intent that the YouTube native app puts out in order ...

Jquery mouseenter() vs mouseover()

So after reading a recently answered question i am unclear if i really understand the difference between the mouseenter() and mouseover(). The post states MouseOver(): Will fire upon entering an element and whenever any mouse movements occur within ...

Could not create SSL/TLS secure channel, despite setting ServerCertificateValidationCallback

I'm trying to establish SSL/TLS connection to test server with self-signed certificate. Communication through unsecure channel worked without issues. Here is my sample code, which I've written based on this solutions: Allowing Untrusted SSL Certific...

How to get current working directory in Java?

Let's say I have my main class in C:\Users\Justian\Documents\. How can I get my program to show that it's in C:\Users\Justian\Documents? Hard-Coding is not an option- it needs to be adaptable if it's moved to another location. I want to dump a bunc...

How to retry image pull in a kubernetes Pods?

I am new to kubernetes. I have an issue in the pods. When I run the command kubectl get pods Result: NAME READY STATUS RESTARTS AGE mysql-apim-db-1viwg 1/1 Running 1 20h mysql-govd...

Dockerfile copy keep subdirectory structure

I'm trying to copy a number of files and folders to a docker image build from my localhost. The files are like this: folder1 file1 file2 folder2 file1 file2 I'm trying to make the copy like this: COPY files/* /files/ However, a...

How to change the type of a field?

I am trying to change the type of a field from within the mongo shell. I am doing this... db.meta.update( {'fields.properties.default': { $type : 1 }}, {'fields.properties.default': { $type : 2 }} ) But it's not working!...

ASP.Net MVC - Read File from HttpPostedFileBase without save

I am uploading the file by using file upload option. And i am directly send this file from View to Controller in POST method like, [HttpPost] public ActionResult Page2(FormCollection objCollection) { HttpPostedFileBase file = Req...

C++ where to initialize static const

I have a class class foo { public: foo(); foo( int ); private: static const string s; }; Where is the best place to initialize the string s in the source file?...

Align inline-block DIVs to top of container element

When two inline-block divs have different heights, why does the shorter of the two not align to the top of the container? (DEMO): _x000D_ _x000D_ .container { _x000D_ border: 1px black solid;_x000D_ width: 320px;_x000D_ height: 120px; ...

How to fill DataTable with SQL Table

I am currently creating and reading a DataTable with the following code in my Page_Load protected void Page_Load(object sender, EventArgs e) { if (Session["AllFeatures1"] == null) { Session["AllFeatures1"] = GetData(); } tabl...

What does %s and %d mean in printf in the C language?

I don't understand what the %s and d% do in this C code: for (i=0;i<sizeof(code)/sizeof(char*); i++) { printf("%s%d%s%d\n", "Length of String ", i, " is ", strlen(code[i])); str = code[i]; printf("%s%d%s%c\n","The first character in s...

Shortcut to open file in Vim

I want to open a file in Vim like in Eclipse using Ctrl + Shift + R, or via the Ctrl + N option of autofill. Invoke a keyboard shortcut, type the file name/pattern, and choose from all the matching files names. I know opening it normally like: :tab...

How to change or add theme to Android Studio?

I have just installed Android Studio in my Window 7 64bit. When I launch the application the background of the screen where we write the code is white. I would prefer black or any other color. I am not sure whether we can change the color/theme OR ad...

Two values from one input in python?

This is somewhat of a simple question and I hate to ask it here, but I can't seem the find the answer anywhere else: is it possible to get multiple values from the user in one line of Python? For instance, in C I can do something like this: scanf("...

Chrome says "Resource interpreted as script but transferred with MIME type text/plain.", what gives?

In FF and all, my javascript works fine. But in Chrome it gives this message: Resource interpreted as script but transferred with MIME type text/plain. I have checked all the script tags and they all have the MIME type="text/javascript". It ev...

Angular2 - Input Field To Accept Only Numbers

In Angular 2, how can I mask an input field (textbox) such that it accepts only numbers and not alphabetical characters? I have the following HTML input: <input type="text" *ngSwitchDefault class="form-control" (change)="onInputChang...

Obtaining only the filename when using OpenFileDialog property "FileName"

I am trying to include only the filename of the file I've selected in the OpenFileDialog in the label1.Text property, but I haven't found a solution yet. I know I could use a method from the string class on the ofd instance to filter out the whole pa...

ng if with angular for string contains

I have the following Angular code: <li ng-repeat="select in Items"> <foo ng-repeat="newin select.values"> {{new.label}}</foo> How can I use an ng-if condition to look for a specific character: ng-if="s...

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

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

How to concatenate string and int in C?

I need to form a string, inside each iteration of the loop, which contains the loop index i: for(i=0;i<100;i++) { // Shown in java-like code which I need working in c! String prefix = "pre_"; String suffix = "_suff"; // This is the stri...

Password Strength Meter

I have a situation where I would like to be able to rate a users password in the web interface to my system, so that before they hit submit they know if they have a bad password. Key Requirements: Must be able to rate the password, not just pass/f...

How do I remove accents from characters in a PHP string?

I'm attempting to remove accents from characters in PHP string as the first step to making the string usable in a URL. I'm using the following code: $input = "Fóø Bår"; setlocale(LC_ALL, "en_US.utf8"); $output = iconv("utf-8", "ascii//TRANSLIT"...

getting "No column was specified for column 2 of 'd'" in sql server cte?

I have this query, but its not working as it should, with c as (select month(bookingdate) as duration, count(*) as totalbookings from entbookings group by month(bookingdate) ...

Using BETWEEN in CASE SQL statement

I want to get the avarage rate for all 12 months from our rate table and divide it by months, i started writing an SQL select with case, but i seem to be doing something wrong in the "Between" part..here's my SQL SELECT AVG(SELL_RATE), AVG(BU...

Android 8.0: java.lang.IllegalStateException: Not allowed to start service Intent

On application launch, app starts the service that should to do some network task. After targeting API level 26, my application fails to start service on Android 8.0 on background. Caused by: java.lang.IllegalStateException: Not allowed to start...

MySQL pivot table query with dynamic columns

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

`IF` statement with 3 possible answers each based on 3 different ranges

I have 3 ranges of numbers and the answer depends on the range. 75-79=0.255 80-84=0.327 85+ =0.559 I tried to create an equation that accounts for the ranges, however Excel states that I have entered too many arguments for this function. Below ...

How do I tar a directory of files and folders without including the directory itself?

I typically do: tar -czvf my_directory.tar.gz my_directory What if I just want to include everything (including any hidden system files) in my_directory, but not the directory itself? I don't want: my_directory --- my_file --- my_file --...

Using setDate in PreparedStatement

In order to make our code more standard, we were asked to change all the places where we hardcoded our SQL variables to prepared statements and bind the variables instead. I am however facing a problem with the setDate(). Here is the code: ...

Failed to read artifact descriptor for org.apache.maven.plugins:maven-source-plugin:jar:2.4

Thanks to a Dropwizard Maven archetype I generated a sample Dropwizard Maven project. The pom.xml notably uses maven-source-plugin: <plugin> <artifactId>maven-source-plugin</artifactId> <version>2.4</version> ...

push multiple elements to array

I'm trying to push multiple elements as one array, but getting error > a = [] [] > a.push.apply(null, [1,2]) TypeError: Array.prototype.push called on null or undefined I'm trying to do similar stuff that I'd do in ruby, I was thinking that ...

How to find NSDocumentDirectory in Swift?

I'm trying to get path to Documents folder with code: var documentsPath = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory:0,NSSearchPathDomainMask:0,true) but Xcode gives error: Cannot convert expression's type 'AnyObject[]!' to type 'NS...

How to set background image of a view?

I am a beginner at Obj-C/Cocoa Touch/iPhone OS. I wish to have a background for my app with different images everytime the the view is called. Say I have 10 images. I 've used it like this: //random image generation NSString* imageName; int aRando...

How to truncate text in Angular2?

Is there a way that I could limit the length of the string to a number characters? for e.g: I have to limit a title length to 20 {{ data.title }}. Is there any pipe or filter to limit the length?...

Uppercase first letter of variable

I have searched over the web can can't find anything to help me. I want to make the first letter of each word upper case within a variable. So far i have tried: toUpperCase(); And had no luck, as it uppercases all letters....

Omit rows containing specific column of NA

I want to know how to omit NA values in a data frame, but only in some columns I am interested in. For example, DF <- data.frame(x = c(1, 2, 3), y = c(0, 10, NA), z=c(NA, 33, 22)) but I only want to omit the data where y is NA, therefore the r...

How do I convert a Python program to a runnable .exe Windows program?

I am looking for a way to convert a Python Program to a .exe file WITHOUT using py2exe. py2exe says it requires Python 2.6, which is outdated. Is there a way this is possible so I can distribute my Python program without the end-user having to instal...

Git pull till a particular commit

I want to do a git pull but only till a specific commit. A->B->C->D->E->F (Remote master HEAD) so suppose my local master HEAD points to B, and I want to pull till E. What should I do ? This is not pulling a specific commit, this ...

In excel how do I reference the current row but a specific column?

Let's say I had the datasheet A B C D ----------- 5 4 6 3 4 4 3 2 5 4 6 2 And I wanted to do something like A B C D E F ---------------------------------------------- 5 4 6 3 =AVERAGE(A1,C1) =AVERAGE(B1,D...

HTML Input - already filled in text

I was wondering, is there a way to put text into an input field? What i've got now is a placeholder, but that's actually an empty inputfield. So that's not what i'm looking for. I'm looking for an (kind of) placeholder that's actually filled in into ...

What does the Java assert keyword do, and when should it be used?

What are some real life examples to understand the key role of assertions?...

how to parse JSON file with GSON

I have a very simple JSON with reviews for products, like: { "reviewerID": "A2XVJBSRI3SWDI", "asin": "0000031887", "reviewerName": "abigail", "helpful": [0, 0], "unixReviewTime": 1383523200, "reviewText": "Perfect red tutu for the p...

How to perform runtime type checking in Dart?

Dart specification states: Reified type information reflects the types of objects at runtime and may always be queried by dynamic typechecking constructs (the analogs of instanceOf, casts, typecase etc. in other languages). Sounds great, but ...

Converting Swagger specification JSON to HTML documentation

For some REST APIs written in PHP, I was asked to create Swagger documentation, and since I was not aware of any easy way of adding annotations to those existing APIs and create such a documentation, I used this editor to generate some for now. I sa...

How to create an integer array in Python?

It should not be so hard. I mean in C, int a[10]; is all you need. How to create an array of all zeros for a random size. I know the zeros() function in NumPy but there must be an easy way built-in, not another module....

Update style of a component onScroll in React.js

I have built a component in React which is supposed to update its own style on window scroll to create a parallax effect. The component render method looks like this: function() { let style = { transform: 'translateY(0px)' }; wind...

R - argument is of length zero in if statement

I am having a little problem with R and I am not sure why. It is telling me that this line: if(temp > data[[k]][[k2]]) { is of argument length 0. Here is the block which is not that big: for(k in 1:length(data)) { temp <- 0 for(...

Remove padding from columns in Bootstrap 3

Problem: Remove padding/margin to the right and left of col-md-* in Bootstrap 3. HTML code: <div class="col-md-12"> <h2>OntoExplorer<span style="color:#b92429">.</span></h2> <div class="col-md-4"> ...

How to convert string to date to string in Swift iOS?

Am learning swift and am struck in converting the date String to NSDate to string. Am getting the date string in this format "Thu, 22 Oct 2015 07:45:17 +0000". I need to show the date in the MM-dd-yyyy format. I tried the following code but, it retur...

Check if directory mounted with bash

I am using mount -o bind /some/directory/here /foo/bar I want to check /foo/bar though with a bash script, and see if its been mounted? If not, then call the above mount command, else do something else. How can I do this? CentOS is the operating ...

How to convert hex strings to byte values in Java

I have a String array. I want to convert it to byte array. I use the Java program. For example: String str[] = {"aa", "55"}; convert to: byte new[] = {(byte)0xaa, (byte)0x55}; What can I do?...

How to resolve the "EVP_DecryptFInal_ex: bad decrypt" during file decryption

I have the following query.Could any one please suggest me a solution. I'm working on encryption and decryption of file for first time. I have encrypted file through command prompt using the command: openssl enc -aes-256-cbc -in file.txt -out file...

Cannot implicitly convert type 'string' to 'System.Threading.Tasks.Task<string>'

I am new to asynchronous programming, so after going through some async sample codes, I thought of writing a simple async code I created a simple Winform application and inside the Form I wrote the following code. But its just not working private T...

Using GroupBy, Count and Sum in LINQ Lambda Expressions

I have a collection of boxes with the properties weight, volume and owner. I want to use LINQ to get a summarized list (by owner) of the box information e.g. **Owner, Boxes, Total Weight, Total Volume** Jim, 5, 1430.00, 3.65 Georg...

Cell spacing in UICollectionView

How do I set cell spacing in a section of UICollectionView? I know there is a property minimumInteritemSpacing I have set it to 5.0 still the spacing is not appearing 5.0. I have implemented the flowout delegate method. - (CGFloat)collectionView:(UI...

python: Appending a dictionary to a list - I see a pointer like behavior

I tried the following in the python interpreter: >>> >>> a = [] >>> b = {1:'one'} >>> a.append(b) >>> a [{1: 'one'}] >>> b[1] = 'ONE' >>> a [{1: 'ONE'}] >>> Here, after append...

R Language: How to print the first or last rows of a data set?

I can print first n rows by the following command: > dataset[1:n, ] Is there a more elegant way to do this? Also, how can I print the last rows of a data set?...

Scroll Element into View with Selenium

Is there any way in either Selenium 1.x or 2.x to scroll the browser window so that a particular element identified by an XPath is in view of the browser? There is a focus method in Selenium, but it does not seem to physically scroll the view in Fire...

Error: unmappable character for encoding UTF8 during maven compilation

I am compiling a package using maven and it says build failure with following compilation error: SpanishTest.java[31, 81] unmappable character for encoding UTF8 I searched online and for many people, changing source encoding from UTF-8 to ISO-8859-...

How to update (append to) an href in jquery?

I have a list of links that all go to a google maps api. the links already have the daddr (destination) parameter in them as static. I am using Geo-Location to find the users position and I want to add the saddr (source address) to the links once I ...

Node Version Manager (NVM) on Windows

I am trying to downgrade my version of node I ran: npm install nvm and I exported the bin folder to my Windows path variable, C:\Program Files (x86)\nodejs\node_modules\npm\bin but I still get: 'nvm' is not recognized as a an internal or ext...

what is reverse() in Django

When I read django code sometimes, I see in some templates reverse(). I am not quite sure what this is but it is used together with HttpResponseRedirect. How and when is this reverse() supposed to be used? It would nice if someone gave an answer wit...

Java - get pixel array from image

I'm looking for the fastest way to get pixel data (int the form int[][]) from a BufferedImage. My goal is to be able to address pixel (x, y) from the image using int[x][y]. All the methods I have found do not do this (most of them return int[]s)....

window.history.pushState refreshing the browser

I am working on some javascript code, and using window.History.pushState to load new HTML pages, instead of using href tags. My code (which is working fine) looks like this. window.History.pushState({urlPath:'/page1'},"",'/page1') strangely, this...

Why Response.Redirect causes System.Threading.ThreadAbortException?

When I use Response.Redirect(...) to redirect my form to a new page I get the error: A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll An exception of type 'System.Threading.ThreadAbortExcepti...

Creating a JSON Array in node js

I need to create in my server written in node js a JSON string to be sent to the client when this request it. The problem is that this JSON depends on the available data in the server, thus, the size of the JSON array is not the same always. I´ve tr...

How to hide Soft Keyboard when activity starts

I have an Edittext with android:windowSoftInputMode="stateVisible" in Manifest. Now the keyboard will be shown when I start the activity. How to hide it? I cannot use android:windowSoftInputMode="stateHidden because when keyboard is visible then mini...

How To Run PHP From Windows Command Line in WAMPServer

I'm new to php and wanted to run php from command line. I have installed WAMP and set the "System Variables" to my php folder ( which is C:\wamp\bin\php\php5.4.3). When i go to Run -> CMD -> Type php -a and hit enter, it says interactive mode enable...

Django: OperationalError No Such Table

I'm building a fairly simple application, research, in my Django project that uses Django-CMS. (It's my first ground-up attempt at a project/application.) It's main purpose is to store various intellectual assets (i.e article, book, etc. written by...

%Like% Query in spring JpaRepository

I would like to write a like query in JpaRepository but it is not returning anything : LIKE '%place%'-its not working. LIKE 'place' works perfectly. Here is my code : @Repository("registerUserRepository") public interface RegisterUserRepository ...

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

Is it possible to set the equivalent of a src attribute of an img tag in CSS?

Is it possible to set the src attribute value in CSS? At present, what I am doing is: <img src="pathTo/myImage.jpg"/> and I want it to be something like this <img class="myClass"/> .myClass { some-src-property: url("pathTo/myIma...

Inconsistent accessibility: property type is less accessible

Please can someone help with the following error: Inconsistent accessibility: property type 'Test.Delivery' is less accessible than property 'Test.Form1.thelivery' private Delivery thedelivery; public Delivery thedelivery { get { return t...

How can I convert an HTML table to CSV?

How do I convert the contents of an HTML table (<table>) to CSV format? Is there a library or linux program that does this? This is similar to copy tables in Internet Explorer, and pasting them into Excel....

PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT (in windows 10)

While running an app on the virtual device (AVD) created on Android studio (in Windows 10), I am getting an error and panic. Emulator: PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT Emulator: Process finished with exit code 1 Wh...

Install python 2.6 in CentOS

I have a shell that runs CentOS. For a project I'm doing, I need python 2.5+, but centOS is pretty dependent on 2.4. From what I've read, a number of things will break if you upgrade to 2.5. I want to install 2.5 separately from 2.4, but I'm not s...

Why does LayoutInflater ignore the layout_width and layout_height layout parameters I've specified?

I've had severe trouble getting LayoutInflater to work as expected, and so did other people: How to use layoutinflator to add views at runtime?. Why does LayoutInflater ignore the layout parameters I've specified? E.g. why are the layout_width and l...

How to clear Route Caching on server: Laravel 5.2.37

This is regarding route cache on localhost About Localhost I have 2 routes in my route.php file. Both are working fine. No problem in that. I was learning route:clear and route:cache and found a small problem below. if I comment any one route in m...

jQuery datepicker, onSelect won't work

I can't get onSelect working on my jQuery datepicker. Heres my code: <script type="text/javascript"> $(function() { $('.date-pick').datePicker( { onSelect: function(date) { alert(date) }, selectWeek: tr...

How to check if a String contains only ASCII?

The call Character.isLetter(c) returns true if the character is a letter. But is there a way to quickly find if a String only contains the base characters of ASCII?...

Using NOT operator in IF conditions

Is it really a good practice to avoid using NOT operator in IF conditions in order to make your code better readable? I heard the if (doSomething()) is better then if (!doSomething())....

When and where to use GetType() or typeof()?

Why this works if (mycontrol.GetType() == typeof(TextBox)) {} and this do not? Type tp = typeof(mycontrol); But this works Type tp = mycontrol.GetType(); I myself use is operator for checking type but my understanding fails when I use typeo...

Creating a list of pairs in java

Which class would work best for a non-ordered list of pairs? I'll be taking a bunch of (float,short) pairs and will need to be able to perform simple math (like multiplying the pair together to return a single float, etc). List only takes one argumen...

What does the Ellipsis object do?

While idly surfing the namespace I noticed an odd looking object called Ellipsis, it does not seem to be or do anything special, but it's a globally available builtin. After a search I found that it is used in some obscure variant of the slicing sy...

Reading Datetime value From Excel sheet

when am trying to read datetime type value from excel sheet it is returning a double value.for example if want to read value '2007-02-19 14:11:45.730' like this, i am getting a double type value .further i am converting this double value using timesp...

How do you get assembler output from C/C++ source in gcc?

How does one do this? If I want to analyze how something is getting compiled, how would I get the emitted assembly code?...

How to get the request parameters in Symfony 2?

I am very new to symfony. In other languages like java and others I can use request.getParameter('parmeter name') to get the value. Is there anything similar that we can do with symfony2. I have seen some examples but none is working for me. Suppose...

How to do case insensitive search in Vim

I'd like to search for an upper case word, for example COPYRIGHT in a file. I tried performing a search like: /copyright/i # Doesn't work but it doesn't work. I know that in Perl, if I give the i flag into a regex it will turn the regex into a...

How to disable text selection highlighting

For anchors that act like buttons (for example Questions, Tags, Users, etc. which are located on the top of the Stack Overflow page) or tabs, is there a CSS standard way to disable the highlighting effect if the user accidentally selects the text? I...

adding 30 minutes to datetime php/mysql

I have a datetime field (endTime) in mysql. I use gmdate() to populate this endTime field. The value stored is something like 2009-09-17 04:10:48. I want to add 30 minutes to this endtime and compare it with current time. ie) the user is allowed t...

TypeScript: Property does not exist on type '{}'

I am using Visual Studio 2013 fully patched. I am trying to use JQuery, JQueryUI and JSRender. I am also trying to use TypeScript. In the ts file I'm getting an error as follows: Property 'fadeDiv' does not exist on type '{}'. I think I have the c...

Inserting records into a MySQL table using Java

I created a database with one table in MySQL: CREATE DATABASE iac_enrollment_system; USE iac_enrollment_system; CREATE TABLE course( course_code CHAR(7), course_desc VARCHAR(255) NOT NULL, course_chair VARCHAR(255), PRIMARY KEY(cou...

Node.js, can't open files. Error: ENOENT, stat './path/to/file'

I have developed a node.js program using the express framework on my computer, where it runs fine with no complaints. However, when I run the program on my SUSE Studio appliance, where it is intended to live, I receive an error at any file interacti...

How to reset a timer in C#?

There are three Timer classes that I am aware of, System.Threading.Timer, System.Timers.Timer, and System.Windows.Forms.Timer, but none of these have a .Reset() function which would reset the current elapsed time to 0. Is there a BCL class that has ...

ALTER TABLE add constraint

CREATE TABLE Properties ( ID int AUTO_INCREMENT, language int, stonecolor int, gamefield int, UserID int, PRIMARY KEY(ID), FOREIGN KEY(language) REFERENCES Language(ID), FOREIGN KEY(stonecolor) REFERENCES StoneColor(ID...

PermissionError: [Errno 13] in python

Just starting to learn some python and I'm having an issue as stated below: a_file = open('E:\Python Win7-64-AMD 3.3\Test', encoding='utf-8') Traceback (most recent call last): File "<pyshell#9>", line 1, in <module> a_file = open...

CSS two divs next to each other

I want to put two <div>s next to each other. The right <div> is about 200px; and the left <div> must fill up the rest of the screen width? How can I do this?...

JavaScript: Alert.Show(message) From ASP.NET Code-behind

I am reading this JavaScript: Alert.Show(message) From ASP.NET Code-behind I am trying to implement the same. So I created a static class like this: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.D...

Why is list initialization (using curly braces) better than the alternatives?

MyClass a1 {a}; // clearer and less error-prone than the other three MyClass a2 = {a}; MyClass a3 = a; MyClass a4(a); Why?...

SqlDataAdapter vs SqlDataReader

What are the differences between using SqlDataAdapter vs SqlDataReader for getting data from a DB? I am specifically looking into their Pros and Cons as well as their speed and memory performances. Thanks...

final keyword in method parameters

I often encounter methods which look like the following: public void foo(final String a, final int[] b, final Object1 c){ } What happens if this method is called without passing it final parameters. i.e. an Object1 that is later changed (so is not...

Modifying local variable from inside lambda

Modifying a local variable in forEach gives a compile error: Normal int ordinal = 0; for (Example s : list) { s.setOrdinal(ordinal); ordinal++; } With Lambda int ordinal = 0; list.forEach(s -> { s.s...

How do I reference the input of an HTML <textarea> control in codebehind?

I'm using a textarea control to allow the user to input text and then place that text into the body of an e-mail. In the code behind, what is the syntax for referencing the users input? I thought I could just use message.Body = test123.Text; but this...

Dynamically add child components in React

My goal is to add components dynamically on a page/parent component. I started with some basic example template like this: main.js: var App = require('./App.js'); var SampleComponent = require('./SampleComponent.js'); ReactDOM.render(<App/>,...

Connection to SQL Server Works Sometimes

An ADO.Net application is only sometimes able to connect to another server on the local network. It seems random whether a given connection attempt succeeds or fails. The connection is using a connection string in the form: Server=THESERVER\The...

How to print a float with 2 decimal places in Java?

Can I do it with System.out.print?...

Prevent Default on Form Submit jQuery

What's wrong with this? HTML: <form action="http://localhost:8888/bevbros/index.php/test" method="post" accept-charset="utf-8" id="cpa-form" class="forms"> <input type="text" name="zip" value="Zip code" id="Zip" class="requir...

Decimal number regular expression, where digit after decimal is optional

I need a regular expression that validates a number, but doesn't require a digit after the decimal. ie. 123 123. 123.4 would all be valid 123.. would be invalid Any would be greatly appreciated!...

How best to read a File into List<string>

I am using a list to limit the file size since the target is limited in disk and ram. This is what I am doing now but is there a more efficient way? readonly List<string> LogList = new List<string>(); ... var logFile = File.ReadAllLines(...

Lost connection to MySQL server at 'reading initial communication packet', system error: 0

I am getting error: "Lost connection to MySQL server at 'reading initial communication packet, system error: 0" while I am going to connect my db. If I am using localhost everything is working fine. But when I am using my live IP address like ...

Calculate number of hours between 2 dates in PHP

How do I calculate the difference between two dates in hours? For example: day1=2006-04-12 12:30:00 day2=2006-04-14 11:30:00 In this case the result should be 47 hours....

jQuery UI DatePicker to show year only

I am using jQuery datepicker to display calender.I want to know if I can use it to Display only 'Year' and not Complete Calender ??...

Set session variable in laravel

I would like to set a variable in the session using laravel this way Session::set('variableName')=$value; but the problem is that I don't know where to put this code, 'cause I would like to set it for one time (when the guest visite the home page ...

Xml serialization - Hide null values

When using a standard .NET Xml Serializer, is there any way I can hide all null values? The below is an example of the output of my class. I don't want to output the nullable integers if they are set to null. Current Xml output: <?xml version=...

Is it possible to cast a Stream in Java 8?

Is it possible to cast a stream in Java 8? Say I have a list of objects, I can do something like this to filter out all the additional objects: Stream.of(objects).filter(c -> c instanceof Client) After this though, if I want to do something wit...

Passing arguments to require (when loading module)

Is it possible to pass arguments when loading a module using require? I have module, login.js which provides login functionality. It requires a database connection, and I want the same database connection to be used in all my modules. Now I export a...

Capture HTML Canvas as gif/jpg/png/pdf?

Is it possible to capture or print what's displayed in an html canvas as an image or pdf? I'd like to generate an image via canvas, and be able to generate a png from that image....

How to convert a Map to List in Java?

What is the best way to convert a Map<key,value> to a List<value>? Just iterate over all values and insert them in a list or am I overlooking something?...

Convert an image to grayscale in HTML/CSS

Is there a simple way to display a color bitmap in grayscale with just HTML/CSS? It doesn't need to be IE-compatible (and I imagine it won't be) -- if it works in FF3 and/or Sf3, that's good enough for me. I know I can do it with both SVG and Canva...

How can I represent 'Authorization: Bearer <token>' in a Swagger Spec (swagger.json)

I am trying to convey that the authentication/security scheme requires setting a header as follows: Authorization: Bearer <token> This is what I have based on the swagger documentation: securityDefinitions: APIKey: type: apiKey na...

Where is the Docker daemon log?

Where is the Docker daemon log? Oddly cannot find an answer to this via man, StackOverflow or Docker Docs. Note I am not asking for the docker container STDOUT, but the daemon log for troubleshooting communications between the client and container vi...

How to set header and options in axios?

I use Axios to perform an HTTP post like this: import axios from 'axios' params = {'HTTP_CONTENT_LANGUAGE': self.language} headers = {'header1': value} axios.post(url, params, headers) Is this correct? Or should I do: axios.post(url, params: para...

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

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

Inverse of matrix in R

I was wondering what is your recommended way to compute the inverse of a matrix? The ways I found seem not satisfactory. For example, > c=rbind(c(1, -1/4), c(-1/4, 1)) > c [,1] [,2] [1,] 1.00 -0.25 [2,] -0.25 1.00 > inv...

MySQL SELECT AS combine two columns into one

Using this solution, I tried to use COALESCE as part of a MySQL query that outputs to a csv file using SELECT As to name the column names when exporting the data. SELECT FirstName AS First_Name , LastName AS Last_Name , ContactPhoneAreaCod...

PHP mail not working for some reason

I am new to PHP and I'm using the mail function to send emails which is not working. I get a success message, but still it does not work same code <?php $email_to = "[email protected]"; $email_subject = "Test mail"; $email_body = "Hello! T...

Adding an assets folder in Android Studio

Android Studio has changed its project structure yet again... now it is project +-- app-module +-- manifests +-- res +-- java I've been looking everywhere online, but I can't find where to put the assets folder. When I try to create the ...

Does Python support short-circuiting?

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

No Application Encryption Key Has Been Specified

I'm new to Laravel and I'm trying to use the Artisan command... php artisan serve It displays... Laravel development server started: http://127.0.0.1:8000 However, it won't automatically launch and when I manually enter http://127.0.0.1:8000...

How to select option in drop down using Capybara

I'm trying to select an item from a drop down menu using Capybara (2.1.0). I want to select by number (meaning select the second, third, etc option). I've Googled like crazy trying all sorts of things but no luck. I was able to select it by using...

How can I consume a WSDL (SOAP) web service in Python?

I want to use a WSDL SOAP based web service in Python. I have looked at the Dive Into Python code but the SOAPpy module does not work under Python 2.5. I have tried using suds which works partly, but breaks with certain types (suds.TypeNotFound: Typ...

Get multiple elements by Id

I have a page with anchor tags throughout the body like this: <a id="test" name="Name 1"></a> <a id="test" name="Name 2"></a> <a id="test" name="Name 3"></a> The ID is always the same but the name changes. I ne...

Which way is best for creating an object in JavaScript? Is `var` necessary before an object property?

So far I saw three ways for creating an object in JavaScript. Which way is best for creating an object and why? I also saw that in all of these examples the keyword var is not used before a property — why? Is it not necessary to declare var before...

Is it possible to make input fields read-only through CSS?

I know that input elements are made read-only by applying the readonly boolean attribute, and being an attribute it is not affected by CSS. On the other hand, my scenario seems to be a very good fit for CSS, so I was hoping there is some kind of a C...

Difference Between Cohesion and Coupling

What is the difference between cohesion and coupling? How can coupling and cohesion lead to either good or poor software design? What are some examples that outline the difference between the two, and their impact on overall code quality?...

How to run a program without an operating system?

How do you run a program all by itself without an operating system running? Can you create assembly programs that the computer can load and run at startup, e.g. boot the computer from a flash drive and it runs the program that is on the CPU?...

Java: Finding the highest value in an array

For some reason this code is printing three values for the highest value in the array when I'm trying to print just one (which is 11.3). Can someone please explain to me why it is doing this? Thanks. import java.util.Scanner; public class Slide24 ...

Recursively counting files in a Linux directory

How can I recursively count files in a Linux directory? I found this: find DIR_NAME -type f ¦ wc -l But when I run this it returns the following error. find: paths must precede expression: ¦ ...

Regular expression to match URLs in Java

I use RegexBuddy while working with regular expressions. From its library I copied the regular expression to match URLs. I tested successfully within RegexBuddy. However, when I copied it as Java String flavor and pasted it into Java code, it does no...

Should operator<< be implemented as a friend or as a member function?

That's basically the question, is there a "right" way to implement operator<< ? Reading this I can see that something like: friend bool operator<<(obj const& lhs, obj const& rhs); is preferred to something like ostream& o...

Pass table as parameter into sql server UDF

I'd like to pass a table as a parameter into a scaler UDF. I'd also prefer to restrict the parameter to tables with only one column. (optional) Is this possible? EDIT I don't want to pass a table name, I'd like to pass the table of data (as a re...

How to sum the values of a JavaScript object?

I'd like to sum the values of an object. I'm used to python where it would just be: sample = { 'a': 1 , 'b': 2 , 'c':3 }; summed = sum(sample.itervalues()) The following code works, but it's a lot of code: function obj_values(object) { v...

Stored Procedure parameter default value - is this a constant or a variable

Here is my code: USE [xxx] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[problemParam] @StartDate INT = CONVERT(INT,(CONVERT(CHAR(8),GETDATE()-130,112))), @EndDate INT = NULL AS BEGIN SSMS is not too happy...

How to connect to a docker container from outside the host (same network) [Windows]

I've created my first docker container, it's running a server using Go but I can't access it from outside the host computer. I've just started with docker so I'm a little lost here. So I have a very simple Go code that starts a server, I have built ...

How do I create a shortcut via command-line in Windows?

I want my .bat script (test.bat) to create a shortcut to itself so that I can copy it to my windows 8 Startup folder. I have written this line of code to copy the file but I haven't yet found a way to create the said shortcut, as you can see it onl...

How do I make an html link look like a button?

I'm using ASP.NET, some of my buttons just do redirects. I'd rather they were ordinary links, but I don't want my users to notice much difference in the appearance. I considered images wrapped by anchors, i.e. tags, but I don't want to have to fir...

Twitter Bootstrap inline input with dropdown

I'm trying to display a text input inline with a dropdown button. I can't figure out how to do this though. Here's the HTML I've tried (I've put all of it on a single line with no results): <div class="input-append"> <input type="text" ...

Renaming Columns in an SQL SELECT Statement

I would like to rename the columns in the results of a SELECT expression. Of course, the following doesn't work: SELECT * AS foobar_* FROM `foobar` As I'm new to SQL, I think I'm just missing a concept, tool, or keyword that would lead to the ans...

How to use Redirect in the new react-router-dom of Reactjs

I am using the last version react-router module, named react-router-dom, that has become the default when developing web applications with React. I want to know how to make a redirection after a POST request. I have been making this code, but after t...

Create a string with n characters

Is there a way in java to create a string with a specified number of a specified character? In my case, I would need to create a string with 10 spaces. My current code is: StringBuffer outputBuffer = new StringBuffer(length); for (int i = 0; i <...

What is the difference between SQL, PL-SQL and T-SQL?

What is the difference between SQL, PL-SQL and T-SQL? Can anyone explain what the differences between these three are, and provide scenarios where each would be relevantly used?...

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

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

How to get current available GPUs in tensorflow?

I have a plan to use distributed TensorFlow, and I saw TensorFlow can use GPUs for training and testing. In a cluster environment, each machine could have 0 or 1 or more GPUs, and I want to run my TensorFlow graph into GPUs on as many machines as pos...

How to compare 2 dataTables

I have 2 datatables and I just want to know if they are the same or not. By "the same", I mean do they have exactly the same number of rows with exactly the same data in each column, or not. I'd love to write (find) a method which accepts both table...

How to git ignore subfolders / subdirectories?

I have a lot of projects in my .Net solution. I would like to exclude all "bin/Debug" and "bin/Release" folders (and their contents), but still include the "bin" folder itself and any dll's contained therein. .gitignore ...

What should I do if the current ASP.NET session is null?

In my web application, I do something like this to read the session variables: if (HttpContext.Current.Session != null && HttpContext.Current.Session["MyVariable"] != null) { string myVariable= (string)HttpContext.Current.Session["MyVar...

Multiline input form field using Bootstrap

<form class="span6"> <h2>Get In Touch</h2><br> <input class="span6" type="text" placeholder="Your first name" required> <input class="span6" type="text" placeholder="Your last name" required> <input clas...

Filter element based on .data() key/value

Say I have 4 div elements with class .navlink, which, when clicked, use .data() to set a key called 'selected', to a value of true: $('.navlink')click(function() { $(this).data('selected', true); }) Every time a new .navlink is clicked, I would li...

How do I handle too long index names in a Ruby on Rails ActiveRecord migration?

I am trying to add an unique index that gets created from the foreign keys of four associated tables: add_index :studies, ["user_id", "university_id", "subject_name_id", "subject_type_id"], :unique => true The database’s limitation for th...

What is %timeit in python?

I always read the code to calculate the time like this way: %timeit function() Can you explain what means "%" here? I think, the "%" is always used to replace something in a string, like %s means replace a string, %d replace a data, but I have ...

Dynamically allocating an array of objects

I have a class that contains a dynamically allocated array, say class A { int* myArray; A() { myArray = 0; } A(int size) { myArray = new int[size]; } ~A() { // Note that as per MikeB's help...

Why does the Visual Studio editor show dots in blank spaces?

I have a strange bug in the Visual Studio text editor. All my blank spaces are replaced by a "." public class Person { int age; } looks like this public..class..Person.......................... {.................. ..int age;................... ...

Eclipse "cannot find the tag library descriptor" for custom tags (not JSTL!)

I have a Java EE project which build fine with Ant, deploys perfectly to JBoss, and runs without any trouble. This project includes a few custom tag libraries (which is not JSTL!), which are also working without any difficulties. The problem is with...

Hide all elements with class using plain Javascript

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

Calculating distance between two points, using latitude longitude?

Here's my try, it's just a snippet of my code: final double RADIUS = 6371.01; double temp = Math.cos(Math.toRadians(latA)) * Math.cos(Math.toRadians(latB)) * Math.cos(Math.toRadians((latB) - (latA))) + Math.sin(Ma...

When use getOne and findOne methods Spring Data JPA

I have an use case where it calls the following: @Override @Transactional(propagation=Propagation.REQUIRES_NEW) public UserControl getUserControlById(Integer id){ return this.userControlRepository.getOne(id); } Observe the @Transactional has Pro...

How can I initialize a MySQL database with schema in a Docker container?

I am trying to create a container with a MySQL database and add a schema to these database. My current Dockerfile is: FROM mysql MAINTAINER (me) <email> # Copy the database schema to the /data directory COPY files/epcis_schema.sql /data/epc...

Export/import jobs in Jenkins

Is it possible to exchange jobs between 2 different Jenkins'? I'm searching for a way to export/import jobs....

float:left; vs display:inline; vs display:inline-block; vs display:table-cell;

My Question(s) Are any of these methods preferred by a professional web designer? Are any of these methods prefereed by a web browser when drawing the website? Is this all just personal preference? Are there other techniques I'm missing? Note: Ab...

Store query result in a variable using in PL/pgSQL

How to assign the result of a query to a variable in PL/pgSQL, the procedural language of PostgreSQL? I have a function: CREATE OR REPLACE FUNCTION test(x numeric) RETURNS character varying AS $BODY$ DECLARE name character varying(255); begin na...

How to extract the n-th elements from a list of tuples?

I'm trying to obtain the n-th elements from a list of tuples. I have something like: elements = [(1,1,1),(2,3,7),(3,5,10)] I wish to extract only the second elements of each tuple into a list: seconds = [1, 3, 5] I know that it could be done w...

Convert String To date in PHP

How can I convert this string 05/Feb/2010:14:00:01 to unixtime ? ...

Colorized grep -- viewing the entire file with highlighted matches

I find grep's --color=always flag to be tremendously useful. However, grep only prints lines with matches (unless you ask for context lines). Given that each line it prints has a match, the highlighting doesn't add as much capability as it could. I'...

Serialize Property as Xml Attribute in Element

I have the following class: [Serializable] public class SomeModel { [XmlElement("SomeStringElementName")] public string SomeString { get; set; } [XmlElement("SomeInfoElementName")] public int SomeInfo { get; set; } } Which (when p...

How can I remove a child node in HTML using JavaScript?

Is there a function like document.getElementById("FirstDiv").clear()?...

How to make Java 6, which fails SSL connection with "SSL peer shut down incorrectly", succeed like Java 7?

I'm seeing an SSL connection from a client running Java 6 fail with an exception like: Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSoc...

Write a file on iOS

How do I write a file on iOS? I'm trying to do it with the following code but I'm doing something wrong: char *saves = "abcd"; NSData *data = [[NSData alloc] initWithBytes:saves length:4]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocu...

Jquery sortable 'change' event element position

Is there way to get current position of helper being dragged on over new position ? $("#sortable").sortable({ start: function (event, ui) { var currPos1 = ui.item.index(); }, change: function (event, ui) { ...

What do the icons in Eclipse mean?

What do the icons in the Eclipse debugger mean? What do the icon decorators in Eclipse mean? What do the icons in Eclipse's Package Explorer mean? What do the little letters on top of Eclipse icons mean? What's the difference between the two error i...

How to detect DIV's dimension changed?

I've the following sample html, there is a DIV which has 100% width. It contains some elements. While performing windows re-sizing, the inner elements may be re-positioned, and the dimension of the div may change. I'm asking if it is possible to hook...

How to post an array of complex objects with JSON, jQuery to ASP.NET MVC Controller?

My current code looks like the following. How can I pass my array to the controller and what kind of parameters must my controller action accept? function getplaceholders() { var placeholders = $('.ui-sortable'); var result = new Array(); ...

Not equal <> != operator on NULL

Could someone please explain the following behavior in SQL? SELECT * FROM MyTable WHERE MyColumn != NULL (0 Results) SELECT * FROM MyTable WHERE MyColumn <> NULL (0 Results) SELECT * FROM MyTable WHERE MyColumn IS NOT NULL (568 Results) ...

Creating an XmlNode/XmlElement in C# without an XmlDocument?

I have a simple class that essentially just holds some values. I have overridden the ToString() method to return a nice string representation. Now, I want to create a ToXml() method, that will return something like this: <Song> <Artist...

Include .so library in apk in android studio

I am trying my hands on developing a simple android application in which I am trying to use sqlcipher, which uses .so libraries internally. I have read the documentation on how to use sqlcipher with android app. I have followed the steps and it compi...

Convert a Unicode string to an escaped ASCII string

How can I convert this string: This string contains the Unicode character Pi(p) into an escaped ASCII string: This string contains the Unicode character Pi(\u03a0) and vice versa? The current Encoding available in C# converts the p characte...

When does a process get SIGABRT (signal 6)?

What are the scenarios where a process gets a SIGABRT in C++? Does this signal always come from within the process or can this signal be sent from one process to another? Is there a way to identify which process is sending this signal?...

Difference between a virtual function and a pure virtual function

What is the difference between a pure virtual function and a virtual function? I know "Pure Virtual Function is a Virtual function with no body", but what does this mean and what is actually done by the line below: virtual void virtualfunctioname(...

How to add new column to an dataframe (to the front not end)?

How to add a new variable to an existing data frame, but I want to add to the front not end. eg. my dataframe is b c d 1 2 3 1 2 3 1 2 3 I want to add a new variable a, so the dataframe will looks like a b c d 0 1 2 3 0 1 2 3 0 1 2 3 ...

How to Validate on Max File Size in Laravel?

I'm trying to validate on a max file size of 500kb in Laravel: $validator = Validator::make($request->all(), [ 'file' => 'size:500', ]); But this says that the file should be exactly 500kb big. How can I edit this rule so that it return...

insert vertical divider line between two nested divs, not full height

I have float left and float right <div> nested within a light blue box div as shown in the image below. I can't figure out how to insert a vertical line between them as shown in this image: That has the following properties: 1) padding/ma...

Append String in Swift

I am new to iOS. I am currently studying iOS using Objective-C and Swift. To append a string in Objective-C I am using following code: NSString *string1 = @"This is"; NSString *string2 = @"Swift Language"; NSString *appendString=[NSString string...

PHP: HTML: send HTML select option attribute in POST

I want to send the selected item value along with some attribute (stud_name) value. Is there any functionality in PHP to do so? Here is the example one. <form name="add"> Age: <select name="age"> <...

mongodb group values by multiple fields

For example, I have these documents: { "addr": "address1", "book": "book1" }, { "addr": "address2", "book": "book1" }, { "addr": "address1", "book": "book5" }, { "addr": "address3", "book": "book9" }, { "addr": "address2", "book"...

How to let an ASMX file output JSON

I created an ASMX file with a code behind file. It's working fine, but it is outputting XML. However, I need it to output JSON. The ResponseFormat configuration doesn't seem to work. My code-behind is: [System.Web.Script.Services.ScriptService] pub...

Escaping quotes and double quotes

How do I properly escape the quotes in the -param value in the following command line? $cmd="\\server\toto.exe -batch=B -param="sort1;parmtxt='Security ID=1234'"" Invoke-Expression $cmd This of course fails. I tried to escape the quotes (single a...

How to convert a DataFrame back to normal RDD in pyspark?

I need to use the (rdd.)partitionBy(npartitions, custom_partitioner) method that is not available on the DataFrame. All of the DataFrame methods refer only to DataFrame results. So then how to create an RDD from the DataFrame data? Note: this ...

SQLite equivalent to ISNULL(), NVL(), IFNULL() or COALESCE()

I'd like to avoid having many checks like the following in my code: myObj.someStringField = rdr.IsDBNull(someOrdinal) ? string.Empty : rdr.GetString(someOrdinal); I figured I could just hav...

Plotting two variables as lines using ggplot2 on the same graph

A very newbish question, but say I have data like this: test_data <- data.frame( var0 = 100 + c(0, cumsum(runif(49, -20, 20))), var1 = 150 + c(0, cumsum(runif(49, -10, 10))), date = seq(as.Date("2002-01-01"), by="1 month", length.ou...

How to check type of variable in Java?

How can I check to make sure my variable is an int, array, double, etc...? Edit: For example, how can I check that a variable is an array? Is there some function to do this?...

Best way to check if an PowerShell Object exist?

I am looking for the best way to check if a Com Object exists. Here is the code that I have; I'd like to improve the last line: $ie = New-Object -ComObject InternetExplorer.Application $ie.Navigate("http://www.stackoverflow.com") $ie.Visible = $tru...

What is a Java String's default initial value?

Consider a Java String Field named x. What will be the initial value of x when an object is created for the class x; I know that for int variables, the default value is assigned as 0, as the instances are being created. But what becomes of String?...

Insert the same fixed value into multiple rows

I've got a table with a column, lets call it table_column that is currently null for all rows of the table. I'd like to insert the value "test" into that column for all rows. Can someone give me the SQL for this? I've tried INSERT INTO table (tab...

How to create Temp table with SELECT * INTO tempTable FROM CTE Query

I have a MS SQL CTE query from which I want to create a temporary table. I am not sure how to do it as it gives an Invalid Object name error. Below is the whole query for reference SELECT * INTO TEMPBLOCKEDDATES FROM ;with Calendar as ( select...

Loop through childNodes

I'm trying to loop through childNodes like this: var children = element.childNodes; children.forEach(function(item){ console.log(item); }); However, it output Uncaught TypeError: undefined is not a function due to forEach function. I also try ...

If strings starts with in PowerShell

Is there a way to check if a string starts with a string? We are checking the groupmembership from the AD user. Our AD groups look like this: S_G_share1_W The script for connecting the networkshares should only run if the groupname starts with "S_G...

How to create a laravel hashed password

I am trying to create an hashed password for Laravel. Now someone told me to use Laravel hash helper but I can't seem to find it or I'm looking in the wrong direction. How do I create a laravel hashed password? And where? Edit: I know what the cod...

How to get AM/PM from a datetime in PHP

I have a date time in a variable. My format is 08/04/2010 22:15:00. I want to display this like 10.15 PM. How to do this in PHP?...

Proper Linq where clauses

I write a fair amount of linq in my day to day life, but mostly simple statements. I have noticed that when using where clauses, there are many ways to write them and each have the same results as far as I can tell. For example; from x in Collecti...

GridView VS GridLayout in Android Apps

I have to use a Grid to implement Photo Browser in Android. So, I would like to know the difference between GridView and GridLayout. So that I shall choose the right one. Currently I'm using GridView to display the images dynamically....

How to delete a whole folder and content?

I want the users of my application to be able to delete the DCIM folder (which is located on the SD card and contains subfolders). Is this possible, if so how?...

How do I display todays date on SSRS report?

I want to show up Todays date as report generated date on SSRS report. How can i do that ? should I use any variable ? please help me I'm newbie to SSRS. For example refer this image: ...

Where's the DateTime 'Z' format specifier?

[Update: Format specifiers are not the same thing as format strings; a format specifier is a piece of a custom format string, where a format string is 'stock' and doesn't provide customization. My problem is with specifiers not formats] I've been tr...

What is the main difference between PATCH and PUT request?

I am using a PUT request in my Rails application. Now, a new HTTP verb, PATCH has been implemented by browsers. So, I want to know what the main difference between PATCH and PUT requests are, and when we should use one or the other. ...

how to put focus on TextBox when the form load?

I have in my C# program textBox I need that when the program start, the focus will be on the textBox I try this on Form_Load: MyTextBox.Focus(); but it wont work...

Getting a machine's external IP address with Python

Looking for a better way to get a machines current external IP #... Below works, but would rather not rely on an outside site to gather the information ... I am restricted to using standard Python 2.5.1 libraries bundled with Mac OS X 10.5.x import ...

How to read keyboard-input?

I would like to read data from the keyboard in python I try this: nb = input('Choose a number') print ('Number%s \n' % (nb)) But it doesn't work, neither with eclipse nor in the terminal, it's always stop of the question. I can type a number but ...

Default passwords of Oracle 11g?

I installed Oracle 11g. I didn't change the passwords for SYSTEM and SYS. However now I find that the default passwords do not work. Please help....

How to get label of select option with jQuery?

<select> <option value="test">label </option> </select> The value can be retrieved by $select.val(). What about the label? Is there a solution that will work in IE6?...

Real life example, when to use OUTER / CROSS APPLY in SQL

I have been looking at CROSS / OUTER APPLY with a colleague and we're struggling to find real life examples of where to use them. I've spent quite a lot of time looking at When should I use Cross Apply over Inner Join? and googling but the main (onl...

jQuery datepicker to prevent past date

How do I disable past dates on jQuery datepicker? I looked for options but don't seem to find anything that indicates the ability to disable past dates. UPDATE: Thanks yall for the quick response. I tried that with no luck. Days were still not gray...

Vertical divider CSS

I am creating a vertical divider, that works fine. But the CSS is cumbersome. The CSS is: .headerDivider1 { border-left:1px solid #38546d;height:80px;position:absolute;right:250px;top:10px; } .headerDivider2 { border-left:1px solid #16222c;height:...

The declared package does not match the expected package ""

I am using Eclipse and have not used Java for sometime. However, I can compile my code on the command-line just fine and generate the necessary .class files. In Eclipse, it complains that The declared package "Devices" does not match the expected pac...

JavaScript - Hide a Div at startup (load)

I have a div in my php page that uses jQuery to hide it once the page has loaded. But is there a way to hide it from the very start of loadup? The reason I ask is because for a brief second, you can see the div when the page is loading, and then hid...

Python: converting a list of dictionaries to json

I have a list of dictionaries, looking some thing like this: list = [{'id': 123, 'data': 'qwerty', 'indices': [1,10]}, {'id': 345, 'data': 'mnbvc', 'indices': [2,11]}] and so on. There may be more documents in the list. I need to convert these to ...

Asyncio.gather vs asyncio.wait

asyncio.gather and asyncio.wait seem to have similar uses: I have a bunch of async things that I want to execute/wait for (not necessarily waiting for one to finish before the next one starts). They use a different syntax, and differ in some details,...

How can I set selected option selected in vue.js 2?

My component vue is like this : <template> <select class="form-control" v-model="selected" :required @change="changeLocation"> <option :selected>Choose Province</option> <option v-for="option in options...

Android ADB doesn't see device

I'm trying to run my applications on OMEGA T107 tablet. But adb doesn't see my device. I tried almost everything....

Correct way to write loops for promise.

How to correctly construct a loop to make sure the following promise call and the chained logger.log(res) runs synchronously through iteration? (bluebird) db.getUser(email).then(function(res) { logger.log(res); }); // this is a promise I tried the...

How to remove all files from directory without removing directory in Node.js

How to remove all files from a directory without removing a directory itself using Node.js? I want to remove temporary files. I am not any good with filesystems yet. I have found this method, which will remove files and the directory. In that, somet...

class method generates "TypeError: ... got multiple values for keyword argument ..."

If I define a class method with a keyword argument thus: class foo(object): def foodo(thing=None, thong='not underwear'): print thing if thing else "nothing" print 'a thong is',thong calling the method generates a TypeError: myfoo = fo...

SignalR - Sending a message to a specific user using (IUserIdProvider) *NEW 2.0.0*

In the latest version of Asp.Net SignalR, was added a new way of sending a message to a specific user, using the interface "IUserIdProvider". public interface IUserIdProvider { string GetUserId(IRequest request); } public class MyHub : Hub { ...

Android Fragments and animation

How should you implement the sort of sliding that for example the Honeycomb Gmail client uses? Can TransactionManager handle this automatically by adding and removing the Fragments, it's kind of difficult to test this due to the emulator being a sli...

CSS3 background image transition

I'm trying to make a "fade-in fade-out" effect using the CSS transition. But I can't get this to work with the background image... The CSS: .title a { display: block; width: 340px; height: 338px; color: black; background: transp...

How to to send mail using gmail in Laravel?

I try again and again to test sending an email from localhost but I still cannot. I don't know anymore how to do it. I try search to find solution but I cannot find one. I edited config/mail.php: <?php return [ /* |--------------------...

S3 limit to objects in a bucket

Does anyone know if there is a limit to the number of objects I can put in an S3 bucket? can I put a million, 10 million etc.. all in a single bucket?...

How to put a jpg or png image into a button in HTML

I want a button with an image in it. I am using this: <input type="submit" name="submit" src="images/stack.png" /> But it does not show the image. I want the whole button to be the image. ...

Array Length in Java

I declared an array as shown below: int[] arr = new int[10]; Then I assigned following values to the array: arr[0] = 1; arr[1] = 2; arr[2] = 3; arr[3] = 4; Then I declared and initialized an integer variable: int arrayLength = arr.length; Th...

Select method in List<t> Collection

I have an asp.net application, and now I am using datasets for data manipulation. I recently started to convert this dataset to a List collection. But, in some places it doesn't work. One is that in my old version I am using datarow[] drow = dataset...

Access to Image from origin 'null' has been blocked by CORS policy

I have JavaScript application in OpenLayers 3, and my base layer is created from local tiles. I work only in my computer so I do not know why I have CORS error. var newLayer = new ol.layer.Tile({ source: new ol.source.OSM({ url: 'E:/...

How to blur background images in Android

What is the best way to blur background images like the image below? I saw some code and libraries but their are a couple of years old or like BlurBehind library, but it doesn't give the same effect. Thanks in advance! ...

Visual Studio Code - is there a Compare feature like that plugin for Notepad ++?

Is there a Compare feature like the Plugin for Notepad++?...

In Angular, how to pass JSON object/array into directive?

Currently, my app has a controller that takes in a JSON file then iterates through them using "ng-repeat". This is all working great, but I also have a directive that needs to iterate through the same JSON file. This is posing a problem as I cannot r...

How to tell PowerShell to wait for each command to end before starting the next?

I have a PowerShell 1.0 script to just open a bunch of applications. The first is a virtual machine and the others are development applications. I want the virtual machine to finish booting before the rest of the applications are opened. In bash I ...

How to choose multiple files using File Upload Control?

I have a file upload control.Now on clicking on that, I want to select multiple files. How can I do so?...

remove legend title in ggplot

I'm trying to remove the title of a legend in ggplot2: df <- data.frame( g = rep(letters[1:2], 5), x = rnorm(10), y = rnorm(10) ) library(ggplot2) ggplot(df, aes(x, y, colour=g)) + geom_line(stat="identity") + theme(legend.position="b...

How to make an HTTP request + basic auth in Swift

I have a RESTFull service with basic authentication and I want to invoke it from iOS+swift. How and where I must provide Credential for this request? My code (sorry, I just start learn iOS/obj-c/swift): class APIProxy: NSObject { var data: NSMutabl...

Get all unique values in a JavaScript array (remove duplicates)

I have an array of numbers that I need to make sure are unique. I found the code snippet below on the internet and it works great until the array has a zero in it. I found this other script here on Stack Overflow that looks almost exactly like it, bu...

How to check Elasticsearch cluster health?

I tried to check it via curl -XGET 'http://localhost:9200/_cluster/health' but nothing happened. Seems it's waiting for something. The console did not come back. Had to kill it with CTRL+C. I also tried to check for existing indices via curl -X...

How do I set Java's min and max heap size through environment variables?

How do I set Java's min and max heap size through environment variables? I know that the heap sizes can be set when launching java, but I would like to have this adjusted through environment variables on my server....

How do I tell what type of value is in a Perl variable?

How do I tell what type of value is in a Perl variable? $x might be a scalar, a ref to an array or a ref to a hash (or maybe other things)....

How to retrieve an element from a set without removing it?

Suppose the following: >>> s = set([1, 2, 3]) How do I get a value (any value) out of s without doing s.pop()? I want to leave the item in the set until I am sure I can remove it - something I can only be sure of after an asynchronous cal...

Powershell: convert string to number

Ok, I am beginner - and lost with this: I have an Array where some drive data from WMI are captured: $drivedata = $Drives | select @{Name="Kapazität(GB)";Expression={$_.Kapazität}} The Array has these values (2 drives): @{Kapazität(GB)=1.500...

urlencode vs rawurlencode?

If I want to create a URL using a variable I have two choices to encode the string. urlencode() and rawurlencode(). What exactly are the differences and which is preferred?...

Pod install is staying on "Setting up CocoaPods Master repo"

I'm cloning a project from a git repo, but when I execute pod install the first line I see is "Setting up CocoaPods Master repo" and after that I can't see anything more, the console stops there. I don't know what is happening. Anyone knows what's h...

Entity Framework: "Store update, insert, or delete statement affected an unexpected number of rows (0)."

I am using Entity Framework to populate a grid control. Sometimes when I make updates I get the following error: Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since...

PHP - find entry by object property from an array of objects

The array looks like: [0] => stdClass Object ( [ID] => 420 [name] => Mary ) [1] => stdClass Object ( [ID] => 10957 [name] => Blah ) ... And I have...

C# using streams

Streams are kind of mysterious to me. I don't know when to use which stream and how to use them. Can someone explain to me how streams are used? If I understand correctly, there are three stream types: stream read stream write stream Is this cor...

jQuery remove all list items from an unordered list

I forgot the jQuery command that will clear all list elements from a list. I did a bit of searching, done it a bunch of times before, but just simply forgot the command. $("ul").clear() $("ul").empty() both didn't seem to accomplish this.. which c...

How to measure elapsed time in Python?

What I want is to start counting time somewhere in my code and then get the passed time, to measure the time it took to execute few function. I think I'm using the timeit module wrong, but the docs are just confusing for me. import timeit start = t...

How to remove new line characters from a string?

I have a string in the following format string s = "This is a Test String.\n This is a next line.\t This is a tab.\n' I want to remove all the occurrences of \n and \r from the string above. I have tried string s = s.Trim(new char[] {'\n', '\r'...

Placing an image to the top right corner - CSS

I need to display an image on the top-right corner of a div (the image is a "diagonal" ribbon) but keeping the current text contained in an internal div, like stuck to the top of it. I tried different things as including the image in another div or ...

Wait Until File Is Completely Written

When a file is created (FileSystemWatcher_Created) in one directory I copy it to another. But When I create a big (>10MB) file it fails to copy the file, because it starts copying already, when the file is not yet finished creating... This causes Can...

How do you prevent install of "devDependencies" NPM modules for Node.js (package.json)?

I have this in my package.json file (shortened version): { "name": "a-module", "version": "0.0.1", "dependencies": { "coffee-script": ">= 1.1.3" }, "devDependencies": { "stylus": ">= 0.17.0" } } I am usin...

Java SE 6 vs. JRE 1.6 vs. JDK 1.6 - What do these mean?

I see many different Java terms floating around. I need to install the JDK 1.6. It was my understanding that Java 6 == Java 1.6. However, when I install Java SE 6, I get a JVM that reports as version 11.0! Who can solve the madness?...

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0. Could not resolve com.android.support:appcompat-v7:26.1.0. Required by: project :app No cached version of com.android.sup...

Opening Chrome From Command Line

I have the following batch file: @echo off REM Starts a chrome browser with multiple tabbed sites C:\Users\UserName\AppData\Local\Google\Chrome\Application\chrome.exe "site1.com" "site2.com" But when I run it, it causes the prompt to hang and rend...

How can I access the MySQL command line with XAMPP for Windows?

How can I access the MySQL command line with XAMPP for Windows?...

Unable to execute dex: Multiple dex files define Lcom/myapp/R$array;

Since updating to ADT 14 I can no longer build my project. It was building fine prior to updating. The error: [2011-10-23 16:23:29 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/myapp/R$array; [2011-10-23 16:23:29 - myProj] Co...

REST API - Use the "Accept: application/json" HTTP Header

When I make a request, I get a response in XML, but what I need is JSON. In the doc it is stated in order to get a JSON in return: Use the Accept: application/json HTTP Header. Where do I find the HTTP Header to put Accept: application/json inside? ...

Angularjs - ng-cloak/ng-show elements blink

I have an issue in angular.js with directive/class ng-cloak or ng-show. Chrome works fine, but Firefox is causing blink of elements with ng-cloak or ng-show. IMHO it's caused by the converting ng-cloak/ng-show to style="display: none;", probably the...

curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number

When I try to connect to any server (e.g. google.com) using curl (or libcurl) I get the error message: curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number Verbose output: $ curl www.google.com --verbose * Rebuilt URL ...

XML Error: There are multiple root elements

I am getting XML from a web service. Here is what the XML looks like: <parent> <child> Text </child> </parent> <parent> <child> <grandchild> Text </grandch...

Automate scp file transfer using a shell script

I have some n number of files in a directory on my unix system. Is there a way to write a shellscript that will transfer all those files via scp to a specified remote system. I'll specify the password within the script, so that I don't have to enter ...

CSS getting text in one line rather than two

I have a small issue with a title where I would like text to display on a single line rather than split onto two as im trying to arrange these blocks as a grid jsFiddle html <div class="garage-row"> <a class="garage-row-title" href="/...

Finding the position of the max element

Is there a standard function that returns the position(not value) of the max element of an array of values? For example: Suppose I have an array like this: sampleArray = [1, 5, 2, 9, 4, 6, 3] I want a function that returns the integer of 3 that ...

vba pass a group of cells as range to function

I'm getting a group of cells and doing some calculations over them in function below. It works if I pass a range (with : sign) as first parameter, but it fails if I choose some cells as its range (A1, A3, B6, B9). It just gets first cell before comm...

Inserting HTML elements with JavaScript

Instead of tediously search for workarounds for each type of attribute and event when using the following syntax: elem = document.createElement("div"); elem.id = 'myID'; elem.innerHTML = ' my Text ' document.body.insertBefore(elem,document.body.chil...

OpenCV NoneType object has no attribute shape

Hello I'm working on Raspberry Pi with OpenCV. I want to try a tutorial which is ball tracking in link http://www.pyimagesearch.com/2015/09/14/ball-tracking-with-opencv/ But when I compile it, i get an error: 'NoneType' object has no attribute 'shap...

How to get the second column from command output?

My command's output is something like: 1540 "A B" 6 "C" 119 "D" The first column is always a number, followed by a space, then a double-quoted string. My purpose is to get the second column only, like: "A B" "C" "D" I intended to use <s...

How to Verify if file exist with VB script

How do I verify via VBScript if the file conf exist under Program Files (i.e. C:\Program Files\conf)? For example if it exists, then msgBox "File exists" If not, then msgbox "File doesn't exist"...

JSF(Primefaces) ajax update of several elements by ID's

One more question concerning JSF.Particularly, Primefaces. Have following problem with ajax update of elements by id's at same time. If elements on page goes one by one ,that ajax update performs ok: <ui:repeat value="#{showProducts.inCart}" var=...

How do I upload a file with metadata using a REST web service?

I have a REST web service that currently exposes this URL: http://server/data/media where users can POST the following JSON: { "Name": "Test", "Latitude": 12.59817, "Longitude": 52.12873 } in order to create a new Media metadata. No...

How to run SUDO command in WinSCP to transfer files from Windows to linux

I am trying to use WinSCP to transfer files over to a Linux Instance from Windows. Im using private key for my instance to login to Amazon instance using ec2-user. However ec2-user does not have access to write to the Linux instance How do i sudo...

hasNext in Python iterators?

Haven't Python iterators got a hasNext method?...

PHP - check if variable is undefined

Consider this Javascript statement isTouch = document.createTouch !== undefined I would like to know if we have a similar statement in PHP, not being isset() but literally checking for an undefined value, something like: $isTouch != "" Is ...

What is the optimal algorithm for the game 2048?

I have recently stumbled upon the game 2048. You merge similar tiles by moving them in any of the four directions to make "bigger" tiles. After each move, a new tile appears at random empty position with a value of either 2 or 4. The game terminates ...

Using GregorianCalendar with SimpleDateFormat

So, I've been racking my brain over this (should-be) simple exercise to make the program turn a date string into a GregorianCalendar object, format it, and return it again as a string when it's done. This is the last little bit of a program that tak...

Why does Vim save files with a ~ extension?

I've found that while using Vim on Windows Vim saves the file, a .ext.swp file that's deleted on closing the Vim window and a .ext~ file. I assume the .ext.swp file is a session backup in case Vim crashes. What's the purpose of the .ext~ file howev...

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

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

How do I display ? Play (Forward) or Solid right arrow symbol in html?

How do I display this ? Play (Forward) or Solid right arrow symbol in html?...

How to dynamically add and remove form fields in Angular 2

I'm trying to add input fields dynamically while the user clicks the add button and for each form field there must be a remove button, when the user clicks that the form fields must be removed, I need to achieve this using Angular 2, as I'm new to An...

Node.js for() loop returning the same values at each loop

I'm making this really simple application to help me explore nodejs and I have a particular handler that generates HTML code based on the top10 messages in my database. The snippet I'm having problem with loops through the messages and call the funct...

Group by multiple field names in java 8

I found the code for grouping the objects by some field name from POJO. Below is the code for that: public class Temp { static class Person { private String name; private int age; private long salary; Person(St...

How to escape a while loop in C#

I am trying to escape a while loop. Basically, if the "if" condition is met, I would like to be able to exit this loop: private void CheckLog() { while (true) { Thread.Sleep(5000); if (!System.IO.File.Exists("Command.bat")) ...

How do I enable Java in Microsoft Edge web browser?

My corporate web application is using Java applet to access users file system. There is no way for us to replace it with anything else for now. How do I enable Java in Microsoft Edge?...

How to set delay in android?

public void onClick(View v) { // TODO Auto-generated method stub switch(v.getId()){ case R.id.rollDice: Random ranNum = new Random(); int number = ranNum.nextInt(6) + 1; diceNum.setText(""+n...

JUnit 5: How to assert an exception is thrown?

Is there a better way to assert that a method throws an exception in JUnit 5? Currently, I have to use an @Rule in order to verify that my test throws an exception, but this doesn't work for the cases where I expect multiple methods to throw excepti...

Difference between Fact table and Dimension table?

When reading a book for business objects, I came across the term- fact table and dimension table. I am trying to understand what is the different between Dimension table and Fact table? I read couple of articles on the internet but I was not able ...

Load content with ajax in bootstrap modal

I am trying to have my bootstrap modal retrieve data using ajax: <a href="{{ path('ajax_get_messages', { 'superCategoryID': 35, 'sex': sex }) }}" data-toggle="modal" data-target="#birthday-modal"> <img src="{{ asset('bundles/yopyourownpoe...

How can I center an image in Bootstrap?

I am struggling to center an image using only Bootstrap's CSS-classes. I already tried several things. One was adding Bootstrap CSS-class mx-auto to the img element, but it does nothing. Help is appreciated. <div class="container"> <di...

List of Java class file format major version numbers?

I saw this list of major version numbers for Java in another post: Java 1.2 uses major version 46 Java 1.3 uses major version 47 Java 1.4 uses major version 48 Java 5 uses major version 49 Java 6 uses major version 50 Java 7 uses major version 51 J...

How to get local server host and port in Spring Boot?

I'm starting up a Spring Boot application with mvn spring-boot:run. One of my @Controllers needs information about the host and port the application is listening on, i.e. localhost:8080 (or 127.x.y.z:8080). Following the Spring Boot documentation, I...

Download a file from NodeJS Server using Express

How can I download a file that is in my server to my machine accessing a page in a nodeJS server? I'm using the ExpressJS and I've been trying this: app.get('/download', function(req, res){ var file = fs.readFileSync(__dirname + '/upload-folder/...

Javascript search inside a JSON object

I had a JSON string / object in my application. {"list": [ {"name":"my Name","id":12,"type":"car owner"}, {"name":"my Name2","id":13,"type":"car owner2"}, {"name":"my Name4","id":14,"type":"car owner3"}, {"name":"my Name4","id":15,"...

What Process is using all of my disk IO

If I use "top" I can see what CPU is busy and what process is using all of my CPU. If I use "iostat -x" I can see what drive is busy. But how do I see what process is using all of the drive's throughput?...

LD_LIBRARY_PATH vs LIBRARY_PATH

I'm building a simple C++ program and I want to temporarily substitute a system supplied shared library with a more recent version of it, for development and testing. I tried setting the LD_LIBRARY_PATH variable but the linker (ld) failed with: ...

phpMyAdmin - config.inc.php configuration?

With this configuration i found the error The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. To find out why click here. When click then the following error is found: ...

Get all files modified in last 30 days in a directory

CentOS. Need to find files modified in last 30 days to see if any of them have been infected with malware. I tried this: root@server [/home/someuser/public_html/]# find . -mtime +30 -exec ls -l {} > last30days.txt \; But instead of the last 3...

Failed to resolve: com.google.firebase:firebase-core:16.0.1

I'm trying to add firebase cloud storage to my app. Below is the app build.gradle. But it says: Failed to resolve: com.google.firebase:firebase-core:16.0.1. Why? There is no firebase-core in the dependencies at all. apply plugin: 'com.android.appli...

Do Java arrays have a maximum size?

Is there a limit to the number of elements a Java array can contain? If so, what is it?...

PHP mailer multiple address

Possible Duplicate: PHPMailer AddAddress() Here is my code. require('class.phpmailer.php'); $mail = new PHPMailer(); $email = '[email protected], [email protected], [email protected]'; $sendmail = "$email"; $mail->AddAddress($sendma...

Updating PartialView mvc 4

Ey! How I could refresh a Partial View with data out of the Model? First time, when the page loads it's working properly, but not when I call it from the Action. The structure I've created looks like: Anywhere in my View: @{ Html.RenderAction("Upd...

ngOnInit not being called when Injectable class is Instantiated

Why isn't ngOnInit() called when an Injectable class is resolved? Code import {Injectable, OnInit} from 'angular2/core'; import { RestApiService, RestRequest } from './rest-api.service'; @Injectable() export class MovieDbService implements OnInit ...

ValidateRequest="false" doesn't work in Asp.Net 4

I have a form at which I use ckeditor. This form worked fine at Asp.Net 2.0 and 3.5 but now it doesn't work in Asp.Net 4+. I have ValidateRequest="false" directive. Any suggestions?...

Ways to insert javascript into URL?

Duplicate of: What common web exploits should I know about? This is a security question. What should I look for in URL that prevents hacking? Is there a way to execute javascript by passing it inside a URL? As you can see I'm pretty new to...

How To Pass GET Parameters To Laravel From With GET Method ?

i'm stuck at this very basic form, that i could not accomplish, which i want to build a search form with an text input, and two select controls, with a route that accept 3 parameters, the problem that when the i submit the form, it map the parameters...

Reverse for '*' with arguments '()' and keyword arguments '{}' not found

Caught an exception while rendering: Reverse for 'products.views.'filter_by_led' with arguments '()' and keyword arguments '{}' not found. I was able to successfully import products.views.filter_by_led from the shell and it worked so the pa...

How to export data with Oracle SQL Developer?

How to export Oracle DB data using SQL Developer? I need all data, tables, constraints, structure and so on....

first-child and last-child with IE8

I have some css for adjusting things in my table. Here it is: .editor td:first-child { width: 150px; } .editor td:last-child input, .editor td:last-child textarea { width: 500px; padding: 3px 5px 5px 5px; border: 1px solid #CCC; ...

How to set the background image of a html 5 canvas to .png image

I would like to know how it is possible to set the background image of a canvas to a .png file. I do not want to add the image in the back of the canvas and make the canvas transparent. I want the user to be able to actually draw on that canvas wit...

Changing an element's ID with jQuery

I need to change an element's ID using jQuery. Apparently these don't work: jQuery(this).prev("li").attr("id")="newid" jQuery(this).prev("li")="newid" I found out that I can make it happen with the following code: jQuery(this).prev("li")show(f...

Python check if website exists

I wanted to check if a certain website exists, this is what I'm doing: user_agent = 'Mozilla/20.0.1 (compatible; MSIE 5.5; Windows NT)' headers = { 'User-Agent':user_agent } link = "http://www.abc.com" req = urllib2.Request(link, headers = headers) ...

Force R not to use exponential notation (e.g. e+10)?

Can I force R to use regular numbers instead of using the e+10-like notation? I have: 1.810032e+09 # and 4 within the same vector and want to see: 1810032000 # and 4 I am creating output for an old fashioned program and I have to write a text...

Create GUI using Eclipse (Java)

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

Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error?

I'm trying to link a UILabel with an IBOutlet created in my class. My application is crashing with the following error. What does this mean? How can I fix it? *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[&...

How to use export with Python on Linux

I need to make an export like this in Python : # export MY_DATA="my_export" I've tried to do : # -*- python-mode -*- # -*- coding: utf-8 -*- import os os.system('export MY_DATA="my_export"') But when I list export, "MY_DATA" not appear : # exp...

Creating temporary files in Android

What's the best way to create a temporary file in Android? Can File.createTempFile be used? The documentation is very vague about it. In particular, it's not clear when temporary files created with File.createTempFile are deleted, if ever....

ImportError: No Module named simplejson

I'm trying to run a command to install bespinclient on my Windows laptop but every time I execute the command python bootstrap.py --no-site-packages, I get an error saying: ImportError: No module named simplejson I'm using Mozilla build tools...

Copy entire contents of a directory to another using php

I tried to copy the entire contents of the directory to another location using copy ("old_location/*.*","new_location/"); but it says it cannot find stream, true *.* is not found. Any other way Thanks Dave...

How do I update a formula with Homebrew?

How do I update a formula? I ran brew update. Then, running brew outdated, outputs: mongodb (1.4.3-x86_64 < 1.6.5-x86_64) Thus, mongodb is outdated. How do I upgrade it? Do I just uninstall and then install?...

Is recursion ever faster than looping?

I know that recursion is sometimes a lot cleaner than looping, and I'm not asking anything about when I should use recursion over iteration, I know there are lots of questions about that already. What I'm asking is, is recursion ever faster than a l...

AngularJS: How to set a variable inside of a template?

How can I avoid having the {{f = ...}} statement in the third line print out the content of forecast[day.iso]? I want to avoid using forecast[day.iso].temperature and so on for every iteration. <div ng-repeat="day in forecast_days"> {{$inde...

Bootstrap how to get text to vertical align in a div container

What is the best/proper way to vertically align the text in the middle of its column? The image height is statically set in the CSS. I have tried setting an outer div to display: table and an inner div to display: table-cell with vertical-align: mid...

angular.service vs angular.factory

I have seen both angular.factory() and angular.service() used to declare services; however, I cannot find angular.service anywhere in official documentation. What is the difference between the two methods? Which should be used for what (assuming the...

URL format with GET parameters?

Is there a specification somewhere listing the correct way to pass GET variables to a URL? Normally I do it like this (first variable indicated by ?, second and subsequent indicated by &: http://www.mysite.com/mypage.html?var1=value1&var2=v...

How to get the current date and time of your timezone in Java?

I have my app hosted in a London Server. I am in Madrid, Spain. So the timezone is -2 hours. How can I obtain the current date / time with my time zone. Date curr_date = new Date(System.currentTimeMillis()); e.g. Date curr_date = new Date(Syst...

Add the loading screen in starting of the android application

My app is loading the start page in 10 seconds. In that time of 10 sec android screen is blank. In that time I want to add the loading screen. How to add it? And tell me in app how to know the starting page is loading? And tell me how to do in my ap...

Docker - Ubuntu - bash: ping: command not found

I've got a Docker container running Ubuntu which I did as follows: docker run -it ubuntu /bin/bash however it doesn't seem to have ping. E.g. bash: ping: command not found Do I need to install that? Seems a pretty basic command to be missing. ...

How schedule build in Jenkins?

How do I schedule a Jenkins build such that it would be able to build only at specific hours every day? For example to start at 4 PM 0 16 1-7 * * I understand that as: 0 minutes, at 4 o'clock PM from Monday to Sunday every month, however it build...

Split string with string as delimiter

I'm trying to split a string in a batch file using a string (rather than a character) as the delimiter. The string has the format: string1 by string2.txt The delimiter is by (yes, space, the word 'by', followed by space). The output I want is: s...

How to add a margin to a table row <tr>

I have a table containing many rows. Some of these rows are class="highlight" and signify a row that needs to be styled differently and highlighted. What I'm trying to do is add some extra spacing before and after these rows so they appear slightly s...

Given URL is not permitted by the application configuration

I have used this in my html page... <script> window.fbAsyncInit = function() { // init the FB JS SDK FB.init({ appId : 'xxxxxxxxxxxxxx', // App ID from the App Dashboard status : true, // check the login statu...

HTML character codes for this ? or this ?

What are the HTML entity character codes for this up arrow (?) and its downward-facing dog version (?) ? I've been using GIFs to represent these arrows since I don't know their codes....

node.js require() cache - possible to invalidate?

From the node.js documentation: Modules are cached after the first time they are loaded. This means (among other things) that every call to require('foo') will get exactly the same object returned, if it would resolve to the same file. Is there...

How to remove all characters after a specific character in python?

I have a string. How do I remove all text after a certain character? (In this case ...) The text after will ... change so I that's why I want to remove all characters after a certain one....

How do I remove an item from a stl vector with a certain value?

I was looking at the API documentation for stl vector, and noticed there was no method on the vector class that allowed the removal of an element with a certain value. This seems like a common operation, and it seems odd that there's no built in way ...

git remote prune – didn't show as many pruned branches as I expected

From the man page: Deletes all stale tracking branches under <name>. These stale branches have already been removed from the remote repository referenced by <name>, but are still locally available in "remotes/<name>". So I remo...

ReadFile in Base64 Nodejs

I'm trying to read an image from client side encoded in base64. How to read with nodejs? My code: // add to buffer base64 image var encondedImage = new Buffer(image.name, 'base64'); fs.readFile(encondedImage, "base64", function(err, buffer){ i...

How to get screen dimensions as pixels in Android

I created some custom elements, and I want to programmatically place them to the upper right corner (n pixels from the top edge and m pixels from the right edge). Therefore I need to get the screen width and screen height and then set position: int ...

How to connect to a secure website using SSL in Java with a pkcs12 file?

I have a pkcs12 file. I need to use this to connect to a webpage using https protocol. I came across some code where in order to connect to a secure web page i need to set the following system properties: System.setProperty("javax.net.ssl.trustStore...

How do you read scanf until EOF in C?

I have this but once it reaches the supposed EOF it just repeats the loop and scanf again. int main(void) { char words[16]; while(scanf("%15s", words) == 1) printf("%s\n", words); return 0; } ...

How to get first and last day of the current week in JavaScript

I have today = new Date(); object. I need to get first and last day of the current week. I need both variants for Sunday and Monday as a start and end day of the week. I am little bit confuse now with a code. Can your help me?...

How do you display JavaScript datetime in 12 hour AM/PM format?

How do you display a JavaScript datetime object in the 12 hour format (AM/PM)?...

Getting NetworkCredential for current user (C#)

I'm trying to invoke a webservice from a console application, and I need to provide the client with a System.Net.NetworkCredential object. Is it possible to create a NetworkCredential object for the user that started the application without prompting...

How to list the contents of a package using YUM?

I know how to use rpm to list the contents of a package (rpm -qpil package.rpm). However, this requires knowing the location of the .rpm file on the filesystem. A more elegant solution would be to use the package manager, which in my case is YUM. How...

The located assembly's manifest definition does not match the assembly reference

I am trying to run some unit tests in a C# Windows Forms application (Visual Studio 2005), and I get the following error: System.IO.FileLoadException: Could not load file or assembly 'Utility, Version=1.2.0.200, Culture=neutral, PublicKeyToken=764d5...

How to test if a double is zero?

I have some code like this: class Foo { public double x; } void test() { Foo foo = new Foo(); // Is this a valid way to test for zero? 'x' hasn't been set to anything yet. if (foo.x == 0) { } foo.x = 0.0; // Will the...

JAVA How to remove trailing zeros from a double

For example I need 5.0 to become 5, or 4.3000 to become 4.3....

How can I perform a str_replace in JavaScript, replacing text in JavaScript?

I want to use str_replace or its similar alternative to replace some text in JavaScript. var text = "this is some sample text that i want to replace"; var new_text = replace_in_javascript("want", "dont want", text); document.write("new_text"); sho...

Understanding generators in Python

I am reading the Python cookbook at the moment and am currently looking at generators. I'm finding it hard to get my head round. As I come from a Java background, is there a Java equivalent? The book was speaking about 'Producer / Consumer', however...

Invoking modal window in AngularJS Bootstrap UI using JavaScript

Using the example mentioned here, how can I invoke the modal window using JavaScript instead of clicking a button? I am new to AngularJS and tried searching the documentation here and here without luck. Thanks...

Detecting when user scrolls to bottom of div with jQuery

I have a div box (called flux) with a variable amount of content inside. This divbox has overflow set to auto. Now, what I am trying to do, is, when the use scroll to the bottom of this DIV-box, load more content into the page, I know how to do this...

The name 'ConfigurationManager' does not exist in the current context

I am trying to access connectionStrings from the config file. The code is ASP.NET + C#. I have added System.Configuration to reference and also mentioned with using. But still it wouldn't accept the assembly. I am using VSTS 2008. Any idea what coul...

Why does the Google Play store say my Android app is incompatible with my own device?

I am hesitant to ask this question, because it appears as though many people have a similar problem and yet I have found no solution that solves my particular instance. I have developed an Android app (link to the actual app) and have uploaded it to...

Use -notlike to filter out multiple strings in PowerShell

I'm trying to read the event log for a security audit for all users except two, but is it possible to do that with the -notlike operator? It's something like that: Get-EventLog -LogName Security | where {$_.UserName -notlike @("*user1","*user2")} ...

Setting default values to null fields when mapping with Jackson

I am trying to map some JSON objects to Java objects with Jackson. Some of the fields in the JSON object are mandatory(which I can mark with @NotNull) and some are optional. After the mapping with Jackson, all the fields that are not set in the JSON...

How to print multiple lines of text with Python

If I wanted to print multiple lines of text in Python without typing print('') for every line, is there a way to do that? I'm using this for ASCII art. (Python 3.5.1)...

Value Change Listener to JTextField

I want the message box to appear immediately after the user changes the value in the textfield. Currently, I need to hit the enter key to get the message box to pop out. Is there anything wrong with my code? textField.addActionListener(new java.awt....

Open JQuery Datepicker by clicking on an image w/ no input field

I want to have the JQuery Datepicker open when the user clicks on an image. There is no input field where the selected date appears afterwards; I'm just going to save the entered date to the server via Ajax. Currently I have this code: <img src=...

Check if a string has white space

I'm trying to check if a string has white space. I found this function but it doesn't seem to be working: function hasWhiteSpace(s) { var reWhiteSpace = new RegExp("/^\s+$/"); // Check for white space if (reWhiteSpace.test(s)) { ...

NoClassDefFoundError on Maven dependency

My first use of Maven and I'm stuck with dependencies. I created a Maven project with Eclipse and added dependencies, and it was working without problems. But when I try to run it via command line: $ mvn package # successfully completes $ java -...

Check array position for null/empty

I have an array which might contain empty/null positions (e.g: array[2]=3, array[4]=empty/unassigned). I want to check in a loop whether the array position is null. array[4]==NULL //this doesn't work I'm pretty new to C++. Thanks. Edit: Here's ...

Swapping two variable value without using third variable

One of the very tricky questions asked in an interview. Swap the values of two variables like a=10 and b=15. Generally to swap two variables values, we need 3rd variable like: temp=a; a=b; b=temp; Now the requirement is, swap values of two varia...

How to uninstall Anaconda completely from macOS

How can I completely uninstall Anaconda from MacOS Sierra and revert back to the original Python? I have tried using conda-clean -yes but that doesn't work. I also remove the stuff in ~/.bash_profile but it still uses the Anaconda python and I can st...

SQL Server - Adding a string to a text column (concat equivalent)

How do you add a string to a column in SQL Server? UPDATE [myTable] SET [myText]=' '+[myText] That doesn't work: The data types varchar and text are incompatible in the add operator. You would use concat on MySQL, but how do you do it on SQL...

How to get error message when ifstream open fails

ifstream f; f.open(fileName); if ( f.fail() ) { // I need error message here, like "File not found" etc. - // the reason of the failure } How to get error message as string?...

What is the meaning of polyfills in HTML5?

What is the meaning of polyfills in HTML5? I saw this word in many sites about HTML5, e.g. HTML5-Cross-Browser-Polyfills. So here we're collecting all the shims, fallbacks, and polyfills in order to implant HTML5 functionality in browsers that ...

pthread function from a class

Let's say I have a class such as class c { // ... void *print(void *){ cout << "Hello"; } } And then I have a vector of c vector<c> classes; pthread_t t1; classes.push_back(c()); classes.push_back(c()); Now, I want to creat...

Access denied for user 'root'@'localhost' with PHPMyAdmin

When I set the root password in PHPMyAdmin, I get this error: #1045 - Access denied for user 'root'@'localhost' (using password: NO) I can't open the PHPMyAdmin panel. What am I doing wrong?...

Solr vs. ElasticSearch

What are the core architectural differences between these technologies? Also, what use cases are generally more appropriate for each?...

VB.NET 'If' statement with 'Or' conditional has both sides evaluated?

Quick question, of which the quickest and easiest answer may well be to rearrange related code, but let's see... So I have an If statement (a piece of code which is a part of a full working solution written in C#) rewritten using VB.NET. I am aware ...

Adjusting HttpWebRequest Connection Timeout in C#

I believe after lengthy research and searching, I have discovered that what I want to do is probably better served by setting up an asynchronous connection and terminating it after the desired timeout... But I will go ahead and ask anyway! Quick sni...

How to retrieve GET parameters from JavaScript

Consider: http://example.com/page.html?returnurl=%2Fadmin For js within page.html, how can it retrieve GET parameters? For the above simple example, func('returnurl') should be /admin. But it should also work for complex query strings......

Validate that a string is a positive integer

I would like the simplest fail-safe test to check that a string in JavaScript is a positive integer. isNaN(str) returns true for all sorts of non-integer values and parseInt(str) is returning integers for float strings, like "2.5". And I don't want ...

Mongoose: findOneAndUpdate doesn't return updated document

Below is my code var mongoose = require('mongoose'); mongoose.connect('mongodb://localhost/test'); var Cat = mongoose.model('Cat', { name: String, age: {type: Number, default: 20}, create: {type: Date, default: Date.now} }); Cat.findO...

Cannot hide status bar in iOS7

I just upgraded my iPhone 5 iOS 7 to four beta version. Now when I run my app from Xcode 5 on this iPhone, status bar doesn’t hide, even though it should. Not Working: [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStat...

When is the @JsonProperty property used and what is it used for?

This bean 'State' : public class State { private boolean isSet; @JsonProperty("isSet") public boolean isSet() { return isSet; } @JsonProperty("isSet") public void setSet(boolean isSet) { this.isSet = isSet;...

What is the final version of the ADT Bundle?

What is the final version of the ADT Bundle that was released by Google? Since "Android Studio" was announced as official IDE for the development of Android apps, the ADT Bundle (Eclipse with ADT Plugin & Android SDK) cannot be downloaded from ...

Export data from Chrome developer tool

Network analysis by Chrome when page loads I would like to export this data to Microsoft Excel so that I will have a list of similar data when loaded at diffrent times. Loading a page one time doesn't really tell me much especially if I want to ...

How to convert Windows end of line in Unix end of line (CR/LF to LF)

I'm a Java developer and I'm using Ubuntu to develop. The project was created in Windows with Eclipse and it's using the Windows-1252 encoding. To convert to UTF-8 I've used the recode program: find Web -iname \*.java | xargs recode CP1252...UTF-8 T...

Draw on HTML5 Canvas using a mouse

I want to draw on a HTML Canvas using a mouse (for example, draw a signature, draw a name, ...) How would I go about implementing this?...

How do I correctly clean up a Python object?

class Package: def __init__(self): self.files = [] # ... def __del__(self): for file in self.files: os.unlink(file) __del__(self) above fails with an AttributeError exception. I understand Python doesn't g...

PHP to search within txt file and echo the whole line

Using php, I'm trying to create a script which will search within a text file and grab that entire line and echo it. I have a text file (.txt) titled "numorder.txt" and within that text file, there are several lines of data, with new lines coming in...

Flutter- wrapping text

I want wrap text as text grows. I searched through and tried wrap with almost everything but still text stays one line and overflows from the screen. Does anyone know how to achieve this? Any help is highly appreciated! Positioned( left: positi...

Select first occurring element after another element

I've got the following HTML code on a page: <h4>Some text</h4> <p> Some more text! </p> In my .css I've got the following selector to style the h4 element. The HTML code above is just a small part of the entire code; there ...

What is the point of the diamond operator (<>) in Java 7?

The diamond operator in java 7 allows code like the following: List<String> list = new LinkedList<>(); However in Java 5/6, I can simply write: List<String> list = new LinkedList(); My understanding of type erasure is that the...

Trouble using ROW_NUMBER() OVER (PARTITION BY ...)

I'm using SQL Server 2008 R2. I have table called EmployeeHistory with the following structure and sample data: EmployeeID Date DepartmentID SupervisorID 10001 20130101 001 10009 10001 20130909 001 10019 10001 ...

Use CSS to make a span not clickable

<html> <head> </head> <body> <div> <a href="http://www.google.com"> <span>title<br></span> <span>description<br></spa...

Get the current user, within an ApiController action, without passing the userID as a parameter

How do we get the current user, within an secure ApiController action, without passing the userName or userId as a parameter? We assume that this is available, because we are within a secure action. Being in a secure action means that the user has ...

boto3 client NoRegionError: You must specify a region error only sometimes

I have a boto3 client : boto3.client('kms') But it happens on new machines, They open and close dynamically. if endpoint is None: if region_name is None: # Raise a more specific error message that will give # ...

Netbeans - class does not have a main method

My program is just a simple System.out.println(""); But netbeans cannot find the main method. Is netbeans 6.7.1 conflict with WIN7? Any possible error?...

PostgreSQL: role is not permitted to log in

I have trouble connecting to my own postgres db on a local server. I googled some similar problems and came up with this manual https://help.ubuntu.com/stable/serverguide/postgresql.html so: pg_hba.conf says: # TYPE DATABASE USER ...