text:
Q: MouseOver of FlexTable with GWT Hello everyone
I have a FlexTable that contains images (one for each cell). I wish I had an event that you move your mouse over the cell comes out a popup that should contain the title of the image.
Someone can give me a hand?
I tried to insert this code does what he must do (at least for me) but the popup remains active when I remove the mouse pointer .where I wrong?
private FlexTable createHTML(ImageResult result,int row,final int i,int currentCol) {

 immagine[i]=new Image(result.getThumbnailUrl());
 resultsTableImm.setWidget(row, currentCol, immagine[i]);
 titleImm[i]=result.getTitleNoFormatting();
 contentImm[i]=result.getContentNoFormatting();
 urlImm[i]=result.getUnescapedUrl();

 immagine[i].addMouseOverHandler(new MouseOverHandler() {

       @Override
        public void onMouseOver(MouseOverEvent event) {

            PopupPanel p = new PopupPanel(true);
            Widget source = (Widget) event.getSource();
            int x = source.getAbsoluteLeft() + 10;
            int y = source.getAbsoluteTop() + 10;
            p.add(new HTML(""+titleImm[i]+"
"+contentImm[i]));
            p.setPopupPosition(x, y);
        p.show();
        }
    });

    return resultsTableImm;
            }

Thank you and have a nice day
JD

A: FlexTable hasn't onMouseOverHandler. It only has clickHandler. So you can't attach mouse over handler to the table(cell). One way is addMouseOverHandler to the image show them in the popuplike that
Image image= new Image();
image.addMouseOverHandler(new MouseOverHandler() {

        @Override
        public void onMouseOver(MouseOverEvent event) {
            PopupPanel p = new PopupPanel(true);
            Widget source = (Widget) event.getSource();
            int x = source.getAbsoluteLeft() + 10;
            int y = source.getAbsoluteTop() + 10;

            p.add(image);
            p.setPopupPosition(x, y);
            p.show();
        }
    });

If you use gwt2.1 then I suggest you to use CellTable
Look at this example Cell Table

A: You can make custom widget with registered onmouseover handler and place it to flex table (idea is not trying to add listener for cell, but have it on widget itself which resides in cell).
Or you can try something like this:
http://www.java2s.com/Code/Java/GWT/TableMouseOverEvent.htm

A: Boiling down Xorty's example to the essentials of the present question you may adapt the following extension of FlexTable:
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.FlexTable;

public class PTable extends FlexTable {

    public static final String ROW_STYLE_NAME  = "pm-PTable-row";

    PTable() {
        setStyleName("pm-PTable");
        sinkEvents(Event.ONMOUSEOVER |Event.ONMOUSEOUT);
    }

    @Override
    public void onBrowserEvent(Event event) {
        super.onBrowserEvent(event);
        Element td = getEventTargetCell(event);
        if (td == null) return;
        Element tr = DOM.getParent(td);
        switch (DOM.eventGetType(event)) {
            case Event.ONMOUSEOVER: {
                tr.addClassName(ROW_STYLE_NAME + "-mouseover");
                break;
            }
            case Event.ONMOUSEOUT: {
                tr.removeClassName(ROW_STYLE_NAME + "-mouseover");
                break;
            }
        }
    }
}


text:
Q: How do I fix ReplicaSetNoPrimary MongooseServerSelectionError when connecting to a local Mongo ReplicaSet from inside a Docker container? I am developing a Node.js app that I want to connect to a Mongo Replica Set and I run the MongoDB replica set locally using the run-rs npm module by executing run-rs --dbpath ./data --keep. When I run my application as a Node application, I successfully connect to the replica set with the following code
const db = mongoose.connect(config.db.url, config.db.options)
    .catch((error) => {
      logger.error('Error connecting to the database', error);
    });

Where the url and options are
debug: Mongoose connecting to mongodb://localhost:27017,localhost:27018,localhost:27019/my-app-dev?replicaSet=rs with options  {"service":"my-app","useNewUrlParser":true,"useUnifiedTopology":true,"useFindAndModify":false}
info: Mongoose successfully connected to mongodb://localhost:27017,localhost:27018,localhost:27019/my-app-dev?replicaSet=rs

When I run the application inside of my Docker container, I get the following
info: Mongoose disconnected from mongodb://host.docker.internal:27017,host.docker.internal:27018,host.docker.internal:27019/my-app-dev?replicaSet=rs {"service":"my-app"}
error: Error connecting to the database connect ECONNREFUSED 127.0.0.1:27017 {"service":"my-app","reason":{"type":"ReplicaSetNoPrimary","setName":"rs","maxSetVersion":1,"maxElectionId":"7fffffff0000000000000079","servers":{},"stale":false,"compatible":true,"compatibilityError":null,"logicalSessionTimeoutMinutes":null,"heartbeatFrequencyMS":10000,"localThresholdMS":15,"commonWireVersion":7},"stack":"MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017\n at NativeConnection.Connection.openUri (/src/node_modules/mongoose/lib/connection.js:800:32)\n at /src/node_modules/mongoose/lib/index.js:341:10\n at /src/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:5\n at new Promise ()\n at promiseOrCallback (/src/node_modules/mongoose/lib/helpers/promiseOrCallback.js:30:10)\n at Mongoose.connect (/src/node_modules/mongoose/lib/index.js:340:10)\n at Object. (/src/index.js:46:21)\n at Module._compile (internal/modules/cjs/loader.js:1138:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)\n at Module.load (internal/modules/cjs/loader.js:986:32)\n at Function.Module._load (internal/modules/cjs/loader.js:879:14)\n at Module.require (internal/modules/cjs/loader.js:1026:19)\n at require (internal/modules/cjs/helpers.js:72:18)\n at Object. (/src/server.js:3:13)\n at Module._compile (internal/modules/cjs/loader.js:1138:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)"}

To connect to the replicaset from inside the container, I am using the following URI
mongodb://host.docker.internal:27017,host.docker.internal:27018,host.docker.internal:27019/my-app-dev?replicaSet=rs

redpajama_set_name: RedPajamaStackExchange


text:
Q: S.O.L.I.D. principles I have a small question. Which approach is correct in the context of SOLID principles? 1 or 2 ?
In the first case, the "CreateTask" method does not return the Task object, but places it on the list that it accepts as the method argument.
In the second case, the "CreateTask" method does not accept arguments, but returns a task object that must be placed in the Tasks list
1.
var tasks = new List<Task>();
CreateTask1(tasks);
CreateTask2(tasks);
CreateTask3(tasks);

private void CreateTask1(List<Task> tasks)
{
   // some other logic about new task object
   tasks.Add(new Task());
}

private void CreateTask2(List<Task> tasks)
{
   // some other logic about new task object
   tasks.Add(new Task());
}

private void CreateTask3(List<Task> tasks)
{
   // some other logic about new task object
   tasks.Add(new Task());
}

2.
var tasks = new List<Task>();
tasks.Add(CreateTask1());
tasks.Add(CreateTask2());
tasks.Add(CreateTask3());

private Task CreateTask1()
{
   // some other logic about new task object
   return new Task();
}

private Task CreateTask2()
{
   // some other logic about new task object
   return new Task();
}

private Task CreateTask3()
{
   // some other logic about new task object
   return new Task();
}

A: I'd go for option 3:
var tasks = new List<Task>
{
    CreateTask1(),
    CreateTask2(),
    CreateTask3()
};

However, I'm unclear how the question relates to SOLID principles
Update
With regards to the single responsibility principle, option 1 is "is responsible for creating the object and inserting it into the list". Does this mean it breaks the principle? No. It no more breaks it than option two with its "responsible for creating the object and returning it back". Rephrase these as "insert a created object in the list" or "return a created object" and the "and" goes away. The presence of "and" in a description of a method's functionality is an unreliable way of assessing whether it has one responsibility.
Option 1 is ugly as it involves mutating a parameter. Option 2 is better, but doesn't make proper use of language features. So go with option 3.

A: Though SOLID argues for #2, you should also do some thinking on your own about possible future changes.
What if you don't want to use a List?  Say, you want to use a SuperSpecialList or a Map?
What if you need to add it to two lists?
What if that List is a Queue with a maximum length and it is full?
All of these also argue for design #2.

A: The SOLID principles are principles for designing object-oriented software. Your code example is not object oriented - it consists of stand-alone functions and some top-level code which is not even in a function. To interpret the code according to SOLID we need to know which class performs these operations for what purpose, and what the underlying responsibilities are. Depending on these factors, either example could be best.
Note specifically that the Single Responsibility Principle is not concerned about the responsibilities of individual methods, but apply on the class or module level. So it is not applicable on these code examples.


text:
Q: How do I merge 2 Content-Security-Policy headers? I have an existing Content-Security-Policy header in my web.config file:
<add name="Content-Security-Policy" value="default-src https: data: 'unsafe-inline' 'unsafe-eval'" />
I want to add an additional rule:
<add name="Content-Security-Policy" value="frame-ancestors 'self' https://*.example.com" />
How do I add this second header line, so that both these rules can exist and not override each other?

A: I solved it. This is the merged line:
<add name="Content-Security-Policy" value="default-src https: data: 'unsafe-inline' 'unsafe-eval'; frame-ancestors 'self' https://*.example.com" />


text:
Q: Error on bundle install I am trying to run my Ruby application.
I am running the bundle install command, however get the error-
An error occurred while installing libv8 (3.1.16.14.3), and Bundler cannot continue.
Make sure that 'gem install libv8 -v '3.1.16.14.3' succeeds before bundling.

So then I tried-
gem install --version '=3.16.14.3' libv8

and get the error-
Error installing libv8:
ERROR: Failed to build gem native extension.

This is required to run the application however I am not sure how to resolve this?

A: RUBYOPT=-rrubygems gem install libv8 -v '3.16.14.3'


text:
Q: How to clean database after scenario in Python behave I'm pretty new to the world of python/behave and API testing, and I'm trying to clean the database after 1 scenario is run by calling the tag @clean_database.
Can you please assist?
I guess that I will need a database_context.py in my context_steps folder but I'm not sure how to do the connection to the database...

A: Seems like you have 2 questions here:

(1) How do I connect to the database?

This question doesn't involve behave, so you should ask this question elsewhere--perhaps on the MySQL-Python thread if you're using MySQL (which you haven't specified) or on the Python thread.

(2) How do I use behave to call specific tags?

For the latter, check out the documentation for running tagged tests and see how to run behave from your Python program.


text:
Q: UserManager's AutoSaveChanges in .NET Core 2.1 I would like to disable automatic SaveChanges method calls of UserManager. I've found that it is possible to do it by setting AutoSaveChanges property of UserStore. But what is the best practice for such things in .NET Core 2.1? Is it possible to do in Startup.cs by configuring IdentityBuilder?

A: You need to create a class that inherits form Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore<IdentityUser> and set AutoSaveChanges to false in the constructor and then register this class to IServiceCollection before AddEntityFrameworkStores.
public class CustomUserStore : UserStore<IdentityUser>
{
    public CustomUserStore(ApplicationDbContext context)
        : base(context)
    {
        AutoSaveChanges = false;
    }
}

Startup.cs
public void ConfigureServices(IServiceCollection services)
{
    services.AddScoped<IUserStore<IdentityUser>, CustomUserStore>();

    services.AddDbContext<ApplicationDbContext>(options =>
        options.UseSqlServer(
            Configuration.GetConnectionString("DefaultConnection")));

    services.AddDefaultIdentity<IdentityUser>()
        .AddDefaultUI(UIFramework.Bootstrap4)
        .AddEntityFrameworkStores<ApplicationDbContext>();
}


text:
Q: Python GIL - Inherent File I/O Protection? Tomorrow I need to write a threaded program that reads all lines from some a src file, does some network bound I/O process, and then writes the output to a dest file. My worry is that two (or more) threads might try to write to disk at the same time and, therefore, I will have jumbled/corrupted data.
Is this something I even need to worry about? I've never multithreaded anything in my life before. Will global interpreter lock (GIL) effectively protect me in this scenario? (The reason I'm doing this is because a single threaded implementation of this will take 30 days).
Many thanks

A: Does your program really need to do the I/O multithreaded? If you are reading / writing to a single file, I would do that part of the program single threaded - it will be faster and you are avoiding locking problems all around. Not to mention the fact that disc i/o is so slow that parallen processes will not really help you.
I see two possible scenarios for you:
1. Single file: Do the i/o in one thread, start N processes to do the heavy computations.
2. N files: Start one thread which manages a queue, which then starts N processes to do the work.
See https://docs.python.org/2/library/multiprocessing.html for "pool" which might be really helpful in your case.
As a word of advice: multithreading is damned hard. Many things can and will go wrong in different ways when you switch from single-threading to multi-threading. So start off with a simple single threaded model and build your way up and ensure that each step still does the correct thing.


text:
Q: Microsoft dynamics CRM 2013 missing New, Delete, Copy a Link, Run Report tool bar I recently restored my production database to my test area, but when users login they are unable to see the tabs shown in the screen shot below. I am able to view them on the server but on any other machine i am also unable to view. I have full rights in the organisation.
Missing tab in ms dynamics crm 2013
This is what i can view on the server
Contains the tabs in the server
Also noted is i can not open an email or case by clicking on the title, i have done my research online but i have not seen anything of this sort.

A: To resolve this issue, delete the Microsoft Internet Explorer cache. To do this, follow these steps:

*

*Exit the Microsoft CRM Web client and the Microsoft Dynamics CRM
client for Outlook.

*Start Microsoft Internet Explorer.

*Click Tools, and then click Internet Options.

*Click Delete Cookies, and then click OK.

*Click Delete Files, and then click OK.


text:
Q: Animate ship with Controls iOS Don't know if I'm over-thinking this or not.. but I'm trying to be able to adjust the sprites showing when my character is moving in different directions.
For example, if the players finger is above the character I want it to go to the 'moveUp' frame. If the players' finger is below the character I want to go to the 'moveDown' frame, otherwise stay at the 'normalState' frame.
Can someone show me an example of this? Or direct me to a good general tutorial about implementing Sprite sheets/Sprites in this sort of way.
I have gone through and used sprite sheets in demo projects but am looking to release this and want to approach it the proper and most successful way.
Thanks!!

A: I assume you have already made your sprite sheet and/or packed it (I like TexturePacker). The code would be something like:
...init...
    //Place all sprite frames from sprite sheet into cache
    [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"spriteSheet.png"];

    CCSpriteBatchNode *gameBatchNode = [CCSpriteBatchNode batchNodeWithFile:@"spriteSheet.png"];
    CCSprite *player = [CCSprite spriteWithSpriteFrameName:@"moveUp"];

    [gameBatchNode addChild: player];
....

- (void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *aTouch = [touches anyObject];

    CGPoint touchPosition = [player.parent convertTouchToNodeSpace:aTouch];
    CGPoint touchPositionRelativeToPlayer = ccpSub(touchPosition, player.position);

    if(touchPositionRelativeToPlayer.y > 0)
        [player setDisplayFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"moveUp"]];
    else
        [player setDisplayFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"moveDown"]];
}

