text:
Q: Can i use google cloud print using a google service account? I cant use OAuth2 authentication for accessing Google cloud print as I can't have a browser redirection for account selection. So I am trying out Google service account for accessing Google cloud print (suggested method for these scenarios). But under the googleapiclient.discovery , I am unable to find a key word for cloud printing. This is the code snippet which I tried.
from google.oauth2 import service_account
import requests

SCOPES = ['https://www.googleapis.com/auth/cloudprint']
SERVICE_ACCOUNT_FILE = 'secret.json'

credentials = service_account.Credentials.from_service_account_file(
        SERVICE_ACCOUNT_FILE, scopes=SCOPES)

sqladmin = googleapiclient.discovery.build('sqladmin', 'v1beta3', credentials=credentials)

I am confused at 2 places in the above code snippet.
1. If the scope provided is valid
2. What is the alternative for argument sqladmin in googleapiclient.discovery.build() function for Google cloud print.


text:
Q: An error occurred while creating datasets: Dataset could not be created I have a running Kylin Cluster in Kubernetes and Superset in Kubernets also.

*

*Kylin is already configured with a built cube "kylin_sales_cube"

*Superset is already configured with Kylin driver and the connection is established.

While trying to create a dataset from a Kylin table I get the following error message:

An error occurred while creating datasets: Dataset could not be created.

On the other hand, I am able to run a query on the same table, but without dataset, I cannot use charts.
Any ideas?

A: It seems a lack of implementation of a method in kylinpy (or somehere else) but until someone solves it, I suggest everyone who has this problem to implement the has_table method in sqla_dialect.py from kylinpy plugin. You will find it in kylinpy/sqla_dialect.py, and the method is:

You should change that return to the next line:
    return table_name in self.get_table_names(connection, schema)

And everything will be back to normal.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Learning Hadoop for System Admin This is not a technical question, but want to have suggestions from more experienced people regarding my career.
I have been working as UNIX admin from past 13 years, majority of Solaris and couple of years on Linux. Now, I want to learn something more which can excel my career. I have been hearing a lot about Hadoop/Big Data from quite sometime. I do not have any programming or scripting knowledge, neither have knowledge of apache or any database.
- I am assuming that there are two different job profile, Developer and Admin. Am I understanding it correctly ?
- Do I need to learn apache, database, java to learn Hadoop (Even for Admin job profile) ?
- At my place training is expensive. if I want to start study with books, which book should I start with ? I can see popular ones are "Hadoop: The Definite Guide - O'Reilly" and also "Big Data for Dummies". (I am asking from beginners level).
Please help with my doubts. Your suggestions will help me to take decision.

A: (Moved from comment because too long.)
In order to administer Hadoop in any meaningful way you need to know a fair bit about (a) how Hadoop works, (b) how Hadoop runs its jobs, and (c) job-specific tuning.
I don't know what "learning Apache" means; Apache is a conglomerate of projects, unless you mean the web server itself.
"Learning databases" is too broad to be useful, and Hadoop isn't a database (HBase is).
You don't need any Java knowledge to administer a Java-based program, although knowing about JVM options, how to specify them, and generalities is certainly helpful.
There is a lot to digest, I would start very small, e.g., intro books. Also, keep in mind that there are other solutions besides Hadoop, and a lot of different ways to actually use Hadoop.
The Kiji project is a good way to get Hadoop/HBase/etc up and running, though if you're interested in doing everything "from scratch", it's not the best path.


text:
Q: Как импортировать настройки AndroidStudio? Вот такая ситуация я долго работал на своем ноуте по Linux но теперь поменял его на Mac и вот думаю , придется ли теперь заново подключать плагины и устанавливать все настройки или можно как то импортировать это все?
Тем более я правда пока не знаю зачем и как это работает, но студия предложила войти использовав гугл аккаунт и я это сделал. Теперь в правом верхнем углу есть мой аватар и я подозреваю, что какае то синхронизация должна быть.

A: В основном меню студии есть кнопки Import/Export settings - при экспорте формируется jar файл с настройками, который можно на другой машине импортировать - так значительная часть настроек применится. Не знаю на счёт плагинов, но всякие штуки типа форматирования кода точно переносятся.


text:
Q: Add Volume Control to Itunes Jump List Is it possible to add a volume control to iTunes' Jump List? The pause and skip buttons are useful, but a volume slider would make it so much better. Is this possible?

A: So far on the program itself can create it's jumplist. There is no way (AFAIK) to inject code into another processes jumplist.
So, no.


text:
Q: Load GeoJSON into layer from a URL? I'm using Mapbox 2.1 and I'm trying to build a chloropleth map from a GeoJSON source, working from this example: https://www.mapbox.com/mapbox.js/example/v1.0.0/choropleth/
However, I've fallen at the first hurdle, because my GeoJSON source is a pure GeoJSON file, not a JS file like their example.
So this line doesn't work for me:
var statesLayer = L.geoJson(statesData,  {
    style: getStyle,
    onEachFeature: onEachFeature
}).addTo(map);

Their JS file defines statesData as a variable:
var statesData = { "type": "FeatureCollection" ... };

But my GeoJSON file is just a GeoJSON file.
How can I define the equivalent of statesData so that I can follow the example?
I guess I could use eval to read in the GeoJSON, but that's generally a bad idea.

A: You can use ajax to snag the data from your own site
Here is a jquery way of doing it.
$.ajax({
dataType: "json", //you shouldn't need to declare geojson
url: "data/district.geojson",
success: function(data) {
    //whatever you want to do with the data, alternatively you could use a closer around the ajax request to capture the data into a variable depending on how you have your code organized
}
}).error(function(e) {
     console.log(e)
});


text:
Q: Make a KVM VM but skip Ubuntu installation process I am currently able to make a Ubuntu 16.04 VM via KVM on my host Ubuntu.
What I'm trying is to install the Ubuntu image but then not have to go through the installation process of choosing a username, password, machine name, and time zone.
Is it possible to do this via KVM?

A: If you already have an installed VM you can simply copy the installed VM This would allow you to go through the installation process only once although you may have to do some editing...
First copy the VM's disks from /var/lib/libvirt/images on src host to the same dir on destination host.
Next, run virsh dumpxml VMNAME > domxml.xml on the source host and copy this xml to the dest. host
Then, on the destination host run virsh define domxml.xml
and start the VM.
Addendum: If the VM has snapshots that you want to preserve, you should dump the snapshot xml-files on the source with virsh snapshot-dumpxml $dom $name > file.xml for each snapshot in the snapshot list of the VM virsh snapshot-list --name $dom.
Then on the destination use virsh snapshot-create --redefine $dom file.xml to finish migrating the snapshots.
If you also care about which snapshot is the current one, then additionally do on the source:
virsh snapshot-current --name $dom
and on the destination:
virsh snapshot-current $dom $name
Note:
    If the disk location differs, you need to edit the xml's devices/disk node to point to the image on the destination host
    If the VM is attached to custom defined networks, you'll need to either edit them out of the xml on the destination host or redefine them as well (virsh net-dumpxml > netxml.xml and the virsh net-define netxml.xml && virsh net-start NETNAME & virsh net-autostart NETNAME)
Sources:
This answer shamelessly modeled on answers found on
https://serverfault.com/questions/434064/correct-way-to-move-kvm-vm

A: You can use virt-builder to create virtual machine images of a wide variety of Linux distributions.
Virt-builder is included in the libguestfs-tools package. Install it with:
sudo apt-get install libguestfs-tools

You run virt-builder by telling it what Linux distribution you want to build an image for. To learn what virtual machines it can build, run:
virt-builder --list
....
ubuntu-10.04             x86_64     Ubuntu 10.04 (Lucid)
ubuntu-12.04             x86_64     Ubuntu 12.04 (Precise)
ubuntu-14.04             x86_64     Ubuntu 14.04 (Trusty)
ubuntu-16.04             x86_64     Ubuntu 16.04 (Xenial)

To build a virtual machine, specify whether you want a raw or QCOW2 image, the disk size you want, and a filename, and go:
virt-builder ubuntu-16.04 --format qcow2 --size 10G --output my-ubuntu-vm.qcow2

By default, virt-builder will enable the root account and set a random password for it. If you don't want this, you can set your own root password. You can also add user accounts, install or remove packages, set the VM hostname, and even run arbitrary commands. The virt-builder man page has all the details on these, if you need them.


text:
Q: How do I use the celery (java version) in Kotlin I am trying to do a tiny poc (a add operation in a celery task) with Kotlin -> celery -> python.
Python->celery->Python is ok. But with https://github.com/crabhi/celery-java and this "wrong" code:
package poc_kotlin_celery

import com.geneea.celery.*

fun main() {
   val client: Celery = Celery.builder()
        .brokerUri("amqp://localhost/%2F")
        .backendUri("rpc://localhost/%2F")
        .build();

   val args = arrayOf(1, 2)
   val result: AsyncResult<Int> = client.submit("task.add", args)
   val suma: Int = result.get() as Int

   println(suma as Int);
}

I can not fix the compilation errors:
$ gradle run

> Task :app:compileKotlin FAILED
e: /home/miguel/code/poc_kotlin_celery/app/src/main/kotlin/poc_kotlin_celery/App.kt: (15, 16): Unresolved reference: AsyncResult
e: /home/miguel/code/poc_kotlin_celery/app/src/main/kotlin/poc_kotlin_celery/App.kt: (15, 42): Not enough information to infer type variable R

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 730ms
1 actionable task: 1 executed


text:
Q: Integer solutions of $x^y-z^3=2$ Is it an open question to solve $x^y-z^3=2$ in integers (both positive, zero and negative)? If not, what kind of methods the solution requires?

A: If $y$ is even, the only solutions to $-t^3 + u^2 = 2$ are $(-1,\pm 1)$
E_+00002: r = 1   t = 1   #III =  1
          E(Q) = <(-1, 1)>
          R =   0.7545769032
           2 integral points
            1. (-1, 1) = 1 * (-1, 1)
            2. (-1, -1) = -(-1, 1)

http://tnt.math.se.tmu.ac.jp/simath/MORDELL/MORDELL+
Things do not change very much if you allow $-2,$ all you get is $27 - 25 = 2.$
E_-00002: r = 1   t = 1   #III =  1
          E(Q) = <(3, 5)>
          R =   1.3495768357
           2 integral points
            1. (3, 5) = 1 * (3, 5)
            2. (3, -5) = -(3, 5)

http://tnt.math.se.tmu.ac.jp/simath/MORDELL/MORDELL-
Also, $y$ cannot be divisible by $3,$ as you can factor the difference of cubes and get a finite number of things to rule out. So, you have $y=5,7,11,13,\ldots$
My guess is that there is a book somewhere on Catalan's conjecture, now proved, with a chapter on changing the difference between powers from $\pm 1$ to $\pm 2, \pm 3,$ and a few other small numbers.
Whatever the exact contents, there is a book called Catalan's Conjecture by Rene Schoof, http://oskicat.berkeley.edu/record=b16478355~S1


text:
Q: Rcpp How to change a value directly inside a R List I know how to get values from a List objet, and how to create one within a C function.
But I would like to change a value in a List  which is given as a parameter
and that the modification would be effective when exiting the function.
Some thing like:
void myfunc(SEXP *lst) '
   List mylist (lst)
// make some modification

}

I need to modify a list within a recursive loop.
Thanks in advance
Daniel

