Examples On Programing Languages

How to write and save html file in python?

This is what I know about writing to an HTML file and saving it: html_file = open("filename","w") html_file.write() html_file.close() But how do I save to the file if I want to write a really long codes like this: 1 <tabl...

How to set android layout to support all screen sizes?

I am developing a program on android version2.2. I have read many documentation on supporting multiple screen sizes but still confused. I designed a layout file, that supports for large and normal screens, when am trying it with small screen it is no...

How can I use interface as a C# generic type constraint?

Is there a way to get the following function declaration? public bool Foo<T>() where T : interface; ie. where T is an interface type (similar to where T : class, and struct). Currently I've settled for: public bool Foo<T>() where T :...

How to iterate a table rows with JQuery and access some cell values?

<table class="checkout itemsOverview"> <tr class="item"> <td>GR-10 Senderos</td> <td><span class="value">15.00</span> €</td> <td><input type="text" value="1" maxle...

How to parse a JSON string into JsonNode in Jackson?

It should be so simple, but I just cannot find it after being trying for an hour. I need to get a JSON string, for example, {"k1":v1,"k2":v2}, parsed as a JsonNode. JsonFactory factory = new JsonFactory(); JsonParser jp = factory....

Opening Android Settings programmatically

How can I open settings programmatically?...

How to open child forms positioned within MDI parent in VB.NET?

How do we arrange child forms in a parent MDI window? I'm able to call and display a child form from a menu on the parent, but the child pops up outside the parent - I want it to actually be inside the parent. I've checked in C# and VB.Net solutions ...

Twitter Bootstrap carousel different height images cause bouncing arrows

I've been using Bootstrap's carousel class and it has been straightforward so far, however one problem I've had is that images of different heights cause the arrows to bounce up and down to adjust to the new height.. This is the code I'm using for m...

How to export MySQL database with triggers and procedures?

How to create a MySQL database dump (.sql file) with all its triggers and procedures?...

Extract values in Pandas value_counts()

Say we have used pandas dataframe[column].value_counts() which outputs: apple 5 sausage 2 banana 2 cheese 1 How do you extract the values in the order same as shown above from max to min ? e.g: [apple,sausage,banana,cheese]...

How to match a line not containing a word

I was wondering how to match a line not containing a specific word using Python-style Regex (Just use Regex, not involve Python functions)? Example: PART ONE OVERVIEW 1 Chapter 1 Introduction 3 I want to match lines that do not contain the word ...

Avoid web.config inheritance in child web application using inheritInChildApplications

I am trying to add <location inheritInChildApplications="false"> to my parent web application's web.config but it doesn't seem to be working. My parent's web.config has: <configuration> <configSections> </configSecti...

Redirect on select option in select box

At the moment I am using this: <select ONCHANGE="location = this.options[this.selectedIndex].value;"> it redirect me on the location inside of the option value. But it doesn't work as expected .. mean that if I click on the first option of t...

Dynamically create an array of strings with malloc

I am trying to create an array of strings in C using malloc. The number of strings that the array will hold can change at run time, but the length of the strings will always be consistent. I've attempted this (see below), but am having trouble, any ...

Regex for allowing alphanumeric,-,_ and space

I am searching for a regular expression for allowing alphanumeric characters, -, _ or spaces in JavaScript/jQuery. I tried Googling but wasn't able to find that. Can anyone help me out with this? Thanks in advance....

embedding image in html email

I'm trying to send a multipart/related html email with embedded gif images. This email is generated using Oracle PL/SQL. My attempts have failed, with the image showing up as a red X (in Outlook 2007 and yahoo mail) I've been sending html emails f...

How can I map "insert='false' update='false'" on a composite-id key-property which is also used in a one-to-many FK?