If you want other directions (W, E, NW, etc..) I would suggest you convert the touchPositionRelativeToPlayer to an angle using atan2 and determine the frame from that.


text:
Q: Show Library view inside SPFx web part Anyone knows of a way to show a filtered list of files in a SPO library with the 3 dots to get the version history and the other commands that exist in SharePoint itself?
Is there an option to do an iframe with calculated SharePoint URL?
Any PNP sample I missed?

A: You could get file version history this way:
    let web = new Web(this.context.pageContext.web.absoluteUrl);
    web.lists.getByTitle("lib").items.getById(3).versions.get().then(r => {

          console.log(r)
        });

But it seems that it could not combine with filter.
Iframe Dialog components:
https://www.npmjs.com/package/react-iframe
https://pnp.github.io/sp-dev-fx-controls-react/controls/IFrameDialog/


text:
Q: Fixing broken CSV with Windows line endings I have a CSV that looks like this:
25/04/2017,23:35:59,unknown,+123456789,Photo Message
25/04/2017,23:36:09,unknown,+123456789,Сириус конторка
25/04/2017,23:36:15,unknown,+123456789,Главный из офис
26/04/2017,08:15:55,unknown,+123456789,Напишіть будь ласка номер Житло-Капітал, за яким повідомляють:
- суму коштів до повернення/доплати
- комісію за управління інвестиційними коштами
26/04/2017,08:17:44,unknown,+123456789,374-03-08
26/04/2017,08:29:24,unknown,+123456789,Для тех, кто не был на собрании. Вчера мы:

1. Собрали контакты (фио + № квартиры + телефон) тех жильцов, которые пресутствовали на собрании.
2. Подписали заявление по счётчикам тепла.
3. Подписали заявление "щодо недоліків".
4. Коллективное обращение по договорах коммуналки.
5. Инициативная группа рассказала про текущий ход переговоров с жеком по поводу договоров.

Что дальше:
1. Ждём результатов переговоров инициативной группы с жеком. Она должна состояться сегодня.
2. Когда будут готовы согласованные с жеком договора, они будут выложены здесь и на форумах, чтобы каждый мог себе их распечатать, и сравнить с тем, что жек даст на подпись при подписании акта.
2. Кто не подписал заявления/обращения, сможет это сделать до четверга. Где их можно будет подписать - позже узнаем.
26/04/2017,08:29:53,unknown,+123456789,Колективне звернення по договорах комуналки.pdf
26/04/2017,08:29:54,unknown,+123456789,Лист щодо недоліків Забудовнику та Управителю.pdf
26/04/2017,08:29:54,unknown,+123456789,Лічильники тепла - Акцепт.pdf

It has several problems:

*

*line endings are ^M character (see "What does ^M character mean in Vim?"),

*final 5th column contains multiline lines,

*final 5th column is not properly escaped, e.g. and it's the one that has bare comas sitting around.

What I know for sure that:

*

*the CSV has 5 columns,

*line ending is always ^M (e.g. it's Windows-encoded line-ending).

How can I make a proper CSV out of this one?

A: I think I overreacted about the complexity of this. The following code in Elixir splits the CSV file into correct list of lists:
File.read!("sample.csv")
|> String.split("\r\n")
|> Enum.map(&String.split(&1, ",", parts: 5))

Result:
[
  ["25/04/2017", "23:36:09", "unknown", "+123456789",
   "Сириус конторка"],
  ["25/04/2017", "23:36:15", "unknown", "+123456789",
   "Главный из офис"],
  ["26/04/2017", "08:15:55", "unknown", "+123456789",
   "Напишіть будь ласка номер Житло-Капітал, за яким повідомляють:\n- суму коштів до повернення/доплати\n- комісію за управління інвестиційними коштами"],
  ["26/04/2017", "08:17:44", "unknown", "+123456789", "374-03-08"],
  ["26/04/2017", "08:29:24", "unknown", "+123456789",
   "Для тех, кто не был на собрании. Вчера мы:\n\n1. Собрали контакты (фио + № квартиры + телефон) тех жильцов, которые пресутствовали на собрании.\n2. Подписали заявление по счётчикам тепла.\n3. Подписали заявление \"щодо недоліків\".\n4. Коллективное обращение по договорах коммуналки.\n5. Инициативная группа рассказала про текущий ход переговоров с жеком по поводу договоров.\n\nЧто дальше: \n1. Ждём результатов переговоров инициативной группы с жеком. Она должна состояться сегодня.\n2. Когда будут готовы согласованные с жеком договора, они будут выложены здесь и на форумах, чтобы каждый мог себе их распечатать, и сравнить с тем, что жек даст на подпись при подписании акта.\n2. Кто не подписал заявления/обращения, сможет это сделать до четверга. Где их можно будет подписать - позже узнаем."],
  ["26/04/2017", "08:29:53", "unknown", "+123456789",
   "Колективне звернення по договорах комуналки.pdf"],
  ["26/04/2017", "08:29:54", "unknown", "+123456789",
   "Лист щодо недоліків Забудовнику та Управителю.pdf"],
  ["26/04/2017", "08:29:54", "unknown", "+123456789",
   "Лічильники тепла - Акцепт.pdf"],
  [""]
]

A: Just in case you want a function that can remove Windows end of line:
" dos2unix ^M
if !exists('*Dos2unixFunction')
    fun! Dos2unixFunction() abort
        "call Preserve('%s/ $//ge')
        call Preserve(":%s/\x0D$//e")
        set ff=unix
        set bomb
        set encoding=utf-8
        set fileencoding=utf-8
    endfun
endif
com! Dos2Unix :call Dos2unixFunction()
cnoreabbrev dos2unix Dos2unix
cnoreabbrev d2u Dos2Unix

" This function can be called to save your cursor position
if !exists('*Preserve')
    function! Preserve(command)
        try
            let l:win_view = winsaveview()
             "silent! keepjumps keeppatterns execute a:command
            silent! execute 'keeppatterns keepjumps ' . a:command
        finally
            call winrestview(l:win_view)
        endtry
    endfunction
endif


text:
Q: android version or pixels problem in flutter? I am a beginner in flutter app development(~1 month). I am getting an error in the code in which the same code runs fine in pixel 2XL (size:- 5.99, API -: 29), but when I run the same code in galaxy Nexus(size-: 4.65, API-: 23) it doesn't run the same. This is a simple page in pixel 2XL

this is the same page in the galaxy nexus
import 'package:flutter/material.dart';

class page1 extends StatefulWidget {
  @override
  _page1State createState() => _page1State();
}

class _page1State extends State<page1> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Colors.blue,
        body: Container(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisSize: MainAxisSize.max,
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: <Widget>[
                Container(
                  height: 300,
                  width: 200,
                  child: Image.asset(
                    'assets/oreo.png',
                    fit: BoxFit.fitHeight,
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.only(left: 15),
                  child: Row(
                    children: <Widget>[
                      Column(
                        children: <Widget>[
                          Text(
                            "mytime is an initiative",
                            style: TextStyle(
                              fontSize: 20,
                              fontWeight: FontWeight.w300,
                              letterSpacing: 2.5,
                              color: Colors.white,
                            ),
                          ),
                          Text(
                            "by XYZ Texhnologies",
                            style: TextStyle(
                              fontSize: 20,
                              fontWeight: FontWeight.w300,
                              letterSpacing: 2.5,
                              color: Colors.white,
                            ),
                          ),
                          Text(
                            "to provide quality",
                            style: TextStyle(
                              fontSize: 20,
                              fontWeight: FontWeight.w300,
                              letterSpacing: 2.5,
                              color: Colors.white,
                            ),
                          ),
                          Text(
                            "programming education to people",
                            style: TextStyle(
                              fontSize: 20,
                              fontWeight: FontWeight.w300,
                              letterSpacing: 2.5,
                              color: Colors.white,
                            ),
                          ),

                          SizedBox(height: 20,),
                        ],
                      ),
                    ],
                  ),
                ),
              ],
            ),
        ),
    );
  }
}