A: There is no magic. Just assign elements from a List object, and modify:
R> Rcpp::cppFunction("List foo(List L) { List L2 = L[0]; L2[1] = 42; return L2;} ")
R> L <- list(list(0,1,2), 2:4, 3.3)
R> foo(L)
[[1]]
[1] 0

[[2]]
[1] 42

[[3]]
[1] 2

R>

We pick the first element (and know it is a List itself; there are predicates for testing).  In that list, we set the second element.  You can do the same returning the original but now modified list:
R> Rcpp::cppFunction("List bar(List L) { List L2 = L[0]; L2[1] = 42; return L;} ")
R> L <- list(list(0,1,2), 2:4, 3.3)
R> bar(L)
[[1]]
[[1]][[1]]
[1] 0

[[1]][[2]]
[1] 42

[[1]][[3]]
[1] 2

[[2]]
[1] 2 3 4

[[3]]
[1] 3.3

R>


text:
Q: Possible to spin up a local php server with gulp? Is it possible to run a local PHP server with gulp? I'm using gulp-connect, but it won't render my php files. I haven't been able to google someone else with this problem, so I assume I'm doing something fundamental wrong?
This is my gulp file for starting a local server:
gulp.task('webserver', function() {
connect.server({
    root: '_development',
    port: 8888
});
});

A: Using the gulp plugin gulp-connect-php, works like a charm:
https://www.npmjs.com/package/gulp-connect-php


text:
Q: IdP initiated saml recieved on SP always has RelayState as null I have been tasked to implement a SAML2.0 SSO proof of concept and I have successfully integrated the spring saml extension which has been pretty straightforward, thanks to the author. Although, I still haven't been able to get the RelayState parameter to work, I always get its value as null on the receiving SP.
I am using SSOCircle's public IdP with an IdP initiated flow (although we have not blocked the SP initiated mode) and appending the RelayState in the URL.
I am trying to use the SAMLRelayStateSuccessHandler where I could get the RelayState parameter from the SAMLCredential instance but its always null. I traced it back to the HTTPPostDecoder.doDecode(MessageContext messageContext) method (HTTP post binding) and it was null there as well. I also traced the browser network url and noticed the SP consumer end point post url i.e. /saml/SSO contains SAMLResponse but there is no RelayState parameter (my understanding is it will be a separate parameter).
I feel the IdP is probably not sending the RelayState to my SP but also don't see any configuration on the IdP side to enable/disable it so not sure.
I would appreciate advice on debugging this or if someone could share their similar experiences.

A: I donot have this issue any more but did not explicitly add any fix either. My best guess is ssocircle put in a fix on their end after which the RelayState url started flowing end to end for me.
Appreciate the help by @hos. Did not want to keep the question open so add this as an answer.


text:
Q: Angular: using an Observable to display and search data I'm developing an Angular component which is supposed to serve as a visual list of objects.
I'm trying to implement the search & filtering example from ng-bootstrap.
The problem I'm having is that I cannot synchronize between fetching the data and displaying the data.
I've tried migrating from using this.antraege to using this.filteredAntraege$ which is an Observable.
If I don't use the Promise between readAntraege() and its invocation in the constructor(), I end up having this.antraege  being empty, so with that construct I'm trying to execute search() AFTER readAntraege() and NOT earlier.
In the template, I could just loop over this.antraege, but that would render me being not able to use the search mechanism (tried that before).
What's the missing brick to using the Observable and making this work?
Thank you in advance!
Michael
the component:
import { AlertService } from './../../_alert/alert.service';
import { Component, OnInit, PipeTransform } from '@angular/core';
import { AntragService } from '../../services/antrag.service';
import { NgbModal, NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { NgbdModalConfirmAutofocus } from '../modal-focus/modal-focus.component';
import { Router } from '@angular/router';
import { Antrag } from '../../shared/antrag.model';
import { DecimalPipe } from '@angular/common';
import { Observable } from 'rxjs';
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { startWith, map, filter } from 'rxjs/operators';

@Component({
  selector: 'app-antrag-list',
  templateUrl: './antrag-list.component.html',
  styleUrls: ['./antrag-list.component.css'],
  providers: [DecimalPipe]
})
export class AntragListComponent implements OnInit {
  activeModal: NgbActiveModal;

  antraege: Antrag[];
  currentAntrag = null;
  currentIndex = -1;
  name = '';

  filteredAntraege$: Observable<Antrag[]>;
  filterfcvar: FormControl;
  filterfg: FormGroup;

  constructor(private antragService: AntragService,
    public alertService: AlertService,
    public modal: NgbActiveModal,
    private router: Router,
    private modalService: NgbModal,
    pipe: DecimalPipe,
    private fb: FormBuilder) {
    this.filterfcvar = new FormControl();
    this.filterfg = this.fb.group({filterfc: this.filterfcvar});
    this.readAntraege().then((result) => {
        // Aufbau des Datenbestandes für das Suchefeld:
        this.filteredAntraege$ = this.filterfcvar.valueChanges.pipe(
          startWith(''),
          map(text => this.search(text, pipe))
        );
      }).catch((err) => {

      });
     }

  ngOnInit(): void {
  }

  readAntraege(): any {
    return new Promise((resolve, reject) => {
      this.antragService.readAll()
        .subscribe(
          antraege => {
            this.antraege = antraege;
            console.log('readAntraege(): antraege===' + antraege);
            console.log('readAntraege(): this.antraege===' + this.antraege);
          },
          error => {
            console.log(error);
          });
      });
    }

  refresh(): void {
    this.readAntraege();
    this.currentAntrag = null;
    this.currentIndex = -1;
  }

  setCurrentAntrag(antrag, index): void {
    this.currentAntrag = antrag;
    this.currentIndex = index;
  }

  search(text: string, pipe: PipeTransform): Antrag[] {
    console.log('search: text===' + text);
    console.log('search: pipe===' + pipe);
    console.log('antrag filter beispiel: ' + this.antraege);
    return this.antraege.filter(antrag => {
      const term = text.toLowerCase();
      return antrag.antragsteller.toLowerCase().includes(term)
          || pipe.transform(antrag.gestelltbei).includes(term)
          || pipe.transform(antrag.status).includes(term);
    });
  }
}

the template:

  <form [formGroup]="filterfg" novalidate>

      Volltextsuche: <input class="form-control ml-2" type="text" formControlName="filterfc"/>

  </form>

    id
    antragsteller
    gestellt bei
    Eingangsdatum
    Förderhöhe
    Status
    Aktion

    {{antrag.id}}
    <ngb-highlight [result]="antrag.antragsteller" [term]="filterfcvar.value"></ngb-highlight>
    {{antrag.gestelltbei}}
    {{antrag.eingangsdatum}}
    {{antrag.foerderhoehe | currency:'EUR':true}}
    {{antrag.status}}

Antrag

              Nr.

{{currentAntrag.id}}

        Name:

{{currentAntrag.antragsteller}}

        Eingangsdatum:

{{currentAntrag.eingangsdatum}}

        Förderhöhe:

{{currentAntrag.foerderhoehe}} {{currentAntrag.foerderhoehewaehrung}}

        Gestellt bei:

{{currentAntrag.gestelltbei}}

        Status:

{{currentAntrag.status}}

        Bearbeiten

Bitte auf einen Antrag klicken, um Details zu sehen

A: The problem here as you correctly stated is that you are trying to search on an empty stream of data. You can fix that by waiting for the call to get Antraege to finish and the continue with the search observable. Based on you example I would do the following
@Component({
  selector: 'app-antrag-list',
  templateUrl: './antrag-list.component.html',
  styleUrls: ['./antrag-list.component.css'],
  providers: [DecimalPipe]
})
export class AntragListComponent implements OnInit {
  activeModal: NgbActiveModal;

  antraege$: Observable<Antrag[]> = this.antragService.readAll()
    .pipe(tap((antraege) => this.antraege = antraege));

  currentAntrag = null;
  currentIndex = -1;
  name = '';

  filteredAntraege$: Observable<Antrag[]>;
  filterfcvar = new FormControl();
  filterfg = this.fb.group({filterfc: this.filterfcvar});;

  constructor(
    private antragService: AntragService,
    public alertService: AlertService,
    public modal: NgbActiveModal,
    private router: Router,
    private modalService: NgbModal,
    pipe: DecimalPipe,
    private fb: FormBuilder
  ) {}

  ngOnInit(): void {
    this.filteredAntraege$ = this.filterfcvar.valueChanges.pipe(
      startWith(''),
      map(text => this.search(text, pipe))
    );
  }

  setCurrentAntrag(antrag, index): void {
    this.currentAntrag = antrag;
    this.currentIndex = index;
  }

  search(text: string, pipe: PipeTransform): Antrag[] {
    console.log('search: text===' + text);
    console.log('search: pipe===' + pipe);
    console.log('antrag filter beispiel: ' + this.antraege);
    return this.antraege.filter(antrag => {
      const term = text.toLowerCase();
      return antrag.antragsteller.toLowerCase().includes(term)
          || antrag.gestelltbei.toLowerCase().includes(term)
          || antrag.status.status.toLowerCase().includes(term);
    });
  }
}

And inside the html template I would use an <ng-container> to wait for the data to load first. Check below:

    id
    antragsteller
    gestellt bei
    Eingangsdatum
    Förderhöhe
    Status
    Aktion

  <ng-container *ngIf="antraege$ | async">

      {{antrag.id}}
      <ngb-highlight [result]="antrag.antragsteller" [term]="filterfcvar.value"></ngb-highlight>
      {{antrag.gestelltbei}}
      {{antrag.eingangsdatum}}
      {{antrag.foerderhoehe | currency:'EUR':true}}
      {{antrag.status}}

  </ng-container>

You can find a working example here bootstrap table filtering with async data


text:
Q: Grails 3.0 context path when deploying to external Tomcat Server I would like to deploy my Grails 3.0 application to an external Tomcat Server instance and not use the embedded tomcat 8 server. The issue I am running into is that there seems to be no way to set the context path when deploying the WAR file to an existing Tomcat 8 container.
In the grails 2.x line, the META-INF/MANIFEST.MF file that was generated contained the Webapp-Context attribute that contained the context path the app could be reached on. With grails 3.0 and deploying the WAR file, the context path is just the name of the war file (without the .war).
Setting server.contextPath in either the application.groovy or application.yml config files has no effect (these only seem to be used when using the embedded tomcat server).
How can I set the context path on Tomcat 8 for a Grails 3.0 war file?

A: I figured out a workaround. By default, grails 3.0 creates a war file of the form <app name>-<app version>.war, which causes the default context path to be <app name>-<app version>.
The fix I used was to edit the build.gradle file to customize the name of the war file. Using the documentation for Tomcat 8, I was able to change the war.archiveName property to
archiveName = "${project.name}##${project.version}.war"

This makes Tomcat 8 take the part before the ## as the context path and the part after the ## as the version. This works around the issue I was having.


text:
Q: Changing multiple elements with CSS? If this has been asked before I sincerely apologize. After around half an hour of searching I cannot seem to find one "best answer," and most solutions I have come across seem to involve JavaScript. While I am not totally opposed to JavaScript - HTML, CSS, and PHP are definitely my stronger skillsets. If this cannot be done without using JavaScript, I will probably need some serious baby talk. Here's my question:
I would like to change the background image of an one element as the hover state of an entirely separate element. Here is an example of how I would like this to work:
.some_element:hover {
    #some_unrelated_div {
         background-image: url('path/to/img.jpg');
    }
}

I hope that conveys a clear enough message of my ideal solution. Thanks guys.