I am working on a legacy code base with an existing DB schema. The existing code uses SQL and PL/SQL to execute queries on the DB. We have been tasked with making a small part of the project database-engine agnostic (at first, change everything event...

Best way to style a TextBox in CSS

I would like to hear what's the best thing to do with pure CSS. The Situation: I'm having a textbox in which i can search for specific items. Yet now i'm also having an advanced search with almost the same textbox yet the width of the advancedSearc...

Fixed sidebar navigation in fluid twitter bootstrap 2.0

Is it possible to make sidebar navigation stay always fixed on scroll in fluid layout?...

Print DIV content by JQuery

suppose i have many div's in my page but i want to print the content of specific div using jquery. i found there is a plugin for that. jQuery Print Element using this plugin we can easily print div content like below. $('SelectorToPrint').printEle...

Open Popup window using javascript

I am looking to open one aspx page (test.aspx) in two different popup windows at the same time. what I have till now second replace first one and page recreate in first. I think it require more clarification here so, Basicaly I create a graph and ...

How can I upload files asynchronously?

I would like to upload a file asynchronously with jQuery. _x000D_ _x000D_ $(document).ready(function () {_x000D_ $("#uploadbutton").click(function () {_x000D_ var filename = $("#file").val();_x000D_ _x000D_ $.ajax({_x000D_ ...

How to insert a newline in front of a pattern?

How to insert a newline before a pattern within a line? For example, this will insert a newline behind the regex pattern. sed 's/regex/&\n/g' How can I do the same but in front of the pattern? Given this sample input file, the pattern to mat...

Getting A File's Mime Type In Java

I was just wondering how most people fetch a mime type from a file in Java? So far I've tried two utils: JMimeMagic & Mime-Util. The first gave me memory exceptions, the second doesn't close its streams off properly. I was just wondering if ...

C#: How to make pressing enter in a text box trigger a button, yet still allow shortcuts such as "Ctrl+A" to get through?

Sorry for the long title, but I couldn't think of another way to put it. I have this: private void textBoxToSubmit_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { buttonSubmit_Click((objec...

How to get text box value in JavaScript

I am trying to use JavaScript to get the value from an HTML text box but value is not coming after white space For example: <input type="text" name="txtJob" value="software engineer"> I only get: "software" from the above. I am using a scr...

pandas loc vs. iloc vs. at vs. iat?

Recently began branching out from my safe place (R) into Python and and am a bit confused by the cell localization/selection in Pandas. I've read the documentation but I'm struggling to understand the practical implications of the various localizatio...

scrollbars in JTextArea

How do I add scrollbars to a JTextArea?...

Insert all values of a table into another table in SQL

I am trying to insert all values of one table into another. But the insert statement accepts values, but i would like it to accept a select * from the initial_Table. Is this possible?...

How to preserve insertion order in HashMap?

I'm using a HashMap. When I iterate over the map, the data is returned in (often the same) random order. But the data was inserted in a specific order, and I need to preserve the insertion order. How can I do this?...

Maven in Eclipse: step by step installation

I have spent been on the Maven site reading the 5- and 30-minute tutorials, and trialing Maven out for the first time. I want to install a Maven plugin and use it to start building Maven projects from Eclipse. Despite an honest effort, I have been ...

failed to find target with hash string android-23

When trying to build OpenStreetMapView from git://github.com/osmdroid/osmdroid, I get this error: failed to find target with hash string android-23: D:\Users\myusername\AppData\Local\Android How can I fix this? Previous questions similar to this s...

Simple regular expression for a decimal with a precision of 2

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

Delete all nodes and relationships in neo4j 1.8

I know this question is asked by many people already for my research, here's some questions asked before How to delete all relationships in neo4j graph? https://groups.google.com/forum/#!topic/neo4j/lgIaESPgUgE But after all, still can't solve ou...

Paste Excel range in Outlook

I want to paste a range of cells in Outlook. Here is my code: Sub Mail_Selection_Range_Outlook_Body() Dim rng As Range Dim OutApp As Object Dim OutMail As Object Set rng = Nothing On Error Resume Next ' Only send the visible cells in the selecti...

How to safely call an async method in C# without await

I have an async method which returns no data: public async Task MyAsyncMethod() { // do some stuff async, don't return any data } I'm calling this from another method which returns some data: public string GetStringData() { MyAsyncMethod(); ...

How to get a value from a Pandas DataFrame and not the index and object type

Say I have the following DataFrame Letter Number A 1 B 2 C 3 D 4 Which can be obtained through the following code import pandas as pd letters=pd.Series(('A', 'B', 'C', 'D')) numbers=pd.Series((1, 2, 3, 4))...

PHP error: "The zip extension and unzip command are both missing, skipping."

When I run a composer update I get this error message: Loading composer repositories with package information Updating dependencies (including require-dev) Failed to download psr/log from dist: The zip extension and unzip command are both missin...

Could not load file or assembly System.Web.Http.WebHost after published to Azure web site

I created a web project and it runs well in Visual studio. However, I got the following error after published it to azurewebsites. What can cause the issue? Could not load file or assembly 'System.Web.Http.WebHost, Version=5.0.0.0, Culture=neut...

Duplicate Symbols for Architecture arm64

When I try running my Xcode Project it fails with an error stating that I have duplicate symbols. I looked online where the find these duplicates but have had no luck: Any ideas how to fix this? ...

How to log in to phpMyAdmin with WAMP, what is the username and password?

What does the word "root" mean in phpMyAdmin? Whenever I write localhost/phpmyadmin on the address bar, I am asked to enter a username and a password, but I don't know what they are. I don't remember when and where I set them. From where can I get m...

How to compare two lists in python?

How to compare two lists in python? date = "Thu Sep 16 13:14:15 CDT 2010" sdate = "Thu Sep 16 14:14:15 CDT 2010" dateArr = [] dateArr = date.split() sdateArr = [] sdateArr = sdate.split() Now I want to compare these two lists. I guess split re...

Why is my CSS style not being applied?

I've got this html: <p> <span class="fancify">Parting is such sweet sorrow!</span><span> - Bill Rattleandrollspeer</span> </p> ...and this css (added to the bottom of Site.css): .fancify { font-size: 1....

How to add an Access-Control-Allow-Origin header

I am designing a website (e.g. mywebsite.com) and this site loads font-face fonts from another site (say anothersite.com). I was having problems with the font face font loading in Firefox and I read on this blog: Firefox (which supports @font-fa...

How to use dashes in HTML-5 data-* attributes in ASP.NET MVC

I am trying to use HTML5 data- attributes in my ASP.NET MVC 1 project. (I am a C# and ASP.NET MVC newbie.) <%= Html.ActionLink("« Previous", "Search", new { keyword = Model.Keyword, page = Model.currPage - 1}, new { @class = "prev", d...

Waiting for another flutter command to release the startup lock

When I run my flutter application it show Waiting for another flutter command to release the startup lock this messages and not proceed further....

Cannot find module '@angular/compiler'

I run the command npm install -g @angular/cli and after i tried to run my app it says, Cannot find module '@angular/compiler' in the terminal. How can i install the compiler in my package.json in order to compile my application //package { "name"...

Handling urllib2's timeout? - Python

I'm using the timeout parameter within the urllib2's urlopen. urllib2.urlopen('http://www.example.org', timeout=1) How do I tell Python that if the timeout expires a custom error should be raised? Any ideas?...

Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to

today I just imported a sample app from Android SDK as a module in my project (analytics) and suddenly I got this gradle error when I try to sync it: Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE envrinment ...

Add days to JavaScript Date

How to add days to current Date using JavaScript. Does JavaScript have a built in function like .Net's AddDay?...

How to append new data onto a new line

My code looks like this: def storescores(): hs = open("hst.txt","a") hs.write(name) hs.close() so if I run it and enter "Ryan" then run it again and enter "Bob" the file hst.txt looks like RyanBob instead of Ryan Bob How do I fi...

How to debug SSL handshake using cURL?

I would like to troubleshoot per directory authentication with client certificate. I would specially like to find out which acceptable client certificates does server send. How do I debug SSL handshake, preferably with cURL? Thanks in advance...

Maven home (M2_HOME) not being picked up by IntelliJ IDEA

I am trying to do a simple maven build with IntelliJ IDEA 10.5.1 on OS X Lion and am getting the following error: Error running my-app [package]: No valid Maven installation found. Either set the home directory in the configuration dialog or ...

What is the best way to uninstall gems from a rails3 project?

I installed all of my gems using bundler via the Gemfile. I thought (mistakenly) that if I deleted a gem from my Gemfile and ran 'bundle install' that the deleted gems would be uninstalled. I've looked at the bundler help file and, so far as I can te...

java.io.IOException: Invalid Keystore format

Does anyone know how to solve this? I tried many things, but none of them worked. And when I click more details I get this: at sun.security.provider.JavaKeyStore.engineLoad(Unknown Source) atsun.security.provider.JavaKeyStore$JKS.engineLoad(Unknown...

Handling null values in Freemarker

How to handle null values in Freemarker? I get some exceptions in the template when null values are present in data....

How to compile for Windows on Linux with gcc/g++?

I have written some effects in C++ (g++) using freeglut on Linux, and I compile them with g++ -Wall -lglut part8.cpp -o part8 So I was wondering if it is possible to have g++ make static compiled Windows executables that contains everything needed...

A CSS selector to get last visible div

A tricky CSS selector question, don't know if it's even possible. Lets say this is the HTML layout: <div></div> <div></div> <div></div> <div style="display:none"></div> <div style="display:...

How to get all checked checkboxes

I have a set of input checkboxes with the same name and I would like to determine which checkboxes have been checked using javascript, how can I achieve that? I know only how to get all the checkboxes as follows: var checkboxes = document.getElement...

SQL Server : Arithmetic overflow error converting expression to data type int

I'm getting this error msg 8115, level 16, state 2, line 18 Arithmetic overflow error converting expression to data type int. with this SQL query DECLARE @year VARCHAR(4); DECLARE @month VARCHAR(2); ...

How do I navigate to a parent route from a child route?

My problem is quite classic. I have a private part of an application which is behind a login form. When the login is successful, it goes to a child route for the admin application. My problem is that I can't use the global navigation menu because th...

Proper MIME media type for PDF files

When working with PDFs, I've run across the MIME types application/pdf and application/x-pdf among others. Is there a difference between these two types, and if so what is it? Is one preferred over the other? I'm working on a web app which must de...

Event on a disabled input

Apparently a disabled <input> is not handled by any event Is there a way to work around this issue ? <input type="text" disabled="disabled" name="test" value="test" /> $(':input').click(function () { $(this).removeAttr('disabled')...

Set default format of datetimepicker as dd-MM-yyyy

I have a datetimepicker which on loading of windows form shows me format in 'MM-dd-yyyy', as follows: I would like it in dd-MM-yyyy. I tried the following: set custom format: "dd-MM-yyyy" But Its not changing. What could be the problem? Plea...

Why does "return list.sort()" return None, not the list?

I've been able to verify that the findUniqueWords does result in a sorted list. However, it does not return the list. Why? def findUniqueWords(theList): newList = [] words = [] # Read a line at a time for item in theList: #...

What's the difference between a single precision and double precision floating point operation?

What is the difference between a single precision floating point operation and double precision floating operation? I'm especially interested in practical terms in relation to video game consoles. For example, does the Nintendo 64 have a 64 bit proc...

How can I find the current OS in Python?

Possible Duplicate: Python: What OS am I running on? As the title says, how can I find the current operating system in python?...

Edit a commit message in SourceTree Windows (already pushed to remote)

How do I edit an incorrect commit message in SourceTree without touching the command line? Additional details: This is not the latest commit. Everything was already pushed to Bitbucket. This is a private repository and I am the only collaborator. ...

JavaScript URL Decode function

What's the best JavaScript URL decode utility? Encoding would be nice too and working well with jQuery is an added bonus....

How to get the directory of the currently running file?

In nodejs I use __dirname . What is the equivalent of this in Golang? I have googled and found out this article http://andrewbrookins.com/tech/golang-get-directory-of-the-current-file/ . Where he uses below code _, filename, _, _ := runtime.Caller(...

Loading PictureBox Image from resource file with path (Part 3)

I understand that this question has been asked (and answered) before. However, none of the solutions are working for me. Below is a screen capture of all the relevant pieces of the puzzle: Screen capture http://dinosaur-island.com/PlantPictureBoxSc...

Why is the Fibonacci series used in agile planning poker?

When estimating the relative size of user stories in agile software development the members of the team are supposed to estimate the size of a user story as being 1, 2, 3, 5, 8, 13, ... . So the estimated values should resemble the Fibonacci series. ...

Static methods - How to call a method from another method?

When I have regular methods for calling another method in a class, I have to do this class test: def __init__(self): pass def dosomething(self): print "do something" self.dosomethingelse() def dosomething...

Remove by _id in MongoDB console

In the MongoDB console how can I remove a record by id? Here's my collection : [ { "_id" : { "$oid" : "4d512b45cc9374271b02ec4f" }, "name" : "Gazza" }, { "_id" : { "$oid" : "4d513345cc9374271b02ec6c" }, "name" : "Dave", ...

Retrieving a random item from ArrayList

I'm learning Java and I'm having a problem with ArrayList and Random. I have an object called catalogue which has an array list of objects created from another class called item. I need a method in catalogue which returns all the information on one...

React Hooks useState() with Object

What is the correct way of updating state, is a nested object, in React with Hooks? export Example = () => { const [exampleState, setExampleState] = useState( {masterField: { fieldOne: "a", fieldTwo: { fieldTwoOne: ...

Get Selected value from Multi-Value Select Boxes by jquery-select2?

I am using Select2 Jquery to bind my dropdown which is used for multiple selection . I am using select2 jquery. It's working fine, I can bind my dropdown but I need to get the selected value from my multi-value selector. I am l...

How can I check if a user is logged-in in php?

I'm pretty new to PHP and I am trying to figure out how to use sessions to check and see if a user is logged into a website so that they would have authorization to access specific pages. Is this something that is complicated or is it because I am a ...

How to return a class object by reference in C++?

I have a class called Object which stores some data. I would like to return it by reference using a function like this: Object& return_Object(); Then, in my code, I would call it like this: Object myObject = return_Object(); I have...

How to create permanent PowerShell Aliases

I want to create an alias of a cmdlet that doesn't expire after I close the current session of Powershell, let's say I have this alias : C:\Users\Aymen> New-Alias Goto Set-Location This perfectly creates the Goto alias, but I want to use it eve...

How to find the sum of an array of numbers

Given an array [1, 2, 3, 4], how can I find the sum of its elements? (In this case, the sum would be 10.) I thought $.each might be useful, but I'm not sure how to implement it....

changing color of h2

How I can change the color of h2 ? I have tried <h2 color="#006699">Process Report</h2> but it's not changed and I am still getting this default black colour Thanks ....

Linux cmd to search for a class file among jars irrespective of jar path

I want to search for a particular class file among many jar files without giving the location of each jar file. Is this possible with a simple command? I tried this command: grep Hello.class *.jar Which did not return a list of jars containing t...

How to add button in ActionBar(Android)?

I want to add a Button to the Action Bar to the right hand side of Example as in this screen shot: I get actionBar in onCreate method as: ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); and back button(onOption...

Is there a keyboard shortcut (hotkey) to open Terminal in macOS?

One of my primary tools used for programming is my Terminal. It makes my programming process more efficient when I'm able to quickly open a Terminal window. In Ubuntu, I was using (window+Alt+T) to open Terminal. But now I use a Macbook at my progra...

StringStream in C#

I want to be able to build a string from a class that I create that derives from Stream. Specifically, I want to be able to write code like this: void Print(Stream stream) { // Some code that operates on a Stream. } void Main() { StringStre...

How to set the 'selected option' of a select dropdown list with jquery

I have the following jquery function: $.post('GetSalesRepfromCustomer', { data: selectedObj.value }, function (result) { alert(result[0]); $('select[name^="salesrep"]').val(result[0]); }); result[0] is a value that I want to set as the...

How to download fetch response in react as file

Here is the code in actions.js export function exportRecordToExcel(record) { return ({fetch}) => ({ type: EXPORT_RECORD_TO_EXCEL, payload: { promise: fetch('/records/export', { credentials: 'same-or...

Java URL encoding of query string parameters

Say I have a URL http://example.com/query?q= and I have a query entered by the user such as: random word £500 bank $ I want the result to be a properly encoded URL: http://example.com/query?q=random%20word%20%A3500%20bank%20%24 What's t...

How to get the stream key for twitch.tv

I write an app for broadcasting to twitch.tv using C++. For that streaming I need to know the user stream key, usually an user gets that key from the page, http://www.twitch.tv/user_name/dashboard/streamkey But I would like get it via my app by us...

What is a monad?

Having briefly looked at Haskell recently, what would be a brief, succinct, practical explanation as to what a monad essentially is? I have found most explanations I've come across to be fairly inaccessible and lacking in practical detail....

Java 6 Unsupported major.minor version 51.0

I recently uninstalled Java 8, to use Java 6 as I want my code/creations to be usable by more people than just those on Java 8. When I do mvn - version it returns: Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/maven/c...

Why I get 'list' object has no attribute 'items'?

Using Python 2.7, I have this list: qs = [{u'a': 15L, u'b': 9L, u'a': 16L}] I'd like to extract values out of it. i.e. [15, 9, 16] So I tried: result_list = [int(v) for k,v in qs.items()] But instead, I get this error: Traceback (most recen...

What does this error mean: "error: expected specifier-qualifier-list before 'type_name'"?

I've been working on the Cell processor and I'm trying to create a struct that will hold an spe_context_ptr_t, which will be used within the thread to launch an spe context and will also hold a pointer to something else that will be passed to the spu...

How can I break up this long line in Python?

How would you go about formatting a long line such as this? I'd like to get it to no more than 80 characters wide: logger.info("Skipping {0} because its thumbnail was already in our system as {1}.".format(line[indexes['url']], video.title)) Is thi...

What is a 'multi-part identifier' and why can't it be bound?

I continually get these errors when I try to update tables based on another table. I end up rewriting the query, change the order of joins, change some groupings and then it eventually works, but I just don't quite get it. What is a 'multi-part iden...

Connection string with relative path to the database file

I load data from sdf database in winforms App. I use full path to the database file . Example : conn = new SqlCeConnection { ConnectionString ="Data Source=F:\\My Documents\\Project1\\bin\\Debug\\Database.sdf" }; I d like use a relative path ...

How to check if keras tensorflow backend is GPU or CPU version?

I understand that when installing tensorflow, you either install the GPU or CPU version. How can I check which one is installed (I use linux). If the GPU version is installed, would it be automatically running on CPU if GPU is unavailable or would ...

IIS7 Cache-Control

I'm trying to do something which I thought would be fairly simple. Get IIS 7 to tell clients they can cache all images on my site for a certain amount of time, let's say 24 hours. I have tried the step on http://www.galcho.com/Blog/post/2008/02/2...

Carriage Return\Line feed in Java

I have created a text file in Unix environment using Java code. For writing the text file I am using java.io.FileWriter and BufferedWriter. And for newline after each row I am using bw.newLine() method (where bw is object of BufferedWriter). And I'...

DatabaseError: current transaction is aborted, commands ignored until end of transaction block?

I got a lot of errors with the message : "DatabaseError: current transaction is aborted, commands ignored until end of transaction block" after changed from python-psycopg to python-psycopg2 as Django project's database engine. The code remains t...

How to build an android library with Android Studio and gradle?

I am trying to migrate a project from Eclipse but nothing I have tried is working. In Eclipse I have 3 projects (2 android app projects and 1 android library project). The 2 app projects depend on the library project. When I do the gradle export I ge...

Conditionally change img src based on model data

I want to represent model data as different images using Angular but having some trouble finding the "right" way to do it. The Angular API docs on expressions say that conditional expressions are not allowed... Simplifying a lot, the model data is ...

Timeout on a function call

I'm calling a function in Python which I know may stall and force me to restart the script. How do I call the function or what do I wrap it in so that if it takes longer than 5 seconds the script cancels it and does something else?...

@Directive vs @Component in Angular

What is the difference between @Component and @Directive in Angular? Both of them seem to do the same task and have the same attributes. What are the use cases and when to prefer one over another?...

How do I check if an element is hidden in jQuery?

Is it possible to toggle the visibility of an element, using the functions .hide(), .show() or .toggle()? How would you test if an element is visible or hidden?...

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 get current formatted date dd/mm/yyyy in Javascript and append it to an input

I would like to add a current date to a hidden HTML tag so that it can be sent to the server: <input type="hidden" id="DATE" name="DATE" value="WOULD_LIKE_TO_ADD_DATE_HERE"> How can I add a formatted date to the VALUE attribute?...

react-router (v4) how to go back?

Trying to figure out how can I go back to the previous page. I am using [react-router-v4][1] This is the code I have configured in my first landing page: <Router> <div> <Link to="/"><div className="routerStyle"><Gly...

How can I get the assembly file version

In AssemblyInfo there are two assembly versions: AssemblyVersion: Specify the version of the assembly being attributed. AssemblyFileVersion: Instructs a compiler to use a specific version number for the Win32 file version resource. The Win32 file v...

PHP Composer update "cannot allocate memory" error (using Laravel 4)

I just can't solve this one. I'm on Linode 1G RAM basic plan. Trying to install a package via Composer and it's not letting me. My memory limit is set to "-1" on PHP.ini Is there anything else I can do to get this installed? Loading composer repos...

Call asynchronous method in constructor?

Summary: I would like to call an asynchronous method in a constructor. Is this possible? Details: I have a method called getwritings() that parses JSON data. Everything works fine if I just call getwritings() in an async method and put await to left...

Difference between window.location.href=window.location.href and window.location.reload()

What is the difference between JavaScript's window.location.href = window.location.href and window.location.reload() functions?...

PHP code to get selected text of a combo box

I have a combo box named "Make". In that combo box I'm loading vehicle manufacturer names. When I click SEARCH button I want to display the selected manufacturer name. Below is part of my HTML code. <label for="Manufacturer"> Manufacturer : &l...

Get an image extension from an uploaded file in Laravel

I have been trying to get the extension from an uploaded file, searching on google, I got no results. The file already exists in a path: \Storage::get('/uploads/categories/featured_image.jpg); Now, How can I get the extension of this file above? ...

Set the value of a variable with the result of a command in a Windows batch file

When working in a Bash environment, to set the value of a variable as the result of a command, I usually do: var=$(command -args) where var is the variable set by the command command -args. I can then access that variable as $var. A more conventi...

How to install the Six module in Python2.7

I am using Python 2.7 and trying to use dateutil as follows: from dateutil import parser as _date_parser However, I get the following error: Traceback (most recent call last): File "<pyshell#17>", line 1, in <module> from dateut...

What is the best Java QR code generator library?

I wish to dynamically generate QR codes in Java. What is the best QR code generator library to use. I will consider both commercial and opensource?...

How to determine the current iPhone/device model?

Is there a way to get the device model name (iPhone 4S, iPhone 5, iPhone 5S, etc) in Swift? I know there is a property named UIDevice.currentDevice().model but it only returns device type (iPod touch, iPhone, iPad, iPhone Simulator, etc). I also kn...

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

How can I check if a JSON is empty in NodeJS?

I have a function that checks to see whether or not a request has any queries, and does different actions based off that. Currently, I have if(query) do this else something else. However, it seems that when there is no query data, I end up with a {} ...

Can You Get A Users Local LAN IP Address Via JavaScript?

I know the initial reaction to this question is "no" and "it can't be done" and "you shouldn't need it, you are doing something wrong". What I'm trying to do is get the users LAN IP address, and display it on the web pag...

Can Python test the membership of multiple values in a list?

I want to test if two or more values have membership on a list, but I'm getting an unexpected result: >>> 'a','b' in ['b', 'a', 'foo', 'bar'] ('a', True) So, Can Python test the membership of multiple values at once in a list? What does t...

Angular error: "Can't bind to 'ngModel' since it isn't a known property of 'input'"

I'm using Angular 4 and I am getting an error in the console: Can't bind to 'ngModel' since it isn't a known property of 'input' How can I resolve this?...

CSS - center two images in css side by side

I am trying to center two images side by side, but for some reason it always displays the images beneath each other. Does anyone know how I could get them centered and next to each other? Thanks! HTML code <a href="mailto:olympiahaacht@hotmail....

VS 2012: Scroll Solution Explorer to current file

VS2010 had the feature that viewing a file would automatically cause Solution Explorer to scroll to that file. With VS2012, viewing different files from within the IDE no longer scrolls and select the file in Solution Explorer automatically. Is it ...

How to generate .json file with PHP?

CREATE TABLE Posts { id INT PRIMARY KEY AUTO_INCREMENT, title VARCHAR(200), url VARCHAR(200) } json.php code <?php $sql=mysql_query("select * from Posts limit 20"); echo '{"posts": ['; while($row=mysql_fetch_array($sql)) { $title=$row['title'];...

How to loop through a directory recursively to delete files with certain extensions

I need to loop through a directory recursively and remove all files with extension .pdf and .doc. I'm managing to loop through a directory recursively but not managing to filter the files with the above mentioned file extensions. My code so far #/b...

How to override application.properties during production in Spring-Boot?

I'm using spring boot and application.properties to select a database during development by @Configuration @Profile("dev"). spring.profiles.active=dev spring.config.location=file:d:/application.properties During production I'd like to create a fil...

Multiple files upload in Codeigniter

I want to upload multiple files using single element. So I try this example. Multiple files upload (Array) with CodeIgniter 2.0 This is my form <form enctype="multipart/form-data" class="jNice" accept-charset="utf-8" method="post" action="http...

How to Force New Google Spreadsheets to refresh and recalculate?

There were some codes written for this purpose but with the new add-ons they are no longer applicable....

PHP If Statement with Multiple Conditions

I have a variable$var. I want echo "true" if $var is equal to any of the following values abc, def, hij, klm, or nop. Is there a way to do this with a single statement like &&??...

ASP.net vs PHP (What to choose)

I have been assigned a task to develop a new web application. Its a kind of social web applications, for the sake of understanding you can say its similar to facebook. Now before start developing such huge application i have few questions to ask: F...

How to know what the 'errno' means?

When calling execl(...), I get an errno=2. What does it mean? How can I know the meaning of this errno?...

JSON - Iterate through JSONArray

I have a JSON file with some arrays in it. I want to iterate through the file arrays and get their elements and their values. This is how my file looks like: { "JObjects": { "JArray1": [ { "A": "a", "B": "b", ...

C++ getters/setters coding style

I have been programming in C# for a while and now I want to brush up on my C++ skills. Having the class: class Foo { const std::string& name_; ... }; What would be the best approach (I only want to allow read access to the name_ fiel...

Remove scrollbars from textarea

Following up to my previous question (Add a scrollbar to a <textarea>) on how to always see the scrollbar in a <textarea>, I am now wondering how you would set it so that there is no scrollbar in the <textarea>, even when the text o...

Pass multiple values with onClick in HTML link

Hi Im trying to pass multiple values with the HTML onclick function. Im using Javascript to create the Table var user = element.UserName; var valuationId = element.ValuationId; $('#ValuationAssignedTable').append('<tr> <td><a href=# o...

How to set Bullet colors in UL/LI html lists via CSS without using any images or span tags

Imagine a simple unsorted list with some <li> items. Now, I have defined the bullets to be square shaped via list-style:square; However, if I set the color of the <li> items with color: #F00; then everything becomes red! While I only wan...

Collision Detection between two images in Java

I have two characters displayed in a game I am writing, the player and the enemy. defined as such: public void player(Graphics g) { g.drawImage(plimg, x, y, this); } public void enemy(Graphics g) { g.drawImage(enemy, 200, 200, this); } Th...

Authentication issues with WWW-Authenticate: Negotiate

I am trying to access a site that is password protected. It is not using basic authentication (even though the same user/pass box pops up in firefox) as the response header is WWW-Authenticate: Negotiate. I want to automate the login process by send...

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

I am getting an interesting error while trying to use Unpickler.load(), here is the source code: open(target, 'a').close() scores = {}; with open(target, "rb") as file: unpickler = pickle.Unpickler(file); scores = unpickler.load(); if no...

Installing Numpy on 64bit Windows 7 with Python 2.7.3

It looks like the only 64 bit windows installer for Numpy is for Numpy version 1.3.0 which only works with Python 2.6 http://sourceforge.net/projects/numpy/files/NumPy/ It strikes me as strange that I would have to roll back to Python 2.6 to use Nu...

How to remove outliers in boxplot in R?

Possible Duplicate: Changing the outlier rule in a boxplot I need to visualize my result using box-plot. x<-rnorm(10000) boxplot(x,horizontal=TRUE,axes=FALSE) How can i filter outliers during visualisation? (1) So that i can hav...

See full command of running/stopped container in Docker

How can I see the full command of a running container/process in Docker? $ docker ps --all CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5b6291859b61 nginx:1.7.8 "nginx -g 'da...

How do I kill an Activity when the Back button is pressed?

I got an Activity that when it starts, it loads an image from the internet. In an effort to save memory, when the Activity is left by the back button being pressed, I want the activity to dump all data, that is get rid of all the strings and images t...

How can the size of an input text box be defined in HTML?

Here is an HTML input text box: <input type="text" id="text" name="text_name" /> What are the options to define the size of the box? How can this be implemented in CSS?...

Total size of the contents of all the files in a directory

When I use ls or du, I get the amount of disk space each file is occupying. I need the sum total of all the data in files and subdirectories I would get if I opened each file and counted the bytes. Bonus points if I can get this without opening eac...

What is a postback?

The best explanation I've found for a postBack is from Wiki. a postback is an HTTP POST to the same page that the form is on. While the article does explain how a second page was needed in ASP, but no longer needed in ASP.NET, it doesn't give much ...

Integer.toString(int i) vs String.valueOf(int i)

I am wondering why the method String.valueOf(int i) exists ? I am using this method to convert int into String and just discovered the Integer.toString(int i) method. After looking the implementation of these methods I saw that the first one is call...

How to decide when to use Node.js?

I am new to this kind of stuff, but lately I've been hearing a lot about how good Node.js is. Considering how much I love working with jQuery and JavaScript in general, I can't help but wonder how to decide when to use Node.js. The web application I ...

Use and meaning of "in" in an if statement?

In an example from Zed Shaw's Learn Python the Hard Way, one of the exercises displays the following code: next = raw_input("> ") if "0" in next or "1" in next: how_much = int(next) I'm having a hard time understanding the meaning of in in ...

How to compile the finished C# project and then run outside Visual Studio?

I just finished designing a simple code program. I called it a "Guessing Game". The program is so far working fine and I would like to open it without opening my Microsoft Visual Studio. How can I do that?...

How to search for a string in text files?

I want to check if a string is in a text file. If it is, do X. If it's not, do Y. However, this code always returns True for some reason. Can anyone see what is wrong? def check(): datafile = file('example.txt') found = False for line in...

how to display none through code behind

I have tried this login_div.Style("display") = "none"; But it's not working.how can I set the display of the div to none through code behind, in aspx I have a div: <div id="login_div" runat="server"> ...

Java, How to add values to Array List used as value in HashMap

What I have is a HashMap<String, ArrayList<String>> called examList. What I want to use it for is to save grades of each course a person is attending. So key for this HashMap is couresID, and value is a ArrayList of all grades (exam attem...

Creating a new column based on if-elif-else condition

I have a DataFrame df: A B a 2 2 b 3 1 c 1 3 I want to create a new column based on the following criteria: if row A == B: 0 if rowA > B: 1 if row A < B: -1 so given the above table, it should be: A B C...

PHP using Gettext inside <<<EOF string

I use PHP's EOF string to format HTML content without the hassle of having to escape quotes etc. How can I use the function inside this string? <?php $str = <<<EOF <p>Hello</p> <p><?= _("World"); ?>&l...

Uninstalling Android ADT

This seems like a trivial task, but I can't find an option to cleanly de-install the ADT from my Eclipse installation. Of course, I could just delete the folder of the SDK, but this just throws errors when starting up Eclipse the next time. The reaso...

React.js: Set innerHTML vs dangerouslySetInnerHTML

Is there any "behind the scenes" difference from setting an element's innerHTML vs setting the dangerouslySetInnerHTML property on an element? Assume I'm properly sanitizing things for the sake of simplicity. Example: var test = React.createClass({...

How to run mysql command on bash?

The following code works on the command line mysql --user='myusername' --password='mypassword' --database='mydatabase' --execute='DROP DATABASE myusername; CREATE DATABASE mydatabase;' However, it doesnt work on bash file on excecution #!/bin/ba...

ORA-01031: insufficient privileges when selecting view

When I try to execute a view that includes tables from different schemas an ORA-001031 Insufficient privileges is thrown. These tables have execute permission for the schema where the view was created. If I execute the view's SQL Statement it works...

Selenium -- How to wait until page is completely loaded

I am trying to automate some test cases using Java and Selenium WebDriver. I have the following scenario: There is a page named 'Products'. When I click on 'View Details' link in the 'Product' page, a popup (modal-dialog) containing the details of ...

Could not load file or assembly System.Net.Http, Version=4.0.0.0 with ASP.NET (MVC 4) Web API OData Prerelease

Problem After installing the Microsoft ASP.NET Web API OData package 5.0.0-rc1 prerelease I end up with the following exception: Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e3...

Conversion failed when converting the nvarchar value ... to data type int

I created the procedure listed below: CREATE procedure getdata ( @ID int, @frm varchar(250), @to varchar(250) ) AS BEGIN DECLARE @SQL nvarchar(500) set @SQL = 'select' set @SQL = @SQL + ' EmpName, Address, Salary from Emp_Tb where 1=1...

Algorithm: efficient way to remove duplicate integers from an array

I got this problem from an interview with Microsoft. Given an array of random integers, write an algorithm in C that removes duplicated numbers and return the unique numbers in the original array. E.g Input: {4, 8, 4, 1, 1, 2, 9} Output:...

Difference between request.getSession() and request.getSession(true)

I understand the difference between request.getSession(true) and request.getSession(false). But request.getSession() & request.getSession(true) look very similar! Both "return the current session associated with this request", but differ in: re...

How to determine if object is in array

I need to determine if an object already exists in an array in javascript. eg (dummycode): var carBrands = []; var car1 = {name:'ford'}; var car2 = {name:'lexus'}; var car3 = {name:'maserati'}; var car4 = {name:'ford'}; carBrands.push(car1); carB...

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

How to get a reference to an iframe's window object inside iframe's onload handler created from parent window

Before I paste any code, here's the scenario: I have an HTML document that creates an empty iframe using JavaScript The JavaScript creates a function and attaches a reference to that function to the iframe's document object (using doc.open() to get ...

How do I discard unstaged changes in Git?

How do I discard changes in my working copy that are not in the index?...

calling a function from class in python - different way

EDIT2: Thank you all for your help! EDIT: on adding @staticmethod, it works. However I am still wondering why i am getting a type error here. I have just started OOPS and am completely new to it. I have a very basic question regarding the different...

Ansible - Save registered variable to file

How would I save a registered Variable to a file? I took this from the tutorial: - hosts: web_servers tasks: - shell: /usr/bin/foo register: foo_result ignore_errors: True - shell: /usr/bin/bar when: foo_result.rc...

Add a property to a JavaScript object using a variable as the name?

I'm pulling items out of the DOM with jQuery and want to set a property on an object using the id of the DOM element. Example const obj = {} jQuery(itemsFromDom).each(function() { const element = jQuery(this) const name = element.attr('id') ...

How to render an array of objects in React?

could you please tell me how to render a list in react js. I do like this https://plnkr.co/edit/X9Ov5roJtTSk9YhqYUdp?p=preview class First extends React.Component { constructor (props){ super(props); } render() { const data =[{"...

pip install access denied on Windows

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

Where is the default log location for SharePoint/MOSS?

I found the answer after digging and thought I'd store it here. C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\LOGS...

Converting Columns into rows with their respective data in sql server

I have a scenario where I need to convert columns of table to rows eg - table - stocks: ScripName ScripCode Price ----------------------------------------- 20 MICRONS 533022 39 I need to represent the table in the foll...

adb connection over tcp not working now

I was trying to use adb over TCP/IP. I have followed these steps adb tcpip 5555 adb connect 194.68.0.100:5555 I have used my device for 2 days and now I am unable to connect to my IP address like when I do adb tcpip 5555 it doesn't respond any...

Docker: Container keeps on restarting again on again

I today deployed an instance of MediaWiki using the appcontainers/mediawiki docker image, and I now have a new problem for which I cannot find any clue. After trying to attach to the mediawiki front container using: docker attach mediawiki_web_1 w...

Javascript event handler with parameters

I want to make an eventHandler that passes the event and some parameters. The problem is that the function doesn't get the element. Here is an example: doClick = function(func){ var elem = .. // the element where it is all about elem.onclick...

Unfortunately Launcher3 has stopped working error in android studio?

When i run android program the emulator says unfortunately Launcher3 has stopped working. What is the reason or how can i fix the problem?...

How can I know when an EditText loses focus?

I need to catch when an EditText loses focus, I've searched other questions but I didn't find an answer. I used OnFocusChangeListener like this OnFocusChangeListener foco = new OnFocusChangeListener() { @Override public void onFocusChange(...

Rewrite all requests to index.php with nginx

In my apache configuration I have the following simple rewrite rule which unless file exists will rewrite to index.php on the urls you never see the file extension (.php) how can I rewrite this in nginx? # # Redirect all to index.php # RewriteEn...

Spring Data JPA - "No Property Found for Type" Exception

Well, I searched Google and found many results, but none of them was able to answer my problem. So, here it goes. I am trying to study Spring MVC and Spring Data JPA by doing a minimal implementation of pinterest clone. So, following is the parts of...

The storage engine for the table doesn't support repair. InnoDB or MyISAM?

After repairing my database I received the following error: scode_tracker.ap_visits note : The storage engine for the table doesn't support repair scode_tracker.visit_length note : The storage engine for the table doesn't support repair I ...

Reading a resource file from within jar

I would like to read a resource from within my jar like so: File file; file = new File(getClass().getResource("/file.txt").toURI()); BufferedReader reader = new BufferedReader(new FileReader(file)); //Read the file and it works fine when ...

Lodash - difference between .extend() / .assign() and .merge()

In the Lodash library, can someone provide a better explanation of merge and extend / assign. Its a simple question but the answer evades me nonetheless. ...

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

Assembly - JG/JNLE/JL/JNGE after CMP

I don't understand the JG/JNLE/JL/JNGE instructions, which come after CMP. for example, If I have: CMP al,dl jg label1 When al=101; dl =200. On what we ask the jg? Is it on al>dl? or al-dl>0? Same prolbem on the next code: test al,dl jg ...

Xcode is not currently available from the Software Update server

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

Right Align button in horizontal LinearLayout

If you look at the attached image. I need my button to be right aligned but for some reason it's not working with 'gravity:right'... Here's my code for that layout: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" ...

IF... OR IF... in a windows batch file

Is there a way to write an IF OR IF conditional statement in a windows batch-file? For example: IF [%var%] == [1] OR IF [%var%] == [2] ECHO TRUE ...

TypeError: expected str, bytes or os.PathLike object, not _io.BufferedReader

I'm trying to iterate through a group of files in a folder on my local machine and upload only ones where the file names contain "Service_Areas" to my FTP site using using this code (Python 3.6.1 32 bit, Windows 10 64 bit): ftp = FTP('ftp.ftpsite.or...

Add a summary row with totals

I know this sounds crazy and probably should not be done this way but I need something like this - I have a records from SELECT [Type], [Total Sales] From Before I want to add an extra row at the end to show the SUM at the end of the table (After). ...

MS-DOS Batch file pause with enter key

Is it possible in MS-DOS batch file to pause the script and wait for user to hit enter key? I wish to do this inside a for loop. After each iteration, I want the script to pause and wait for user to hit 'Enter'...

How do include paths work in Visual Studio?

Visual Studio drives me crazy and I am suspecting I am doing something wrong. This is what I do: I installed Visual Studio (Pro '08) a long time ago, I installed the Windows SDK (Win 7 x64), someone emails me a project, it fails to build. Invariabl...

How to len(generator())

Python generators are very useful. They have advantages over functions that return lists. However, you could len(list_returning_function()). Is there a way to len(generator_function())? UPDATE: Of course len(list(generator_function())) would work......

java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex in Android Studio 3.0

This is my app level gradle file: apply plugin: 'com.android.application' android { compileSdkVersion 26 buildToolsVersion '27.0.0' useLibrary 'org.apache.http.legacy' defaultConfig { multiDexEnabled true applica...

PHP float with 2 decimal places: .00

When I do this typecasting: (float) '0.00'; I get 0. How do I get 0.00 and still have the data type as a float? ...

How to delete an app from iTunesConnect / App Store Connect

I submitted a brand new app to AppStore and it got rejected by the Lords ... (nothing new there). What I want to do is delete that app completely from my itunesconnect account. I don't know what apple recently changed but in the past once the app was...

Set object property using reflection

Is there a way in C# where I can use reflection to set an object property? Ex: MyObject obj = new MyObject(); obj.Name = "Value"; I want to set obj.Name with reflection. Something like: Reflection.SetProperty(obj, "Name") = "Value"; Is there a...

Anaconda / Python: Change Anaconda Prompt User Path

I want to change my Anaconda Prompt User file path. Currently it is as follows: I want it to change to: C:\Users\u354590 How do I do this? The current version of anaconda I have is: Python 3.6.3 |Anaconda, Inc.| (default, Oct 15 2017, 03:27:4...

Color different parts of a RichTextBox string

I'm trying to color parts of a string to be appended to a RichTextBox. I have a string built from different strings. string temp = "[" + DateTime.Now.ToShortTimeString() + "] " + userid + " " + message + Environment.NewLine; This is ...

How can I specify the schema to run an sql file against in the Postgresql command line

I run scripts against my database like this... psql -d myDataBase -a -f myInsertFile.sql The only problem is I want to be able to specify in this command what schema to run the script against. I could call set search_path='my_schema_01' but the f...

data.frame rows to a list

I have a data.frame which I would like to convert to a list by rows, meaning each row would correspond to its own list elements. In other words, I would like a list that is as long as the data.frame has rows. So far, I've tackled this problem in the...

javascript regular expression to check for IP addresses

I have several ip addresses like: 115.42.150.37 115.42.150.38 115.42.150.50 What type of regular expression should I write if I want to search for the all the 3 ip addresses? Eg, if I do 115.42.150.* (I will be able to search for all 3 ip address...

How do I clone a subdirectory only of a Git repository?

I have my Git repository which, at the root, has two sub directories: /finisht /static When this was in SVN, /finisht was checked out in one place, while /static was checked out elsewhere, like so: svn co svn+ssh://[email protected]/home/admin/rep...

Can't fix Unsupported major.minor version 52.0 even after fixing compatibility

When I try running my java .jar on another machine I get the error Unsupported major.minor version 52.0 I compiled my program using the jdk 1.6 and my machine (separate one) has java 7 installed. This is the java version my machine is running:...

Tree view of a directory/folder in Windows?

In Linux/KDE, I can see a directory as a tree. How can I do it in Windows 7? Consider I do NOT mean "Windows Explorer". This just shows the directories, I also want the files....

What is DOM element?

What is the meaning of DOM element in the following statements? Statement #1 You can add multiple classes to a single DOM element. Statement #2 The -- point is that inheritance in CSS is done not through classes, but through element...

./configure : /bin/sh^M : bad interpreter

I've been trying to install lpng142 on my fed 12 system. Seems like a problem to me. I get this error [root@localhost lpng142]# ./configure bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory [root@localhost lpng142]# How do ...

Is "delete this" allowed in C++?

Is it allowed to delete this; if the delete-statement is the last statement that will be executed on that instance of the class? Of course I'm sure that the object represented by the this-pointer is newly-created. I'm thinking about something like t...

Android check internet connection

I want to create an app that uses the internet and I'm trying to create a function that checks if a connection is available and if it isn't, go to an activity that has a retry button and an explanation. Attached is my code so far, but I'm getting t...

Testing HTML email rendering

Are there any good tools to easily test how HTML email will look across different email clients? I prefer something with instant feed back rather than a submit and wait service like http://litmusapp.com Or at the very least a way to test the Outlook ...

"React.Children.only expected to receive a single React element child" error when putting <Image> and <TouchableHighlight> in a <View>

I have the following render method in my React Native code: render() { const {height, width} = Dimensions.get('window'); return ( <View style={styles.container}> <Image style={{ height:height, ...

Nginx location priority

What order do location directives fire in?...

Why do I get a SyntaxError for a Unicode escape in my file path?

The folder I want to get to is called python and is on my desktop. I get the following error when I try to get to it >>> os.chdir('C:\Users\expoperialed\Desktop\Python') SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes...

Checking to see if a DateTime variable has had a value assigned

Is there an easy way within C# to check to see if a DateTime instance has been assigned a value or not?...

SQL Server String Concatenation with Null

I am creating a computed column across fields of which some are potentially null. The problem is that if any of those fields is null, the entire computed column will be null. I understand from the Microsoft documentation that this is expected and ca...

How to convert Milliseconds to "X mins, x seconds" in Java?

I want to record the time using System.currentTimeMillis() when a user begins something in my program. When he finishes, I will subtract the current System.currentTimeMillis() from the start variable, and I want to show them the time elapsed using a ...

EF LINQ include multiple and nested entities

Ok, I have tri-leveled entities with the following hierarchy: Course -> Module -> Chapter Here was the original EF LINQ statement: Course course = db.Courses .Include(i => i.Modules.Select(s => s.Chapters)) .Si...

How to set 00:00:00 using moment.js

I want to get current date but time should be 00:00:00.000 I've try this: var m = moment(); m.set({hour:0,minute:0,second:0,millisecond:0}); console.log(m.toISOString()); but I've got: 2016-01-12T23:00:00.000Z why 23 and not 00?...

how to store Image as blob in Sqlite & how to retrieve it?

I want to store an image(from url) into a sqlite database. For that I use: db = new DataBase(getApplicationContext()); URL url = new URL("http://sree.cc/wp-content/uploads/schogini_team.png"); URLConnection ucon = url.openConnection(); InputStream...

How to read GET data from a URL using JavaScript?

I'm trying to pass data from one page to another. www.mints.com?name=something How to read name using JavaScript?...

How to embed small icon in UILabel

I need to embed small icons ( sort of custom bullets ) to my UILabel in iOS7. How can I do this in interface designer? Or at least in code? In Android there are leftDrawable and rightDrawable for labels, but how it is done in iOS? Sample in android ...

Bootstrap 4 card-deck with number of columns based on viewport

I'm trying to implement the card-deck feature in bootstrap 4 to make all of my cards the same height. The examples that bootstrap provides show 4 nice cards, but it's 4 cards on the row, no matter the viewport. See the codeply here. This doesn't ma...

C# elegant way to check if a property's property is null

In C#, say that you want to pull a value off of PropertyC in this example and ObjectA, PropertyA and PropertyB can all be null. ObjectA.PropertyA.PropertyB.PropertyC How can I get PropertyC safely with the least amount of code? Right now I would c...

How to split a dos path into its components in Python

I have a string variable which represents a dos path e.g: var = "d:\stuff\morestuff\furtherdown\THEFILE.txt" I want to split this string into: [ "d", "stuff", "morestuff", "furtherdown", "THEFILE.txt" ] I have tried using split() and replace() bu...

How to animate RecyclerView items when they appear

How can I animate the RecyclerView Items when there are appearing? The default item animator only animates when a data is added or removed after the recycler data has been set. I'm new developing applications and don't have any clue where to start. ...

'Incorrect SET Options' Error When Building Database Project

We are using Visual Studio and a database project to generate our database. I just made a number of database changes (including adding a new table named Correspondence) imported those changes into the database project, and attempted to deploy (rebui...

Hide scroll bar, but while still being able to scroll

I want to be able to scroll through the whole page, but without the scrollbar being shown. In Google Chrome it's: ::-webkit-scrollbar { display: none; } But Mozilla Firefox and Internet Explorer don't seem to work like that. I also tried thi...

Google Maps API Multiple Markers with Infowindows

I am trying to add multiple markers each with its own infowindow that comes up when clicked on. I am having trouble with getting the infowindows coming up, when I try it either shows up only one marker without an infowindow. Thanks, let me know if ...

Detect if an element is visible with jQuery

Using .fadeIn() and .fadeOut(), I have been hiding/showing an element on my page, but with two buttons, one for hide and one for show. I now want to have one button to toggle both. My HTML / JavaScript as it is: <a onclick="showTestElement()">...

Access blocked by CORS policy: Response to preflight request doesn't pass access control check

I'm trying to create a user administration API for my web app. When I send an API call from my frontend to my backend, a cors error occurs. How can the cors problem be solved? I've read a lot of threads, but I haven't made any progress. Error after ...

Why use String.Format?

Why would anyone use String.Format in C# and VB .NET as opposed to the concatenation operators (& in VB, and + in C#)? What is the main difference? Why are everyone so interested in using String.Format? I am very curious....

MongoDB query with an 'or' condition

So I have an embedded document that tracks group memberships. Each embedded document has an ID pointing to the group in another collection, a start date, and an optional expire date. I want to query for current members of a group. "Current" means ...

SSIS expression: convert date to string

I'm new to SSIS and I'm trying to convert a GetDate() to string "DD-MM-YYYY". This is the expression I've built so far: (DT_WSTR, 8) DAY( GETDATE()) + "-" + (DT_WSTR, 8) (MONTH(GETDATE()) - 1) + "-" + (DT_WSTR, 8) YEAR(GETDATE()) The problem I'...

What is the purpose of .PHONY in a Makefile?

What does .PHONY mean in a Makefile? I have gone through this, but it is too complicated. Can somebody explain it to me in simple terms?...

How do I create a slug in Django?

I am trying to create a SlugField in Django. I created this simple model: from django.db import models class Test(models.Model): q = models.CharField(max_length=30) s = models.SlugField() I then do this: >>> from mysite.books.m...

Expand a random range from 1–5 to 1–7

Given a function which produces a random integer in the range 1 to 5, write a function which produces a random integer in the range 1 to 7. What is a simple solution? What is an effective solution to reduce memory usage or run on a slower CPU? ...

What is Scala's yield?

I understand Ruby and Python's yield. What does Scala's yield do?...

Custom edit view in UITableViewCell while swipe left. Objective-C or Swift

How to make a custom edit view in iOS7 UITableView with Objective C like the Evernote or the Apple Reminders app while swipe left. I have tried to set an custom editingAccessoryView, but this didn't work. Evernote edit view: Reminders edit view: ...

How to get my project path?

Possible Duplicate: get path for my .exe using c# Hello I have a question: How can I get my root project path? what I mean is the first folder in the project where the solution is. I found that command : System.IO.Directory.GetCurrentDir...

Javascript window.open pass values using POST

I have a javascript function that uses window.open to call another page and returning the result. Here is the section of my code: var windowFeatures = "status=0, toolbar=0, location=0, menubar=0, directories=0, resizable=1, scrollbars=1"; window.op...

Meaning of end='' in the statement print("\t",end='')?

This is the function for printing all values in a nested list (taken from Head first with Python). def printall(the_list, level): for x in the_list: if isinstance(x, list): printall(x, level=level + 1) else: ...

How can I exclude a directory from Visual Studio Code "Explore" tab?

I'm trying to exclude several folders on the "Explore" tab in Visual Studio Code. To do that I have added a following jsconfig.json to the root of my project: { "compilerOptions": { "target": "ES6" }, "exclude": [ "node_m...

How to use Angular2 templates with *ngFor to create a table out of nested arrays?

Given the following array in component property groups: [ { "name": "pencils", "items": ["red pencil","blue pencil","yellow pencil"] }, { "name": "rubbers", "items": ["big rubber","small rubber"] }, ] How to create ...

Replace last occurrence of character in string

Is there an easy way in javascript to replace the last occurrence of an '_' (underscore) in a given string?...

"R cannot be resolved to a variable"?

In Eclipse, I've created a project from a source and now it shows errors - "R cannot be resolved to a variable". From what I found here, I had cleared and rebuilt the project, but still the R file doesn't appear in the /gen folder. Any ideas?...

How do I POST a x-www-form-urlencoded request using Fetch?

I have some parameters that I want to POST form-encoded to my server: { 'userName': '[email protected]', 'password': 'Password!', 'grant_type': 'password' } I'm sending my request (currently without parameters) like this var obj = { me...

How to get `DOM Element` in Angular 2?

I have a component that has a <p> element. It's (click) event will change it into a <textarea>. So, the user can edit the data. My question is: How can I make the focus on the textarea? How can I get the element, so I can apply the .focu...

if, elif, else statement issues in Bash

I can't seem to work out what the issue with the following if statement is in regards to the elif and then. Keep in mind the printf is still under development I just haven't been able to test it yet in the statement so is more than likely wrong. The...

Python WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect:

I am new to programming, this is actually my first work assignment with coding. my code below is throwing an error: WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect. I'm not able to find where the issue ...

Android: Scale a Drawable or background image?

On a layout I want to scale the background image (keeping its aspect ratio) to the space allocated when the page gets created. Does anyone have an idea how to do this? I am using layout.setBackgroundDrawable() and a BitmapDrawable() to set gravity f...

Jenkins restrict view of jobs per user

Is there a way to restrict user to view only certain jobs in Jenkins. Jenkins allows the restriction of user ability per project via the "Project-based Matrix Authorization Strategy". The problem is that a user can not access anything without the '...

Enzyme - How to access and set <input> value?

I'm confused about how to access <input> value when using mount. Here's what I've got as my test: it('cancels changes when user presses esc', done => { const wrapper = mount(<EditableText defaultValue="Hello" />); const inpu...

Javascript : natural sort of alphanumerical strings

I'm looking for the easiest way to sort an array that consists of numbers and text, and a combination of these. E.g. '123asd' '19asd' '12345asd' 'asd123' 'asd12' turns into '19asd' '123asd' '12345asd' 'asd12' 'asd123' This is going to be used in co...

multiple prints on the same line in Python

I want to run a script, which basically shows an output like this: Installing XXX... [DONE] Currently, I print Installing XXX... first and then I print [DONE]. However, I now want to print Installing xxx... and [DONE] on the same li...

Is it possible to insert HTML content in XML document?

I need to insert HTML content into an XML document, is this possible or should HTML content be, for example, encoded in BASE64 or with something else like that?...

Parse JSON from JQuery.ajax success data

I am having trouble getting the contents of JSON object from a JQery.ajax call. My call: $('#Search').click(function () { var query = $('#query').valueOf(); $.ajax({ url: '/Products/Search', type: "POST", data: query,...

If Else If In a Sql Server Function

I have this function I am trying to create. When I parse it, it works fine, but to actually create the function in the database it says my column names are invalid. That is not true, I spelled them correctly. Here is the code: ALTER FUNCTION [dbo].[...

continuous page numbering through section breaks

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

In git how is fetch different than pull and how is merge different than rebase?

I just cant understand this. I been reading a lot on the web and books and something is just not staying in my head. Can someone please give me the dummy version of the following: git fetch vs pull git merge vs rebase ...

How to prevent vim from creating (and leaving) temporary files?

Why does vim create <filename>~ files? Is there a way to disable that? If it's for backup (or something), I use git for that. Also, these .<filename.with.path.hints>.swp files too. How do I tell vim not to create those, or at the leas...

How to enable copy paste from between host machine and virtual machine in vmware, virtual machine is ubuntu

I am trying to copy and paste from my pc to the vm but i cant. I also enable copy and paste but i still can't copy and paste from my pc to the vm. My pc runs windows 8.1 my vm has fedora....

How to make padding:auto work in CSS?

I am working on a legacy project that has CSS Reset with *{ margin:0; padding:0 } applied to everything. Now, my new code doesn't need that as it relies on Normalize.css. This hasn't been much of a problem but at some places I need to use both styles...

Force encode from US-ASCII to UTF-8 (iconv)

I'm trying to transcode a bunch of files from US-ASCII to UTF-8. For that, I'm using iconv: iconv -f US-ASCII -t UTF-8 file.php > file-utf8.php My original files are US-ASCII encoded, which makes the conversion not happen. Apparently it occurs...

How to iterate over associative arrays in Bash

Based on an associative array in a Bash script, I need to iterate over it to get the key and value. #!/bin/bash declare -A array array[foo]=bar array[bar]=foo I actually don't understand how to get the key while using a for-in loop....

Plot two graphs in same plot in R

I would like to plot y1 and y2 in the same plot. x <- seq(-2, 2, 0.05) y1 <- pnorm(x) y2 <- pnorm(x, 1, 1) plot(x, y1, type = "l", col = "red") plot(x, y2, type = "l", col = "green") But when I do it like this, they are not plotted in th...

How do I format date value as yyyy-mm-dd using SSIS expression builder?

hi I have taking flatfile source name dynamically I.e. filename like "source 2011-08-11" I'm creating expression builder for taking most recent file as per filename. I did like Created one variable which is having folder path : C\backup\ now inside ...

How do I center align horizontal <UL> menu?

I need to center align a horizontal menu. I've tried various solutions, including the mix of inline-block / block / center-align etc., but haven't succeeded. Here is my code: <div class="topmenu-design"> <!-- Top menu content: START --...

How to set a class attribute to a Symfony2 form input

How can I set the HTML class attribute to a form <input> using the FormBuilder in Symfony2 ? Something like this: ->add('birthdate', 'date',array( 'input' => 'datetime', 'widget' => 'single_text', 'attr' => array...

How to verify that a specific method was not called using Mockito?

How to verify that a method is not called on an object's dependency? For example: public interface Dependency { void someMethod(); } public class Foo { public bar(final Dependency d) { ... } } With the Foo test: public class...

PHP/Apache: PHP Fatal error: Call to undefined function mysql_connect()

I have MySQL (5.5.23 Community Server), Apache (2.2), and PHP (5.3.13) running on a Fedora 15 machine (64-bit). Each works with no problem on their own. I thought that PHP was configured/compiled to work with MySQL, but when I try to load any PHP we...

Adding <script> to WordPress in <head> element

I'm trying to insert this code: <script type="text/javascript"> some Javascript codes comes here </script> to WordPress' <head></head> section in front end and in admin panel E.g., Joomla! 1.6 has an API that allows t...

How to use multiple LEFT JOINs in SQL?

Is it possible to use multiple left joins in sql query? LEFT JOIN ab ON ab.sht = cd.sht i want to add to attach one more query like this to it? will it work? LEFT JOIN ab AND aa ON ab.sht = cd.sht ...

TypeScript: Interfaces vs Types

What is the difference between these statements (interface vs type)? interface X { a: number b: string } type X = { a: number b: string }; ...

What is Hive: Return Code 2 from org.apache.hadoop.hive.ql.exec.MapRedTask

I am getting: FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.MapRedTask While trying to make a copy of a partitioned table using the commands in the hive console: CREATE TABLE copy_table_name LIKE table_name; INSERT OV...

String.Format for Hex

With below code, the colorsting always gives #DDDD. Green, Red and Space values int he How to fix this? string colorstring; int Blue = 13; int Green = 0; int Red = 0; int Space = 14; colorstring = String.Format("#{0:X}{0:X}{0:X}{0:X}", Blue, Green, ...

Combine [NgStyle] With Condition (if..else)

I have read NgStyle Documentation For Angular 2, and it is a little bit confusing for me. How do I use NgStyle with condition like (if...else) to set background image of any element? ...

How do I obtain a list of all schemas in a Sql Server database

I want to retrieve a list of all schemas in a given Sql Server database. Using the ADO.NET schema retrieval API I get a list of all collections but there is no collection for 'Schemas'. I could traverse the 'Tables', 'Procedures' collections (and oth...

Using COALESCE to handle NULL values in PostgreSQL

I have the following query SELECT DISTINCT pt.incentive_marketing, pt.incentive_channel, pt.incentive_advertising FROM test.pricing pt WHERE pt.contract_id = 90000 group by 1,2,3 order by pt.incentive_marketing; The above q...

How to remove all .svn directories from my application directories

One of the missions of an export tool I have in my application, is to clean all .svn directories from my application directory tree. I am looking for a recursive command in the Linux shell that will traverse the entire tree and delete the .svn files....

Html table with button on each row

I have a table with multiple rows and one column. Each table cell has a button in it. Like this: <table id="table1" border="1"> <thead> <tr> <th>Select</th> </tr> </thead> &...

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

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

gcc: undefined reference to

I would like to compile this. program.c #include <libavcodec/avcodec.h> int main(){ int i = avpicture_get_size(AV_PIX_FMT_RGB24,300,300); } Running this gcc -I$HOME/ffmpeg/include program.c gives error /tmp/ccxMLBme.o: In function...

How to set some xlim and ylim in Seaborn lmplot facetgrid

I'm using Seaborn's lmplot to plot a linear regression, dividing my dataset into two groups with a categorical variable. For both x and y, I'd like to manually set the lower bound on both plots, but leave the upper bound at the Seaborn default. Here...

Color theme for VS Code integrated terminal

Can we change color settings of VS Code Integrated Terminal? Mine looks dull with just white. ...

How to Decode Json object in laravel and apply foreach loop on that in laravel

i am getting this request.    { "area": [ { "area": "kothrud" }, { "area": "katraj" } ] } and i want to provide response to this by searching records in database based on above request...

How to export private key from a keystore of self-signed certificate

I just created a self-signed certificate on a linux box running tomcat 6. I created the keys like this, valid for 10 years: keytool -genkey -alias tomcatorange -keyalg RSA -validity 3650 and copied the keystore into a folder in tomcat, and update...

How to group by month from Date field using sql

How can I group only by month from a date field (and not group by day)? Here is what my date field looks like: 2012-05-01 Here is my current SQL: select Closing_Date, Category, COUNT(Status)TotalCount from MyTable where Closing_Date >= '20...

Simple PowerShell LastWriteTime compare

I need a PowerShell script that can access a file's properties and discover the LastWriteTime property and compare it with the current date and return the date difference. I have something like this... $writedate = Get-ItemProperty -Path $source -N...

How to convert java.sql.timestamp to LocalDate (java8) java.time?

In Java 8, how can I convert a Timestamp (in java.sql) to a LocalDate (in java.time)?...

Windows CMD command for accessing usb?

I have tried googling it but couldn't find it. I know the command for it is cd /media for linux but have no idea what it is for Windows.I also tried the dir command but couldn't find anything related to media or usb....

JRE 1.7 - java version - returns: java/lang/NoClassDefFoundError: java/lang/Object

When running any java application, or just 'java', the jvm fails: Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object Here is a list of wrong answers: The correct Java home directory, including the /b...

Statistics: combinations in Python

I need to compute combinatorials (nCr) in Python but cannot find the function to do that in math, numpy or stat libraries. Something like a function of the type: comb = calculate_combinations(n, r) I need the number of possible combinations, not ...

Setting DIV width and height in JavaScript

I have a div with id="div_register". I want to set its width dynamically in JavaScript. I am using this following code: getElementById('div_register').style.width=500; but this line of code isn't working. I also tried using the units px like the...

Creating a UITableView Programmatically

I have an application in Xcode 4.6 which uses storyboards. I added a UITableView to a view controller class, which worked as expected. However, when I tried deleting the UITableView in the storyboard and adding it back into the same class programmati...

How do I display a MySQL error in PHP for a long query that depends on the user input?

In PHP, I am trying to execute a long MySQL query that depends on the user input. However, my query fails with the following message, "Query Failed". Actually I have printed this message whenever the query fails, but I am having hard time looking ...

Is there a JavaScript function that can pad a string to get to a determined length?

I am in need of a JavaScript function which can take a value and pad it to a given length (I need spaces, but anything would do). I found this: Code: String.prototype.pad = function(l, s, t){ return s || (s = " "), (l -= this.length) &g...

How to enter special characters like "&" in oracle database?

I want to insert special character & in my insert statement. My insert is: INSERT INTO STUDENT(name, class_id) VALUES ('Samantha', 'Java_22 & Oracle_14'); If I try to run this query I am getting a popup and it asks me to enter value for Or...

How do I view the full content of a text or varchar(MAX) column in SQL Server 2008 Management Studio?

In this live SQL Server 2008 (build 10.0.1600) database, there's an Events table, which contains a text column named Details. (Yes, I realize this should actually be a varchar(MAX) column, but whoever set this database up did not do it that way.) T...

Is it acceptable and safe to run pip install under sudo?

I've started to use my Mac to install Python packages in the same way I do with my Windows PC at work; however on my Mac I've come across frequent permission denied errors while writing to log files or site-packages. Therefore I thought about runnin...

How to read a file in other directory in python

I have a file named 5_1.txt in a directory named direct, how can I read that file using read? I verified the path using : import os os.getcwd() os.path.exists(direct) the result was True x_file=open(direct,'r') and I got this error : ...

form_for but to post to a different action

I want to have a form_for @user, but post to a custom action in the users controller. How can I do this?...

How to decrypt the password generated by wordpress

I am using a wordpress site. I just want to know , How to get a plain text from encrypted password(stored in wordpress database). I used the $wp_hasher->CheckPassword($plain_password, $password_hashed) to check the password is correct or not. But ...

Merging arrays with the same keys

In a piece of software, I merge two arrays with array_merge function. But I need to add the same array (with the same keys, of course) to an existing array. The problem: $A = array('a' => 1, 'b' => 2, 'c' => 3); $B = array('c' => 4, '...

C# How to determine if a number is a multiple of another?

Without using string manipulation (checking for an occurrence of the . or , character) by casting the product of an int calculation to string. and without using try / catch scenarios relying on errors from data types. How do you specifically chec...

Error: Execution failed for task ':app:clean'. Unable to delete file

I'm trying to rebuild my Android Studio Gradle project (containing mostly Kotlin code), but it started to throw an UnableToDeleteFileException during the cleaning/rebuilding process: Execution failed for task ':app:clean'. > Unable to delete file...

How to picture "for" loop in block representation of algorithm

I have probem / strange question, i got algorithm with few "for" loops and now i need to do block scheme of this algorithm. I know how to picture "while" loop, but is this acceptable to represent "for" loop using "while" and at this point make diff...

How to get the changes on a branch in Git

What is the best way to get a log of commits on a branch since the time it was branched from the current branch? My solution so far is: git log $(git merge-base HEAD branch)..branch The documentation for git-diff indicates that git diff A...B is e...

Get div tag scroll position using JavaScript

How do I get the amount of scroll in a div tag using JavaScript? Please provide me with an example. I don't want to use jQuery, only JavaScript....

How can I customize the tab-to-space conversion factor?

How do I customize the tab-to-space conversion factor when using Visual Studio Code? For instance, right now in HTML it appears to produce two spaces per press of TAB, but in TypeScript it produces 4....

Visual Studio Community 2015 expiration date

I have downloaded the Visual Studio Community 2015 (free version) and I don't see when the expiration date is. I have tried to see the expiration date at Help Menu -> About Microsoft Visual Studio and there is no expiration date there. Is there any...

How can I change column types in Spark SQL's DataFrame?

Suppose I'm doing something like: val df = sqlContext.load("com.databricks.spark.csv", Map("path" -> "cars.csv", "header" -> "true")) df.printSchema() root |-- year: string (nullable = true) |-- make: string (nullable = true) |-- model: st...

How to change content on hover

I've been playing around with this, and I thought it would be pretty simple. What I'm trying to do is hover over the 'NEW' label. Once in its hover state, change the content from 'NEW' to 'ADD' using only CSS. _x000D_ _x000D_ body{_x000D_ font-f...

how to show progress bar(circle) in an activity having a listview before loading the listview with data

I have a ListView in my second activity.OnItemClick of it I called a webservice and trying to fetch data. And after that I am moving to third activity which also have a ListView having description of previous activities ListView item. I want to disp...

Handling 'Sequence has no elements' Exception

I am updating a quantity in my cart, but it is throwing a Sequence has no elements' exception. And I don't know what that even means. At first I thought that maybe there was a null value being passed somewhere, but that isn't the case, as I've check...

Better way of getting time in milliseconds in javascript?

Is there an alternative in JavaScript of getting time in milliseconds using the date object, or at least a way to reuse that object, without having to instantiate a new object every time I need to get this value? I am asking this because I am trying ...

Custom CSS Scrollbar for Firefox

I want to customize a scrollbar with CSS. I use this WebKit CSS code, which works well for Safari and Chrome: ::-webkit-scrollbar { width: 15px; height: 15px; } ::-webkit-scrollbar-track-piece { background-color: #C2D2E4; } ::-webkit...

Declaring an unsigned int in Java

Is there a way to declare an unsigned int in Java? Or the question may be framed as this as well: What is the Java equivalent of unsigned? Just to tell you the context I was looking at Java's implementation of String.hashcode(). I wanted to test th...

Inserting a text where cursor is using Javascript/jquery

I have a page with a lot of textboxes. When someone clicks a link, i want a word or two to be inserted where the cursor is, or appended to the textbox which has the focus. For example, if the cursor/focus is on a textbox saying 'apple' and he click...

How to use HTTP_X_FORWARDED_FOR properly?

Alright, I have an small authentication issue. My web service allows to connect to my API over HTTP with a username and password, but this connection can also be restricted to a specific IP address. This means that the $_SERVER['REMOTE_ADDR'] can be...

curl: (60) SSL certificate problem: unable to get local issuer certificate

root@sclrdev:/home/sclr/certs/FreshCerts# curl --ftp-ssl --verbose ftp://{abc}/ -u trup:trup --cacert /etc/ssl/certs/ca-certificates.crt * About to connect() to {abc} port 21 (#0) * Trying {abc}... * Connected to {abc} ({abc}) port 21 (#0) < 220...

SQL RANK() versus ROW_NUMBER()

I'm confused about the differences between these. Running the following SQL gets me two idential result sets. Can someone please explain the differences? SELECT ID, [Description], RANK() OVER(PARTITION BY StyleID ORDER BY ID) as 'Rank' ...

Apply CSS to jQuery Dialog Buttons

So I currently have a jQuery dialog with two buttons: Save and Close. I create the dialog using the code below: $dialogDiv.dialog({ autoOpen: false, modal: true, width: 600, resizable: false, buttons: { Cancel: function()...

Split array into chunks

Let's say that I have an Javascript array looking as following: ["Element 1","Element 2","Element 3",...]; // with close to a hundred elements. What approach would be appropriate to chunk (split) the array into many smaller arrays with, lets say...

PHP & MySQL: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given

I'm trying to Integrate HTML Purifier http://htmlpurifier.org/ to filter my user submitted data but I get the following error below. And I was wondering how can I fix this problem? I get the following error. on line 22: mysqli_num_rows() expects pa...

compareTo with primitives -> Integer / int

Is it better to write int primitive1 = 3, primitive2 = 4; Integer a = new Integer(primitive1); Integer b = new Integer(primitive2); int compare = a.compareTo(b); or int primitive1 = 3, primitive2 = 4; int compare = (primitive1 > primitive2) ?...

UTF-8: General? Bin? Unicode?

I'm trying to figure out what collation I should be using for various types of data. 100% of the content I will be storing is user-submitted. My understanding is that I should be using UTF-8 General CI (Case-Insensitive) instead of UTF-8 Binary. How...

RecyclerView vs. ListView

From android developer (Creating Lists and Cards): The RecyclerView widget is a more advanced and flexible version of ListView. Okay, it sounds cool, but when I saw this example picture, I got really confused about the difference between thes...

Adding Text to DataGridView Row Header

Does C# allow you to add a String to a RowHeader in a DataGridView? If so, how is it accomplished? I'm writing a Windows Form to displayed Customer Payment Data for the year so far. The ColumnHeaders display January, February, March, etc... and rat...

Fastest way to count exact number of rows in a very large table?

I have come across articles that state that SELECT COUNT(*) FROM TABLE_NAME will be slow when the table has lots of rows and lots of columns. I have a table that might contain even billions of rows [it has approximately 15 columns]. Is there a bette...

Get list of all tables in Oracle?

How do I query an Oracle database to display the names of all tables in it?...

Postgres - Transpose Rows to Columns

I have the following table, which gives multiple email addresses for each user. I need to flatten this out to columns on a user query. To give me the "newest" 3 email addresses based on the creation date. user.name | user.id | email1 | e...

Replace all elements of Python NumPy Array that are greater than some value

I have a 2D NumPy array and would like to replace all values in it greater than or equal to a threshold T with 255.0. To my knowledge, the most fundamental way would be: shape = arr.shape result = np.zeros(shape) for x in range(0, shape[0]): for...

How to convert a list into data table

I have a data list with some property. I want to convert that list data into data table. How to convert a list into datable. ...

How do I make a branch point at a specific commit?

In Git, I understand that a branch is a pointer to a commit. How do I make a specific branch point to a specific commit? Say I want to make master point at 1258f0d0aae..., how do I do that?...

How to initialize log4j properly?

After adding log4j to my application I get the following output every time I execute my application: log4j:WARN No appenders could be found for logger (slideselector.facedata.FaceDataParser). log4j:WARN Please initialize the log4j system properly. ...

How do I display an alert dialog on Android?

I want to display a dialog/popup window with a message to the user that shows "Are you sure you want to delete this entry?" with one button that says 'Delete'. When Delete is touched, it should delete that entry, otherwise nothing. I have written a ...

how to get right offset of an element? - jQuery

This is probably a really simple question, but how do I go about getting the right offset of an element in jQuery? I can do: $("#whatever").offset().left; and it is valid. But it seems that: $("#whatever").offset().right is undefined. So ho...

How to create exe of a console application

How can we create the exe for a console forms application ?...

How do I get the directory of the PowerShell script I execute?

I run a PowerShell script. How do I get the directory path of this script I run? How to do this?...

What's the difference between isset() and array_key_exists()?

How do the following two function calls compare: isset($a['key']) array_key_exists('key', $a) ...

Get everything after and before certain character in SQL Server

I got the following entry in my database: images/test.jpg I want to trim the entry so I get: test So basically, I want everything after / and before . How can I solve it?...

Parsing a YAML file in Python, and accessing the data?

I am new to YAML and have been searching for ways to parse a YAML file and use/access the data from the parsed YAML. I have come across explanations on how to parse the YAML file, for example, the PyYAML tutorial, "How can I parse a YAML file in Py...

How can I read SMS messages from the device programmatically in Android?

I want to retrieve the SMS messages from the device and display them?...

What is and how to fix System.TypeInitializationException error?

private static void Main(string[] args) { string str = null; Logger.InitUserLogWithRotation(); // <--- error occur ... } When I build project, it has no error. But When I execute it, it always aborted. I tried to debug pr...

Arraylist swap elements

How do I swap the the first and last elements of an ArrayList? I know how to swap the elements of an array: setting a temporary value to store the first element, letting the first element equal the last element, then letting the last element equal th...

LDAP filter for blank (empty) attribute

I have searched on this topic, but all I find are filters that return entries where a certain attribute is not present, like: (!(manager=*)) However, I want to find entries where the attribute is present, but has a null value (i.e. an empty/blank ...

Redirect to new Page in AngularJS using $location

I am testing with the following AngularJS $location. I don't what's the problem with this. Just want to check if the redirection is working or not: HTML <body data-ng-controller="MainCtrl"> Hello {{name}}! <button ng-click='go()'>...

How to add number of days to today's date?

I need to be able to add 1, 2 , 5 or 10 days to today's date using jQuery....

TSQL PIVOT MULTIPLE COLUMNS

I have the following table but unsure of whether it is possible to pivot this and retain all the labels. RATIO RESULT SCORE GRADE Current Ratio 1.294 60 Good Gearing Ratio 0.3384 70 Good Performance Ratio...

expand/collapse table rows with JQuery

I want to expand and collapse table rows when header columns is clicked. I only want to expand/collapse rows which are under the specific header (clicked). Here is my table structure: _x000D_ _x000D_ <table border="0">_x000D_ <tr>...

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

TLS 1.2 not working in cURL

I am having trouble curling an HTTPS url that uses TLS1.2, in my curl operation I post my login data into the website and save it in cookiefile. The error message I am getting is this error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert ...

How to access global variables

How do I access a variable that was declared/init in my main.go in a different .go package/file? Keeps telling me that the variable is undefined (I know that global variables are bad but this is just to be used as a timestamp) in main.go var StartT...

Getting XML Node text value with Java DOM

I can't fetch text value with Node.getNodeValue(), Node.getFirstChild().getNodeValue() or with Node.getTextContent(). My XML is like <add job="351"> <tag>foobar</tag> <tag>foobar2</tag> </add> And I'm ...

Using Server.MapPath in external C# Classes in ASP.NET

I'm trying to get the absolute path of certain files in a C# class. Server.MapPath works great of course for ASPX and their code-behind pages, but that doesn't exist in another class file. I tried HostingEnvironment.MapPath(), but that complains th...

How to decode encrypted wordpress admin password?

I forgot my WordPress admin password, and I see it in the phpMyAdmin file. But it is in a different form. How I can decode it to know what my password is? Is there any tool for decoding passwords? $P$BX5675uhhghfhgfhfhfgftut/0 Help me....

What does Html.HiddenFor do?

Although I have read the documentation on Html.HiddenFor, I've not grasped what is it used for... Could somebody explain its uses and give a short example? Where should those helpers go in the code? ...

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

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

Bootstrap 3 dropdown select

We are trying re-implement our sign-up form with bootstrap. Our sign up form contains a drop-down list which represents a company type. I have searched extensively online but I do not see any example where a form input would be a drop down. Bootstra...

sorting a List of Map<String, String>

I have a list variable created like this: List<Map<String, String>> list = new ArrayList<Map<String, String>>(); In my Android application, this list gets populated. just an example: Map<String, String> map1 = new H...

How can I print a quotation mark in C?

In an interview I was asked Print a quotation mark using the printf() function I was overwhelmed. Even in their office there was a computer and they told me to try it. I tried like this: void main() { printf("Printing quotation mark " "); ...

spacing between form fields

I have an HTML form element: <form action="doit" id="doit" method="post"> Name <br/> <input id="name" name="name" type="text" /> <br/> Phone number <br/> <input id="phone" name="phone" type="text" /> <br/> Y...

Excel select a value from a cell having row number calculated

In column A i have numbers calculated like so: [A] [1] [2] [3] [4] [1] [2] [3] ... In column K I have values: [row] [K] [ 1 ] [7] [ 2 ] [3] [ 3 ] [6] [ 4 ] [9] How could I pull values from column K given that row number is the number stored i...

How to create a directory using Ansible

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

How to check if X server is running?

Is there any way to find out if the current session user is running an Xserver (under Linux) ? I'v started off with things like: ps -e | grep X but this doesn't work always and one more thing I tried is checking the $DISPLAY variable Are there...

jQuery: set selected value of dropdown list?

What's wrong with this code? jQuery $(document).ready(function() { $("#routetype").val('quietest'); )}; HTML <select id="routetype" name="routetype"> <option value="fastest">Fastest</option> <option selected="tru...

sql primary key and index

Say I have an ID row (int) in a database set as the primary key. If I query off the ID often do I also need to index it? Or does it being a primary key mean it's already indexed? Reason I ask is because in MS SQL Server I can create an index on this...

What is the best way to get the minimum or maximum value from an Array of numbers?

Let's say I have an Array of numbers: [2,3,3,4,2,2,5,6,7,2] What is the best way to find the minimum or maximum value in that Array? Right now, to get the maximum, I am looping through the Array, and resetting a variable to the value if it is great...

Sass nth-child nesting

I'm refactoring these CSS selectors over to Sass: #romtest .detailed th:nth-child(2), #romtest .detailed th:nth-child(4), #romtest .detailed th:nth-child(6), #romtest .detailed td:nth-child(2), #romtest .detailed td:nth-child(3), #romtest .detailed ...

Android Spinner: Get the selected item change event

How can you set the event listener for a Spinner when the selected item changes? Basically what I am trying to do is something similar to this: spinner1.onSelectionChange = handleSelectionChange; void handleSelectionChange(Object sender){ //ha...

How can I find the location of origin/master in git, and how do I change it?

I'm a Git newbie. I recently moved a Rails project from Subversion to Git. I followed the tutorial here: http://www.simplisticcomplexity.com/2008/03/05/cleanly-migrate-your-subversion-repository-to-a-git-repository/ I am also using unfuddle.com to...

python requests file upload

I'm performing a simple task of uploading a file using Python requests library. I searched Stack Overflow and no one seemed to have the same problem, namely, that the file is not received by the server: import requests url='http://nesssi.cacr.caltec...

Difference between binary semaphore and mutex

Is there any difference between a binary semaphore and mutex or are they essentially the same?...

CUSTOM_ELEMENTS_SCHEMA added to NgModule.schemas still showing Error

I just upgraded from Angular 2 rc4 to rc6 and having troubles doing so. I see the following error on my console: Unhandled Promise rejection: Template parse errors: 'cl-header' is not a known element: 1. If 'cl-header' is an Angular component, th...

Preloading CSS Images

I have a hidden contact form which is deployed clicking on a button. Its fields are set as CSS background images, and they always appears a bit later than the div that have been toggled. I was using this snippet in the <head> section, but with...

MS Excel showing the formula in a cell instead of the resulting value

The above image shows 3 cells containing the formula instead of the value; The first cell is under PHP Hourly Rate, the second is under Name and the third is the Invoice Sub Total. However, the values will show after I double click the cell then pr...

I get exception when using Thread.sleep(x) or wait()

I have tried to delay - or put to sleep - my Java program, but an error occurs. I'm unable to use Thread.sleep(x) or wait(). The same error message appears: unreported exception java.lang.InterruptedException; must be caught or declared to be t...

How to find Oracle Service Name

I have an Oracle database on my network which I am able to connect to with Oracle SQL Developer, using hostname, port, username, password and the SID. I need to connect another application (Quantum Gis), however it uses the Service Name instead of t...

How can I make the contents of a fixed element scrollable only when it exceeds the height of the viewport?

I have a div positioned fixed on the left side of a web page, containing menu and navigation links. It has no height set from css, the content determines the height, the width is fixed. The problem is that if the content is too much, the div will be ...

Unable to begin a distributed transaction

I'm trying to run SQL against a linked server, but I get the errors below : BEGIN DISTRIBUTED TRANSACTION SELECT TOP 1 * FROM Sessions OLE DB provider "SQLNCLI" for linked server "ASILIVE" returned message "No transaction i...

Django Cookies, how can I set them?

I have a web site which shows different content based on a location the visitor chooses. e.g: User enters in 55812 as the zip. I know what city and area lat/long. that is and give them their content pertinent to that area. My question is how can I st...

Given two directory trees, how can I find out which files differ by content?

If I want find the differences between two directory trees, I usually just execute: diff -r dir1/ dir2/ This outputs exactly what the differences are between corresponding files. I'm interested in just getting a list of corresponding files whose ...

Compare objects in Angular

Is it possible to do a "deep" comparison of two object in Angular? What I would like to do is compare each key/value pair. For example: Object 1 { key1: "value1", key2: "value2", key3: "value3" } Object 2 { key1: "value1", key2: "...

Removing empty lines in Notepad++

How can I replace empty lines in Notepad++? I tried a find and replace with the empty lines in the find, and nothing in the replace, but it did not work; it probably needs regex....

sorting and paging with gridview asp.net

I'm trying to get a gridview to sort and page manually with no success. The problem is that when a user clicks the column they want to sort, it sorts that page, but doesn't sort the datasource (dataview) behind the gridview. So when they progress t...

How can I loop through a C++ map of maps?

How can I loop through a std::map in C++? My map is defined as: std::map< std::string, std::map<std::string, std::string> > For example, the above container holds data like this: m["name1"]["value1"] = "data1"; m["name1"]["value2"] = ...

Display Back Arrow on Toolbar

I'm migrating from ActionBar to Toolbar in my application. But I don't know how to display and set click event on Back Arrow on Toolbar like I did on Actionbar. With ActionBar, I call mActionbar.setDisplayHomeAsUpEnabled(true). But there is no ...

How do I fix MSB3073 error in my post-build event?

I'm working on a project that requires that DLLs generated by building my solution to be copied from the bin folder to another folder, both of which are on my machine, in my C drive. I've written a batch file that uses xcopy to accomplish this, which...

Singleton with Arguments in Java

I was reading the Singleton article on Wikipedia and I came across this example: public class Singleton { // Private constructor prevents instantiation from other classes private Singleton() {} /** * SingletonHolder is loaded on th...

React-router: How to manually invoke Link?

I'm new to ReactJS and to React-Router. I have a component that receives through props a <Link/> object from react-router. Whenever the user clicks on a 'next' button inside this component I want to invoke <Link/> object manually. Right ...

CertificateException: No name matching ssl.someUrl.de found

I'm trying to connect to one of my servers through ssl, with Java. I tried a lot of options here is my best try: I generate a jssecacerts with the recommendet script: http://blogs.oracle.com/andreas/resource/InstallCert.java with the command: java I...

Python Requests package: Handling xml response

I like very much the requests package and its comfortable way to handle JSON responses. Unfortunately, I did not understand if I can also process XML responses. Has anybody experience how to handle XML responses with the requests package? Is it nec...

SimpleXml to string

Is there any function that makes string from PHP SimpleXMLElement?...

MySQL error: key specification without a key length

I have a table with a primary key that is a varchar(255). Some cases have arisen where 255 characters isn't enough. I tried changing the field to a text, but I get the following error: BLOB/TEXT column 'message_id' used in key specification without ...

How to use PHP with Visual Studio

First let me say I've never used PHP but I'm looking to learn it, so my question is this how do you use PHP within Visual Studio Ultimate? is it similar to how you declare JQuery i.e $(document).ready(function () { // Code goes here? }); ...

Delete topic in Kafka 0.8.1.1

I need to delete the topic test in Apache Kafka 0.8.1.1. As expressed in the documentation here, I have executed: bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic test However, this results in the following message: Command must i...

How to return multiple objects from a Java method?

I want to return two objects from a Java method and was wondering what could be a good way of doing so? The possible ways I can think of are: return a HashMap (since the two Objects are related) or return an ArrayList of Object objects. To be more ...

Error: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'text/plain;charset=UTF-8' not supported

I'm newbie in Spring Data. I keep getting the error: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'text/plain;charset=UTF-8' not supported I've tried to change consumes inside @RequestMapping annotation to text/plain but u...

How to get a div to resize its height to fit container?

How can I get the nav div to have expand down or have the height the same as its parent div? _x000D_ _x000D_ * {_x000D_ border:0; _x000D_ padding:0; _x000D_ margin:0;_x000D_ }_x000D_ #container {_x000D_ margin-left: auto;_x000D_ ...

jQuery find and replace string

I have somewhere on website a specific text, let's say "lollypops", and I want to replace all the occurrences of this string with "marshmellows". The problem is that I don't know where exactly the text is. I know I could do something like: $(body).h...

Sum a list of numbers in Python

I have a list of numbers such as [1,2,3,4,5...], and I want to calculate (1+2)/2 and for the second, (2+3)/2 and the third, (3+4)/2, and so on. How can I do that? I would like to sum the first number with the second and divide it by 2, then sum the ...

How to Detect Browser Window /Tab Close Event?

I am Trying with onbeforeunload, and Unload function. But it didn't work. When clicking a link or refreshing, this event got triggered. I want an event that is triggered only when a browser window or tab is closed. The code must work in all browsers....

How to merge a transparent png image with another image using PIL

I have a transparent png image "foo.png" and I've opened another image with im = Image.open("foo2.png"); now what i need is to merge foo.png with foo2.png. ( foo.png contains some text and I want to print that text on foo2.png )...

Why are C++ inline functions in the header?

NB This is not a question about how to use inline functions or how they work, more why they are done the way they are. The declaration of a class member function does not need to define a function as inline, it is only the actual implementation of t...

Tips for debugging .htaccess rewrite rules

Many posters have problems debugging their RewriteRule and RewriteCond statements within their .htaccess files. Most of these are using a shared hosting service and therefore don't have access to the root server configuration. They cannot avoid usin...

The localhost page isn’t working localhost is currently unable to handle this request. HTTP ERROR 500

I know that there is some 500 Internal Server Error when is see this page, The localhost page isn’t working localhost is currently unable to handle this request. HTTP ERROR 500 I have already set the variables display_errors: On and error_re...

how to make password textbox value visible when hover an icon

Good day all, I have a form that has a password field: <input type="password" name="password" size="30" /> Naturally, the input text will be replaced by (*). So if the user typed 123 the box will show ***. Up to here, it is straight forwa...

How to get the current directory in a C program?

I'm making a C program where I need to get the directory that the program is started from. This program is written for UNIX computers. I've been looking at opendir() and telldir(), but telldir() returns a off_t (long int), so it really doesn't help ...

Can you have if-then-else logic in SQL?

I need to do select data from a table based on some kind of priority like so: select product, price from table1 where project = 1 -- pseudo: if no price found, do this: select product, price from table1 where customer = 2 -- pseudo: if still no pr...

HorizontalScrollView within ScrollView Touch Handling

I have a ScrollView that surrounds my entire layout so that the entire screen is scrollable. The first element I have in this ScrollView is a HorizontalScrollView block that has features that can be scrolled through horizontally. I've added an onto...

CentOS: Enabling GD Support in PHP Installation

How do I go about enabling GD Support in a CentOS Installation?...

Setting maxlength of textbox with JavaScript or jQuery

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

Django: Calling .update() on a single model instance retrieved by .get()?

I have a function which currently calls Models.object.get(), which returns either 0 or 1 model objects. If it returns 0, I create a new model instance in the except DoesNotExist clause of the function. Otherwise, I would like to update the fields in ...

How to lock specific cells but allow filtering and sorting

I'm using the following code to lock the content of certain cells Sub LockCell(ws As Worksheet, strCellRng As String) With ws .Unprotect .Cells.Locked = False .Range(strCellRng).Locked = True .Protect Contents:=True, AllowFormattingCel...

Which characters make a URL invalid?

Which characters make a URL invalid? Are these valid URLs? example.com/file[/].html http://example.com/file[/].html ...

What CSS selector can be used to select the first div within another div

I have something like: <div id="content> <h1>Welcome to Motor City Deli!</h1> <div style=" font-size: 1.2em; font-weight: bolder;">Sep 19, 2010</div> <div > ... </div> What is the css selector fo...

Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`

I built an app with ReactNative both for iOS and android with a ListView. When populating the listview with a valid datasource, the following warning is printed at the bottom of the screen: Warning: Each child in an array or iterator should have ...

How to copy marked text in notepad++

I have a part of HTML source file that contains strings that I want to select and copy at once, using the regex functionality of Notepad++. Here is a part of the text source: <option value="Performance" >Performance</option> <option ...

npm install doesn't create node_modules directory

I am trying to do a homework for a mongodb uni course. They gave us some files, instructions are: run npm install mongodb then node app.js for some reason npm install does not create a node_modules directory but I don't see any build errors: mongo...

Sort Pandas Dataframe by Date

I have a pandas dataframe as follows: Symbol Date A 02/20/2015 A 01/15/2016 A 08/21/2015 I want to sort it by Date, but the column is just an object. I tried to make the column a date object, but I ran into an issue where that ...

How to use the ProGuard in Android Studio?

This is my first project in Android Studio, and the code of my apps are not obfuscated. Im using this configuration in build.gradle file: I'm using the Build > Generate Signed APK... with the Run Proguard checked. And, when I have tested using the ...

What is the use of "assert"?

I have been reading some source code and in several places I have seen the usage of assert. What does it mean exactly? What is its usage?...

No tests found for given includes Error, when running Parameterized Unit test in Android Studio

I tried run Parameterized Unit Test as below in Android Studio. import android.test.suitebuilder.annotation.SmallTest; import junit.framework.TestCase; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; ...

Passing parameters to JavaScript files

Often I will have a JavaScript file that I want to use which requires certain variables be defined in my web page. So the code is something like this: <script type="text/javascript" src="file.js"></script> <script type="text/javascri...

How to validate an e-mail address in swift?

Does anyone know how to validate an e-mail address in Swift? I found this code: - (BOOL) validEmail:(NSString*) emailString { if([emailString length]==0){ return NO; } NSString *regExPattern = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+...

YouTube embedded video: set different thumbnail

I want to embed a video from YouTube that is not mine (so I can not change it at YouTube). The video has a thumbnail that is not representative for the video (I refer to the initial still that is shown when you embed a video, shown before the user pl...

How to add "active" class to Html.ActionLink in ASP.NET MVC

I'm trying to add an"active" class to my bootstrap navbar in MVC, but the following doesn't show the active class when written like this: <ul class="nav navbar-nav"> <li>@Html.ActionLink("Home", "Index", "Home", null, new {@class="acti...

how to get curl to output only http response body (json) and no other headers etc

I am using curl in a bash script to fetch the response of a service as below, response=$(curl -isb -H "Accept: application/json" "http://host:8080/some/resource") Service response is of json type and on browser I could perfectly fine response. How...

batch script - run command on each file in directory

I need to convert some xls files into xlsx files. I can successfully convert one xls file into xlsx by running this command into cmd prompt (windows): ssconvert inputFileName.xls outputFileName.xlsx (ssconvert is a Gnumeric's command-line utility ...

How do I concatenate strings in Swift?

How to concatenate string in Swift? In Objective-C we do like NSString *string = @"Swift"; NSString *resultStr = [string stringByAppendingString:@" is a new Programming Language"]; or NSString *resultStr=[NSString stringWithFormat:@"%@ is a new ...

Push local Git repo to new remote including all branches and tags

I have a local Git repo that I would like to push to a new remote repo (brand new repo set up on Beanstalk, if that matters). My local repo has a few branches and tags, and I would like to keep all of my history. It looks like I basically just nee...

Android how to use Environment.getExternalStorageDirectory()

How can i use Environment.getExternalStorageDirectory() to read a a stored image from the SD card or is there a better way to do it?...

How to lazy load images in ListView in Android

I am using a ListView to display some images and captions associated with those images. I am getting the images from the Internet. Is there a way to lazy load images so while the text displays, the UI is not blocked and images are displayed as they a...

Can I have an onclick effect in CSS?

I have an image element that I want to change on click. <img id="btnLeft"> This works: #btnLeft:hover { width:70px; height:74px; } But what I need is: #btnLeft:onclick { width:70px; height:74px; } But, it doesn't work, ...

How to set a transparent background of JPanel?

Can JPanels background be set to transparent? My frame is has two JPanels: Image Panel and Feature Panel. Feature Panel is overlapping Image Panel. The Image Panel is working as a background and it loads image from a remote URL. On Feature P...

how to place last div into right top corner of parent div? (css)

Can I somehow use CSS to place the block2 in top right corner of block1? Context : block2 must be the (very) last inside HTML code of block1 or it could be placed after block1. I can't make it the first element in block1. Within block1 there could ...

Running Jupyter via command line on Windows

I have installed Jupyter on Windows 10, Python 3.x via $ pip install jupyter The installation works fine, even though I did restart the terminal. But trying to run $ jupyter notebook gives the following error 'jupyter' is not recognized as an inter...

Why does my JavaScript code receive a "No 'Access-Control-Allow-Origin' header is present on the requested resource" error, while Postman does not?

Mod note: This question is about why Postman is not subject to CORS restrictions in the same way an XMLHttpRequest is. This question is not about how to fix a "No 'Access-Control-Allow-Origin'..." error. Please stop posting: CORS conf...

Mobile website "WhatsApp" button to send message to a specific number

A mobile website can be customized to allow users to share a pre-filled message in WhatsApp to a manually chosen contact. As given here it is done using Custom URL Scheme. An example: <a href="whatsapp://send?text=Hello%20World!">Hello, world!...

Is it possible to move/rename files in Git and maintain their history?

I would like to rename/move a project subtree in Git moving it from /project/xyz to /components/xyz If I use a plain git mv project components, then all the commit history for the xyz project gets lost. Is there a way to move this such that th...

Changing PowerShell's default output encoding to UTF-8

By default, when you redirect the output of a command to a file or pipe it into something else in PowerShell, the encoding is UTF-16, which isn't useful. I'm looking to change it to UTF-8. It can be done on a case-by-case basis by replacing the >...

Hive cast string to date dd-MM-yyyy

How can I cast a string in the format 'dd-MM-yyyy' to a date type also in the format 'dd-MM-yyyy' in Hive? Something along the lines of: CAST('12-03-2010' as date 'dd-mm-yyyy') ...

Exists Angularjs code/naming conventions?

Does anyone know if exists any official or most accepted reference for Angular naming conventions to use when we build our applications? Angular has many different types of components such as filters, directives, services, and so on. Wouldn't you agr...

How to pass macro definition from "make" command line arguments (-D) to C source code?

I usually pass macro definitions from "make command line" to a "makefile" using the option : -Dname=value. The definition is accessible inside the makefile. I also pass macro definitions from the "makefile" to the "source code" using the similar com...

How to reset a select element with jQuery

I have <select id="baba"> <option>select something</option> <option value="1">something 1</option> <option value=2">something 2</option> </select> Using jQuery, what would be the easiest (less to wri...

JSON.stringify doesn't work with normal Javascript array

I must be missing something here, but the following code (Fiddle) returns an empty string: var test = new Array(); test['a'] = 'test'; test['b'] = 'test b'; var json = JSON.stringify(test); alert(json); What is the correct way of JSON'ing this arr...

Oracle's default date format is YYYY-MM-DD, WHY?

Oracle's default date format is YYYY-MM-DD. Which means if I do: select some_date from some_table ...I lose the time portion of my date. Yes, I know you can "fix" this with: alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss'; But ser...

How to convert a Scikit-learn dataset to a Pandas dataset?

How do I convert data from a Scikit-learn Bunch object to a Pandas DataFrame? from sklearn.datasets import load_iris import pandas as pd data = load_iris() print(type(data)) data1 = pd. # Is there a Pandas method to accomplish this? ...

Laravel Update Query

I am trying to update a User on the basis of the email not there id, is there a way of doing this without raw queries. Currently the error {"error":{"type":"ErrorException","message":"Creating default object from empty value","file":"C:\wa...

IOCTL Linux device driver

Can anyone explain me, What is IOCTL? What is it used for? How can I use it? Why can't I define new function that does the same work as IOCTL? ...

How to convert timestamp to datetime in MySQL?

How to convert 1300464000 to 2011-03-18 16:00:00 in MySQL?...

Unrecognized SSL message, plaintext connection? Exception

I have a java complied package to speak with the https server on net. Running the compilation gives the following exception: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? at com.sun.net.ssl.internal.ssl.InputRecord....

Foreach loop, determine which is the last iteration of the loop

I have a foreach loop and need to execute some logic when the last item is chosen from the List, e.g.: foreach (Item result in Model.Results) { //if current result is the last item in Model.Results //then do something in the code } ...

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

The problem Im facing while trying to connect to database for mysql. I have also given the database settings that i have used. Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) Fi...

MongoDB logging all queries

The question is as basic as it is simple... How do you log all queries in a "tail"able log file in mongodb? I have tried: setting the profiling level setting the slow ms parameter starting mongod with the -vv option The /var/log/mongodb/mongodb...

Center Contents of Bootstrap row container

I have the code below and I'd like to center the "well" elements of the outer "row" div. I've tried various approaches such as text-align: center (which just centers the text and not the inner DIV elements. Here is a jsfiddle. The idea is that I...

Handling multiple IDs in jQuery

Can multiple ids be handled like in the code? <script> $("#segement1, #segement2, #segement3").hide() </script> <div id="segement1"/> <div id="segement2"/> <div id="segement3"/> ...

How to get json response using system.net.webrequest in c#?

I need to get json data from an external domain. I used webrequest to get the response from a website. Here's the code: var request = WebRequest.Create(url); string text; var response = (HttpWebResponse) request.GetResponse(); using (var sr = new S...

How to change color and font on ListView

I am trying to change my font(color and size) and the back ground on my ListView. I want to change it with code lines not on xml. my list view looks like: the xml: <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://sch...

No more data to read from socket error

We are using Oracle as the database for our Web application. The application runs well most of the time, but we get this "No more data to read from socket" error. Caused by: java.sql.SQLRecoverableException: No more data to read from socket at o...

Difference between setUp() and setUpBeforeClass()

When unit testing with JUnit, there are two similar methods, setUp() and setUpBeforeClass(). What is the difference between these methods? Also, what is the difference between tearDown() and tearDownAfterClass()? Here are the signatures: @BeforeCla...

How to determine when a Git branch was created?

Is there a way to determine when a Git branch was created? I have a branch in my repo and and I don't remember creating it and thought maybe seeing the creation timestamp would jog my memory. ...

What are all the different ways to create an object in Java?

Had a conversation with a coworker the other day about this. There's the obvious using a constructor, but what are the other ways there?...

Iterate over object in Angular

I am trying to do some things in Angular 2 Alpha 28, and am having an issue with dictionaries and ngFor. I have an interface in TypeScript looking like this: interface Dictionary { [index: string]: string } In JavaScript this will translate to a...

How to echo shell commands as they are executed

In a shell script, how do I echo all shell commands called and expand any variable names? For example, given the following line: ls $DIRNAME I would like the script to run the command and display the following ls /full/path/to/some/dir The pur...

Why is Tkinter Entry's get function returning nothing?

I'm trying to use an Entry field to get manual input, and then work with that data. All sources I've found claim I should use the get() function, but I haven't found a simple working mini example yet, and I can't get it to work. I hope someone can ...

Using $state methods with $stateChangeStart toState and fromState in Angular ui-router

I'm writing a handler for $stateChangeStart: var stateChangeStartHandler = function(e, toState, toParams, fromState, fromParams) { if (toState.includes('internal') && !$cookies.MySession) { e.preventDefault(); // Some log...

How can I detect when the mouse leaves the window?

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

How can I hide a checkbox in html?

I want to hide a checkbox. But also want that, when I click on label associated with corresponding checkbox, the checkbox should get checked/unchecked. I also want that the checkbox MUST be able to be focused. I am doing the following: <div cla...

.NET obfuscation tools/strategy

My product has several components: ASP.NET, Windows Forms App and Windows Service. 95% or so of the code is written in VB.NET. For Intellectual Property reasons, I need to obfuscate the code, and until now I have been using a version of dotfuscator ...

for each loop in groovy

How to implement foreach in Groovy? I have an example of code in Java, but I don't know how to implement this code in Groovy... Java: for (Object objKey : tmpHM.keySet()) { HashMap objHM = (HashMap) list.get(objKey); } I read http://groovy.cod...

Send PHP variable to javascript function

I have a php file that generates a variable and I would like the variable to be put into a javascript function which is called by onclick on the main page. Is this possible to send from PHP to javascript? ...

How to put a new line into a wpf TextBlock control?

I'm fetching text from an XML file, and I'd like to insert some new lines that are interpreted by the textblock render as new lines. I've tried: <data>Foo bar baz \n baz bar</data> But the data is still displayed without the new line....

ORA-06550: line 1, column 7 (PL/SQL: Statement ignored) Error

I am getting following error for the stored procedure and not able to understand the issue (must be from db side) While googling, I found similar issues but couldn't get the solution. Can any one help me please find the error in PROCEDURE ?? Error :...

Python requests - print entire http request (raw)?

While using the requests module, is there any way to print the raw HTTP request? I don't want just the headers, I want the request line, headers, and content printout. Is it possible to see what ultimately is constructed from HTTP request?...

How can I make a button have a rounded border in Swift?

I'm building an app using swift in the latest version of Xcode 6, and would like to know how I can modify my button so that it can have a rounded border that I could adjust myself if needed. Once that's done, how can I change the color of the border ...

Dialogs / AlertDialogs: How to "block execution" while dialog is up (.NET-style)

Coming from the .NET-environment, I'm now looking to understand how Dialogs work in Android. In .NET, when calling MessageBox.Show(...) that creates and shows a popup dialog. In the call to Show I can specify what buttons should be available in the ...

Can I rollback a transaction I've already committed? (data loss)

I committed an incorrect UPDATE statement and have lost some data. Is it possible to rollback now, after I've already committed? Any help? ROLLBACK says NOTICE: there is no transaction in progress....

INSERT with SELECT

I have a query that inserts using a SELECT statement: INSERT INTO courses (name, location, gid) SELECT name, location, gid FROM courses WHERE cid = $cid Is it possible to only select "name, location" for the insert, and set gid to somet...

How do I get the absolute directory of a file in bash?

I have written a bash script that takes an input file as an argument and reads it. This file contains some paths (relative to its location) to additional files used. I would like the script to go to the folder containing the input file, to execute ...

Runnable with a parameter?

I have a need for a "Runnable that accepts a parameter" although I know that such runnable doesn't really exist. This may point to fundamental flaw in the design of my app and/or a mental block in my tired brain, so I am hoping to find here some adv...

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 do I force Postgres to use a particular index?

How do I force Postgres to use an index when it would otherwise insist on doing a sequential scan?...

Mock functions in Go

I'm puzzled with dependencies. I want to be able to replace some function calls with mock ones. Here's a snippet of my code: func get_page(url string) string { get_dl_slot(url) defer free_dl_slot(url) resp, err := http.Get(url) i...

How to insert 1000 rows at a time

I made Wpf appliaction. I want to test it with 1000 values in grid. I want to check that whether my grid will load 1000 data records fastly or not. So how to write one query to insert more than 1000 records in my database table. can i use for loop. ...

How do you modify the web.config appSettings at runtime?

I am confused on how to modify the web.config appSettings values at runtime. For example, I have this appSettings section: <appSettings> <add key="productspagedesc" value="TODO: Edit this default message" /> <add key="servicespage...

Highlight Anchor Links when user manually scrolls?

I apologize for the long post. I wanted to include everything that might be helpful. I have a single page website that consists of several divs stacked vertically. I'm using a floating nav bar and softscroll.js to make anchor links move to the divs ...

Wordpress - Images not showing up in the Media Library

I have a huge problem with my Wordpress. My uploaded images don't list in the Media Library. It is weird tho, it says I have 75 images, but display none. Take a look yourself. Even weirder, if I go into gallery (the images you uploaded in the pag...

No 'Access-Control-Allow-Origin' header is present on the requested resource error

I'm trying to fetch the feed of a news website. Thought I'd use google's feed API to convert the feedburner feed into json. The following url will return 10 posts from the feed, in json format. http://ajax.googleapis.com/ajax/services/feed/load?v=1.0...

How to put img inline with text

I have this code: <div class = "content-dir-item"> <p>Text input</p> <img src="./images/email.png" class = "mail" alt="img-mail" /> </div> I would put img inline with text using css. How can I do this?...

List files recursively in Linux CLI with path relative to the current directory

This is similar to this question, but I want to include the path relative to the current directory in unix. If I do the following: ls -LR | grep .txt It doesn't include the full paths. For example, I have the following directory structure: test1/...

How to commit a change with both "message" and "description" from the command line?

I'm new to both git and GitHub. I managed to set up everything locally on my Mac, so that now I can push commits to GitHub via git (on the command line, not the Mac app). When I push commits directly from the GitHub web interface (e.g. quickly fixin...

MySQL Update Column +1?

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

Check if SQL Connection is Open or Closed

How do you check if it is open or closed I was using if (SQLOperator.SQLCONNECTION.State.Equals("Open")) however, even the State is 'Open' it fails on this check....

Android: set view style programmatically

Here's XML: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" style="@style/LightStyle" android:layout_width="fill_parent" android:layout_height="55dip" android:clickable="true" android:orientatio...