this is the code for the page.
I have no idea why this is happening. can anyone help me with this?
thank you in advance.

A: The yellow, black strip means that you are "overflowing".
Overflowing means that the element is to big for it's container.
In your particular case the text font and spacing is too big and when changing phone since you didn't set it dynamically to adapt to different screen sizes it goes beyond the borders.
You can either reduce the font size or set it dynamically.
If you are new to Flutter i recommend this course to get such basics.
--> https://www.udemy.com/course/learn-flutter-dart-to-build-ios-android-apps/
I took it myself and it's very well explained and goes from basics topics like this one to difficult ones.
Hope this will help you more then just answering the question.


text:
Q: Handle inaccurracy of float I have a string
strValue = "11.900000"

I want to parse it to a float value. So I tried:
float fValue = -1;
sscanf_s(strValue.c_str(), "%f", &fValue);

try
{
    double test = std::stod(strValue, &sz);
    fValue = (float) std::stod(strValue, &sz);
}
catch (...)
{
    fValue = -1;
}

For double it is accurate:
test = 11.900000000000000

For float it is inaccurate:
fValue = 11.8999996

Is there a possibility to do this accurately? (I know there is a inaccuracy while working with floats, but is there a better way to do it?)

A: The value 11.8999996 is the most precise approximation of 11.9 that can be represented by the float type.

A: It's not correct for double or any other binary floating-point types. Just print more digits after the radix point and you'll begin to see "garbage" digits soon
The only way for you is to use a decimal floating-point type. If your platform has FLT_RADIX == 10 then you can directly use the built-in float, but obviously it's not your case, and I don't know any current system that uses decimal float except IBM z-series.
So you need a custom type for that. You can use some IEEE-754 decimal32 libraries like Intel® Decimal Floating-Point Math Library or libdfp. Or if you use gcc then it already has support for decimal float via the _Decimal32 type
You can find more information in this question How do I use decimal (float) in C++?


text:
Q: Spring MVC project missing images & styles when deploying in Eclipse to Tomcat I have a Spring MVC project in Eclipse. Maven packages it as a WAR and then I have it deployed to Tomcat through Eclipse. The issue I am running into is that the /images, /styles and the /js folders in the /webapp folder are not coming through. The page will generate and the Spring MVC functionality works (calls the Controller, etc). However, none of the styling will appear. I would greatly appreciate any help getting this to work.
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
    <display-name>Some Project</display-name>
    <context-param>
        <param-name>webAppRootKey</param-name>
        <param-value>some-project.root</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>some-project</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>some-project</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <session-config>
        <session-timeout>60</session-timeout>
    </session-config>
</web-app>

some-project-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
                           http://www.springframework.org/schema/context
                           http://www.springframework.org/schema/context/spring-context-4.0.xsd">

    <context:component-scan base-package="my.com.project.controllers" />

    <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
        <property name="basename" value="classpath:messages" />
        <property name="cacheSeconds" value="60" />
    </bean>

   <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/WEB-INF/views/" />
        <property name="suffix" value=".jsp" />
    </bean>

    <!-- Need this to handle multipart files -->
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />

    <bean class="my.com.project.validators.SomeValidator" />
    <bean class="my.com.project.validators.OtherValidator" />
</beans>