A: CSS cannot accomplish this. CSS is meant to be read line-by-line and very quickly, so logic isn't something that should be done in CSS.
That being said, you can do this:
.some_element:hover #child_div {
  background-image: url('path/to/img.jpg');
}

Iff your HTML is similar to this:

Hello

This works because the selector matches the #child_div belonging to a :hovered .some_element.
If you plan on using jQuery, this skeleton code will accomplish the job:
$('#trigger').hover(function() {
  $('#some_element').css('background-image', 'url("foo.png")');
}, function() {
  $('#some_element').css('background-image', 'url("bar.png")');
});

A: This can be done in pure CSS but only if the element that you wish to change the background image of is a child of the element you are hovering over. For example:
#element1:hover #element2 {
    background-image: ...
}

If it is not a child then you will need JavaScript.

A: You must use a comma if you wish to apply the same styles to multiple selectors. If you only separate them by a space, it implies that the latter must be a child element of the former in order to match. What it sounds like you're asking for is:
.some_element:hover, #some_unrelated_div {
  background-image: url('path/to/img.jpg');
}

Translation to English: All elements hovered over with class "some_element", as well as the element with id "some_unrelated_div" will have background image path/to/img.jpg.

A: You will need to use Javascript / jQuery for this, as it is an event triggered by a hover event on another element (like a menu button, etc).
CSS will style the elements for you, and you can use something like toggle() in jQuery to achieve this, but you ultimately need to create this functionality using JS.

A: .some_element:hover #some_unrelated_div {
         background-image: url('path/to/img.jpg');
    }

this is the style that you want

A: You can use jQuery to achieve your desire. Here when ever user hovers the mouse on that element automatically jQuery Function will be called and after that you can put your own code to change the back-ground image url....
and if you want the reference then visit this link here

A: To my knowledge, CSS can't do this kind of stuff.  There MAY be a way to make a horrible chain of selectors if #some_unrelated_div is a distant child of .some_element.
Your best bet is including the jQuery library (like so):

Then, in a script tag or an included file, write the following jQuery:
[Untested, first-draft code]
//this just waits for the DOM to finish loading
$(function(){

    //this selects .some_element and waits for the "hover" event
    $('.some_element').hover(

        // This is the function that executes when hover STARTS.
        function(){

            // this selects #some_unrelated_div and edits its CSS (an object)
            $('#some_unrelated_div').css({
                'background-image' : "url('path/to/img.jpg')"
            });
        },

        // This is the function that executes when hover ENDS.
        function(){
            $('#some_unrelated_div').css({
                'background-image' : [original style]
            });
        }
    );
})

A: Maybe you could also do this with CSS.
But that's only possible if you have the div's somehow as adjacents.
I made you a JS-Fiddle: jsFiddle
The key part is this:
#hoveredDiv:hover ~ div > #target
{
    background-color: #f00;
}

Here is the link to the w3c Specs about the ~-Selector: Click me

A: You will need to use javascript or jQuery to achive this.
However there is a workaround to achieve only using css. And that is to use parent-child element relationship.
let us assume div2 is inside div1
so you will need to add css as

*

*#div1:hover #div2 {background-color:#F00}
If you don't want the div2 to look like inside div1 then you can add position:absulute to it. As below:

*

*#div1 {position:relative; width:100px; height:100px}

*#div2 {position:absolute; top:0; left:200px; height:100px}
But I will always like to use jQuery to do this.


text:
Q: Right Triangle calculations in C# Long time since high school.  If I have a right triangle, and know angle A, I'd like to work out the length of the side opposite it.  The c# cookbook page on this (http://www.gibmonks.com/c_sharp/csharpckbk2-CHP-1-SECT-14.html) suggests:
oppositeSide = Math.Sin(theta) * hypotenuse;
Assuming angle A (theta) is 45, and hypotenuse is 10 units long, this code gives me a result of 8.51.  At least 4 online triangle solvers give me an answer of 7.07 however ( eg http://www.cleavebooks.co.uk/scol/calrtri.htm, and http://www.endmemo.com/geometry/triangle.php).  This gives me serious doubts!
I'm not au fait enough in trig to see which is accurate, but I'd probably favour the internet calculators.
Can anyone assist on the correct formula to do this, or point me toward a useful c# right triangle solver class?
Thanks

A: From the documentation, the value of theta must be in radians. It looks like the online solvers you're using are interpreting theta in degrees.
You can convert from degrees to radians as follows:
theta = theta * Math.PI/180

A: You are specifying the angle in degrees, but the Math.Sin method takes radians.
You can convert degrees to radians using theta * 2 * PI / 360:
oppositeSide = Math.Sin(theta * 2.0 * Math.PI / 360.0) * hypotenuse;

A: Incidentally, for a right-angle triangle with one other angle known of 45deg, the 2 remaining sides are of equal length, and you can also calculate their lengths using this formula;
(a*a) + (b*b) = (c*c)

So, in this case;
(a*a) * (a*a) = (10*10)

(a*a) * (a*a) = 100

(a*a) = 100 / 2

a = sqrt(50)

Just as a another way to help you verify the result in this unique case, and prove that ~7.07 is the correct answer.

A: The sine of 45 degrees is .707.  Your calculations are incorrect.


text:
Q: Getting insert id with insert PDO MySQL Im getting to grips with the basics of PDO.
However Im trying to get the id of the inserted row, Im using:
$query = $system->db->prepare("INSERT INTO {$this->_table} (name,description) VALUES (:name,:description)");
$query->execute(array('name'=>$name,'description'=>$description));

The tutorials I have come across are regarding transactions, however I am not using transactions!

A: You're probably looking for lastInsertId. "Returns the ID of the last inserted row or sequence value".
$insertedId = $system->db->lastInsertId() ;

A: Pay attention when using transactions.
If you call lastInsertedId after you call commit, lastInsertedId will return 0 instead of the id.
Call lastInsertedId right after execute, but before commit.
$this->db->beginTransaction();
$this->stmt->execute();
$id = $this->db->lastInsertId();
$this->db->commit();


text:
Q: Download 1 blob from 200 containers I have got more than 200 containers and I need to download 1 blob from every container. If I will download each blob in loop it's take a lot of time. For this reason I decided to download blobs parallel.
let testFunctions = [];

containers.array.forEach( container => {
  testFunctions.push(
        (callback) => {
            that.blobService.getBlobToText(container, 'container/' + date, (error: any, blob: any) => {
                if (blob!== null) {
                    callback(null, blob);
                } else {
                    callback(error, null);
                }
            });
        }
    )
});

async.parallel(testFunctions, async (error, blobs) => {
          //Todo
});

But after some requests I have got this error:
{ Error: connect ETIMEDOUT 1.2.3.4:443
    at Object.exports._errnoException (util.js:1022:11)
    at exports._exceptionWithHostPort (util.js:1045:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1087:14)
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '1.2.3.4',
  port: 443 } ,

Can you help me to solve this problem or do you know another way how can I fast download blobs frome more than 200 containers?
P.s. I'm using azure-storage V 2.3.0 & nodejs


text:
Q: Should a mysql slave answer queries much slower then the master? I am seeing a slight issue on a mysql slave server, or at least on the surface it appears there might be an issue.
Both mysql's are virtual machines
The master and slave are the same OS (debian10) and the sql's are the same version, 10.3.27, and were installed installed only half-hour apart.
The replication itself works great, and most writes to the slave appear within seconds including new db's, changed data etc.
I have run a few tests recently, where I change some wordpress config's to point at the ip of the slave instead of the master so I can feel a bit more comfortable all is working well with replication and as a disaster recovery test.
The problem is any sites utilizing the slave for sql data are horribly slow, and as soon as I change the ip back to the master speed returns.
Keep in mind, in this scenario the web server never changes.
In this scenario, NEITHER sql server touches the internet as the public cards are disabled on both master and slave.
Both sql servers have absolutely nothing else installed on them and are stock Debian, maria and webmin.
Private traffic and public traffic are on different subnets and different vlans in the switch so completely segmented. (untagged)
I have tried moving the virtual machine to different hosts and it does not have any effect.
I have tried clearing the web server cache and even restarting the web server.
Ping times to the ip's of each sql server are identical at 1ms or less.
Both have identical firewall rules, and tests where firewall is disabled there is no change.
Before anyone suggests switch ports, this also happens even when both VM's are on the same physical host, so the PRIVATE traffic would be going in and out the same NIC's and traversing the same port on the switch.
I have not enabled any automatic failover, but before I even begin to think about that I would like to see this issue resolved. We are talking of cases where a small site that may take a few seconds to load on the master suddenly taking 10 to 20 or even 30 seconds for a page load.
Now I understand a slave is not exactly designed for the reads, but is it normal for a slave to be a half minute slower on the query then the master?
I have done a bit of searching and have yet to see anyone talk about this, but most query's on the subject start talking about the replication traffic itself being slow, or the time factor for the slave to catch up from the replication log files etc from the master, but none of that is the case, replication itself is pretty darn close to instant.
I hope I explained the situation clearly and if anyone has things to try let me know.
Universal4


text:
Q: Qt .pro file get Qtkit name I have a Qt project that is dependent on other 3rd party libraries that I've compiled from source. When compiling these 3rd party libraries I specify what Qt kit to use for compiling (as these 3rd party libs are dependent on Qt)
For example, these 3rd party libs might have been compiled using Qt5.9.2_x64_msvc2015, they also might have been compiled using Qt5.7.2_x64_msvc2013.
So in the project I'm developing, if I want to compile using the Qt5.9.2_x64_msvc2015 kit, then I would like the project to automatically switch the LIBS and INCLUDEPATH to the 3rd party libraries that I compiled with the same Qt kit.
I know I can use the QT_MAJOR_VERSION, QT_MINOR_VERSION, and QT_PATCH_VERSION to check what "version" of the qt kit I'm using, but how could I get in the .pro file if the kit being used is x64 vs x86 as well as msvc2013 vs msvc2015?

A: Looks  like I figured it out on my own. The term I was looking for was stored in the CONFIG variable.
if you do a message($$CONFIG), you will see a whole bunch of stuff printed, but the one you're looking for is the win32-msvc2013 or win32-msvc2015 items.
So a check on this would look something like the following:
CONFIG("win32-msvc2013") {
    # do something specific to the msvc2013 kit
}
CONFIG("win32-msvc2015") {
    # do something else specific to the msvc2015 kit
}


text:
Q: Search results missing for web application for external connections We have SharePoint exposed externally via ForeFront TMG.  The SSL connection terminates at TMG and is then proxyed internally over HTTP.
Our "hosted" application is accessed internally by http://hosted.corp.com and the same app externally is accessed by https://hosted.corp.com. Internally all results show up fine, but externally we get no results.
Our other web applications which are crawled by the same service work fine internally and externally.


text: Q: Can i get Xpath from UIAutomator Viewer in Appium? How can i get Xpath or css path from UIAutomator Viewer, am testing android app in my case there is no id,name. It's showing only the index and classname.


text:
Q: Leading 0xff in C structure components in the output Something of the strangest nature is happening. Follows the code:
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>

struct s
{
  char a;
  char b;
  char c;

  unsigned int d;
  unsigned int e;
}__attribute__((packed));

int main(void)
{
  struct s *m = (void *)malloc(sizeof (struct s));
  assert(m);

  m->a=0x33;
  m->b=0x33;
  m->c=0x33;
  m->d=0xabcdefab;
  m->e=0x12345678;
  *(char *)(m + 1) = 0;

  while (*((char*)m))
  {
    printf("%p -> %x\n", m, *((char *)m));
    m = (struct s *)((char*) m + 1);
  }
}

And here is the output:
0x85a010 -> 33
0x85a011 -> 33
0x85a012 -> 33
0x85a013 -> ffffffab
0x85a014 -> ffffffef
0x85a015 -> ffffffcd
0x85a016 -> ffffffab
0x85a017 -> 78
0x85a018 -> 56
0x85a019 -> 34
0x85a01a -> 12

By now, you probably have spotted the bizareness in the output. Indeed, there are no '0xff' in memory at addresses 0x85a013 to 0x85a016, nor is there 4 bytes per byte?!?! (I mean, is that even logical ?). It seems to me that it is a display problem, but I cannot figure out why or how.

A: EDIT
Change (char *) casts to (unsigned char *). And to prevent undefined behaviour, don't try to post a sentinel, but work with the struct size. My version:
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>

#pragma pack(push, 1)
struct s
{
    char a;
    char b;
    char c;
    unsigned int d;
    unsigned int e;
};
#pragma pack(pop)

int main(void)
{
    int i;
    unsigned char *cptr;
    struct s *m = malloc(sizeof (struct s));
    assert(m);

    m->a=0x33;
    m->b=0x33;
    m->c=0x33;
    m->d=0xabcdefab;
    m->e=0x12345678;

    cptr = (unsigned char*)m;
    for (i=0; i<sizeof(struct s); i++)
        printf("%p -> %02x\n", (void*)(cptr+i), cptr[i]);
}

Program output:
001C2DD0 -> 33
001C2DD1 -> 33
001C2DD2 -> 33
001C2DD3 -> ab
001C2DD4 -> ef
001C2DD5 -> cd
001C2DD6 -> ab
001C2DD7 -> 78
001C2DD8 -> 56
001C2DD9 -> 34
001C2DDA -> 12

A: This is being caused by signed integer promotion. The printf specifier for %x wants at least a full sized int value.
And to avoid various problems with value sizes, variable argument functions like printf convert values into at least int and double sizes.
That means that a signed char value like 0xab is sign-extended to a 32-bit 0xffffffab

A: Format specifier %x requires unsigned int argument in printf. Using an int argument in its place is only allowed if the int value is non-negative. If the value is negative, the behavior is undefined.
You are passing a char argument for %x format specifier. A variadic char argument gets automatically converted to int and passed as int. If the original char (and therefore the resultant int) happens to have a negative value, the behavior is undefined. This is apparently what happens in your case. Your ff output is a consequence of your invalid attempts to print negative int values by using %x format specifier.
You can fix your broken code in several different ways. For example, you can convert the printf argument to unsigned int type explicitly
printf("%p -> %x\n", (void *) m, (unsigned) *((char *)m));

This will get rid of the undefined behavior, but will most likely leave the output unchanged. Now the ff will appear as a [perfectly defined] consequence of modulo conversion of negative value to unsigned int type.
This
m = (struct s *)((char*) m + 1);

is also a formally questionable practice. The language does not guarantee you that a struct pointer can preserve the exact value of a char * pointer.


text:
Q: Selecting Unread Documents in PostgreSQL (JOINS?) I have a PostgreSQL table containing users, a PostgreSQL table containing documents, and a table mapping the users to the documents they've read. Like so:
Table: users
------------
| oid      |
| username |
| ...      |
------------

Table: documents
------------
| oid      |
| title    |
| ...      |
------------

Table: users_documents
-----------------
| oid           |
| user_oid      |
| document_oid  |
-----------------

Whenever a user reads a document, a record is added to users_documents with their user id and the document id. This is all working fine.
What I want to do though is select a random unread document for a given user. I feel like I should be able to do this with a fairly simple JOIN, but I can't get my head around exactly what the query should look like.
Can someone help please? Thanks.

A: For most data, you can go to the users_documents table.  For instance,
a query of the documents read by user_oid = ? would be
SELECT document_oid
FROM users_documents
WHERE user_oid = ?

However, you want the records which are missing.
You can do an outer join, and find the NULLs in the results.
SELECT users_documents.document_oid
FROM users_documents
  RIGHT OUTER JOIN documents
    ON users_documents.document_oid = documents.oid AND users_documents.user_oid = ?

It is important that the "users_documents.user_oid = ?" be in the join in the FROM clause rather than in a WHERE clause, because it would not work in the WHERE clause.


text:
Q: Angular 2+ and debounce In AngularJS I was able to debounce a model by using ng-model options.
ng-model-options="{ debounce: 1000 }"

How can I debounce a model in Angular?
I tried to search for debounce in the docs but I couldn't find anything.
https://angular.io/search/#stq=debounce&stp=1
A solution would be to write my own debounce function, for example:
import {Component, Template, bootstrap} from 'angular2/angular2';

// Annotation section
@Component({
  selector: 'my-app'
})
@Template({
  url: 'app.html'
})
// Component controller
class MyAppComponent {
  constructor() {
    this.firstName = 'Name';
  }

  changed($event, el){
    console.log("changes", this.name, el.value);
    this.name = el.value;
  }

  firstNameChanged($event, first){
    if (this.timeoutId) window.clearTimeout(this.timeoutID);
    this.timeoutID = window.setTimeout(() => {
        this.firstName = first.value;
    }, 250)
  }

}
bootstrap(MyAppComponent);

And my html
<input type=text [value]="firstName" #first (keyup)="firstNameChanged($event, first)">

But I'm looking for a built in function, is there one in Angular?

A: Solution with initialization subscriber directly in event function:
import {Subject} from 'rxjs';
import {debounceTime, distinctUntilChanged} from 'rxjs/operators';

class MyAppComponent {
    searchTermChanged: Subject<string> = new Subject<string>();

    constructor() {
    }

    onFind(event: any) {
        if (this.searchTermChanged.observers.length === 0) {
            this.searchTermChanged.pipe(debounceTime(1000), distinctUntilChanged())
                .subscribe(term => {
                    // your code here
                    console.log(term);
                });
        }
        this.searchTermChanged.next(event);
    }
}

And html:
<input type="text" (input)="onFind($event.target.value)">

A: Since the topic is old, most of the answers don't work on Angular 6-13 and/or use other libs.
So here is a short and simple solution for Angular 6+ with RxJS.
Import the necessary stuff first:
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Subject, Subscription } from 'rxjs';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';