pom.xml (parts of it
...
<packaging>war</packaging>
...
<!-- The Build -->
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <warName>some-project</warName>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>
...
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>4.2.5.RELEASE</version>
</dependency>
<!-- using Hibernate 4.3.11.Final -->

JSP
<link rel="stylesheet" type="text/css" media="all" href="/styles/screen.css" />
<link rel="stylesheet" type="text/css" media="print" href="/styles/print.css" />
<link rel="stylesheet" type="text/css" href="/styles/jquery/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="/styles/roper-center.css">
<link rel="stylesheet" type="text/css" href="/styles/font-awesome-4.5.0/css/font-awesome.css">

<script src="js/modernizr.js"></script>
<script src="js/framework/iws.js"></script>
<script src="js/sorttable.js"></script>
<script src="js/jquery/jquery-1.12.2.min.js"></script>
<script src="js/jquery/external/jquery/jquery.js"></script>
<script src="js/jquery/jquery-ui.js"></script>
<script src="js/jquery/jquery.autotab.js"></script>

As you can see above, I tried putting a / before the styles and did not put them in the "js" part. I viewed the page source of the page and clicked on the link for both and Tomcat comes back saying it can't find either.
If I look into the deployment folder (/opt/apache-tomcat-8.0.32/webapps/some-project), I see the following folders:

META-INF
  WEB-INF
  images
  js
  styles

And here is my webapp folder in Eclipse:

And in case, here is my Deployment Assembly

A: I don't have much experience when it comes to xml spring configurations. But when I look at one project I have I find the following configurations for my resources. Note my file structure is like yours as well.
<mvc:resources mapping="/css/**" location="/css/" />
<mvc:resources mapping="/images/**" location="/images/" />
<mvc:resources location="/js/" mapping="/js/**" />
<mvc:annotation-driven />

I have that in the same file where I declare my InternalResourceViewResolver. Hope it helps.

The complete file:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd">

    <context:component-scan base-package="my.app.package" />

    <!-- Internal (final) resolver -->
    <bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix">
            <value>/WEB-INF/jsp/</value>
        </property>
        <property name="suffix">
            <value>.jsp</value>
        </property>
        <property name="order">
            <value>4</value>
        </property>
    </bean>

    <mvc:resources mapping="/css/**" location="/css/" />
    <mvc:resources mapping="/images/**" location="/images/" />
    <mvc:resources location="/js/" mapping="/js/**" />
    <mvc:annotation-driven />

</beans>

A: I think your web.xml configuration has problems.
<servlet-mapping>
   <servlet-name>some-project</servlet-name>
   <url-pattern>/</url-pattern>
</servlet-mapping>

that means you can not visit the static resources.
two solutions:

*

*<url-pattern>/*</url-pattern>

*<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.css</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.gif</url-pattern>

</servlet-mapping>

<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.jpg</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.js</url-pattern>
</servlet-mapping>

A: Have a folder called resources under WebContent and inside that have different folders as script (for js files), images, and css.
Add the following in your some-project-servlet.xml for spring to identify your resources.
<mvc:resources location="/resources/" mapping="/resources/**" />

Also don't forget to get the mvc namespace if you already don't have it.
Then include the resources in jsp as below.
<link href="${pageContext.request.contextPath}/resources/css/screen.css" rel="stylesheet" type="text/css" />

<link href="${pageContext.request.contextPath}/resources/script/jquery.js" rel="script" type="text/javascript" />


text:
Q: UNIX - why doesn't $# include the command (thus always being >= 1)? It's kind of hard to search for an answer on this since $# doesn't seem to go through properly on search engines. I was curious as to why argv typically includes the command name itself, while $# doesn't.
To make it clearer, if I have a script called testing.sh
#!/bin/bash
echo $#

./testing.sh returns 0 and not 1. Why?

A: bash is following the POSIX specification for $#:

Expands to the decimal number of positional parameters. The command name (parameter 0) shall not be counted in the number given by '#' because it is a special parameter, not a positional parameter.

The shell's interface to the arguments is simply different from C's. In bash terms, you might define
argv=( "$0" "$@")
argc=${#argv[@]}

since the shell (sensibly) separates the command name from the command's arguments.


text:
Q: Laravel 9 microservices I am new to microservices and have already read many articles but I did not find any practically helpful tutorial.
So I will be building microservices in Laravel 9 with passport on docker and it will be using database per service and API gateway. All the request will flow through API gateway where it will be authenticated and than it will be forwarded it to the specific microservice.
Please note that only my API gateway will be publicly accessible and other microservices will be not be exposed publicly, they will be used internally.
Also this will be hosted on AWS and will be using serverless architecture maybe Lambda with Api Gateway or Fargate not really decided yet.
I have following questions:

*

*What grant type is suitable in API gateway architecture ?

*Do I need to write all routes from all microservices in API gateway ? if yes than means that routes will be written twice i.e. in API gateway and individual microservice as well, so how to write the API gateway exactly ?

*If I want to combine data from different mciroservices into one than should I do that in api gateway ?

*How to authenticate request between microservices as I want it to be secure internally too, should I use the public and private key feature that is provided in passport ? if yes how to verify the keys when request arrives in each microservice ?
Thanks in advance

A: I suppose your System will look something like this:
System Architecture
@1 Grant Type
The grant type is not so much dependent on your API gateway architecture, but more dependent on the types of clients that will use the API. Can you elaborate on that a little more?
@2 Routing in the API Gateway
As you said correctly, the API Gateway will be responsible for authentication and routing. One of the main reasons one will choose to implement a microservices architecture, is to decompose a system into smaller, independent services. There is a dependency between the API Gateway and the services, but you can keep this dependency at a manageable level by using wildcards. Eg. all requests that match /pets/* go to the "Pets" service.
@3 Combining Data from multiple services
The aggregation of data from multiple microservices to assemble a single response should not be done in the API Gateway because this usually is an implementation of some kind of business logic. The API Gateway should not implement business logic, it should authenticate and route requests.
The proper way to implement something like this is a BFF (Backend for frontend) which basically is an additional microservice that implements the desired behavior.
It would look something like this: System with BFF
@4 Internal authentication
This is also hard to generalize. But you can use the users' authorization token if you like. A way to verify this token is to only check if the token hasn't expired yet in the microservices. This works if the API Gateway takes care that the token is valid in general.
If you need to communicate between your microservices without a user context, then you need to find an alternative approach.


text:
Q: How to get my jquery banner to be random on page refresh, Has timer on it How to get my jquery banner to be random on page refresh, it has a timer on it so the banner changes every 23 seconds or so without reloading the page.
However the same banner shows up at the start, so i figure it could be fixed with a random page reload jquery.
Here is the code it works fine just need the banners to also refresh when page gets reloaded.
I have tried many options and cant find a solution.
Thanks.

You can view the code in action on the homepage of the site. it works fine just need it reload different banner on page reload https://paidtoclick.ca
Really thanks in advance.
Second banner code...

HERE IS THE ENTIRE CODE ON SITE.

A: You should generate a random value for currentAd1 on the server, or change the js to this:
var imgCt1 = 14;
var currentAd1 = Math.floor(Math.random() * imgCt1);
console.log(currentAd1);
function cycle1() {
    currentAd1 = (currentAd1 + 1) % imgCt1;
    console.log(currentAd1);
    var banner1 = document.getElementById('adBanner1');
    var link1 = document.getElementById('adLink1');
    banner1.src=imgs1[currentAd1]
    banner1.alt=alt1[currentAd1]
    document.getElementById('adLink1').href=lnks1[currentAd1]
}
cycle1();  //you need to execute this once when page loads to change the banner randomly
window.setInterval(cycle1,23000); // no need for 'cycle1()', can just be cycle1

Fiddle: http://jsfiddle.net/ggQB6/6/
The best way to do this though is to generate a random currentAd1 on the server and get rid of the first cycle1() call.


text:
Q: How do I align links to left and right in a Bootstrap 3 navigation in MVC 5 I'm trying to get my Navigation Bar to look like this. However the text won't align to the right side of the screen seemingly no matter what changes I make to the base layout code.
My  html code is as follows:

        @if (Session["Logged_In"] == null)
        {

@Html.ActionLink("Home", "Index", "OUsers")

@Html.ActionLink("Create", "Create", "OUsers")

@Html.ActionLink("Login", "Login", "OUsers")

        }
        @if (Session["Logged_In"] != null)
        {

@Html.ActionLink("Home", "LoggedIndex", "OUsers")

@Html.ActionLink("Delete Account", "DeleteProfile", "OUsers")

@Html.ActionLink("Edit Profile", "EditProfile", "OUsers")

@Html.ActionLink("Sign Out", "SignOut", "OUsers")

        }

This isn't the full Layout code granted however it's what I've actually edited and seems relevant to text alignment. Also my "navbar-right" class consists of only float: right; and text-align: right;
The strange thing is that when I inspect the Login and Create actionlinks on the website the "navbar-right" class is applied yet there is no alignment changed. It may be worth noting I tried putting the css class within the actionlink parameters and nothing changed and I also attmepted a new division with navbar right but that seemed to align Login under the Home actionlink which was also bizarre to me.

A: It seems you are using Bootstrap 3. Then this will work

Link

Link

Link

Link

Link

Link

A: The navbar-nav class have float:left property with it which align all the nav to left side
try to override


text:
Q: Just publish modified controllers, models and some parts of a ASP.NET MVC project If I change my views (.cshtml) or styles (.css) or scripts (.js) in my MVC projects then I can publish it easily by right click on it and select Publish FILE_NAME

If I changed some controllers files or BLL classes or infrastructure classes,

*

*Which files should be published? which DLLs?

*Of course added references must be published but what are another?

*Should I publish all the DLL files in the bin folder or just some?

*Is there an easy way to VS detect modified files and publish theme by a command or...?

Edit1
I use FTP method to direct publish and upload our site to the server.
My Publish Preview Step Snapshot:

*

*What is the name of DLL files that contains the compiled information of controllers, BLL classes and...?

A: I just published the MVC5Bootstrap-3-1-1-Less.dll and it worked!
So if we uploaded a website and then want only publish the new modified controllers or classes of the MVC web application (here: MVC5) to the server, we should upload the following files:

*

*MVC5Bootstrap-3-1-1-Less.dll after build

*Added references to the bin folder after build

Here is a image of how publish DLLs of bin folder from Visual Studio:

A: The publish wizard on the project (right click on project > Publish...) should automatically determine which files have changed and need to be updated, and show you what files will be updated.

After clicking Start Preview:


text:
Q: Auto grab ID function? Alright so I have two tables that I am working with.
The first is set up something like these tables
Destination

IDDestination    Name        IDCity  IDState
1              Scottsdale     3        4
2                Miami        5        7

and
Destinations_Citites

IDDestinationCity    IDDestination    IDCity
1                      1               3
2                      2               5

Now with my plugin I have an add a new destination button which adds a new destination with its Name, IDCity and IDState filled out by the user and the IDDestination is automatically generated.
So what I want to figure out how to do is to grab that automatically generated IDDestination # and enter it into the Destinations_Cities table with out having the user do anything else.
Basically how can I insert the automatically generated IDDEstination that was just created and throw it into my other table without the user having to add it themselves.
Here is the code I am using to Insert and Update for my add destinations button
if(isset($_POST['Add_Destination'])) {
    $idstate = $_POST['idstate1'];
    $idcity = $_POST['idcity'];
    $name = $_POST['addname'];
    $SQL="INSERT INTO destination (name, IDCity, IDState) VALUES ('". $name ."','". $idcity ."','". $idstate ."')";
    $SQL1="UPDATE city SET is_active='1' WHERE IDCity='$idcity'";
    $result=mysql_query($SQL) or die (mysql_error());
    $result1=mysql_query($SQL1) or die (mysql_error());
    print $SQL;
    print $SQL1;
}

A: You can get the most recent auto-increment id generated during your session:
$dest_id = mysql_insert_id();

Refer to the documentation: http://php.net/manual/en/function.mysql-insert-id.php

Not exactly about your question, but I echo the comment above that you should protect your queries from SQL injection vulnerabilities. Don't copy PHP variables into SQL strings unless you have made sure the variables are made safe.

*

*If a variable is supposed to be an integer, use (int) to cast it to an integer as you read it.

*For string values, use escaping provided by the MySQL API.

Also, there's no need to do all the . concatenation if you're just putting simple variables inside PHP strings. There's no need in SQL to put quotes around integer literals.
Here's an example:
if(isset($_POST['Add_Destination'])) {
    $idstate = (int) $_POST['idstate1'];
    $idcity = (int) $_POST['idcity'];
    $name = mysql_real_escape_string($_POST['addname']);
    $SQL="INSERT INTO destination (name, IDCity, IDState)
        VALUES ('$name', $idcity, $idstate)";
    $dest_id = mysql_insert_id();
    $SQL1="UPDATE city SET is_active='1' WHERE IDCity='$idcity'";
    . . .

If you convert your code to use PDO, you can use SQL query parameters, in which case you wouldn't need to worry about escaping and such.


text:
Q: Find the sum of quadratic residues modulo $101$ Given that $2$ is a primitive root (mod $101$), find the remainder when the sum of all the quadratic residues (mod $101$) is divided by $101$. A quadratic residue $r$ is a residue (mod $101$) such that there exists some $x$ such that $x^2\equiv r \;(\bmod 101)$.
I know there's a formula for this, but I don't know how to prove it. $p*(p-1)/4,$ I think. Also, I'm pretty sure the answer to this question is $0$ but when I submitted $0$, it was wrong.

A: I'm pretty sure it's $0$ too.
One way to see this:  given $2$ is a primitive root,
the quadratic residues (besides $0$) are $2^2, 2^4, 2^6, \dots$, and $2^{100}$,
so their sum is $2^2+2^4+2^6+\cdots+2^{100}=\dfrac{2^{102}-2^2}{2^2-1}=\dfrac23(2^{101}-2),$
which is a multiple of $101$ by Fermat's little theorem.
Another way to see this:  since $101\equiv1\pmod4,$ $-1$ is a quadratic residue mod $101$,
so for every quadratic residue in the sum,
its additive inverse $\bmod 101$ is also a quadratic residue in the sum,
so the sum is $0$.


text:
Q: Determine visible sections of a UITableView when sections have no rows I am attempting to determine which sections are currently visible in my UITableView. However, sometimes my sections do not have rows and only display their section header. Is there a way to determine, maybe by using the section headers, which sections in my UITableView is currently being displayed? Asking for -(NSArray *)indexPathsForVisibleRows does not work to determine the section, because there are no actual rows that are visible, just the section headers.

A: The best I can come up with is to use contentOffset and frame.size to compute the visible rectangle and iterate over each section calling rectForSection: and see which ones intersect.  Something like:
-(NSIndexSet*)visibleSections
{
    NSMutableIndexSet*  indexSet = [NSMutableIndexSet new];
    CGRect              visible = self.tableView.bounds;

    for(NSInteger section = 0 ; section < [self numberOfSections])
    {
        CGRect          sectBounds = [self.tableView rectForSection:section];

        if(CGRectIntersectsRect(sectBounds, visible))
        {
            [indexSet addIndex:section];
        }
    }

    return indexSet;
}

A: Swift version
if let visibleRows = tableView.indexPathsForVisibleRows {
    let visibleSections = visibleRows.map({$0.section})
}

A: Swift 3 versions od @David answer
func visibleSection() -> IndexSet {

        var indexSet: IndexSet = IndexSet()
        let visibleRect: CGRect = self.bounds

        for sectionIndex in 0..<self.numberOfSections {

            let sectionBounds = self.rect(forSection: sectionIndex)

            if sectionBounds.intersects(visibleRect) {

                indexSet.insert(sectionIndex)
            }
        }
        return indexSet
    }


text:
Q: elementFromPoint not recognising certain elements I have an issue with which I've been battling for a couple of days now and I cannot understand what the problem is.
I want to fire up an event when a certain element hits the top of my
. It works well with most of the elements in my document except one, which incidentally is the one I'm interested in.
They're all span, with different classes. I'm detecting the class with el.classList.contains("myclass"). See my snippet below, with pagenum in the function, which gets picked up (although several times, but that's another minor issue). It works with line, line-group, and pagenum. It doesn't work with mspage.
Can someone tell me please what I am missing?
Thanks.
Update
I just noticed that if I give the mspage elements a height of 2 rem then it does detect them. Ideally I wanted those spans to be invisible to the user, and if I use display:none or visibility:hidden they don't get caught.

document.getElementById('xslt-transformation').addEventListener('scroll', function(e) {

    const el = document.elementFromPoint(this.getBoundingClientRect().x, this.getBoundingClientRect().y);
    if (el.classList.contains("pagenum")) {

            console.log(el.id)

    }
});
html, body, #mapdiv{
  height: 100%;
  margin: 0;
}

#xslt-transformation {

max-height: 63vh;
overflow: auto;

}

.mspage {
  display: block;
}

.line {
  display: block;
}

.line-group {
  padding: 2rem;
}

.footnotes {
  padding: 1rem;
  display: block;
}

.catchword {
  display: block;
  padding: 1rem
}

.diva-wrapper {
    min-height: 70vh !important;
  }

Transcription

Your beautiful transcription here

               Latha gan raibh Padric 'na * Mhùr
               Cha raibh sailm air ùidh, ach ceol.
               Chaidh è thigh Oissain Mhic Fhinn,
               O sann leis bu bhinn a ghloir.

               Failt ort fein, a shean-fhir shuairc,
               Air chuairt thugad thainig mi,
               A laoich mhòir *** mhìlidh nach meat
               Cha d' eur thu riamh neach mu d'ni.

               Sgeul a b'ait leom fhaotainn uait
               Odha Chuthaill is cruaidh colg,
               An Cath is tinn' a thug an Fhiann
               O na ghineadh tu riamh 'n an lorg

               Dh'innsinn sin duitse gun dàil,
               Dheagh Mhic Ailpein nan salm binn,
               An Cath is tinn' a thug na fir
               O'n a ghin iad Fiannaibh Fhinn.

               Dearmad air † fleadh a rinn Fionn
               Ann  Albuinn ri h àm nan laoch,

               Footnotes: * Lùth-chuirt †cuirm, fèisd
               Chuir

               4

               Chuir pairt do'n Fheinn fui' struim dearg,
               Dh'eirich orra fearg is fraoch

               Tre Chaoilte Mhic Rannachair mhoir
               'S Mac o Dòrain a bhi leinn,
               Mar sud is Àillidh maith ùr
               Thug breiteachd bliadhna ri Mùr Fhinn

               Ghluais an trithear a dh'Fhiannaibh Fhinn
               Gu Righ Lochlann nan srian sliom,
               Seirbheis blia'na thug iad dha
               'N trithear a bha 'n ùidh ri h uaill.

               Gabh Bann-righ Lochlann nan sgiath donn
               Trom ghaoil trom, 's cha∧'s cha b' ann gu deas,
               Air Àillidh greadhnach nan arm geur
               Gus an d'èirich a cheilg leis.

               Ghluais i a leabuidh an Righ
               An gniomh mun do dhoirteadh an fhuil,
               Gu hAlbuinn fhlathail nam Fiann
               Thugadar an triath th'air muir.

               Bha Righ air Lochlann san uair
               Leis am buinnte buaidh is blàr
               Earragan Mac Ainnir nan lonng,
               A Righ bu mhaith a làmh 's a lann.

               Chruinnich Righ Lochlann mor shluagh
               Cabhlach cruaidh a dh'fhàs gu treun:

               Dh'èirich

               5

               Dh'èirich sud o'n àirde tuath
               Naoi Righrin, 's an sluagh leis.

               Sheol iad air an abhais àrd
               O chòrs Eirinn bu gharg gàir
               Gu h Albuinn fhlathail nam Fiann
               Thogadar an triath th' air muir.

               Teachdoireachd thainig∧ thugainn gu luath,
               Sgeula cruaidh chuir ruinn gu geur,
               Còmhrag nam fear Innse-fàil
               Fhaolainn air an tràigh mu dheas.

               Thairig Fionn doibh cumha mhòr
               Làn an tunna do'n dearg òr:
               Do Righ Lochlann nan arm sean,
               Araon, agus a bhean fein.

               Lochlannaich a bhuithinn bhorb
               Le meud an stoirm as an lèathachd
               Cha ghabh iad cumha fui'm ghrein
               Gun an Fheinn a bhi 'n an dèigh

               Comhairl' eil' a chinn aig Fionn,
               'S aig maithibh na Feinne gu leir;
               Nighean Righ na' n gabht' i uath,
               Gun d'fhuair è sud, 's a bhean fhein.

            Chuir

            6

               Chuir sinn 'ga fhios nighean Righ
               Bu ghuirme sùil, 's bu ghrinne meur;
               Chuir sinne ga coimhead ceud each
               A b'fhearr ris an deachaidh srian,
               Le'n ceud marcaich air a' muin
               Fui' chulaibh shròil le'n laste gniomh

               Theirinn i'n sud air n raon,
               'S dh'fhàg i 'na dèigh na h eich,
               Thug i ceum uighe d' an coir
               'S da choinnleir air 'na làimh dheis,
               Da choinneil air ghuaillnibh a guin
               'S dealbh a chrùin o gheug nam port

               Do naigheachds' o phobull Fhinn
               Innis dhuinn a bhri', 's a bheachd?
               Mo naigheachds' o phobull Fhinn
               Gum faigheadh tu bhri' gu ceart;

               Mu rinn do bhean ort beairt chli,
               'S gun d'iomair i 'n gniomh gu cearr:
               Thoir cairdeas is comunn do dh'Fhionn
               'S gum faigheadh tu mi 'na geall.

               Gheibhe tu sud is ciad seud,
               Is ciad leug o'n uirbhich shaor:
               Gheibhe tu sudceud seothag suairc'
               Air am bitheadh buaidh nan eun:

            Gheibhe

            7

               Gheibhe tu sud is ciad mias
               Do chùrsa Righ bheath' an àidh,
               'S ge b' è ghleidheadh iad r' a bheo
               Chumadh iad duin' òg a ghnà.

               Gheibhe tu sud is ciad greidh,
               Is làn Glinne do chridh bàn
               'S a mhacain mar gabh thu sin
               Thoir leat do bhean, 's thoir dhuinne sith.

               'Ta cha d'thugainn sith do neach
               Do dh' Àillidh, no ghin d' ar Feinn,
               Ach Fionn fein a thigh 'n fui'm bhreith
               Is a chreach a thoirt gu tràigh.

               'Ta cha d'thug thu leat do neart
               Na bheireadh a chreach gu tràigh:
               Falbhai mis' is beannachd leat,
               O'n chaidh t aithneachd bun os cionn.

               Cha'n fahlbh thus' a chiabh na'n cleachd,
               A Ribhinn fharust a bheoil bhinn
               Gheibhe tu na seuda saor,
               'S cheanglainn thu ri m' thaobh deas.

               Cha 'n fhan mis' a cheann na'n cliar,
               O nach traogh mi t fhiamh, is t fhearg;

               'S o

               8

               'S nach faighinn saor fui' m' bhreith
               Ceann na deise bu | ghann ciall

               Cha 'n fhàg mi agaibh do theach
               Do bheinn, no dh' amhuinn, no thulaich;
               Ach Albuinn a thogail leom
               'Na cròchcan glas ann am loinngeas.

               Thionndaidh i ris a cùl,
               'S mharcaich i do 'n chùirt gu dian:
               Bu lion' ar sròl 'ga thogail suas,
               'S ann òrdugh gu luath chaidh an Fhiann.

               Fhreagair Àillidh 'n  còmhrag cruaidh,
               Do 'n t sluagh a thainig ann gèill.
               Ceann Mhic Nì', Mhic Naomh, Mhic Near,
               Leigeadh leis air an treas beum.

               Deich Ceannarda-fichead d'ar Feinn
               'S ceann Àillidh fein air an tùs,
               Thuit sud air laimh Earragainn mhoir
               Man deachaidh na sloigh ann dlùths'.

               'N sin chaidh Fionn fein air thùs,
               Deagh Mhac Chuthaill a ghnuis ghil;
               'S deich Ceannard-fichead air a laimh dheis,
               Do shiol Chuthaill na'n cleas lùth.

            Labhair

            9

               Labhair Fionn flath na'n cuach,
               Ri maithibh uaislibh Innse-fàil;
               Co dh'iongas Earragainn sa ghreis
               Nan leigeamaid leis ar tàir.

               'S ann bha fhreagradh sud aig Goll
               An Sonn a bha deachdair achlaoi.
               D'iongaidh mi Earragainn sa ghreis
               'S bheir mi d'fheuchainn d'a chleas lùithe.

               Mac an Luthaich, 's Diarmad donn,
               An t Oscar mòr, is Mac an Lèig,
               Ga d' dhion o shrith-bhuillean an laoich,
               Cum dithis air gach taobh do d' sgèith.

               Dolphinne Mac Mhalcain o'n Ghrèig
               * Muime Earragainn, 's cha bi bhreug,
               'N àm sgathach a chinn d' a dhaltadh
               A Ri' mhòir bu do amhluidh iomairt:
               'S mar bhithe mi 's Fionn nam fleadh
               Gum buineadh è 'n ceann do'n chearthar.

Footnotes: * Ge d' a tha ùghdar na h eachdrui so
   a'g radh gum b'e Dolphinne Muime
   Earragainn, tha 'n leughair r 'a thuig=,
   sinn gur è Oide bha ann.

            10

               Seachd fichead 's mìle sonn
               Thuit le Garadh, 's thuit le Goll:
               Urdal le Oissain an Oscar an àidh,
               'S le Conall, 's le Coireall cneas bhàn.

               'S air a bhaiste thainig orm
               A Phadric, chleirich a chanas na sailm,
               Thuit leam fein, 's le Fionn nam fleadh
               A cheart choi'-lion ceann ris a chearthar.

               'S mar duine chaidh as am beul airm,
               No chaidh mar cheo do 'n ghrein;
               Do dh'arm Righ Lochlann gu fior
               Cha 'n fhac' iad riamh an tir fein.

               Tuille mor is leith nam Fiann,
               Thuit iad air an t sliabh mu dheas;
               'S ge d' thainig cuid dhinne as
               Cha d' rinn sinn an lath' ud ar leas.

A: Using elementFromPoint is not a good approach. Your interested element will not be detected if it doesn't happen to stay under that point. Even worse, the chances for a zero height element to be detected is zero. You should compare the offsetTop of your interested element with the scrollTop + offsetTop of the scrolling element. The find can be further optimised with binary search if necessary.

let mspages = [...document.querySelectorAll(".mspage")];
let currentPage = mspages[0];
mspages = mspages.reverse();
document.getElementById('xslt-transformation').addEventListener('scroll', function (e) {
    let mspage = mspages.find(p => e.target.scrollTop + e.target.offsetTop >= p.offsetTop );
    if (mspage != currentPage) {
        currentPage = mspage;
        console.log(currentPage?.id);
    }
});
html, body, #mapdiv{
  height: 100%;
  margin: 0;
}

#xslt-transformation {

max-height: 63vh;
overflow: auto;

}

.mspage {
  display: block;
}

.line {
  display: block;
}

.line-group {
  padding: 2rem;
}

.footnotes {
  padding: 1rem;
  display: block;
}

.catchword {
  display: block;
  padding: 1rem
}

.diva-wrapper {
    min-height: 70vh !important;
  }

Transcription

Your beautiful transcription here

                    Latha gan raibh Padric 'na * Mhùr
                    Cha raibh sailm air ùidh, ach ceol.
                    Chaidh è thigh Oissain Mhic Fhinn,
                    O sann leis bu bhinn a ghloir.

                    Failt ort fein, a shean-fhir shuairc,
                    Air chuairt thugad thainig mi,
                    A laoich mhòir *** mhìlidh nach meat
                    Cha d' eur thu riamh neach mu d'ni.

                    Sgeul a b'ait leom fhaotainn uait
                    Odha Chuthaill is cruaidh colg,
                    An Cath is tinn' a thug an Fhiann
                    O na ghineadh tu riamh 'n an lorg

                    Dh'innsinn sin duitse gun dàil,
                    Dheagh Mhic Ailpein nan salm binn,
                    An Cath is tinn' a thug na fir
                    O'n a ghin iad Fiannaibh Fhinn.

                    Dearmad air † fleadh a rinn Fionn
                    Ann Albuinn ri h àm nan laoch,

                    Footnotes: * Lùth-chuirt †cuirm, fèisd
                    Chuir

                    4

                    Chuir pairt do'n Fheinn fui' struim dearg,
                    Dh'eirich orra fearg is fraoch

                    Tre Chaoilte Mhic Rannachair mhoir
                    'S Mac o Dòrain a bhi leinn,
                    Mar sud is Àillidh maith ùr
                    Thug breiteachd bliadhna ri Mùr Fhinn

                    Ghluais an trithear a dh'Fhiannaibh Fhinn
                    Gu Righ Lochlann nan srian sliom,
                    Seirbheis blia'na thug iad dha
                    'N trithear a bha 'n ùidh ri h uaill.

                    Gabh Bann-righ Lochlann nan sgiath donn
                    Trom ghaoil trom, 's cha∧'s cha b' ann gu deas,
                    Air Àillidh greadhnach nan arm geur
                    Gus an d'èirich a cheilg leis.

                    Ghluais i a leabuidh an Righ
                    An gniomh mun do dhoirteadh an fhuil,
                    Gu hAlbuinn fhlathail nam Fiann
                    Thugadar an triath th'air muir.

                    Bha Righ air Lochlann san uair
                    Leis am buinnte buaidh is blàr
                    Earragan Mac Ainnir nan lonng,
                    A Righ bu mhaith a làmh 's a lann.

                    Chruinnich Righ Lochlann mor shluagh
                    Cabhlach cruaidh a dh'fhàs gu treun:

                    Dh'èirich

                    5

                    Dh'èirich sud o'n àirde tuath
                    Naoi Righrin, 's an sluagh leis.

                    Sheol iad air an abhais àrd
                    O chòrs Eirinn bu gharg gàir
                    Gu h Albuinn fhlathail nam Fiann
                    Thogadar an triath th' air muir.

                    Teachdoireachd thainig∧ thugainn gu luath,
                    Sgeula cruaidh chuir ruinn gu geur,
                    Còmhrag nam fear Innse-fàil
                    Fhaolainn air an tràigh mu dheas.

                    Thairig Fionn doibh cumha mhòr
                    Làn an tunna do'n dearg òr:
                    Do Righ Lochlann nan arm sean,
                    Araon, agus a bhean fein.

                    Lochlannaich a bhuithinn bhorb
                    Le meud an stoirm as an lèathachd
                    Cha ghabh iad cumha fui'm ghrein
                    Gun an Fheinn a bhi 'n an dèigh

                    Comhairl' eil' a chinn aig Fionn,
                    'S aig maithibh na Feinne gu leir;
                    Nighean Righ na' n gabht' i uath,
                    Gun d'fhuair è sud, 's a bhean fhein.

                Chuir

                6

                    Chuir sinn 'ga fhios nighean Righ
                    Bu ghuirme sùil, 's bu ghrinne meur;
                    Chuir sinne ga coimhead ceud each
                    A b'fhearr ris an deachaidh srian,
                    Le'n ceud marcaich air a' muin
                    Fui' chulaibh shròil le'n laste gniomh

                    Theirinn i'n sud air n raon,
                    'S dh'fhàg i 'na dèigh na h eich,
                    Thug i ceum uighe d' an coir
                    'S da choinnleir air 'na làimh dheis,
                    Da choinneil air ghuaillnibh a guin
                    'S dealbh a chrùin o gheug nam port

                    Do naigheachds' o phobull Fhinn
                    Innis dhuinn a bhri', 's a bheachd?
                    Mo naigheachds' o phobull Fhinn
                    Gum faigheadh tu bhri' gu ceart;

                    Mu rinn do bhean ort beairt chli,
                    'S gun d'iomair i 'n gniomh gu cearr:
                    Thoir cairdeas is comunn do dh'Fhionn
                    'S gum faigheadh tu mi 'na geall.

                    Gheibhe tu sud is ciad seud,
                    Is ciad leug o'n uirbhich shaor:
                    Gheibhe tu sudceud seothag suairc'
                    Air am bitheadh buaidh nan eun:

                Gheibhe

                7

                    Gheibhe tu sud is ciad mias
                    Do chùrsa Righ bheath' an àidh,
                    'S ge b' è ghleidheadh iad r' a bheo
                    Chumadh iad duin' òg a ghnà.

                    Gheibhe tu sud is ciad greidh,
                    Is làn Glinne do chridh bàn
                    'S a mhacain mar gabh thu sin
                    Thoir leat do bhean, 's thoir dhuinne sith.

                    'Ta cha d'thugainn sith do neach
                    Do dh' Àillidh, no ghin d' ar Feinn,
                    Ach Fionn fein a thigh 'n fui'm bhreith
                    Is a chreach a thoirt gu tràigh.

                    'Ta cha d'thug thu leat do neart
                    Na bheireadh a chreach gu tràigh:
                    Falbhai mis' is beannachd leat,
                    O'n chaidh t aithneachd bun os cionn.

                    Cha'n fahlbh thus' a chiabh na'n cleachd,
                    A Ribhinn fharust a bheoil bhinn
                    Gheibhe tu na seuda saor,
                    'S cheanglainn thu ri m' thaobh deas.

                    Cha 'n fhan mis' a cheann na'n cliar,
                    O nach traogh mi t fhiamh, is t fhearg;

                    'S o

                    8

                    'S nach faighinn saor fui' m' bhreith
                    Ceann na deise bu | ghann ciall

                    Cha 'n fhàg mi agaibh do theach
                    Do bheinn, no dh' amhuinn, no thulaich;
                    Ach Albuinn a thogail leom
                    'Na cròchcan glas ann am loinngeas.

                    Thionndaidh i ris a cùl,
                    'S mharcaich i do 'n chùirt gu dian:
                    Bu lion' ar sròl 'ga thogail suas,
                    'S ann òrdugh gu luath chaidh an Fhiann.

                    Fhreagair Àillidh 'n còmhrag cruaidh,
                    Do 'n t sluagh a thainig ann gèill.
                    Ceann Mhic Nì', Mhic Naomh, Mhic Near,
                    Leigeadh leis air an treas beum.

                    Deich Ceannarda-fichead d'ar Feinn
                    'S ceann Àillidh fein air an tùs,
                    Thuit sud air laimh Earragainn mhoir
                    Man deachaidh na sloigh ann dlùths'.

                    'N sin chaidh Fionn fein air thùs,
                    Deagh Mhac Chuthaill a ghnuis ghil;
                    'S deich Ceannard-fichead air a laimh dheis,
                    Do shiol Chuthaill na'n cleas lùth.

                Labhair

                9

                    Labhair Fionn flath na'n cuach,
                    Ri maithibh uaislibh Innse-fàil;
                    Co dh'iongas Earragainn sa ghreis
                    Nan leigeamaid leis ar tàir.

                    'S ann bha fhreagradh sud aig Goll
                    An Sonn a bha deachdair achlaoi.
                    D'iongaidh mi Earragainn sa ghreis
                    'S bheir mi d'fheuchainn d'a chleas lùithe.

                    Mac an Luthaich, 's Diarmad donn,
                    An t Oscar mòr, is Mac an Lèig,
                    Ga d' dhion o shrith-bhuillean an laoich,
                    Cum dithis air gach taobh do d' sgèith.

                    Dolphinne Mac Mhalcain o'n Ghrèig
                    * Muime Earragainn, 's cha bi bhreug,
                    'N àm sgathach a chinn d' a dhaltadh
                    A Ri' mhòir bu do amhluidh iomairt:
                    'S mar bhithe mi 's Fionn nam fleadh
                    Gum buineadh è 'n ceann do'n chearthar.

                Footnotes: * Ge d' a tha ùghdar na h eachdrui so
                    a'g radh gum b'e Dolphinne Muime
                    Earragainn, tha 'n leughair r 'a thuig=,
                    sinn gur è Oide bha ann.

                10

                    Seachd fichead 's mìle sonn
                    Thuit le Garadh, 's thuit le Goll:
                    Urdal le Oissain an Oscar an àidh,
                    'S le Conall, 's le Coireall cneas bhàn.

                    'S air a bhaiste thainig orm
                    A Phadric, chleirich a chanas na sailm,
                    Thuit leam fein, 's le Fionn nam fleadh
                    A cheart choi'-lion ceann ris a chearthar.

                    'S mar duine chaidh as am beul airm,
                    No chaidh mar cheo do 'n ghrein;
                    Do dh'arm Righ Lochlann gu fior
                    Cha 'n fhac' iad riamh an tir fein.

                    Tuille mor is leith nam Fiann,
                    Thuit iad air an t sliabh mu dheas;
                    'S ge d' thainig cuid dhinne as
                    Cha d' rinn sinn an lath' ud ar leas.


text:
Q: I face this kind of Error in Azure SQL Auditing Error Message.Could you help me with this 'where' operator: failed to resolve column or scalar expression named 'database_name_s'
I don't know how to solve this problem


text:
Q: Double mapped relation in symfony? It is possible? I have no ideal how to double map entity in symfony.
I have table
Matches
________
id

u_id1 : reference to user

u_id2 : reference to user

status: enum

Now i don't want to create double records per one match.
I want to load user matches where u_id1 = user_id or u_id2 = user_id.
So.. i want make my method in user object inteligent usefully . eg $user->getMatches(); what returns matches where first or second u_id have current user id.
Any idea?

A: Maybe you can try something like this.
Define two relations in User entity
class Matches {

        /**
         * @ORM\ManyToOne(targetEntity="User", inversedBy="userOneMatches")
         * @ORM\JoinColumn(name="u_id1", referencedColumnName="id")
         * **/
        protected $u_id1;

        /**
         * @ORM\ManyToOne(targetEntity="User", inversedBy="userTwoMatches")
         * @ORM\JoinColumn(name="u_id2", referencedColumnName="id")
         * **/
        protected $u_id2;
}