Implement the ngOnInit and ngOnDestroy:
export class MyComponent implements OnInit, OnDestroy {
  public notesText: string;
  public notesModelChanged: Subject<string> = new Subject<string>();
  private notesModelChangeSubscription: Subscription

  constructor() { }

  ngOnInit() {
    this.notesModelChangeSubscription = this.notesModelChanged
      .pipe(
        debounceTime(2000),
        distinctUntilChanged()
      )
      .subscribe(newText => {
        this.notesText = newText;
        console.log(newText);
      });
  }

  ngOnDestroy() {
    this.notesModelChangeSubscription.unsubscribe();
  }
}

Use this way:
<input [ngModel]='notesText' (ngModelChange)='notesModelChanged.next($event)' />

P.S. For more complex and efficient solutions you might still want to check other answers.

A: I solved this by writing a debounce decorator. The problem described could be solved by applying the @debounceAccessor to the property's set accessor.
I've also supplied an additional debounce decorator for methods, which can be useful for other occasions.
This makes it very easy to debounce a property or a method. The parameter is the number of milliseconds the debounce should last, 100 ms in the example below.
@debounceAccessor(100)
set myProperty(value) {
  this._myProperty = value;
}

@debounceMethod(100)
myMethod (a, b, c) {
  let d = a + b + c;
  return d;
}

And here's the code for the decorators:
function debounceMethod(ms: number, applyAfterDebounceDelay = false) {

  let timeoutId;

  return function (target: Object, propName: string, descriptor: TypedPropertyDescriptor<any>) {
    let originalMethod = descriptor.value;
    descriptor.value = function (...args: any[]) {
      if (timeoutId) return;
      timeoutId = window.setTimeout(() => {
        if (applyAfterDebounceDelay) {
          originalMethod.apply(this, args);
        }
        timeoutId = null;
      }, ms);

      if (!applyAfterDebounceDelay) {
        return originalMethod.apply(this, args);
      }
    }
  }
}

function debounceAccessor (ms: number) {

  let timeoutId;

  return function (target: Object, propName: string, descriptor: TypedPropertyDescriptor<any>) {
    let originalSetter = descriptor.set;
    descriptor.set = function (...args: any[]) {
      if (timeoutId) return;
      timeoutId = window.setTimeout(() => {
        timeoutId = null;
      }, ms);
      return originalSetter.apply(this, args);
    }
  }
}

I added an additional parameter for the method decorator which let's you trigger the method AFTER the debounce delay. I did that so I could for instance use it when coupled with mouseover or resize events, where I wanted the capturing to occur at the end of the event stream. In this case however, the method won't return a value.

A: We can create a [debounce] directive which overwrites ngModel's default viewToModelUpdate function with an empty one.
Directive Code
@Directive({ selector: '[debounce]' })
export class MyDebounce implements OnInit {
    @Input() delay: number = 300;

    constructor(private elementRef: ElementRef, private model: NgModel) {
    }

    ngOnInit(): void {
        const eventStream = Observable.fromEvent(this.elementRef.nativeElement, 'keyup')
            .map(() => {
                return this.model.value;
            })
            .debounceTime(this.delay);

        this.model.viewToModelUpdate = () => {};

        eventStream.subscribe(input => {
            this.model.viewModel = input;
            this.model.update.emit(input);
        });
    }
}

How to use it

  <input debounce [delay]=500 [(ngModel)]="myData" type="text">

A: It could be implemented as Directive
import { Directive, Input, Output, EventEmitter, OnInit, OnDestroy } from '@angular/core';
import { NgControl } from '@angular/forms';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
import { Subscription } from 'rxjs';

@Directive({
  selector: '[ngModel][onDebounce]',
})
export class DebounceDirective implements OnInit, OnDestroy {
  @Output()
  public onDebounce = new EventEmitter<any>();

  @Input('debounce')
  public debounceTime: number = 300;

  private isFirstChange: boolean = true;
  private subscription: Subscription;

  constructor(public model: NgControl) {
  }

  ngOnInit() {
    this.subscription =
      this.model.valueChanges
        .debounceTime(this.debounceTime)
        .distinctUntilChanged()
        .subscribe(modelValue => {
          if (this.isFirstChange) {
            this.isFirstChange = false;
          } else {
            this.onDebounce.emit(modelValue);
          }
        });
  }

  ngOnDestroy() {
    this.subscription.unsubscribe();
  }

}

use it like
<input [(ngModel)]="value" (onDebounce)="doSomethingWhenModelIsChanged($event)">

component sample
import { Component } from "@angular/core";

@Component({
  selector: 'app-sample',
  template: `
<input[(ngModel)]="value" (onDebounce)="doSomethingWhenModelIsChanged($event)">
<input[(ngModel)]="value" (onDebounce)="asyncDoSomethingWhenModelIsChanged($event)">
`
})
export class SampleComponent {
  value: string;

  doSomethingWhenModelIsChanged(value: string): void {
    console.log({ value });
  }

  async asyncDoSomethingWhenModelIsChanged(value: string): Promise<void> {
    return new Promise<void>(resolve => {
      setTimeout(() => {
        console.log('async', { value });
        resolve();
      }, 1000);
    });
  }
}

A: Not directly accessible like in angular1 but you can easily play with NgFormControl and RxJS observables:
<input type="text" [ngFormControl]="term"/>

this.items = this.term.valueChanges
  .debounceTime(400)
  .distinctUntilChanged()
  .switchMap(term => this.wikipediaService.search(term));

This blog post explains it clearly:
http://blog.thoughtram.io/angular/2016/01/06/taking-advantage-of-observables-in-angular2.html
Here it is for an autocomplete but it works all scenarios.

A: HTML file:
<input [ngModel]="filterValue"
       (ngModelChange)="filterValue = $event ; search($event)"
        placeholder="Search..."/>

TS file:
timer = null;
time = 250;
  search(searchStr : string) : void {
    clearTimeout(this.timer);
    this.timer = setTimeout(()=>{
      console.log(searchStr);
    }, time)
  }

A: DebounceTime in Angular 7 with RxJS v6
Source Link
Demo Link

In HTML Template
<input type="text" #movieSearchInput class="form-control"
            placeholder="Type any movie name" [(ngModel)]="searchTermModel" />

In component
    ....
    ....
    export class AppComponent implements OnInit {

    @ViewChild('movieSearchInput') movieSearchInput: ElementRef;
    apiResponse:any;
    isSearching:boolean;

        constructor(
        private httpClient: HttpClient
        ) {
        this.isSearching = false;
        this.apiResponse = [];
        }

    ngOnInit() {
        fromEvent(this.movieSearchInput.nativeElement, 'keyup').pipe(
        // get value
        map((event: any) => {
            return event.target.value;
        })
        // if character length greater then 2
        ,filter(res => res.length > 2)
        // Time in milliseconds between key events
        ,debounceTime(1000)
        // If previous query is diffent from current
        ,distinctUntilChanged()
        // subscription for response
        ).subscribe((text: string) => {
            this.isSearching = true;
            this.searchGetCall(text).subscribe((res)=>{
            console.log('res',res);
            this.isSearching = false;
            this.apiResponse = res;
            },(err)=>{
            this.isSearching = false;
            console.log('error',err);
            });
        });
    }

    searchGetCall(term: string) {
        if (term === '') {
        return of([]);
        }
        return this.httpClient.get('http://www.omdbapi.com/?s=' + term + '&apikey=' + APIKEY,{params: PARAMS.set('search', term)});
    }

    }

A: You could also solve this by using a decorators, For an instance by using the debounce decorator from utils-decorator lib (npm install utils-decorators):
import {debounce} from 'utils-decorators';

class MyAppComponent {

  @debounce(500)
  firstNameChanged($event, first) {
   ...
  }
}

A: You can create an RxJS (v.6) Observable that does whatever you like.
view.component.html
<input type="text" (input)="onSearchChange($event.target.value)" />

view.component.ts
import { Observable } from 'rxjs';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';

export class ViewComponent {
    searchChangeObserver;

  onSearchChange(searchValue: string) {

    if (!this.searchChangeObserver) {
      new Observable(observer => {
        this.searchChangeObserver = observer;
      }).pipe(debounceTime(300)) // wait 300ms after the last event before emitting last event
        .pipe(distinctUntilChanged()) // only emit if value is different from previous value
        .subscribe(console.log);
    }

    this.searchChangeObserver.next(searchValue);
  }

}

A: Updated for RC.5
With Angular 2 we can debounce using RxJS operator debounceTime() on a form control's valueChanges observable:
import {Component}   from '@angular/core';
import {FormControl} from '@angular/forms';
import {Observable}  from 'rxjs/Observable';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/throttleTime';
import 'rxjs/add/observable/fromEvent';

@Component({
  selector: 'my-app',
  template: `<input type=text [value]="firstName" [formControl]="firstNameControl">

{{firstName}}`
})
export class AppComponent {
  firstName        = 'Name';
  firstNameControl = new FormControl();
  formCtrlSub: Subscription;
  resizeSub:   Subscription;
  ngOnInit() {
    // debounce keystroke events
    this.formCtrlSub = this.firstNameControl.valueChanges
      .debounceTime(1000)
      .subscribe(newValue => this.firstName = newValue);
    // throttle resize events
    this.resizeSub = Observable.fromEvent(window, 'resize')
      .throttleTime(200)
      .subscribe(e => {
        console.log('resize event', e);
        this.firstName += '*';  // change something to show it worked
      });
  }
  ngDoCheck() { console.log('change detection'); }
  ngOnDestroy() {
    this.formCtrlSub.unsubscribe();
    this.resizeSub  .unsubscribe();
  }
}

Plunker
The code above also includes an example of how to throttle window resize events, as asked by @albanx in a comment below.

Although the above code is probably the Angular-way of doing it, it is not efficient.  Every keystroke and every resize event, even though they are debounced and throttled, results in change detection running.  In other words, debouncing and throttling do not affect how often change detection runs. (I found a GitHub comment by Tobias Bosch that confirms this.)  You can see this when you run the plunker and you see how many times ngDoCheck() is being called when you type into the input box or resize the window. (Use the blue "x" button to run the plunker in a separate window to see the resize events.)
A more efficient technique is to create RxJS Observables yourself from the events, outside of Angular's "zone".  This way, change detection is not called each time an event fires. Then, in your subscribe callback methods, manually trigger change detection – i.e., you control when change detection is called:
import {Component, NgZone, ChangeDetectorRef, ApplicationRef,
        ViewChild, ElementRef} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/throttleTime';
import 'rxjs/add/observable/fromEvent';

@Component({
  selector: 'my-app',
  template: `<input #input type=text [value]="firstName">

{{firstName}}`
})
export class AppComponent {
  firstName = 'Name';
  keyupSub:  Subscription;
  resizeSub: Subscription;
  @ViewChild('input') inputElRef: ElementRef;
  constructor(private ngzone: NgZone, private cdref: ChangeDetectorRef,
    private appref: ApplicationRef) {}
  ngAfterViewInit() {
    this.ngzone.runOutsideAngular( () => {
      this.keyupSub = Observable.fromEvent(this.inputElRef.nativeElement, 'keyup')
        .debounceTime(1000)
        .subscribe(keyboardEvent => {
          this.firstName = keyboardEvent.target.value;
          this.cdref.detectChanges();
        });
      this.resizeSub = Observable.fromEvent(window, 'resize')
        .throttleTime(200)
        .subscribe(e => {
          console.log('resize event', e);
          this.firstName += '*';  // change something to show it worked
          this.cdref.detectChanges();
        });
    });
  }
  ngDoCheck() { console.log('cd'); }
  ngOnDestroy() {
    this.keyupSub .unsubscribe();
    this.resizeSub.unsubscribe();
  }
}

Plunker
I use ngAfterViewInit() instead of ngOnInit() to ensure that inputElRef is defined.
detectChanges() will run change detection on this component and its children. If you would rather run change detection from the root component (i.e., run a full change detection check) then use ApplicationRef.tick() instead.  (I put a call to ApplicationRef.tick() in comments in the plunker.) Note that calling tick() will cause ngDoCheck() to be called.

A: Simple solution would be to create a directive which you can apply to any control.
import { Directive, ElementRef, Input, Renderer, HostListener, Output, EventEmitter } from '@angular/core';
import { NgControl } from '@angular/forms';

@Directive({
    selector: '[ngModel][debounce]',
})
export class Debounce
{
    @Output() public onDebounce = new EventEmitter<any>();

    @Input('debounce') public debounceTime: number = 500;

    private modelValue = null;

    constructor(public model: NgControl, el: ElementRef, renderer: Renderer){
    }

    ngOnInit(){
        this.modelValue = this.model.value;

        if (!this.modelValue){
            var firstChangeSubs = this.model.valueChanges.subscribe(v =>{
                this.modelValue = v;
                firstChangeSubs.unsubscribe()
            });
        }

        this.model.valueChanges
            .debounceTime(this.debounceTime)
            .distinctUntilChanged()
            .subscribe(mv => {
                if (this.modelValue != mv){
                    this.modelValue = mv;
                    this.onDebounce.emit(mv);
                }
            });
    }
}

usage would be
<textarea [ngModel]="somevalue"
          [debounce]="2000"
          (onDebounce)="somevalue = $event"
          rows="3">
</textarea>

A: If you don't want to deal with @angular/forms, you can just use an RxJS Subject with change bindings.
view.component.html
<input [ngModel]='model' (ngModelChange)='changed($event)' />

view.component.ts
import { Subject } from 'rxjs';
import { Component }   from '@angular/core';
import 'rxjs/add/operator/debounceTime';

export class ViewComponent {
    model: string;
    modelChanged: Subject<string> = new Subject<string>();

    constructor() {
        this.modelChanged
            .debounceTime(300) // wait 300ms after the last event before emitting last event
            .distinctUntilChanged() // only emit if value is different from previous value
            .subscribe(model => this.model = model);
    }

    changed(text: string) {
        this.modelChanged.next(text);
    }
}

This does trigger change detection. For a way that doesn't trigger change detection, check out Mark's answer.

Update
.pipe(debounceTime(300), distinctUntilChanged()) is needed for rxjs 6.
Example:
   constructor() {
        this.modelChanged.pipe(
            debounceTime(300),
            distinctUntilChanged())
            .subscribe(model => this.model = model);
    }

A: For anyone using lodash, it is extremely easy to debounce any function:
changed = _.debounce(function() {
    console.log("name changed!");
}, 400);

then just throw something like this into your template:
<(input)="changed($event.target.value)" />

A: Spent hours on this, hopefully I can save someone else some time.  To me the following approach to using debounce on a control is more intuitive and easier to understand for me.  It's built on the angular.io docs solution for autocomplete but with the ability for me to intercept the calls without having to depend on tying the data to the DOM.
Plunker
A use case scenario for this might be checking a username after it's typed to see if someone has already taken it, then warning the user.
Note: don't forget, (blur)="function(something.value) might make more sense for you depending on your needs.

A: This is the best solution I have found till now. Updates the ngModelon blur and debounce
import { Directive, Input, Output, EventEmitter,ElementRef } from '@angular/core';
import { NgControl, NgModel } from '@angular/forms';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/fromEvent';
import 'rxjs/add/operator/map';

@Directive({
    selector: '[ngModel][debounce]',
})
export class DebounceDirective {
    @Output()
    public onDebounce = new EventEmitter<any>();

    @Input('debounce')
    public debounceTime: number = 500;

    private isFirstChange: boolean = true;

    constructor(private elementRef: ElementRef, private model: NgModel) {
    }

    ngOnInit() {
        const eventStream = Observable.fromEvent(this.elementRef.nativeElement, 'keyup')
            .map(() => {
                return this.model.value;
            })
            .debounceTime(this.debounceTime);

        this.model.viewToModelUpdate = () => {};

        eventStream.subscribe(input => {
            this.model.viewModel = input;
            this.model.update.emit(input);
        });
    }
}

as borrowed from https://stackoverflow.com/a/47823960/3955513
Then in HTML:
<input [(ngModel)]="hero.name"
        [debounce]="3000"
        (blur)="hero.name = $event.target.value"
        (ngModelChange)="onChange()"
        placeholder="name">

On blur the model is explicitly updated using plain javascript.
Example here: https://stackblitz.com/edit/ng2-debounce-working


text:
Q: How to exclude a certain number of entries when calling upon a json feed Here's a simple script that displays two latest posts under a certain label (in this example, the label "main"), in some section of a Blogger blog.

Note that HMTL7 is the id that has been automatically assigned by Blogger to my HTML/Javascript-widget, which constitutes a div element by itself.
I have intentionally skipped including any post title variable in the script, so I'm just displaying the posts' content - no more, no less.
What I'd like to do is have two of these scripts for two different sections of my blog, where the second one would omit the two latest posts under the "main" label (same for both scripts), since they are already displayed by means of the first script.
What would I have to add to the second script to achieve this?