and in User entity method getAllMatches(); to combine all matches.
class User {
    /** @ORM\OneToMany(targetEntity="Matches", mappedBy="u_id1" **/
    protected $userOneMatches;

    /** @ORM\OneToMany(targetEntity="Matches", mappedBy="u_id2" **/
    protected $userTwoMatches;

   public function getAllMatches()
   {
    // return $userOneMatches + $userTwoMatches
   }

}


text:
Q: Why do these arrangements of embedded c code perform so differently? Background
I am working with and 8052 based microcontroller. I have an LCD and and encoder wheel hooked up.  The user can navigate a menu displayed on the LCD by rotating and pressing the encoder wheel.
The rotation of the encoder wheel is interrupt based.
The direction the encoder wheel is being rotated (encoder_turn) is set inside of the encoder interrupt.
I call update_lcd() inside of a loop.
New Responsive Code
void update_lcd()
{

        //ENCODER TURN
        switch(encoder_turn)
        {
            case RIGHT:
                 lcd_clear();
                 next_screen();
                 break;
            case LEFT:
                lcd_clear();
                previous_screen();
                break;
            default:
                break;
        }
 }

void next_screen()
{
    if(current_test_screen < screen5)
    {
        current_test_screen++;
    }

    draw_current_test_screen();
}