A: Initialize for loop variable with 2 var i = 2; and maximum results 4 max-results=4

A: Add the start-index query parameter in the script src and initialize it from 3 (as the 1st and 2nd post would already be shown via the first instance of the code in the other section. The new code will look like -

The exact ID of HTML widget will depend on your blog (mainly it will be different from HTML7)


text:
Q: Manually customize position of Winter Bash hats
Possible Duplicate:
Allow more specific positioning of hats?
Can we resize hats?

I really like the idea of Winter Bash. But unfortunately all the hats I have do not fit on my picture :(
It would be really cool and nice if we can drag the hat and manually adjust the position of hat?

A: The best bet for you right now would be to customize your own profile picture to get it aligned with the hat. I don't see anything in the near future happening in the direction you requested to let users drop the hat where they want.


text:
Q: Program saying the ".move" function does not exist I have some code to make a circle with a certain size location and color move around on the screen. This is my first attempt to do something like this with objects as the first time I did this I hardcoded it all.
import tkinter as tk

class Head:

    def __init__(self, location, color, size, speed):
        self.location = location
        self.color = color
        self.size = size
        self.speed = speed

player = Head([375, 375], "orange4", 75, 5)

def movement(event, mover):
    key = event.keysym
    if key == "Right":
        window.move(mover, player.speed, 0)
    elif key == "Left":
        window.move(mover, -player.speed, 0)
    elif key == "Up":
        window.move(mover, 0, -player.speed)
    elif key == "Down":
        window.move(mover, 0, player.speed)

window = tk.Tk()
window.title("Tour")
display = tk.Canvas(window, width=750, height=750)
display.pack()

player = display.create_oval((player.location[0] - (player.size / 2)), (player.location[1] - (player.size / 2)),
                             (player.location[0] + (player.size / 2)), (player.location[1] + (player.size / 2)),
                             fill=player.color)
window.bind_all("<Key>", lambda event: movement(event, mover=player))

window.mainloop()

When I run this code I get the error
AttributeError: '_tkinter.tkapp' object has no attribute 'move'
when I try to move with the arrow keys. I tried changing the window variable to the player and the display variables but it still did not work.
After what jasonharper and acw1668  said I changed to code to this:
import tkinter as tk

class Head:

    def __init__(self, location, color, size, speed):
        self.location = location
        self.color = color
        self.size = size
        self.speed = speed

player = Head([375, 375], "orange4", 75, 5)

def movement(event, mover):
    key = event.keysym
    if key == "Right":
        display.move(mover, player.speed, 0)
    elif key == "Left":
        display.move(mover, -player.speed, 0)
    elif key == "Up":
        display.move(mover, 0, -player.speed)
    elif key == "Down":
        display.move(mover, 0, player.speed)

window = tk.Tk()
window.title("Tour")
display = tk.Canvas(window, width=750, height=750)
display.pack()

drawn_player = display.create_oval((player.location[0] - (player.size / 2)), (player.location[1] - (player.size / 2)),
                             (player.location[0] + (player.size / 2)), (player.location[1] + (player.size / 2)),
                             fill=player.color)
window.bind_all("<Key>", lambda event: movement(event, mover=player))

window.mainloop()

Now while there are no errors, the circle does not move. What is wrong?

A: Besides the problem referring to the canvas in the movement() function, you also have two variables named player which will cause a new problem. I fix the latter by renaming the second one to player_drawn and all the references to it.
The code now works and moves the oval.
import tkinter as tk

class Head:

    def __init__(self, location, color, size, speed):
        self.location = location
        self.color = color
        self.size = size
        self.speed = speed

player = Head([375, 375], "orange4", 75, 5)

def movement(event, mover):
    key = event.keysym
    if key == "Right":
        display.move(mover, player.speed, 0)
    elif key == "Left":
        display.move(mover, -player.speed, 0)
    elif key == "Up":
        display.move(mover, 0, -player.speed)
    elif key == "Down":
        display.move(mover, 0, player.speed)

window = tk.Tk()
window.title("Tour")
display = tk.Canvas(window, width=750, height=750)
display.pack()

drawn_player = display.create_oval((player.location[0] - (player.size / 2)),
                                   (player.location[1] - (player.size / 2)),
                                   (player.location[0] + (player.size / 2)),
                                   (player.location[1] + (player.size / 2)),
                                   fill=player.color)
window.bind_all("<Key>", lambda event: movement(event, mover=drawn_player))

window.mainloop()


text:
Q: centos 7 VM keep shutdown and restart automatically for unknown reason centos 7 VM keep shutdown and restart automatically for unknown reason.
I have checked my log messages, But I can't find what is the exact reason?. Please give any suggestions. I have attached my system messages below.
Nov 12 00:45:55 my01vps2018 systemd: Starting Security Auditing Service...
Nov 12 00:45:55 my01vps2018 augenrules: /sbin/augenrules: No change
Nov 12 00:45:55 my01vps2018 auditd[820]: Started dispatcher: /sbin/audispd pid: 833
Nov 12 00:45:55 my01vps2018 kernel: type=1305 audit(1541972755.424:3): audit_pid=820 old=0 auid=4294967295 ses=4294967295 res=1
Nov 12 00:45:55 my01vps2018 auditd[820]: Init complete, auditd 2.4.1 listening for events (startup state enable)
Nov 12 00:45:55 my01vps2018 audispd: No plugins found, exiting
Nov 12 00:45:55 my01vps2018 augenrules: No rules
Nov 12 00:45:55 my01vps2018 augenrules: enabled 1
Nov 12 00:45:55 my01vps2018 augenrules: flag 1
Nov 12 00:45:55 my01vps2018 augenrules: pid 820
Nov 12 00:45:55 my01vps2018 augenrules: rate_limit 0
Nov 12 00:45:55 my01vps2018 augenrules: backlog_limit 320
Nov 12 00:45:55 my01vps2018 augenrules: lost 0
Nov 12 00:45:55 my01vps2018 augenrules: backlog 1
Nov 12 00:45:55 my01vps2018 systemd: Started Security Auditing Service.
Nov 12 00:45:55 my01vps2018 systemd: Starting Update UTMP about System Boot/Shutdown...
Nov 12 00:45:55 my01vps2018 systemd: Started Update UTMP about System Boot/Shutdown.
Nov 12 00:45:55 my01vps2018 systemd: Reached target System Initialization.
Nov 12 00:45:55 my01vps2018 systemd: Starting System Initialization.
Nov 12 00:45:55 my01vps2018 systemd: Started Flexible branding.
Nov 12 00:45:55 my01vps2018 systemd: Starting Flexible branding.
Nov 12 00:45:55 my01vps2018 systemd: Reached target Paths.
Nov 12 00:45:55 my01vps2018 systemd: Starting Paths.
Nov 12 00:45:55 my01vps2018 systemd: Started Daily Cleanup of Temporary Directories.
Nov 12 00:45:55 my01vps2018 systemd: Starting Daily Cleanup of Temporary Directories.
Nov 12 00:45:55 my01vps2018 systemd: Reached target Timers.
Nov 12 00:45:55 my01vps2018 systemd: Starting Timers.
Nov 12 00:45:55 my01vps2018 systemd: Listening on D-Bus System Message Bus Socket.
Nov 12 00:45:55 my01vps2018 systemd: Starting D-Bus System Message Bus Socket.
Nov 12 00:45:55 my01vps2018 systemd: Listening on RPCbind Server Activation Socket.
Nov 12 00:45:55 my01vps2018 systemd: Starting RPCbind Server Activation Socket.
Nov 12 00:45:55 my01vps2018 systemd: Reached target Sockets.
Nov 12 00:45:55 my01vps2018 systemd: Starting Sockets.
Nov 12 00:45:55 my01vps2018 systemd: Reached target Basic System.
Nov 12 00:45:55 my01vps2018 systemd: Starting Basic System.
Nov 12 00:45:55 my01vps2018 systemd: Started D-Bus System Message Bus.
Nov 12 00:45:55 my01vps2018 systemd: Starting D-Bus System Message Bus...
Nov 12 00:45:55 my01vps2018 systemd: Started irqbalance daemon.
Nov 12 00:45:55 my01vps2018 systemd: Starting irqbalance daemon...
Nov 12 00:45:55 my01vps2018 systemd: Started libstoragemgmt plug-in server daemon.
Nov 12 00:45:55 my01vps2018 systemd: Starting libstoragemgmt plug-in server daemon...
Nov 12 00:45:55 my01vps2018 systemd: Starting GSSAPI Proxy Daemon...
Nov 12 00:45:55 my01vps2018 systemd: Starting Resets System Activity Logs...
Nov 12 00:45:55 my01vps2018 systemd: Starting Login Service...
Nov 12 00:45:55 my01vps2018 systemd: Started Hardware RNG Entropy Gatherer Daemon.
Nov 12 00:45:55 my01vps2018 systemd: Starting Hardware RNG Entropy Gatherer Daemon...
Nov 12 00:45:55 my01vps2018 systemd: Started Load CPU microcode update.
Nov 12 00:45:55 my01vps2018 systemd: Starting Dump dmesg to /var/log/dmesg...
Nov 12 00:45:55 my01vps2018 systemd: Starting Network Manager...
Nov 12 00:45:55 my01vps2018 systemd: Started Self Monitoring and Reporting Technology (SMART) Daemon.
Nov 12 00:45:55 my01vps2018 systemd: Starting Self Monitoring and Reporting Technology (SMART) Daemon...
Nov 12 00:45:55 my01vps2018 rngd: Unable to open file: /dev/tpm0
Nov 12 00:45:55 my01vps2018 systemd: Started OpenSSH Server Key Generation.
Nov 12 00:45:55 my01vps2018 systemd: Started ABRT Automated Bug Reporting Tool.
Nov 12 00:45:55 my01vps2018 systemd: Starting ABRT Automated Bug Reporting Tool...
Nov 12 00:45:55 my01vps2018 systemd: Started ABRT kernel log watcher.
Nov 12 00:45:55 my01vps2018 systemd: Starting ABRT kernel log watcher...
Nov 12 00:45:55 my01vps2018 systemd: Started ABRT Xorg log watcher.
Nov 12 00:45:55 my01vps2018 systemd: Starting Install ABRT coredump hook...
Nov 12 00:45:55 my01vps2018 systemd: Starting System Logging Service...
Nov 12 00:45:55 my01vps2018 systemd: Started Software RAID monitoring and management.
Nov 12 00:45:55 my01vps2018 systemd: Started Login Service.
Nov 12 00:45:55 my01vps2018 systemd-logind: New seat seat0.
Nov 12 00:45:55 my01vps2018 systemd-logind: Watching system buttons on /dev/input/event0 (Power Button)
Nov 12 00:45:55 my01vps2018 systemd-logind: Watching system buttons on /dev/input/event4 (AT Translated Set 2 keyboard)
Nov 12 00:45:55 my01vps2018 systemd: Started Dump dmesg to /var/log/dmesg.
Nov 12 00:45:56 my01vps2018 systemd: Started Resets System Activity Logs.
Nov 12 00:45:56 my01vps2018 systemd: Started GSSAPI Proxy Daemon.
Nov 12 00:45:56 my01vps2018 systemd: Started RPC security service for NFS client and server.
Nov 12 00:45:56 my01vps2018 systemd: Started RPC security service for NFS server.
Nov 12 00:45:56 my01vps2018 systemd: Reached target NFS client services.
Nov 12 00:45:56 my01vps2018 systemd: Starting NFS client services.
Nov 12 00:45:56 my01vps2018 systemd: Reached target Remote File Systems (Pre).
Nov 12 00:45:56 my01vps2018 systemd: Starting Remote File Systems (Pre).
Nov 12 00:45:56 my01vps2018 systemd: Reached target Remote File Systems.
Nov 12 00:45:56 my01vps2018 systemd: Starting Remote File Systems.
Nov 12 00:45:56 my01vps2018 systemd: Starting Permit User Sessions...
Nov 12 00:45:56 my01vps2018 systemd: Started System Logging Service.
Nov 12 00:45:56 my01vps2018 systemd: Started Permit User Sessions.
Nov 12 00:45:56 my01vps2018 systemd: Starting Wait for Plymouth Boot Screen to Quit...
Nov 12 00:45:56 my01vps2018 systemd: Started Job spooling tools.
Nov 12 00:45:56 my01vps2018 systemd: Starting Job spooling tools...
Nov 12 00:45:56 my01vps2018 systemd: Started Command Scheduler.
Nov 12 00:45:56 my01vps2018 systemd: Starting Command Scheduler...
Nov 12 00:45:56 my01vps2018 systemd: Starting Terminate Plymouth Boot Screen...
Nov 12 00:45:56 my01vps2018 systemd: Received SIGRTMIN+21 from PID 438 (plymouthd).
Nov 12 00:45:56 my01vps2018 systemd: Started Wait for Plymouth Boot Screen to Quit.
Nov 12 00:45:56 my01vps2018 systemd: Started Terminate Plymouth Boot Screen.
Nov 12 00:45:56 my01vps2018 systemd: Started Getty on tty1.
Nov 12 00:45:56 my01vps2018 systemd: Starting Getty on tty1...
Nov 12 00:45:56 my01vps2018 systemd: Reached target Login Prompts.
Nov 12 00:45:56 my01vps2018 systemd: Starting Login Prompts.
Nov 12 00:45:56 my01vps2018 smartd[852]: smartd 6.2 2013-07-26 r3841 [x86_64-linux-3.10.0-327.el7.x86_64] (local build)
Nov 12 00:45:56 my01vps2018 smartd[852]: Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
Nov 12 00:45:56 my01vps2018 smartd[852]: Opened configuration file /etc/smartmontools/smartd.conf
Nov 12 00:45:56 my01vps2018 smartd[852]: Configuration file /etc/smartmontools/smartd.conf was parsed, found DEVICESCAN, scanning devices
Nov 12 00:45:56 my01vps2018 smartd[852]: Device: /dev/sda, opened
Nov 12 00:45:56 my01vps2018 smartd[852]: Device: /dev/sda, [Msft     Virtual Disk     1.0 ], lu id: 0x600224800d204937430c52b21cef22f1, 536 GB
Nov 12 00:45:56 my01vps2018 smartd[852]: Device: /dev/sda, Bad IEC (SMART) mode page, err=5, skip device
Nov 12 00:45:56 my01vps2018 smartd[852]: Monitoring 0 ATA and 0 SCSI devices
Nov 12 00:45:56 my01vps2018 systemd: Started Install ABRT coredump hook.
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  NetworkManager (version 1.0.6-27.el7) is starting...
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  Read config: /etc/NetworkManager/NetworkManager.conf and conf.d: 10-ibft-plugin.conf
Nov 12 00:45:56 my01vps2018 systemd: Started Network Manager.
Nov 12 00:45:56 my01vps2018 systemd: Starting Network Manager Wait Online...
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  Loaded settings plugin ifcfg-rh: (c) 2007 - 2015 Red Hat, Inc.  To report bugs please use the NetworkManager mailing list. (/usr/lib64/NetworkManager/libnm-settings-plugin-ifcfg-rh.so)
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  Loaded settings plugin iBFT: (c) 2014 Red Hat, Inc.  To report bugs please use the NetworkManager mailing list. (/usr/lib64/NetworkManager/libnm-settings-plugin-ibft.so)
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  Loaded settings plugin keyfile: (c) 2007 - 2015 Red Hat, Inc.  To report bugs please use the NetworkManager mailing list.
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  ifcfg-rh: new connection /etc/sysconfig/network-scripts/ifcfg-eth0 (afc36ee0-5576-41ca-8356-85ae624af876,"eth0")
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  monitoring kernel firmware directory '/lib/firmware'.
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  Loaded device plugin: NMVxlanFactory (internal)
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  Loaded device plugin: NMVlanFactory (internal)
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  Loaded device plugin: NMVethFactory (internal)
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  Loaded device plugin: NMTunFactory (internal)
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  Loaded device plugin: NMMacvlanFactory (internal)
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  Loaded device plugin: NMInfinibandFactory (internal)
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  Loaded device plugin: NMGreFactory (internal)
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  Loaded device plugin: NMEthernetFactory (internal)
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  Loaded device plugin: NMBridgeFactory (internal)
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  Loaded device plugin: NMBondFactory (internal)
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  Loaded device plugin: NMTeamFactory (/usr/lib64/NetworkManager/libnm-device-plugin-team.so)
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  WiFi enabled by radio killswitch; enabled by state file
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  WWAN enabled by radio killswitch; enabled by state file
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  WiMAX enabled by radio killswitch; enabled by state file
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  Networking is enabled by state file
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  (eth0): new Ethernet device (carrier: OFF, driver: 'hv_netvsc', ifindex: 2)
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  (eth0): device state change: unmanaged -> unavailable (reason 'managed') [10 20 2]
Nov 12 00:45:56 my01vps2018 kernel: IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  (eth0): link connected
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  (lo): link connected
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  (lo): new Generic device (carrier: ON, driver: 'unknown', ifindex: 1)
Nov 12 00:45:56 my01vps2018 dbus[842]: [system] Activating via systemd: service name='org.freedesktop.PolicyKit1' unit='polkit.service'
Nov 12 00:45:56 my01vps2018 dbus-daemon: dbus[842]: [system] Activating via systemd: service name='org.freedesktop.PolicyKit1' unit='polkit.service'
Nov 12 00:45:56 my01vps2018 dbus[842]: [system] Activating via systemd: service name='fi.w1.wpa_supplicant1' unit='wpa_supplicant.service'
Nov 12 00:45:56 my01vps2018 dbus-daemon: dbus[842]: [system] Activating via systemd: service name='fi.w1.wpa_supplicant1' unit='wpa_supplicant.service'
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  (eth0): device state change: unavailable -> disconnected (reason 'none') [20 30 0]
Nov 12 00:45:56 my01vps2018 systemd: Configuration file /usr/lib/systemd/system/wpa_supplicant.service is marked executable. Please remove executable permission bits. Proceeding anyway.
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  Auto-activating connection 'eth0'.
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  (eth0): Activation: starting connection 'eth0' (afc36ee0-5576-41ca-8356-85ae624af876)
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  (eth0): device state change: disconnected -> prepare (reason 'none') [30 40 0]
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  NetworkManager state is now CONNECTING
Nov 12 00:45:56 my01vps2018 systemd: Starting WPA Supplicant daemon...
Nov 12 00:45:56 my01vps2018 systemd: Starting Authorization Manager...
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  (eth0): device state change: prepare -> config (reason 'none') [40 50 0]
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  (eth0): device state change: config -> ip-config (reason 'none') [50 70 0]
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  (eth0): device state change: ip-config -> ip-check (reason 'none') [70 80 0]
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  (eth0): device state change: ip-check -> secondaries (reason 'none') [80 90 0]
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  (eth0): device state change: secondaries -> activated (reason 'none') [90 100 0]
Nov 12 00:45:56 my01vps2018 NetworkManager[850]: <info>  NetworkManager state is now CONNECTED_LOCAL
Nov 12 00:45:56 my01vps2018 polkitd[906]: Started polkitd version 0.112
Nov 12 00:45:56 my01vps2018 dbus[842]: [system] Successfully activated service 'org.freedesktop.PolicyKit1'
Nov 12 00:45:56 my01vps2018 dbus-daemon: dbus[842]: [system] Successfully activated service 'org.freedesktop.PolicyKit1'
Nov 12 00:45:56 my01vps2018 systemd: Started Authorization Manager.
Nov 12 00:45:56 my01vps2018 dbus[842]: [system] Successfully activated service 'fi.w1.wpa_supplicant1'
Nov 12 00:45:56 my01vps2018 dbus-daemon: dbus[842]: [system] Successfully activated service 'fi.w1.wpa_supplicant1'
Nov 12 00:45:56 my01vps2018 systemd: Started WPA Supplicant daemon.
Nov 12 00:46:01 my01vps2018 abrtd: Init complete, entering main loop
Nov 12 00:46:01 my01vps2018 NetworkManager[850]: <info>  NetworkManager state is now CONNECTED_GLOBAL
Nov 12 00:46:01 my01vps2018 NetworkManager[850]: <info>  Policy set 'eth0' (eth0) as default for IPv4 routing and DNS.
Nov 12 00:46:01 my01vps2018 NetworkManager[850]: <info>  (eth0): Activation: successful, device activated.
Nov 12 00:46:01 my01vps2018 dbus[842]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'
Nov 12 00:46:01 my01vps2018 dbus-daemon: dbus[842]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'
Nov 12 00:46:01 my01vps2018 NetworkManager[850]: <info>  wpa_supplicant running
Nov 12 00:46:01 my01vps2018 systemd: Starting Network Manager Script Dispatcher Service...
Nov 12 00:46:01 my01vps2018 dbus[842]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Nov 12 00:46:01 my01vps2018 systemd: Started Network Manager Script Dispatcher Service.
Nov 12 00:46:01 my01vps2018 dbus-daemon: dbus[842]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Nov 12 00:46:01 my01vps2018 nm-dispatcher: Dispatching action 'up' for eth0
Nov 12 00:46:02 my01vps2018 NetworkManager[850]: <info>  startup complete
Nov 12 00:46:02 my01vps2018 systemd: Started Network Manager Wait Online.
Nov 12 00:46:02 my01vps2018 systemd: Starting LSB: Bring up/down networking...
Nov 12 00:46:02 my01vps2018 network: Bringing up loopback interface:  Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'
Nov 12 00:46:02 my01vps2018 network: Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'
Nov 12 00:46:02 my01vps2018 network: Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'
Nov 12 00:46:02 my01vps2018 network: Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'
Nov 12 00:46:03 my01vps2018 network: [  OK  ]
Nov 12 00:46:03 my01vps2018 network: Bringing up interface eth0:  [  OK  ]
Nov 12 00:46:03 my01vps2018 systemd: Started LSB: Bring up/down networking.
Nov 12 00:46:03 my01vps2018 systemd: Reached target Network.
Nov 12 00:46:03 my01vps2018 systemd: Starting Network.
Nov 12 00:46:03 my01vps2018 systemd: Starting Postfix Mail Transport Agent...
Nov 12 00:46:03 my01vps2018 systemd: Starting The Apache HTTP Server...
Nov 12 00:46:03 my01vps2018 systemd: Starting Dynamic System Tuning Daemon...
Nov 12 00:46:03 my01vps2018 systemd: Starting NFS status monitor for NFSv2/3 locking....
Nov 12 00:46:03 my01vps2018 systemd: Started OpenSSH server daemon.
Nov 12 00:46:03 my01vps2018 systemd: Starting OpenSSH server daemon...
Nov 12 00:46:03 my01vps2018 systemd: Started Redis persistent key-value database.
Nov 12 00:46:03 my01vps2018 systemd: Starting Redis persistent key-value database...
Nov 12 00:46:03 my01vps2018 systemd: Starting ProFTPD FTP Server...
Nov 12 00:46:03 my01vps2018 systemd: Starting NFS Mount Daemon...
Nov 12 00:46:03 my01vps2018 rpc.statd[1115]: Version 1.3.0 starting
Nov 12 00:46:03 my01vps2018 rpc.statd[1115]: Flags: TI-RPC
Nov 12 00:46:03 my01vps2018 systemd: Starting MariaDB database server...
Nov 12 00:46:03 my01vps2018 systemd: Reached target Network is Online.
Nov 12 00:46:03 my01vps2018 systemd: Starting Network is Online.
Nov 12 00:46:03 my01vps2018 systemd: Starting LSB: Start or stop the Webmin server...
Nov 12 00:46:03 my01vps2018 systemd: Starting Crash recovery kernel arming...
Nov 12 00:46:03 my01vps2018 systemd: Starting RPC bind service...
Nov 12 00:46:03 my01vps2018 systemd: Started RPC bind service.
Nov 12 00:46:03 my01vps2018 systemd: Started NFS status monitor for NFSv2/3 locking..
Nov 12 00:46:03 my01vps2018 rpc.mountd[1418]: Version 1.3.0 starting

A: That log doesn't contain any information of restart. You can check the information from Journalctl logs. That collect logs from kernel level.


text:
Q: Changing /lib directory from initramfs to mounted partition's /lib I want to change the /lib loaded from initramfs to a mounted partition's /lib ideally without having to rm the initramfs' /lib and then symlink-ing to the new /lib.
The problem with this approach is that once I delete the original /lib, my binaries in /bin (particularly busybox) have no libraries to refer to so the subsequent linking would fail.
The reason I need to symlink a new /lib because I need to load additional modules that is too big to be included in the initramfs (as it will bloat the whole kernel)
Is there any tool that I could use to change the /lib directory into a symlink in a single operation?
Or is there any other way I can make my binaries be able to access the other lib directory without overwriting the original /lib?

A: There are not a lot of size limitations on initrd (I've put 50 MB of extra stuff in there on occasion). I believe the initrd store is freed after the pivot is complete. So.... a couple
things come to mind. You could just wait until the real /lib is available before inserting your special purpose module (you probably thought of this).
Another option would be to load your special purpose module optionally based on a kernel cmdline parameter. In this way you could create a grub-menu that provides booting with or without the special module.


text:
Q: Change the default time zone of the app in swift I'm using picker view to select a new time zone and here I set a new default time zone for the app:
 if let local = selectedTimeZone {
     let timeZone = TimeZone(identifier: local)
     NSTimeZone.default = timeZone!
 }

here for example, selectedTimeZone is equal "America/Chicago"
And whenever this page get open, I read default value of time zone and show it as a selected time zone:
  if let index = timeZone.firstIndex(where: { $0.zoneName == NSTimeZone.default.identifier }) {
     pickerViewField.textField.text = timeZone[index].zoneName
  }

When a new time zone is selected, it seems work and in the app, the user can go around and when the user opens the setting, the picker view label shows the new time zone.
But when I close the app completely and open it again, the time zone gets back the default time zone of the device, not the new one that selected in the app.
Now my question is; do I need to store the new value of the time zone somewhere and when the app gets open, I set the new value again in the first place? Or there is something wrong in my code?
Many thanks


text:
Q: Launch MongoDB built from source on ARM I followed this tutorial to compile a MongoDB on a raspberry pi. I ended up with the content of the tarball which is on the same repo.
The unpacked archive has the following structure:
mongo-embedded-sdk-4.0.4
include lib share

mongo-embedded-sdk-4.0.4/include:
libbson-1.0 libmongoc-1.0   mongo_embedded  mongoc_embedded

mongo-embedded-sdk-4.0.4/include/libbson-1.0:
bson    bson.h

mongo-embedded-sdk-4.0.4/include/libbson-1.0/bson:
bcon.h              bson-context.h          bson-json.h         bson-oid.h          bson-value.h
bson-atomic.h           bson-decimal128.h       bson-keys.h         bson-reader.h           bson-version-functions.h
bson-clock.h            bson-endian.h           bson-macros.h           bson-string.h           bson-version.h
bson-compat.h           bson-error.h            bson-md5.h          bson-types.h            bson-writer.h
bson-config.h           bson-iter.h         bson-memory.h           bson-utf8.h         bson.h

mongo-embedded-sdk-4.0.4/include/libmongoc-1.0:
mongoc      mongoc.h

mongo-embedded-sdk-4.0.4/include/libmongoc-1.0/mongoc:
mongoc-apm.h            mongoc-error.h          mongoc-init.h           mongoc-socket.h         mongoc-topology-description.h
mongoc-bulk-operation.h     mongoc-find-and-modify.h    mongoc-iovec.h          mongoc-ssl.h            mongoc-uri.h
mongoc-change-stream.h      mongoc-flags.h          mongoc-log.h            mongoc-stream-buffered.h    mongoc-version-functions.h
mongoc-client-pool.h        mongoc-gridfs-file-list.h   mongoc-macros.h         mongoc-stream-file.h        mongoc-version.h
mongoc-client-session.h     mongoc-gridfs-file-page.h   mongoc-matcher.h        mongoc-stream-gridfs.h      mongoc-write-concern.h
mongoc-client.h         mongoc-gridfs-file.h        mongoc-opcode.h         mongoc-stream-socket.h      mongoc.h
mongoc-collection.h     mongoc-gridfs.h         mongoc-rand.h           mongoc-stream-tls-libressl.h
mongoc-config.h         mongoc-handshake.h      mongoc-read-concern.h       mongoc-stream-tls-openssl.h
mongoc-cursor.h         mongoc-host-list.h      mongoc-read-prefs.h     mongoc-stream-tls.h
mongoc-database.h       mongoc-index.h          mongoc-server-description.h mongoc-stream.h

mongo-embedded-sdk-4.0.4/include/mongo_embedded:
v1

mongo-embedded-sdk-4.0.4/include/mongo_embedded/v1:
mongo_embedded

mongo-embedded-sdk-4.0.4/include/mongo_embedded/v1/mongo_embedded:
mongo_embedded.h

mongo-embedded-sdk-4.0.4/include/mongoc_embedded:
v1

mongo-embedded-sdk-4.0.4/include/mongoc_embedded/v1:
mongoc_embedded

mongo-embedded-sdk-4.0.4/include/mongoc_embedded/v1/mongoc_embedded:
mongoc_embedded.h

mongo-embedded-sdk-4.0.4/lib:
cmake           libbson-1.0.so.0    libmongo_embedded.so    libmongoc-1.0.so.0  libmongoc_embedded.so
libbson-1.0.so      libbson-1.0.so.0.0.0    libmongoc-1.0.so    libmongoc-1.0.so.0.0.0  pkgconfig

mongo-embedded-sdk-4.0.4/lib/cmake:
libbson-1.0 libmongoc-1.0

mongo-embedded-sdk-4.0.4/lib/cmake/libbson-1.0:
libbson-1.0-config-version.cmake    libbson-1.0-config.cmake

mongo-embedded-sdk-4.0.4/lib/cmake/libmongoc-1.0:
libmongoc-1.0-config-version.cmake  libmongoc-1.0-config.cmake

mongo-embedded-sdk-4.0.4/lib/pkgconfig:
libbson-1.0.pc      libmongoc-1.0.pc

mongo-embedded-sdk-4.0.4/share:
doc     mongo-c-driver

mongo-embedded-sdk-4.0.4/share/doc:
mongo_embedded  mongoc_embedded

mongo-embedded-sdk-4.0.4/share/doc/mongo_embedded:
LICENSE-Community.txt   LICENSE-Embedded.txt    THIRD-PARTY-NOTICES

mongo-embedded-sdk-4.0.4/share/doc/mongoc_embedded:
LICENSE-Community.txt   LICENSE-Embedded.txt

mongo-embedded-sdk-4.0.4/share/mongo-c-driver:
uninstall.sh

When I installed it from a package I just had to run
dbPath="/home/pi/app/mongodb_data"
mongod --dbpath "$dbPath" &

Question:
How can I launch the MongoDB to listen on a port?

A: The tutorial you have followed is for building MongoDB as a library to embed in your application (aka MongoDB Mobile). This embedded build does not provide a standalone server daemon (mongod); you have to link this library directly into your application. The output of the embedded SDK build is the required development header files (include/*.h) and compiled library files (lib/*.so).
For more context, see the original blog post related to the repo you found: Embedded MongoDB 4.0 on Raspberry Pi.

How can I launch the MongoDB to listen on a port?

This requires a build of the normal MongoDB community server. You could try to follow the server build instructions on Build MongoDB from source or look for a precompiled binary for your O/S distro.
Note that Raspberry Pi isn't a generally supported target for the server so you will likely encounter some challenges (particularly on 32-bit O/S). The standard MongoDB server is designed to run on 64-bit hardware with more resources than are typical on a Pi.


text:
Q: Home router difficult to access remotely I've been trying to debug this problem for a week or two now, and haven't been able to figure out what the issue is/if there's anything I can do to resolve it.
I have a home Xfinity router that's port forwarding for both SSH and a Minecraft server, both hosted on my desktop computer running Arch Linux. The remote machines trying to connect to the desktop are only able to do so intermittently. Here are the facts I've gathered:

*

*The remote machines can always ping my router, that's never failed.

*All of the machines have had trouble connecting to my desktop via the port forwards at some point (both SSH and via Minecraft). Some of those have had their IP addresses blocked by my router, so I whitelisted them. Others don't show up as blocked by the router at all, yet often still fail to connect.

*Of the remote machines, some are running Arch Linux, some on OSX, and one on Windows. The issue does not seem to be OS or firewall based as far as I can tell.

*A couple of the remote machines reside behind the same NAT (another home Xfinity router). I initially had to whitelist their IP address, after which they were only sometimes able to connect to the Minecraft server, then after a few successful/failed attempts they've been able to consistently connect. Restarting the router seems to help them succeed sometimes, but that doesn't work every time.

*Even when some of the remote machines are able to connect at a given time, others are still unable (even if those other machines have successfully connected in the past). However, if one machine behind a particular NAT is able to connect, other machines behind that NAT seem to be able to as well.

*If a machine cannot connect to the Minecraft server, it also seems unable to connect to the SSH server (but can still successfully ping the router). I've only tested this with two of the remote machines, which were behind different NATs.

Based on the above facts, it seems that there's something happening between the routers that stops the connection from happening. But because of (1), it seems like less of a discoverability thing and maybe something based on the specific port connection attempts, or with IP reputation (?). Right now my best alternative seems to be to host the Minecraft server on a Digital Ocean server or something, because I'm not sure there's anything I can do to make this work reliably for new users aside from constantly restarting the router/hoping that works until they can reliably connect (which has only really worked for one household so far).
Does anyone have an idea of what's happening here, whether moving the server to a hosted server will fix this issue, or how I can make this work without moving anything?


text:
Q: How to document self-declared types in haddock? I have a function with the signature Own_type1 -> String -> Own_type2 -> IO () and want that I can explain my own types and that in the eventual documentation it is properly linked up etc. etc.
How can I achieve this when using Haddock?

A: You link to your own types in just the same way as you link to other types (see section 3.8.6 in the Haddock documentation).