void draw_current_test_screen()
{
    switch(current_test_screen)
    {
        case screen1:
            draw_screen1();
            break;
        case screen2:
            draw_screen2();
            break;
        case screen3:
            draw_screen3();
            break;
        case screen4:
            draw_screen4();
            break;
        case screen5:
            draw_screen5();
            break;
        default:
        break;
    }
}

Old Unresponsive Code
void update_lcd()
{

        //ENCODER TURN
        switch(encoder_turn)
        {
            case RIGHT:
                 lcd_clear();
                 next_screen();
                 break;
            case LEFT:
                lcd_clear();
                previous_screen();
                break;
            default:
                break;
        }

        switch(current_test_screen)
        {
            case screen1:
                draw_screen1();
                break;
            case screen2:
                draw_screen2();
                break;
            case screen3:
                draw_screen3();
                break;
            case screen4:
                draw_screen4();
                break;
            case screen5:
               draw_screen5();
               break;
            default:
               break;
       }

 }

void next_screen()
{
    if(current_test_screen < screen5)
    {
        current_test_screen++;
    }
}

The Question
Why is one responsive and the other completely useless?
When I say responsive I am referring to the fact that when I rotate the encoder the screen change is responsive.  Both methods "work" but one is unacceptable from a usage standpoint.

A: Those two pieces of code are almost equivalent, apart from one very subtle difference.
If you try refactoring your old code to try make it look more like your new code, you find that your old code makes one extra function call. Look carefully at the difference:
void update_lcd()
{
        //ENCODER TURN
        switch(encoder_turn)
        {
            case RIGHT:
                 lcd_clear();
                 next_screen();
                 break;
            case LEFT:
                lcd_clear();
                previous_screen();
                break;
            default:
                draw_current_test_screen();   // <--- your new code omits this call
                break;
        }
 }

Try taking your new code and adding that line and see if it causes the unresponsiveness problem.

A: Just a guess, but I suspect: Since the only thing you changed is the function nesting, encoder_turn is probably being cached by the optimizer. You need to mark encoder_turn as volatile, as the interrupt can occur and change its value at any time.


text:
Q: not able to execute lsnrctr status command using java code I am connecting remote server using java code, but one of the unix command is not executing as expected.
Unix Command as below :
 /u01/db/oracle/db/tech_st/11.1.0/bin/lsnrctl status VIS

Output:
LSNRCTL for Linux: Version 11.1.0.7.0 - Production on 06-NOV-2017 10:48:10

Copyright (c) 1991, 2008, Oracle.  All rights reserved.

TNS-01101: Message 1101 not found; No message file for product=network, facility=TNS

can any one help me to on this.
Thank you all.

A: Try to test it from the command line first. The point is you run lsnrctl without required environment variable ORACLE_HOME.
Here you have it reproduced:
jxa@ub16a|2001$ ssh test1 /opt/oracle/product/11.2.0/dbhome_1/bin/lsnrctl status
Message 1053 not found; No message file for product=network,
facility=TNSMessage 1020 not found; No message file for product=network,
facility=TNSMessage 1021 not found; No message file for product=network,
facility=TNSMessage 1022 not found;
[...]

After setting correctly ORACLE_HOME (add it before the command):
jxa@ub16a|2007$ ssh test1 ORACLE_HOME=/opt/oracle/product/11.2.0/dbhome_1 \
                     /opt/oracle/product/11.2.0/dbhome_1/bin/lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 09-NOV-2017 12:35:56
Copyright (c) 1991, 2011, Oracle.  All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
[...]

Now just figure out the way to add the environment variable in java and you're done. Or just add it to .bashrc (the most probable place for Linux) or another appropriate init file at the target host.
By the way, the error your lsnrctl reports is:
xxx:~ $ oerr tns 1101
01101, 00000, "Could not find service name %s"
// *Cause:  The ervice name could not be resolved by name-lookup.
// *Action: Verify that the listener name or service name specified to
// LSNRCTL has the correct name and address defined in LISTENER.ORA or in
// TNSNAMES.ORA.
xxx:~ $

I hope it helps.


text:
Q: footer colour colours full web page - how to fix? Im making a test web page in html 5 in Sublime text (mac) with css and i've repeatedly checked what the problem is but i can't fix the issue. I want the orange colour to colour only the footer (and header border bottom) but it fills the whole webpage (minus header).
How do I fix this?
Additionally, what mistake did I make?
ps - I have tried colouring the aside and article but that doesn't work since the height of the 2 are different and the footer still colours everything that isn't yet coloured (apart from the body). Also adding a break (br) in the html doesn't work as it adds a break to the colour at the top of the page
heres my code for the html:
    <!DOCTYPE html>

    <title>Task 3b</title>
    <link rel="stylesheet" type="text/css" href="../CSS/hwk.css">

                Main Header

HOME ABOUT SERVICES

                Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
                quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
                cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
                proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

                Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
                quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse

                -- © 2019 | Contact Us

                ----------

And here is the css:
.container{
    width: 80%;
    margin: auto;
    overflow: hidden;
}

a{
    text-decoration: none;
}

body{
    background-color: #f3f3f3;
    font-family: Arial;
    line-height: 1.5em;
    margin: 0;
    padding: 0;
}

/* header */

header{
    background: #35424a;
    margin: 0;
    padding: 20px;
    color: #fff;
    text-align: center;
    border-bottom: 3px #e8491d solid;
}

header h1{
    float: left;
}

header #highlight{
    color: #e8491d;
}

header nav{
    float: right;
    padding-top: 4px;
}

header nav a{
    color: #e2e2e2;
    font-weight: bold;
}

header nav a:hover{
    color: #fff;
}

/* text */

article{
    float: left;
    width: 65%;
}

aside{
    float: right;
    width: 35%;
    border-left: 1px #a8a8a8 solid;
    box-sizing: border-box;
}

footer{
    text-align: center;
    color: #fff;
    background-color: #e8491d;
}

Footer colour (orange) colours whole webpage
Thanks in advance!

A: The issue you are having is that you are positioning the page content using float, thus your footer is actually taking up the space behind the content. Instead of using float to position your body content, I would recommend using flexbox. To read up more on it see: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
I have modified your css and html to use flexbox instead and it resolves the issue you are having.
HTML

    <title>Task 3b</title>
    <link rel="stylesheet" type="text/css" href="../CSS/hwk.css">

                Main Header

HOME ABOUT SERVICES

                Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
                quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
                cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
                proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

                Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
                quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse

                -- © 2019 | Contact Us

                ----------

CSS
.container{
    width: 80%;
    margin: auto;
    overflow: hidden;
}

a{
    text-decoration: none;
}

body{
    background-color: #f3f3f3;
    font-family: Arial;
    line-height: 1.5em;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: space-between;
    flex-direction: column;
}

/* header */

header{
    background: #35424a;
    margin: 0;
    padding: 20px;
    color: #fff;
    text-align: center;
    border-bottom: 3px #e8491d solid;
}

header h1{
    float: left;
}

header #highlight{
    color: #e8491d;
}

header nav{
    float: right;
    padding-top: 4px;
}

header nav a{
    color: #e2e2e2;
    font-weight: bold;
}

header nav a:hover{
    color: #fff;
}

/* text */

article{

    width: 65%;
    background: white;
}

aside{
    width: 35%;
    border-left: 1px #a8a8a8 solid;
    box-sizing: border-box;
}

.content {
  display:flex;
    flex-direction: row;
}
footer{
    text-align: center;
    color: #fff;
    background-color: #e8491d;
}

Link to working example: https://jsfiddle.net/Matthew_/u2weo0g8/4/

A: You have to make change to footer css as below. Just add clear: both;
footer {
    clear: both;
    text-align: center;
    color: #fff;
    background-color: #e8491d;
}

.container{
    width: 80%;
    margin: auto;
    overflow: hidden;
}

a{
    text-decoration: none;
}

body{
    background-color: #f3f3f3;
    font-family: Arial;
    line-height: 1.5em;
    margin: 0;
    padding: 0;
}

/* header */

header{
    background: #35424a;
    margin: 0;
    padding: 20px;
    color: #fff;
    text-align: center;
    border-bottom: 3px #e8491d solid;
}

header h1{
    float: left;
}

header #highlight{
    color: #e8491d;
}

header nav{
    float: right;
    padding-top: 4px;
}

header nav a{
    color: #e2e2e2;
    font-weight: bold;
}

header nav a:hover{
    color: #fff;
}

/* text */

article{
    float: left;
    width: 65%;
}

aside{
    float: right;
    width: 35%;
    border-left: 1px #a8a8a8 solid;
    box-sizing: border-box;
}

footer {
    clear: both;
    text-align: center;
    color: #fff;
    background-color: #e8491d;
}
<!DOCTYPE html>

    <title>Task 3b</title>
    <link rel="stylesheet" type="text/css" href="../CSS/hwk.css">

                Main Header

HOME ABOUT SERVICES

                Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
                quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
                cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
                proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

                Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
                quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse

                -- © 2019 | Contact Us

                ----------

For more reference about clear property refer here =>
What is a clearfix?
Read about it in this article - by Chris Coyer @ CSS-Tricks


text:
Q: How move divs up/down using CSS animation without a "blink" between directions? I'm trying to move these divs up and down based on clicks:

*

*Initial click moves them up

*Next Click moves them down (then repeat on next clicks)

Moving them up works well, but when i click to move them down, they flash invisible first and then move down. What am I doing wrong?
JSFiddle: https://jsfiddle.net/9q0scpa0/
HTML:

    Page 1

Page 1

Page 1

Page 1

    Page 1

Page 1

Page 1

    Page 1

Page 1

Page 1

    Page 1

Page 1

Page 1

    Page 2

CSS:
*
{
  margin: 0em;
  padding: 0em;
}

html
{
  height: 100%;
  width: 100%;
}

body
{
  height: 100%;
  width: 100%;
  overflow: hidden;
}

.page
{
  position: relative;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background-color: red;
}

@keyframes moveNext
{
  0% {
    transform: translate(0em,100%);
    -webkit-transform: translate(0em,0%);
    -moz-transform: translate(0em,0%);
  }

  100% {
    transform: translate(0em,-100%);
    -webkit-transform: translate(0em,-100%);
    -moz-transform: translate(0em,-100%);
  }
}

@keyframes movePrevious
{
  0% {
    transform: translate(0em,-100%);
    -webkit-transform: translate(0em,-100%);
    -moz-transform: translate(0em,-100%);
    display: block;
  }

  100% {
    transform: translate(0em,0%);
    -webkit-transform: translate(0em,0%);
    -moz-transform: translate(0em,0%);
  }
}

#page1.leave
{
  z-index: 0;
  animation-name: moveNext;
  -webkit-animation-delay: 200ms;
  animation-delay: 200ms;
  animation-duration: 800ms;
  animation-iteration-count: 1;
  animation-timing-function: ease-in-out;
  animation-fill-mode: forwards;
}

#page2.enter
{
  background-color: blue;
  z-index: 1;
  animation-name: moveNext;
  animation-duration: 750ms;
  animation-iteration-count: 1;
  animation-timing-function: ease-in-out;
  animation-fill-mode: forwards;
}

#page1.enter
{
  z-index: 0;
  animation-name: movePrevious;
  animation-duration: 800ms;
  animation-iteration-count: 1;
  animation-timing-function: ease-in-out;
  animation-fill-mode: forwards;
}

#page2.leave
{
  background-color: blue;
  z-index: 1;
  animation-name: movePrevious;
  -webkit-animation-delay: 200ms;
  animation-delay: 200ms;
  animation-duration: 750ms;
  animation-iteration-count: 1;
  animation-timing-function: ease-in-out;
  animation-fill-mode: forwards;
}

JavaScript:
var isMoveNext = true;
var page1 = document.getElementById( "page1" );
var page2 = document.getElementById( "page2" );

window.restart = function()
{
  //Moving next
  if ( isMoveNext )
  {
    page1.className = "page leave";
    page2.className = "page enter";
    isMoveNext = false;
  }

  else
  {
    page1.className = "page enter";
    page2.className = "page leave";
    isMoveNext = true;
  }
}

A: You achieve your animation by using only transition you don't need to use keyframes
this how css look like :
*
{
  margin: 0em;
  padding: 0em;
}

html
{
  height: 100%;
  width: 100%;
}

body
{
  height: 100%;
  width: 100%;
  overflow: hidden;
}

.page
{
    position: relative;
    height: 100%;
    width: 100%;
    overflow: hidden;
    background-color: red;
    transition:all linear 800ms;
}

#page2{

    background-color: blue;
}

#page1.leave,#page2.enter
{
    transform: translate(0em,-100%);
    -webkit-transform: translate(0em,-100%);
    -moz-transform: translate(0em,-100%);
}

#page1.enter,#page2.leave
{
    transform: translate(0em,-0%);
    -webkit-transform: translate(0em,-0%);
    -moz-transform: translate(0em,-0%);
}

See demo here

A: Add one more transition translate(0em,-100%) in #page2.leave to remove the blink

var isMoveNext = true;
var page1 = document.getElementById( "page1" );
var page2 = document.getElementById( "page2" );

window.restart = function()
{
 //Moving next
  if ( isMoveNext )
  {
  page1.className = "page leave";
    page2.className = "page enter";
    isMoveNext = false;
  }

  else
  {
   page1.className = "page enter";
    page2.className = "page leave";
    isMoveNext = true;
  }
}
*
{
  margin: 0em;
  padding: 0em;
}

html
{
  height: 100%;
  width: 100%;
}

body
{
  height: 100%;
  width: 100%;
  overflow: hidden;
}

.page
{
  position: relative;
 height: 100%;
 width: 100%;
 overflow: hidden;
 background-color: red;
}

@keyframes moveNext
{
  0% {
  transform: translate(0em,100%);
  -webkit-transform: translate(0em,0%);
  -moz-transform: translate(0em,0%);
 }

 100% {
  transform: translate(0em,-100%);
  -webkit-transform: translate(0em,-100%);
  -moz-transform: translate(0em,-100%);
 }
}

@keyframes movePrevious
{
  0% {
  transform: translate(0em,-100%);
  -webkit-transform: translate(0em,-100%);
  -moz-transform: translate(0em,-100%);
    display: block;
 }

 100% {
  transform: translate(0em,0%);
  -webkit-transform: translate(0em,0%);
  -moz-transform: translate(0em,0%);
 }
}

#page1.leave
{
  z-index: 0;
  animation-name: moveNext;
  -webkit-animation-delay: 200ms;
  animation-delay: 200ms;
  animation-duration: 800ms;
  animation-iteration-count: 1;
  animation-timing-function: ease-in-out;
  animation-fill-mode: forwards;
}

#page2.enter
{
  background-color: blue;
  z-index: 1;
  animation-name: moveNext;
  animation-duration: 750ms;
  animation-iteration-count: 1;
  animation-timing-function: ease-in-out;
  animation-fill-mode: forwards;
}

#page1.enter
{
  z-index: 0;
  animation-name: movePrevious;
  animation-duration: 800ms;
  animation-iteration-count: 1;
  animation-timing-function: ease-in-out;
  animation-fill-mode: forwards;
}

#page2.leave
{
  background-color: blue;
  z-index: 1;
  animation-name: movePrevious;
  -webkit-animation-delay: 200ms;
  animation-delay: 200ms;
  animation-duration: 750ms;
  animation-iteration-count: 1;
  animation-timing-function: ease-in-out;
  animation-fill-mode: forwards;
      transform: translate(0em,-100%);
        -webkit-transform: translate(0em,-100%);
        -moz-transform: translate(0em,-100%);
}

Page 1

Page 1

Page 1

Page 1

Page 1

Page 1

Page 1

Page 1

Page 1

Page 1

Page 1

Page 1

Page 1

Page 2


text:
Q: Value that increases the Standard Deviation I am puzzled by the following statement:
" In order to increase the standard deviation of a set of numbers, you must add a value that is more than one standard deviation away from the mean"
What is the proof of that? I know of course how we define the standard deviation but that part I seem to miss somehow. Any comments?

A: The puzzling statement gives a necessary but insufficient condition for the standard deviation to increase. If the old sample size is $n$, the old mean is $m$, the old standard deviation is $s$, and a new point $x$ is added to the data, then the new standard deviation will be less than, equal to, or greater than $s$ according as $|x-m|$ is less than, equal to, or greater than $s\sqrt{1+1/n}$.

A: For any $N$ numbers $y_1,y_2, \ldots, y_N$ with mean
$\displaystyle \bar{y} = \frac{1}{N}\sum_{i=1}^N y_i$, the variance is given by
$$\begin{align}
\sigma^2 &= \frac{1}{N-1}\sum_{i=1}^N (y_i-\bar{y})^2\\
&= \frac{1}{N-1}\sum_{i=1}^N \left(y_i^2 - 2y_i\bar{y} + \bar{y}^2\right)\\
&= \frac{1}{N-1}\left[\left(\sum_{i=1}^Ny_i^2\right) - 2N(\bar{y})^2
+ N(\bar{y})^2 \right] \\
\sigma^2 &=\frac{1}{N-1}\sum_{i=1}^N \left(y_i^2 - (\bar{y})^2\right) \tag{1}
\end{align}$$
Applying $(1)$ to the given set of $n$ numbers $x_1, x_2, \ldots x_n$
which we take for convenience in exposition to have mean $\bar{x} = 0$,
we have that
$$\sigma^2 = \frac{1}{n-1}\sum_{i=1}^n \left(x_i^2-(\bar{x})^2\right)
= \frac{1}{n-1}\sum_{i=1}^n x_i^2$$
If we now add in a new observation $x_{n+1}$ to this data set, then the new mean of
the data set is
$$\frac{1}{n+1}\sum_{i=1}^{n+1}x_i
= \frac{n\bar{x} + x_{n+1}}{n+1} = \frac{x_{n+1}}{n+1}$$
while the new variance is
$$\begin{align}
\hat{\sigma}^2 &= \frac{1}{n}\sum_{i=1}^{n+1} \left(x_i^2-\frac{x_{n+1}^2}{(n+1)^2}\right)\\
&= \frac{1}{n}\left[\left((n-1)\sigma^2 + x_{n+1}^2\right)
- \frac{x_{n+1}^2}{n+1}\right]\\
&= \left.\left.\frac{1}{n}\right[(n-1)\sigma^2 + \frac{n}{n+1}x_{n+1}^2\right]\\
&> \sigma^2 ~ \text{only if}~ x_{n+1}^2 > \frac{n+1}{n}\sigma^2.
\end{align}$$
So $|x_{n+1}|$ needs to be larger than $\displaystyle\sigma\sqrt{1+\frac{1}{n}}$
or, more generally, $x_{n+1}$ needs to
differ from the mean $\bar{x}$ of the original data
set by more than $\displaystyle\sigma\sqrt{1+\frac{1}{n}}$, in order for
the augmented data set to have larger variance than the original data set.
See also Ray Koopman's answer which points out that the new variance is larger
than, equal to, or smaller than, the original variance according as $x_{n+1}$
differs from the mean by more than, exactly, or less than $\displaystyle\sigma\sqrt{1+\frac{1}{n}}$.

A: Leaving aside the algebra (which also works) think about it this way: The standard deviation is square root of the variance. The variance is the average of the squared distances from the mean. If we add a value that is closer to the mean than this, the variance will shrink. If we add a value that is farther from the mean than this, it will grow.
This is true of any average of values that are non-negative. If you add a value that is higher than the mean, the mean increases. If you add a value that is less, it decreases.

A: I'll get you started on the algebra, but won't take it quite all of the way. First, standardize your data by subtracting the mean and dividing by the standard deviation: $$ Z = \frac{x-\mu}{\sigma} .$$ Note that if $x$ is within one standard deviation of the mean, $Z$ is between -1 and 1. Z would be 1 if $x$ were exactly one sd away from the mean. Then look at your equation for standard deviation: $$\sigma = \sqrt{\frac{\sum_{i=1}^{N}Z_i^2}{N-1}}$$ What happens to $\sigma$ if $Z_N$ is between -1 and 1?


text:
Q: how grep text upto next space? 7/04/27 10:50:17 INFO Master: Driver submitted org.apache.spark.deploy.worker.DriverWrapper
17/04/27 10:50:17 INFO Master: Launching driver driver-20170427105017-0000 on worker worker-20170427103840-192.168.5.242-7078
17/04/27 10:50:22 INFO Master: 192.168.5.5:53156 got disassociated, removing it.
17/04/27 10:50:22 INFO Master: 192.168.5.5:37668 got disassociated, removing it.
17/04/27 10:50:22 INFO Master: 192.168.5.5:53154 got disassociated, removing it.
17/04/27 10:55:27 INFO Master: Registering app ETL DataPipeline App
17/04/27 10:55:27 INFO Master: Registered app ETL DataPipeline App with ID app-20170427105527-0000
17/04/27 10:55:27 INFO Master: Launching executor app-20170427105527-0000/0 on worker worker-20170427103842-192.168.5.175-7078
17/04/27 10:55:27 INFO Master: Launching executor app-20170427105527-0000/1 on worker worker-20170427103838-192.168.5.37-7078
17/04/27 11:08:25 INFO Master: Asked to kill driver driver-20170427105017-0000
17/04/27 11:08:25 INFO Master: Kill request for driver-20170427105017-0000 submitted
17/04/27 11:08:26 INFO Master: Received unregister request from application app-20170427105527-0000

How i will get driver-20170427105017-0000 and respective 192.168.5.242 and similarly how to grep app-20170427105527-0000/0 and its respective 192.168.5.175 .

A: Using sed to get all driver and executor messages related to "Launching":
$ sed -n -E 's/^.*Launching (driver|executor) ([^ ]*).*worker-[0-9]*-([^-]*).*$/\2 \3/p' file.in
driver-20170427105017-0000 192.168.5.242
app-20170427105527-0000/0 192.168.5.175
app-20170427105527-0000/1 192.168.5.37

*

*[^ ]* will match any number of any characters, except space.

*\2 and \3 are back-references to what's matched by the second and third parentheses respectively. The second parentheses contains [^ ]* and will match the text after Launching driver or Launching executor, and the third parentheses  contains [^-]* and will match the IP address (up to the - which terminates the address).

*^ and $ in s/^...$/.../p anchors the regular expression at the start and end of the line, while p tells sed to "print" the result of the substitution if one is made.

Alternatively, and possibly more robust because of less regular expression magic, using awk:
$ awk '/Launching/ { split($NF, a, "-"); print $7, a[3] }' file.in