text:
Q: Magento2: how to add a custom import adapter? I want to extend the catalog import to support xml files. At this time it only supports csv and zip.
The source adapter is detected inside Magento\ImportExport\Model\Import\Adapter using file extension in the factory method:
$adapterClass = 'Magento\ImportExport\Model\Import\Source\\' . ucfirst(strtolower($type));

    if (!class_exists($adapterClass)) {
        throw new \Magento\Framework\Exception\LocalizedException(
            __('\'%1\' file extension is not supported', $type)
        );
    }
    $adapter = new $adapterClass($source, $directory, $options);

How can I add another adapter type?
At first I tought that a preference could be the right way, but preferences can't be used in this case because you can only specify preferences for injectable classes and this isn't injectable.
Actually this class is essentially a copy paste from Magento 1 Mage_ImportExport_Model_Import_Adapter class.
If I can't rewrite this class, can't use a preference or a plugin to extend this class functionality or functionalities of other classes related to the file type adapter, how to achieve that?
Sure I'm missing something obvious.

A: That's for sure a bug, please create issue on github.
For quick workaround you need create class in namespace Magento\ImportExport\Model\Import\Source. To autoload this class you should declare it the same as registration.php
"autoload": {
    "files": [
        "registration.php",
         "path/to/XmlImportSoure.php"
    ],

A: Here is few free import extensions for Magento 2 on GitHub with active development process, you can see lot of examples and useful code to get started with Magento 2 Import Customisation:

*

*https://github.com/firegento/FireGento_FastSimpleImport2

*https://github.com/firebearstudio/importexportfree

*https://github.com/macopedia/magmi-git


text:
Q: Float left divs going to next line I have something similar to below:

Test

The issue is that I need to have this div repeat multiple times.  If it repeats to many times, instead of forcing you to scroll right to see the rest of it (like I want it to), it instead goes down to the next line.
Example of the issue: http://jsfiddle.net/ruh7z/1/
Any help with this would be great, thanks

A: That behavior is exactly what floating is supposed to do.  If you use table-cell for your display style, that may give you more of what you're expecting.  Note that you'll have to use padding instead of margins if you use table-cell.
.container div
{
    display: table-cell;
    padding-left: 5px;
}

Here's a sample of this in use.

A: put the div's in a "fixed width" container div and prevent overflow.  then have buttons or whatever at each end of the container div to "slide" the child divs left or right.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to unhide Integrity Checker within Field Service Lightning I am looking to use the Integrity Checker feature from Field Service Lightning but I cannot seem to locate it under Field Service Settings.
I did find a statement within the release notes back in summer 18 that mentions the following:

The integrity checker, an rarely needed feature, under Scheduled Jobs
  is hidden by default.

Here is the link to it. Link to the statement above
How can this functionality be unhidden?
Update: I found a static resource named settingsBundle which contains the following code but is not modifiable.
$scope.hideIntegrityCheckerAutomator = JSON.parse($scope.settings.GeneralConfig['Hide Integrity Checker Automator'][fieldNames.General_Config__c.Value__c]);
hide-section="hideIntegrityCheckerAutomator"></automators>

A: Created a case with Salesforce and received the following information:

Integrity Checker has become an obsolete tool that is no longer needed
  within FSL.Integrity Checker is an old version of the current Health
  Checker in FSL.


text:
Q: CarouselView in XamarinForms I'm trying to use the CarouselView in the Xamarin project. But I can't do it. Here are the installed packages:

Here is the xaml code:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         xmlns:local="clr-namespace:FlowersStore"
         xmlns:cv="clr-namespace:Xamarin.Forms;assembly=Xamarin.Forms.CarouselView"
         x:Class="FlowersStore.MainPage">

<StackLayout>

    <Grid RowSpacing="0">
        <Grid.RowDefinitions>
            <RowDefinition Height=".3*"/>
            <RowDefinition Height=".7*"/>
        </Grid.RowDefinitions>
        <cv:CarouselView ItemsSource="{Binding Zoos}" x:Name="CarouselZoos">
            <cv:CarouselView.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Image Grid.RowSpan="2" Aspect="AspectFill" Source="{Binding ImageUrl}"/>
                        <StackLayout Grid.Row="1" BackgroundColor="#80000000" Padding="12">
                            <Label TextColor="White" Text="{Binding Name}" FontSize="16" HorizontalOptions="Center" VerticalOptions="CenterAndExpand"/>
                        </StackLayout>
                    </Grid>
                </DataTemplate>
            </cv:CarouselView.ItemTemplate>
        </cv:CarouselView>
    </Grid>

</StackLayout>

And here is the c # code:
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using Xamarin.Forms;

namespace FlowersStore
{
    public class Zoo
    {
        public string ImageUrl { get; set; }
        public string Name { get; set; }
    }

    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
            LoadDataCatouselView();
        }

        public void LoadDataCatouselView()
        {
            ObservableCollection<Zoo> Zoos = new ObservableCollection<Zoo>
        {
            new Zoo
            {
                ImageUrl = "http://content.screencast.com/users/JamesMontemagno/folders/Jing/media/23c1dd13-333a-459e-9e23-c3784e7cb434/2016-06-02_1049.png",
                Name = "Woodland Park Zoo"
            },
                new Zoo
            {
                ImageUrl =    "http://content.screencast.com/users/JamesMontemagno/folders/Jing/media/6b60d27e-c1ec-4fe6-bebe-7386d545bb62/2016-06-02_1051.png",
                Name = "Cleveland Zoo"
                },
            new Zoo
            {
                ImageUrl = "http://content.screencast.com/users/JamesMontemagno/folders/Jing/media/e8179889-8189-4acb-bac5-812611199a03/2016-06-02_1053.png",
                Name = "Phoenix Zoo"
            }
        };
            CarouselZoos.ItemsSource = Zoos;
        }

    }
}

I use Xamarin Live Player for debugging. The log on the mobile phone displays the following message:
[LogEntry: Time=19.11.2018 14:54:54 +03:00, Level=Error, Title=Visualization Error, Message=The given key was not present in the dictionary. (KeyNotFoundException)]
How to fix it? Thanks.
Update 1:
I replaced the code based on your advice. I used your advice. I tried to run the application on:

*

*Androind version: 7.1

*Emulator: Genymotion Galaxy S7 7.1.0 API 25

And got this error:

What it? :(

A: The problem is with the long path.
An easy solution is to move the entire project solution to a shorter path like C:\
Here's an explanation from microsoft:
Path Too Long Exception

A: In your XAML you have the following line:
<cv:CarouselView ItemsSource="{Binding Zoos}" x:Name="CarouselZoos">

This means that the code is looking to bind a property named Zoos to the ItemsSource property of the CarouselView. You will need to create a property of type List<View> and implement the INotifyPropertyChanged structure to update the view. You'll also need to assign the content page's BindingContext to itself (BindingContext = this;).
You may also find that you cannot simply bind a URL to the Image source, and expect the image to appear.

A: Add the BindingContext=this; after the InitializeComponent(); or else add CarouselZoos.ItemsSource = Zoos; in OnAppearing() method

A: Try this
First add this class, for property binding and implement the INotifyPropertyChanged structure to update the view.
public class ViewModelBase : INotifyPropertyChanged
{

    string title = string.Empty;

    /// <summary>
    /// Gets or sets the title.
    /// </summary>
    /// <value>The title.</value>
    public string Title
    {
        get { return title; }
        set { SetProperty(ref title, value); }
    }

    string icon = string.Empty;

    /// <summary>
    /// Gets or sets the icon.
    /// </summary>
    /// <value>The icon.</value>
    public string Icon
    {
        get { return icon; }
        set { SetProperty(ref icon, value); }
    }

    bool isBusy;

    /// <summary>
    /// Gets or sets a value indicating whether this instance is busy.
    /// </summary>
    /// <value><c>true</c> if this instance is busy; otherwise, <c>false</c>.</value>
    public bool IsBusy
    {
        get { return isBusy; }
        set
        {
            SetProperty(ref isBusy, value);
        }
    }

    /// <summary>
    /// Sets the property.
    /// </summary>
    /// <returns><c>true</c>, if property was set, <c>false</c> otherwise.</returns>
    /// <param name="backingStore">Backing store.</param>
    /// <param name="value">Value.</param>
    /// <param name="propertyName">Property name.</param>
    /// <param name="onChanged">On changed.</param>
    /// <typeparam name="T">The 1st type parameter.</typeparam>
    protected bool SetProperty<T>(
        ref T backingStore, T value,
        [CallerMemberName]string propertyName = "",
        Action onChanged = null)
    {
        if (EqualityComparer<T>.Default.Equals(backingStore, value))
            return false;

        backingStore = value;
        onChanged?.Invoke();
        OnPropertyChanged(propertyName);
        return true;
    }

    /// <summary>
    /// Occurs when property changed.
    /// </summary>
    public event PropertyChangedEventHandler PropertyChanged;
    /// <summary>
    /// Raises the property changed event.
    /// </summary>
    /// <param name="propertyName">Property name.</param>
    protected void OnPropertyChanged([CallerMemberName]string propertyName = "") => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

Now when you got the base class for bind properties you can add a view model class for bind the properties and follow the MVVM pattern. I think this is the most property way to manipulate the data.
public class Zoo
{
    public string ImageUrl { get; set; }
    public string Name { get; set; }
}

public class CarouselViewModel : ViewModelBase
{
    private ObservableCollection<Zoo> zoos;
    public ObservableCollection<Zoo> Zoos
    {
        get => zoos; set => SetProperty(ref zoos, value);
    }

    public CarouselViewModel()
    {
        zoos = new ObservableCollection<Zoo>
        {
            new Zoo
            {
                ImageUrl = "http://content.screencast.com/users/JamesMontemagno/folders/Jing/media/23c1dd13-333a-459e-9e23-c3784e7cb434/2016-06-02_1049.png",
                Name = "Woodland Park Zoo"
            },
                new Zoo
            {
                ImageUrl =    "http://content.screencast.com/users/JamesMontemagno/folders/Jing/media/6b60d27e-c1ec-4fe6-bebe-7386d545bb62/2016-06-02_1051.png",
                Name = "Cleveland Zoo"
                },
            new Zoo
            {
                ImageUrl = "http://content.screencast.com/users/JamesMontemagno/folders/Jing/media/e8179889-8189-4acb-bac5-812611199a03/2016-06-02_1053.png",
                Name = "Phoenix Zoo"
            }
        };
    }
}
public partial class MainPage : ContentPage
{
    public CarouselViewModel viewModel;
    public MainPage()
    {
        InitializeComponent();
        this.BindingContext = viewModel = new CarouselViewModel();
    }
}


text:
Q: this.element.querySelectorAll('li') vs this.element.children where all children are LI When all of the children are 'li' elements, why doesn't this.el.children work when this.el.querySelectorAll('li'); does?
For example:
function RadioGroup(id) {
this.el = document.querySelector(id);
this.buttons = slice(this.el.querySelectorAll('.radio'));
this.focusedIdx = 0;
this.focusedButton = this.buttons[this.focusedIdx];

this.el.addEventListener('keydown', this.handleKeyDown.bind(this));
this.el.addEventListener('click', this.handleClick.bind(this));

this.el.setAttribute('role', 'radiogroup');

// This works
this.el.querySelectorAll('li').forEach(function (item){
  item.setAttribute('role', 'radio');
});

// But this doesn't
this.el.children.forEach(function (item){
  item.setAttribute('role', 'radio');
});
}

Where this is the HTML:

Water

Tea

Coffee

Cola

Ginger Ale

A: Element.querySelectorAll returns a NodeList which does contain the forEach method, where as Node.children is an HTMLCollection and does not contain forEach.
[1] https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll
[2] https://developer.mozilla.org/en-US/docs/Web/API/NodeList
[3] https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/children
[4] https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection

A: With ES6's spread operator, you can make both to work in the same way.
function RadioGroup(id) {
this.el = document.querySelector(id);
this.buttons = slice(this.el.querySelectorAll('.radio'));
this.focusedIdx = 0;
this.focusedButton = this.buttons[this.focusedIdx];

this.el.addEventListener('keydown', this.handleKeyDown.bind(this));
this.el.addEventListener('click', this.handleClick.bind(this));

this.el.setAttribute('role', 'radiogroup');

// This works
[...this.el.querySelectorAll('li')].forEach(function (item){
  item.setAttribute('role', 'radio');
});

// And this too ;-)
[...this.el.children].forEach(function (item){
  item.setAttribute('role', 'radio');
});
}


text:
Q: Can we make an image dynamic in WordPress that is set as background in Style.css? I have converted HTML template to WP theme. and want to make everything dynamic.
Firstly I want to make my slider (Slider parts i.e. img, heading, content, button) dynamic.
Now all code is available in index.php except Image so I had made all other contents(heading, text, detailed content, buttons) dynamic in that file but Image is available in Style.css. Code is below:
#HeroBanner {
        background: url(../images/banner.jpg)no-repeat 0 0 / cover;
        height: 630px;
        position: relative;
    }

Now this ID(#HeroBanner) is called in index.php to display img on slider. Code is below:-

Our work is dedicated to the
 prosperity of our clients!

 Lorem ipsum dolor sit amet, consec tetuer

 adipiscing elit. Praesent vestibu lum molestie

lacus. Aenean nonummy hendrerit

maurishasellus

                                        Click Here

                                    Read More

please guide me Can I make this image dynamic? If yes, then how is it possible?
Thanks in Advance.

A: I believe you're trying to make background images dynamic in your WordPress theme. You can do something like this:
In your functions.php file register a customizer and add an action hook to execute the customization.
function mytheme_customize_register( $wp_customize ) {

}
 add_action( 'customize_register', 'mytheme_customize_register' );

and if you follow the theme customization api in wordpress documentation at: https://codex.wordpress.org/Theme_Customization_API
You can see we have three things in our Customization.

*

*Panels. 2. Sections. And 3rd Settings. We first have to create a Panel and inside that panel we can have a section or multiple sections and for each section we can have multiple settings and for each setting we've a controller that controls that setting. For example.
$wp_customize->add_panel('panel_id',array(
     'panel'=>'panel_id',
     'title'=>__('Theme Options'),
     'priority'=>10,
 ));

 $wp_customize->add_section( 'Header' , array(
     'panel'=> 'panel_id',
     'title'      => __( 'Headers', 'mytheme' ),
     'priority'   => 30,
 ) );

 /*
     Background Image Custmoization
 */
 $wp_customize->add_setting('header_slider_image', array(
     'default'           => 'mydefault image link',
     'capability'        => 'edit_theme_options',
     'type'           => 'theme_mod',
     'transport' => 'refresh'

 ));

 $wp_customize->add_control( new WP_Customize_Image_Control($wp_customize, 'image_upload_test', array(
     'label'    => __('Header Image', 'gym'),
     'section'  => 'Header',
     'settings' => 'header_slider_image',
 )));

This can add the functionality to your theme customization option inside a Theme Options > Header > And Background Image. You can then call that image from customization sidebar by using the get_theme_mod('setting_name'); wordpress function inside your page.

A: You should try the customizer api and also check out this plugin which allows you to add custom fields and assign them to any template. This way, you can have an image upload option on any page/template and then call it anywhere in your code. Also, it provides a theme options kind of functionality that could be used globally. You can research it here.


text:
Q: SAS code to calculative Percent Difference I am dealing with a "long" dataset which contains numerous entries for various blood measures. I would like to be able to calculate the %difference for each new LDL level relative to the first reading for LDL.
I was successful at creating a start_dt variable that gets kept for each successive observation, but I can't figure out how to add a "start_LDL" level so that within each row, I can then calculate the %difference between the newest entry and the first entry.
Here is a sample of the dataset (clearly, there are a lot of missings (.) that just look like black spaces):
id  ldl  lab_dt     start_dt    diff_ldl    VISIT
1       17Oct2001   17Oct2001                 1
1       17Oct2001   17Oct2001                 2
1   173 17Oct2001   17Oct2001                 3
1       20Oct2006   17Oct2001                 4
1       20Oct2006   17Oct2001                 5
1       20Oct2006   17Oct2001                 6
1   165 20Oct2006   17Oct2001                 7
2       06Jul2000   06Jul2000                 1
2       06Jul2000   06Jul2000                 2
2       06Jul2000   06Jul2000                 3
2   166 06Jul2000   06Jul2000                 4
2       09Jan2001   06Jul2000                 5
2       09Jan2001   06Jul2000                 6
2       09Jan2001   06Jul2000                 7
2   209 09Jan2001   06Jul2000                 8
2       02Mar2001   06Jul2000                 9
2       06Mar2001   06Jul2000                10
2       06Mar2001   06Jul2000                11
2       06Mar2001   06Jul2000                12
2   203 06Mar2001   06Jul2000                13
2       18Apr2001   06Jul2000                14
2       18Apr2001   06Jul2000                15
2       18Apr2001   06Jul2000                16
2   183 18Apr2001   06Jul2000                17
2       02May2001   06Jul2000                18
2       07May2001   06Jul2000                19
2       08May2001   06Jul2000                20
2       17May2001   06Jul2000                21
2       31May2001   06Jul2000                22
2       31May2001   06Jul2000                23
2       31May2001   06Jul2000                24
2   83  31May2001   06Jul2000                25

And here is my current code. Sometimes the first record for an id (first.id) has missing value for ldl, so start_ldl is (.) which means nothing works moving forward from there forward (or the coding may be wrong overall!).

proc sort data=lab; by id date; run;

data labnew;
set lab;
by id;
retain start_dt ldl diff_ldl ;

IF FIRST.id THEN VISIT = 1;
ELSE VISIT + 1;

if first.id then start_dt=date;
else start_dt=start_dt;

if first.id then start_ldl=ldl;
else start_ldl=start_ldl;

yeardiff=floor((date-start_dt)/365.25);
diff_ldl=((ldl-start_ldl)/start_ldl)*100;

format start_dt date9.;

    run;
If anyone could advise on how I might code for this, I would greatly appreciate it!
Many thanks!

*

*Dee

A: You want first non-missing ldl to carry forward, right?
Untested, would suggest:
data labnew;
  set lab;
  by id;
  retain start_dt start_ldl diff_ldl ;

  *initialize retained variables for each by group;
  if first.id then do;
    visit=0;
    start_dt=date;
    start_ldl=.;
    diff_ldl=.;
  end;

  visit+1;
  if missing(start_ldl) then start_ldl=ldl;

  yeardiff=floor((date-start_dt)/365.25);
  if n(ldl,start_ldl)=2 then diff_ldl=((ldl-start_ldl)/start_ldl)*100;

  format start_dt date9.;
run;


text:
Q: dynamic mysql query in c++ i have a query ->
LOAD DATA INFILE 'hello2.csv'
INTO TABLE failure_report.master_entry
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 2 ROWS

in c++ i have->
string h1="hello2.csv";
string h2;
ostringstream strstr;
strstr << "LOAD DATA INFILE'" << h1 << "'INTO TABLE failure_report.master_entry    FIELDS  TERMINATED BY'"<<","<<"'ENCLOSED BY '"<<'"'<<"'LINES TERMINATED BY '"<<"\n"<<" '  ignore 2 rows";
h2=strstr.str();
int query_state=mysql_query(con,h2.c_str());

mysql_query does return 0 but the database is not updated.mysql_error is null.

A: You are missing spaces between some words and apostrophes ' and escape for \n (it also has special meaning in C++ and only literal new line gets send to mysql server, you have to use \\n), try using:
strstr << "LOAD DATA INFILE '" << h1 << "' "
       << "INTO TABLE failure_report.master_entry "
       << "FIELDS  TERMINATED BY ',' "
       << "ENCLOSED BY '\"' "
       << "LINES TERMINATED BY '\\n' "
       << "IGNORE 2 ROWS";

Also note the space before every " in the end of the line.
In future use printf("Executing query: %s", h2) and mysql_error() for debugging.

A: I believe problem is with the way you are using opening and closing ' quotes around statements, and excaping ".
strstr << "LOAD DATA INFILE '" << h1 << "' INTO TABLE failure_report.master_entry FIELDS  TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\\n' ignore 2 rows";


text:
Q: How to apply toggle? here is my code of html on which i have to apply togle

Agent Details

Office hours

Products offered

Languages

Visit Agent Site

Mon-Fri 9:00AM-5:00PM

Auto, Home

English, Spanish

and here is my code of jquery
$(document).ready(function(){
    $(".contact-link-list").click(function(){
        ('.senf').slideToggle("fast");
    });
});

here is my jsfiddle - http://jsfiddle.net/n7U6b/
please suggest me where i am wrong

A: There is no element in your example with a class of senf. Also you are missing a $ before your selector:
$('.senf').slideToggle("fast");

Edit
Here is an updated fiddle from your example. You are still missing the $, and you have a stray closing  tag in there, but you also need to add a class of senf to the item you want to toggle. For example:

A: $(document).ready(function(){
    $(".contact-link-list").click(function(){
        $('.senf').slideToggle("fast");
    });
 });

You just missed a $ sign on '.senf'
Plus where is the item with class senf?? I might have missed it!


text:
Q: Installation of Clingo on a Mac I am trying to install Clingo on my Mac (macOS Mojave -- 10.14.3).
I have downloaded the last version of Clingo (5.3.0) and unzipped it. If I open the Clingo file with the terminal it says:
Last login: Fri Mar  1 09:31:31 on ttys000
Mattias-MacBook-Pro:~ esther$
/Users/esther/Documents/clingop/clingo ; exit;
clingo version 5.3.0
Reading from stdin

I have also downloaded homebrew and Xcode.
I have .lp file (pippo.pl) that I would like to run. What should I do to run this file?
I tried in several ways from the Terminal, but nothing happens.
I have created an alias clingo="documents/clingop/clingo" and then from the directory of the pippo.pl file I wrote
clingo pippo , but the Terminal says: -bash: documents/clingop/clingo: No such file or directory
So it seams that somehow it cannot read the file clingo
Do you know how I could solve this? thanks a lot

A: The important line is Reading from stdin.
You can call clingo so that it processes your file as follows:
/Users/esther/Documents/clingop/clingo pippo.pl
or if your shell is bash (or similar):
cat pippo.pl |/Users/esther/Documents/clingop/clingo
or
/Users/esther/Documents/clingop/clingo <pippo.lp


text:
Q: how can i use the magic methods correctly? I've thought about magic methods(based on php)in Magento help developers work more easily.Especially, getter method is pretty useful to create own custom module.
As far as i know, get methods has some rules for existing

*

*use camelCase like getName() , getLastName()

*format like $this->getVariable
Actually, i've search on Google, i couldn't find the what extactly i have to write on gray part. I mean that i don't know what i write as variablemeans extactly.
is it from field name base on table ? or any other stuffs?
And i want to know the part what i checked as $order->getShippingdescription() , $product->getName(). is it called frontname?
Thank you so much!

A: If you have an object of a model class, your table column names are firstname, email_address, id. You can get this value following way:

$model->getFirstname(),
$model->getEmailAddress()

etc. that means every underscore remove and next first letter should be capital letter.
N.B: If any method name you can find that are unavailable in table column, it must be an model class custom method. Example: $order->getId() returns sales_flat_order table entity_id column.
If method is not an column name then it must be present in model class. e.g: $order->getPayment() return payment model object and its present in Mage_Sales_Model_Order class.


text:
Q: without pointer C++ string how to expression string is nullptr? On C++ string can expression two case :
1. string flag;                     /* empty string */
1. string flag = "Other content";   /* other string */

On Java String can expression three case :
1. String flag = NULL;              /* NULL */
2. String flag = "";                /* empty string */
2. String flag = "Other content";   /* other string */

On C++ can we expression the string as NULL (nullptr) ? if not use pointer .
My scene:
I got string data from mysql , mysql expression way same as Java for string , NULL/empty/other .
My data model is used for Mysql And nlohmann Json .

A: So you can use std::optional to express this:
std::optional<std::string> null_string = std::nullopt; // this is the "null" state

if (optional_string) { /// Can be used like a null or bool type

std::optional<std::string> empty_string = ""; // This is the empty string
std::optional<std::string> other_string = "Other content"; // The full string

Just be aware, that to use string interfaces, you will need to get the value of the string with .value() or operator*:
void print_string(const std::string& s);

print_string(*other_string);

This requires you to check that the string is actually valid before calling or you will invoke undefined behaviour.

A: The answer below is quite theoretical.
In practice usually there's no real need to distinguish between an empty string and a null one and using std::string as is is the best solution. And if you only need to add only the "nullabilty" to your C++ string you can use std::optional as mentioned in the comments and other answer.

Having said that:
In Java a String is a reference type, meaning variables like flag actually hold a reference to the String object (and the reference can be null). An object can have multiple references to it, and when this number becomes zero the object can be automatically destroyed.
If you want to achieve an overall similar behavior in C++, you can use std::shared_ptr holding a std::string:
#include <memory>
#include <string>
//...
std::shared_ptr<std::string> s1 = nullptr;      // null string
std::shared_ptr<std::string> s2 = std::make_shared<std::string>("");    // empty string
std::shared_ptr<std::string> s3 = std::make_shared<std::string>("abs"); // non empty string

A:
On C++ can we expression the string as NULL (nullptr) ?

No you can't . want to expression string as nullptr need string pointer

On C++ can we expression the string as NULL (nullptr) ? if not use pointer .

Maybe std::optional is answer .

My data model is used for Mysql And nlohmann Json .

*assume select std::optional<string> flag

*for mysql  , you can expression string NULL , flag = nullopt

*for nlohmann Json , you must to compatible with std::optional
namespace nlohmann {
  /* https://github.com/nlohmann/json#how-do-i-convert-third-party-types */
  template <typename T>
  struct adl_serializer<std::optional<T>> {
      static void to_json(json& j, const std::optional<T>& opt) {
        if(opt.has_value()) {
            // this will call adl_serializer<T>::to_json which will
            // find the free function to_json in T's namespace!
            j = opt.value();
        } else {
            j = nullptr;
        }
      }

      static void from_json(const json& j, std::optional<T>& opt) {
          if (j.is_null()) {
            opt = std::nullopt;
          } else {
            opt = j.get<T>(); // same as above, but with
                              // adl_serializer<T>::from_json
          }
      }
  };
}

Other things

*

*Copy form @wohlstad In Java a String is a reference type, meaning variables like flag actually hold a reference to the String object (and the reference can be null).

My Reference :

*

*https://github.com/nlohmann/json/issues/1749

*https://www.kdab.com/jsonify-with-nlohmann-json/


text:
Q: jquery dynamically created li element click not working .jsp

.js
var sugList = $("#suggestions");

$("#info").on("input", function(e) {
    var text = $(this).val();
    if(text.length < 1) {
        sugList.html("");
        sugList.listview("refresh");
    } else {
        $.post("infoAutoComplete", {input:text,data:currentData}, function(response) {
            var str = "";
            $.each( response.ids, function ( i, val ) {
                str += "
" + val + "
";
            });
            sugList.html(str);
            sugList.listview("refresh");
        },"json");
    }
});

above code is working well!(AutoComplete)
However, li click is not working once!
.js
$('#suggestions').on("click", "li", function() {
   console.log("click!!!!!");
});

After trying twice, working well...
I tried to solve this problem but I can't...
I don't know why this is working like this...
Help me!!

A: use below code. it is event delegation issue . read more about event delegation
$(document).on("click", "#suggestions li", function() {
  console.log("click!!!!!");
});


text:
Q: Using Qthread to run a function I want to run a function of a class as a thread continuously,till the object of the class is destroyed.
client.h
class client:public QWidget
{
   Q_OBJECT
   public:
   //some declarations

   client();
   void setclientui();
   //some ui elements
   void receiveme();  //i want this function to be run as a thread
                      //It has to be run continuously to receive
                      //messages from socket and when a message is
                      //received ,it must display it in the gui.

 public slots:
   int prework();
   void sendme();
};

Note:receiveme() uses recv() of tcp sockets which gets blocked until message is received.
client.cpp
 void receiveme(){
 while(1){
    if(recv(sockfd,receivebuf,1024,0)<0)
    {
        qDebug()<<errno;
        break;
    }
   receivebuf[20]='\0';
    qDebug()<<receivebuf;
   outputbox->append(a);
}}

mainwindow.h
  class MainWindow : public QMainWindow
{
   Q_OBJECT
public:
   Dialog* newdialog;//join a new chat
QString ipp,portt;
QTabWidget *wdg;
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
    void receivesocketaddress();
void on_actionJoin_a_chat_triggered();
};

mainwindow.cpp
   MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
    wdg=new QTabWidget;
   ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_actionJoin_a_chat_triggered()
{
    newdialog=new Dialog();
    newdialog->setWindowTitle("Join a chat");
    newdialog->setModal(true);
    qDebug()<< QObject::connect(newdialog->conne,SIGNAL(clicked()),this,SLOT(receivesocketaddress()));
   newdialog->exec();
}
 void MainWindow::receivesocketaddress()
{
     client *aclient=new client;
     aclient->iptoconnect=newdialog->ip->text().toLocal8Bit().data();
     aclient->porti=newdialog->port->text().toLocal8Bit().data();
     if(aclient->prework()==0)//ie connected
     {
        newdialog->close();
        wdg->addTab(aclient,tr("new chat"));
        setCentralWidget(wdg);
        //here the ui is shown.Now the aclient->receiveme() should
        //running
     }
     else
     {
        newdialog->displayerror();
        layout->addWidget(error,3,0,2,2);
        qDebug()<<"cud not connect";
     }

}
If aclient->prework()==0 then a gui is displayed but how can i run aclient->receiveme() at this time as a thread so that it is continuously running and reading messages from socket.If a message is received,it should be displayed in the gui.
Without thread the gui would freeze.I tried to use QThread::movetothread() but i receive the following error
QThread::cannot move object with parent

and to use subclass method, client class must inherit QThread but since it is already inheriting QWidget,the following error is thrown
call to QObject is ambiguous

How can i use QThread here?

A: *

*Widgets can run only within GUI thread, so you need to implement client as QObject subclass and communicate with UI via signal/slot connection. Qt wont allow you to do outputbox->append(a) in non UI thread (Supposing that outputbox is some QWidget here);

*You probably don't even need to use threads here - Qt provides it's own socket classes with event (signal/slot) based API;

*If you still need to use recv() in different thread, you need to subclass QThread (one approach) or QObject (another approach); In both cases you need to have signal like messageReceived(QByteArray) that will be connected to slot in your UI object that will handle message; So receiveme() slot might looks like:
void client::receiveme()
{
        while(1){
            if(recv(sockfd,receivebuf,1024,0)<0)
            {
                qDebug()<<errno;
                break;
            }
            receivebuf[20]='\0';
            QByteArray msg(receivebuf);
            emit messageReceived(msg);
        }
}

*This article might help


text:
Q: Why does the paging library stop loading data after several calls? I implemented a paging library and it does not work quite as it should. I request data from the github and paginate the list of repositories. The code works well, but after several changes to the search query, it stops loading data. In the debug, the data always loads well. I guess the problem is asynchrony, but I can't figure out where to look.
My code:
RepoDataSource
public class RepoDataSource extends PageKeyedDataSource<Integer, Repo> {
@Override
    public void loadInitial(@NonNull LoadInitialParams<Integer> params, @NonNull LoadInitialCallback<Integer, Repo> callback) {
        Timber.d("Initial RepoDataSource");
        try {
            Response<RepoSearchResponse> response = githubService.searchRepos(query, firstNumberPage).execute();
            RepoSearchResponse repoSearchResponse = response.body();
            if (repoSearchResponse != null) {
                List<Repo> items = repoSearchResponse.getItems();
                callback.onResult(items, 1, 2);
            }
        } catch (IOException e) {
            Timber.i(e);
        }
    }

    @Override
    public void loadBefore(@NonNull LoadParams<Integer> params, @NonNull LoadCallback<Integer, Repo> callback) {
    }

    @Override
    public void loadAfter(@NonNull LoadParams<Integer> params, @NonNull LoadCallback<Integer, Repo> callback) {
        Timber.d("Fetching next page: %s", params.key);
        try {
            Response<RepoSearchResponse> response = githubService.searchRepos(query, params.key).execute();
            if (response.isSuccessful()) {
                RepoSearchResponse repoSearchResponse = response.body();
                if (repoSearchResponse != null) {
                    List<Repo> items = repoSearchResponse.getItems();
                    callback.onResult(items, params.key + 1);
                }
            }
        } catch (IOException e) {
            Timber.i(e);
        }
    }
}

GithubApiCall
@GET("search/repositories")
    Call<RepoSearchResponse> searchRepos(@Query("q") String query, @Query("page") Integer page);

RepoDataSourceFactory
public class RepoDataSourceFactory extends DataSource.Factory<Integer, Repo> {

    private GithubService githubService;
    private String query;

    public RepoDataSourceFactory(GithubService githubService, String query) {
        this.githubService = githubService;
        this.query = query;
    }

    @NonNull
    @Override
    public DataSource<Integer, Repo> create() {
        return new RepoDataSource(githubService, query);
    }
}

Repository method
public class RepoRepository {
...
...
public RepoDataSourceFactory getRepoPagedFactory(String query) {
        return new RepoDataSourceFactory(githubService, query);
    }
}

ViewModel
public final class MyViewModel {
...
public MutableLiveData<String> searchQuery = new MutableLiveData<>();
...
public LiveData<PagedList<Repo>> getRepos() {
        return Transformations.switchMap(searchQuery, query -> {
            RepoDataSourceFactory factory = repository.getRepoPagedFactory(query);
            return new LivePagedListBuilder<>(factory, pagedListConfig).build();
        });
    }
...
public SearchView.OnQueryTextListener listener = new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            if (query != null && !query.trim().equals("")) {
                searchQuery.postValue(query);
            }
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return true;
        }
    };
...
}

And in my activity
viewModel.getRepos().observe(this, adapter::submitList);

A: There is nothing wrong with your code. I was on a GitHub project, and was stuck in the same problem until I realize GitHub has a Rate Limit of 10 requests per minute for unauthenticated requests. But if it is an authenticated one, you can make up to 30 requests per minute.
I assume you also send request for every changes in the search query, just like I did, where typing/changing 5 characters equals 5 requests. So the real cause is the very limited request rate from GitHub, not your code.
Check this out: https://developer.github.com/v3/search/#rate-limit


text:
Q: SQL query to join 3 tables I'm fairly new to SQL, so I'm not sure if what I'm trying to do is even called a join.
I have 4 tables, with this schema:
CREATE TABLE survey (
    id           serial    PRIMARY KEY,
    title        text,
    password     text
);

CREATE TABLE question (
    id           serial    PRIMARY KEY,
    surveyId     integer   REFERENCES survey(id),
    value        text
);

CREATE TABLE answer (
    id           serial    PRIMARY KEY,
    questionId   integer   REFERENCES question(id) ,
    value text
);

CREATE TABLE vote (
    id           serial,
    questionId   integer   REFERENCES question(id),
    answerId     integer   REFERENCES answer(id)
);

Given a specific survey.id (surveyId), I need to:

*

*Find all question rows where question.surveyId = surveyId

*For each question row found in (1), find all answer rows where answer.questionId = question.id

*For each of the answers found in (2), find all vote rows where vote.answerId = answer.id.

*Return a count of vote rows for each unique answerId.

So if I have the following test data:
question
=============
id | surveyId
1  | 3
2  | 3
3  | 3
4  | 5
5  | 6

answer
===============
id | questionId
1  | 1
2  | 1
3  | 2
4  | 3

vote
==========================
id | questionId | answerId
1  | 1          | 1
2  | 1          | 2
3  | 1          | 1
4  | 2          | 3
5  | 4          | 22

If the initial surveyId is 3, then I would expect the result of this query to be:
answerId | count
================
1        | 2
2        | 1
3        | 1

Is there any way to do this as a single SQL query?

A: Here's a query you need:
SELECT v.answerId, COUNT(*)
FROM survey AS s
     INNER JOIN question AS q ON s.id = q.surveyId
     INNER JOIN answer AS a ON q.id = a.questionId
     INNER JOIN vote AS v ON a.id = v.answerId
WHERE  s.id = 3 -- This's your specific value of surveyId
GROUP BY v.answerId
ORDER BY v.answerId

But this query can be optimized. You can give up single join given the relations of your tables:
SELECT v.answerId, COUNT(*)
FROM survey AS s
     INNER JOIN question AS q ON s.id = q.surveyId AND s.id = 3
     INNER JOIN vote AS v ON q.id = v.questionId
GROUP BY v.answerId
ORDER BY v.answerId

And note that you cannot create a such set of test data. Because the value of answerId from table vote violates foreign key constraint answerId from this table. 22 is not present in table answer.

A: SELECT
  a.answerId
  , vote = COUNT(v.vote)
FROM survey s
  INNER JOIN question q
    ON s.surveyid = q.surveyId
  INNER JOIN answer a
    ON q.questionId = a.questionID
  INNER JOIN vote v
    ON a.answerId = v.answerId
WHERE s.surveyID = @yourValue
GROUP BY a.answerId

Is what I think you are looking for.


text:
Q: error in assigning a dictionary from a list of dictionaries python I am working with list of dictionaries and I have an object like that:
table_settings = [
        {'table_name': 't1' , 'reindex': True, 'partition_deletion': False },
        {'table_name': 't2' , 'reindex': False, 'partition_deletion': True },
        {'table_name': 't3' ,'reindex': False, 'partition_deletion': True },
        {'table_name': 't4', 'reindex': False, 'partition_deletion': True }
    ]

The table_name is entered through command line. I want to assign that element of the table_settings which is matching with the table_name entered.
For example, if someone entered table_name as  't3', then the value in the table_conf should be {'table_name': 't3' ,'reindex': False, 'partition_deletion': True }
If someone enters a value which is not in list , say 't5', then the value of table_conf should be 'None'.
I am trying this code:
import sys
table_name = sys.argv[1]
table_conf = settings for settings in table_settings if settings['table_name'] == table_name

But this is giving me syntax error.
Any help would be highly appreciated.

A: If you want to use a list comprehension, which looks like what you're trying to write, you want something like this:
import sys
table_name = sys.argv[1]

try:
    table_conf = [s for s in table_settings if s['table_name'] == table_name][0]
    print(table_conf)
except IndexError:
    # perhaps you want to do something different here, like return a default
    print("Table not found!")

So, add brackets to make this a list comprehension, return only the 0th element of the list, and add an exception to deal with the case that the table is not found (i.e. the list you generated is empty and has no element 0).

A: You don't have to use a list comprehension:
import sys
table_name = sys.argv[1]

for settings in table_settings:
    if settings['table_name'] == table_name:
        table_conf = settings
        break
else:
    table_conf = None


text:
Q: How to find the largest open files? Looking for the largests among the open files by all processes.
lsof already has the open files with their sizes. It may be passing the right parameters to lsof and processing the output.

A: You can do the following
lsof | grep REG | awk '{ print $1,$7,$9 }' | sort -t ' ' -k 2 -V

Using the awk you filter the output to include command, size and filename and sort it based on the 2nd column, which is size.
-t specifies the delimiter, -V sort 'naturally' - so 1, 2, 10 will be sorted this way instead of 1, 10, 2. -k is the key for the sort (the column you want to sort by)

A: One convoluted way looks like this:
lsof \
| grep REG \
| grep -v "stat: No such file or directory" \
| grep -v DEL \
| awk '{if ($NF=="(deleted)") {x=3;y=1} else {x=2;y=0}; {print $(NF-x) "  " $(NF-y) } }'  \
| sort -n -u  \
| numfmt  --field=1 --to=iec

Output
...
....
129M  /var/log/maillog
166M  /var/log/nginx/access_log
172M  /var/log/metrics/kubernetes/kubelet.log
185M  /var/log/metrics/kubernetes/etcd.log
257M  /var/log/metrics/kubernetes/etcd.log.1
335M  /var/log/metrics/kubernetes/kubelet.log.1

I know this is not perfect. For example if the file name contains "DEL" this would purge that file from the output list.
lsof also has a -F option described in the OUTPUT FOR OTHER PROGRAMS section. Using that may be simpler.
Details
lsof prints something like this:
COMMAND      PID    TID           USER   FD      TYPE             DEVICE  SIZE/OFF       NODE NAME
systemd        1                  root  cwd       DIR              253,0      4096        128 /
tuned       2975                  root    7u      REG              253,0      4096  805307770 /tmp/ffiKkVeXD (deleted)
python2    49888  49890           root  DEL       REG               0,18            196039884 /dev/shm/sem.NXPFow
systemd        1                  root  mem       REG              253,0     90664      10063 /usr/lib64/libz.so.1.2.7
java      149435 175229            box   69r      REG              253,0 350872273  808108999 /box/var/log/metrics/kubernetes/kubelet.log.1
java      149435 149580            box  107w     FIFO                0,8       0t0  272526226 pipe
prometheu 147867 148211           root  mem       REG              253,6             31457463 /lib64/ld-2.12.so (stat: No such file or directory)

grep REG keep regular files

grep -v "stat: No such file or directory" Remove the files that have stat error. (I do not know why this happens)

grep -v DEL Discard the  Linux map files that have been deleted;
From lsof documentation:

''DEL'' for a Linux map file that have been deleted;

After this processing we are left with something like this:
tuned       2975                  root    7u      REG              253,0      4096  805307770 /tmp/ffiKkVeXD (deleted)
systemd        1                  root  mem       REG              253,0     90664      10063 /usr/lib64/libz.so.1.2.7
java      149435 175229            box   69r      REG              253,0 350872273  808108999 /box/var/log/metrics/kubernetes/kubelet.log.1

The size is either the 3rd or the 2nd column from last depending on the value of the last column. If the last column is (deleted) pick the 3rd from last otherwise 2nd.
awk '{if ($NF=="(deleted)") {x=3;y=1} else {x=2;y=0}; {print $(NF-x) "  " $(NF-y) } }'

sort -n -u  | numfmt  --field=1 --to=iec
Sort, uniquify and make the bytes count human readable

A: You can use the -F option of lsof to get almost unambiguous output which is machine-parseable with only moderate pain. The output is ambiguous because lsof rewrites newlines in file names to \n.
The lsof output consists of one field per line. The first character of each name indicates the field type and the rest of the line is the field value. The fields are: p=PID (only for the first descriptor in a given process), f=descriptor, t=type (REG for regular files, the only type that has a size), s=size (only if available), n=name. The awk code below collects entries that have a size and prints the size and the file name. The rest of the pipelines sorts the output and retains the entry with the largest size.
lsof -Fnst | awk '
    { field = substr($0,1,1); sub(/^./,""); }
    field == "p" { pid = $0; }
    field == "t" { if ($0 == "REG") size = 0; else next; }
    field == "s" { size = $0; }
    field == "n" && size != 0 { print size, $0; }
' | sort -k1n -u | tail -n42 | sed 's/^[0-9]* //'


text:
Q: Error in asymptote using upacity to draw a lemniscate I am trying to draw a lemniscate using the code from this answer:
How to draw lemniscate with TikZ
However, if when I run asymptote I get the following error messages:
Error: /undefined in .setopacityalpha
Operand stack:
   0.5
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   2045   1   3   %oparray_pop   2044   1   3   %oparray_pop   --nostringval--   2025   1   3   %oparray_pop   1884   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:967/1684(ro)(G)--   --dict:0/20(G)--   --dict:82/200(L)--
Current allocation mode is local
Current file position is 31005
GPL Ghostscript 9.26: Unrecoverable error, exit code 1
/opt/texlive/2018/texmf-dist/asymptote/plain_shipout.asy: 87.10: runtime: shipout failed
Error: /undefined in .setopacityalpha
Operand stack:
   0.2
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   2045   1   3   %oparray_pop   2044   1   3   %oparray_pop   --nostringval--   2025   1   3   %oparray_pop   1884   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:967/1684(ro)(G)--   --dict:0/20(G)--   --dict:82/200(L)--
Current allocation mode is local
Current file position is 38506
GPL Ghostscript 9.26: Unrecoverable error, exit code 1
/opt/texlive/2018/texmf-dist/asymptote/plain_shipout.asy: 87.10: runtime: shipout failed

A: A better workaround for this ghostscript bug has already been implemented in the git source (and will be in the upcoming 2.48 Asymptote release):
https://github.com/vectorgraphics/asymptote/issues/77

A: Wow.
After a lot of digging I found this bug report (which isn't actually a bug) which suggests that GhostScript (which is called by Asymptote) runs into problems when opacity is used along the the -dSAFER option. This option assures that no PostScript code which could be harmful to the system is executed. Enabling this option makes the opacity fail. If you change the line fpen=lightred+opacity(0.5); to fpen=lightred;//+opacity(0.5); and pen fpen=lightgreen+opacity(0.2); to pen fpen=lightgreen;//+opacity(0.2); (commenting out the opacity) the picture is generated:

but it's not what you'd expect. And if you enable the opacity the problem persists because Asymptote calls GhostScript with -dSAFER by default since 2008 (from the change log):
commit 407a627a5d18b773739a9535b486b8a177dd7c49
Author: John Bowman <bowman@ualberta.ca>
Date:   Mon Jun 23 11:00:40 2008 -0600

    By default run gs with -dSAFER.

After more digging through code and documentation looking for opacity without success, I searched for safe and voilà:

there is a -nosafe option which you can (when you trust the code your are executing) pass to asy so that the opacity will work.
So you can use the same code from the answer you linked (How to draw lemniscate with TikZ) and compile the document with:
pdflatex cassini.tex
asy -nosafe cassini-*asy
pdflatex cassini.tex

and it will work :)

A: If you run into this error while using pstricks in general, I found a solution in  different question. So give the original author an upvote, if this works for you:
% GhostScript 9.53
\usepackage[pspdf={-dALLOWPSTRANSPARENCY}]{pstricks-pdf}
% GhostScript < 9.53
\usepackage[pspdf={-dNOSAFER}]{pstricks-pdf}


text:
Q: Limit aggregation feed to return when activity_count is greater than N Imagine we have 2 verbs, posted and listened, added to a flat feed. Then we have an aggregated feed following that flat feed. Lets say we base our aggregation rules on time and we have 5 activityGroups so far:
[0] verb: listened, activityCount: 3
[1] verb: posted,   activityCount: 1,
[2] verb: listened, activityCount: 1,
[3] verb: listened, activityCount: 2,
[4] verb: posted,   activityCount: 1,

My question is:
Is it possible to remove the listened verb activityGroup until they hit a threshold for instance greater than 2?
The result would have me seeing the aggregated feed like this:
[0] verb: listened, activityCount: 3
[1] verb: posted,   activityCount: 1,
[2] verb: posted,   activityCount: 1,

The reason I'd like the service and not my server or client to handle this is because I want to preserve the pagination that stream supplies.
Thanks!

A: It's not possible to get that functionality with an aggregation template, because the template can only take into account the single activity which is being added, not all the activities which belong to the same group. The fields available are described in https://getstream.io/docs/#aggregated-feeds in the Aggregation Format Syntax section. Also check-out https://getstream.io/blog/aggregated-feeds-demystified/ for some inspiration.


text:
Q: how to run two sequential merges in SQL? I am running a SQL request such as
SELECT data1.agent_name, data2.agent_phone
FROM mydata data1
INNER JOIN mydata2 data2 ON data1.ID = data2.ID

The problem is that I would like to further merge the resulting dataset (above) with another table, data3 using a LEFT JOIN on data1.ID2 from data1 and data3.ID2 from data3.
Is this possible in the same request?
Thanks!


text:
Q: HUB USB Disconnection, detect and reload without reboot Our machine uses WiFi & 3G communications. Both devices share the same USB connection through a HUB.
Given a time it seems to disconnect both devices and the firmware is unable to recover them.
Our goal is to recover those interfaces without needing to reboot.
Comparing a well-working machine and non-working one we appreciate these differences:
root@well-working:~# lsusb -t
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ci_hdrc/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/2p, 480M
        |__ Port 1: Dev 3, If 0, Class=Vendor Specific Class, Driver=ath9k_htc, 480M
        |__ Port 2: Dev 4, If 0, Class=Vendor Specific Class, Driver=option, 480M
        |__ Port 2: Dev 4, If 1, Class=Vendor Specific Class, Driver=option, 480M
        |__ Port 2: Dev 4, If 2, Class=Vendor Specific Class, Driver=option, 480M
        |__ Port 2: Dev 4, If 3, Class=Vendor Specific Class, Driver=option, 480M
        |__ Port 2: Dev 4, If 4, Class=Communications, Driver=cdc_ether, 480M
        |__ Port 2: Dev 4, If 5, Class=CDC Data, Driver=cdc_ether, 480M

root@well-working:~# ls -l /sys/bus/usb/devices/
lrwxrwxrwx    1 root     root             0 Jan  1  1970 1-0:1.0 -> ../../../devices/soc0/80080000.ahb/80090000.usb/ci_hdrc.1/usb1/1-0:1.0
lrwxrwxrwx    1 root     root             0 Jan  1  1970 1-1 -> ../../../devices/soc0/80080000.ahb/80090000.usb/ci_hdrc.1/usb1/1-1
lrwxrwxrwx    1 root     root             0 Jan  1  1970 1-1.1 -> ../../../devices/soc0/80080000.ahb/80090000.usb/ci_hdrc.1/usb1/1-1/1-1.1
lrwxrwxrwx    1 root     root             0 Jan  1  1970 1-1.1:1.0 -> ../../../devices/soc0/80080000.ahb/80090000.usb/ci_hdrc.1/usb1/1-1/1-1.1/1-1.1:1.0
lrwxrwxrwx    1 root     root             0 Jan  1  1970 1-1.2 -> ../../../devices/soc0/80080000.ahb/80090000.usb/ci_hdrc.1/usb1/1-1/1-1.2
lrwxrwxrwx    1 root     root             0 Jan  1  1970 1-1.2:1.0 -> ../../../devices/soc0/80080000.ahb/80090000.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2:1.0
lrwxrwxrwx    1 root     root             0 Jan  1  1970 1-1.2:1.1 -> ../../../devices/soc0/80080000.ahb/80090000.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2:1.1
lrwxrwxrwx    1 root     root             0 Jan  1  1970 1-1.2:1.2 -> ../../../devices/soc0/80080000.ahb/80090000.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2:1.2
lrwxrwxrwx    1 root     root             0 Jan  1  1970 1-1.2:1.3 -> ../../../devices/soc0/80080000.ahb/80090000.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2:1.3
lrwxrwxrwx    1 root     root             0 Jan  1  1970 1-1.2:1.4 -> ../../../devices/soc0/80080000.ahb/80090000.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2:1.4
lrwxrwxrwx    1 root     root             0 Jan  1  1970 1-1.2:1.5 -> ../../../devices/soc0/80080000.ahb/80090000.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2:1.5
lrwxrwxrwx    1 root     root             0 Jan  1  1970 1-1:1.0 -> ../../../devices/soc0/80080000.ahb/80090000.usb/ci_hdrc.1/usb1/1-1/1-1:1.0
lrwxrwxrwx    1 root     root             0 Jan  1  1970 usb1 -> ../../../devices/soc0/80080000.ahb/80090000.usb/ci_hdrc.1/usb1

root@non-working:~# lsusb -t
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ci_hdrc/1p, 480M

root@non-working:~# ls -l /sys/bus/usb/devices/
lrwxrwxrwx    1 root     root             0 Jan  1  1970 1-0:1.0 -> ../../../devices/soc0/80080000.ahb/80090000.usb/ci_hdrc.1/usb1/1-0:1.0
lrwxrwxrwx    1 root     root             0 Jan  1  1970 usb1 -> ../../../devices/soc0/80080000.ahb/80090000.usb/ci_hdrc.1/usb1

When a machine loses it's WiFi & 3G all the USB devices related dissapear.
We have already tried changing it's power related params values, with no success.
root@non-working:~# ls /sys/bus/usb/devices/usb1/power/
    active_duration         connected_duration      runtime_active_time
    autosuspend             control                 runtime_status
    autosuspend_delay_ms    level                   runtime_suspended_time

Here is an example of a disconnection event:
[1795405.092245] usb 1-1: USB disconnect, device number 2
[1795405.113015] usb 1-1.1: USB disconnect, device number 3
[1795405.287948] option1 ttyUSB3: option_instat_callback: error -71
[1795405.893171] ath: phy0: Chip reset failed
[1795405.915900] ath: phy0: Unable to reset channel (2412 Mhz) reset status -22
[1795405.948908] ath: phy0: Unable to set channel
[1795406.054290] ath: phy0: Failed to wakeup in 500us
[1795406.134293] ath: phy0: DMA failed to stop in 10 ms AR_CR=0xa83aa0c7 AR_DIAG_SW=0xa83aa0c7 DMADBG_7=0xa83aa0c7
[1795406.262963] ath: phy0: Failed to wakeup in 500us
[1795407.423023] ath: phy0: DMA failed to stop in 10 ms AR_CR=0x803aa0c7 AR_DIAG_SW=0x803aa0c7 DMADBG_7=0x803aa0c7
[1795408.171040] usb 1-1.1: ath9k_htc: USB layer deinitialized
[1795408.341405] usb 1-1.2: USB disconnect, device number 4
[1795408.451976] option1 ttyUSB0: GSM modem (1-port) converter now disconnected from ttyUSB0
[1795408.527829] option 1-1.2:1.0: device disconnected
[1795408.612111] option1 ttyUSB1: GSM modem (1-port) converter now disconnected from ttyUSB1
[1795408.662332] option 1-1.2:1.1: device disconnected
[1795408.759173] option1 ttyUSB2: GSM modem (1-port) converter now disconnected from ttyUSB2
[1795408.809315] option 1-1.2:1.2: device disconnected
[1795408.913052] option1 ttyUSB3: GSM modem (1-port) converter now disconnected from ttyUSB3
[1795408.965253] option 1-1.2:1.3: device disconnected
[1795409.026255] cdc_ether 1-1.2:1.4 eth0: unregister 'cdc_ether' usb-ci_hdrc.1-1.2, CDC Ethernet Device

At this time, our only way to recover those interfaces is to reboot the whole machine... When the OS starts again and loads its modules the interfaces are detected again:
[    5.107845] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    5.114635] ehci-platform: EHCI generic platform driver
[    5.123058] usbcore: registered new interface driver usb-storage
[    5.131111] usbcore: registered new interface driver usbserial
[    5.137924] usbcore: registered new interface driver option
[    5.145798] usbserial: USB Serial support registered for GSM modem (1-port)
[    5.202460] ci_hdrc ci_hdrc.1: EHCI Host Controller
[    5.209070] ci_hdrc ci_hdrc.1: new USB bus registered, assigned bus number 1
[    5.224634] ci_hdrc ci_hdrc.1: USB 2.0 started, EHCI 1.00
[    5.236611] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    5.243661] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    5.251115] usb usb1: Product: EHCI Host Controller
[    5.256220] usb usb1: Manufacturer: Linux 3.17.2-fslc+g6725f55 ehci_hcd
[    5.263414] usb usb1: SerialNumber: ci_hdrc.1
[    5.288768] hub 1-0:1.0: USB hub found
[    5.293575] hub 1-0:1.0: 1 port detected

[    5.632202] usb 1-1: new high-speed USB device number 2 using ci_hdrc
[    5.785868] usb 1-1: New USB device found, idVendor=0424, idProduct=2422
[    5.793740] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    5.826896] hub 1-1:1.0: USB hub found
[    5.833666] hub 1-1:1.0: 2 ports detected
[    6.136125] usb 1-1.1: new high-speed USB device number 3 using ci_hdrc
[    6.257841] usb 1-1.1: New USB device found, idVendor=0cf3, idProduct=9271
[    6.265532] usb 1-1.1: New USB device strings: Mfr=16, Product=32, SerialNumber=48
[    6.274210] usb 1-1.1: Product: SKW17
[    6.279177] usb 1-1.1: Manufacturer: SKYLAB
[    6.284601] usb 1-1.1: SerialNumber: 12345
[    6.426135] usb 1-1.2: new high-speed USB device number 4 using ci_hdrc
[    6.528004] usb 1-1.2: New USB device found, idVendor=05c6, idProduct=9003
[    6.535563] usb 1-1.2: New USB device strings: Mfr=4, Product=3, SerialNumber=5
[    6.544201] usb 1-1.2: Product: UMTS/HSPA Module
[    6.550141] usb 1-1.2: Manufacturer: Quectel, Incorporated
[    6.580942] option 1-1.2:1.0: GSM modem (1-port) converter detected
[    6.606089] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB0
[    6.636850] option 1-1.2:1.1: GSM modem (1-port) converter detected
[    6.661615] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB1
[    6.689028] option 1-1.2:1.2: GSM modem (1-port) converter detected
[    6.711116] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB2
[    6.742213] option 1-1.2:1.3: GSM modem (1-port) converter detected
[    6.765995] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB3

Hardware related observed details:
We are unable to define what causes those desconnections. We suspect about a HW related issue.
Analising the HUB's crystal clock with an oscillator we can observe an anomalous behaviour:

When the firmware is unable to detect & recover the interfaces, HUB's crystal clock seems to loop.
Only with the kernel module reload at boot seems to be reinitialised and works properly.


text:
Q: How to improve this example? $ seq 12 | awk '{ if(NR%2) { print $0, (NR+1)/2 } else { print $0, NR/2} }'
1 1
2 1
3 2
4 2
5 3
6 3
7 4
8 4
9 5
10 5
11 6
12 6

How do I change the above command? I want to print:
1 1
2 1
3 1
4 2
5 2
6 2
7 3
8 3
9 3
10 4
11 4
12 4

A: Hmm. Just applying your algorithm to 3:
seq 12|awk '{if((NR%3)==1) { print $0, (NR+2)/3 } else if ((NR%3)==2) { print $0, (NR+1)/3 } else { print $0, NR/3} }'

But I'm sure there is also a shorter algo...

A: awk '{print $0, int((NR+2)/3)}'


text:
Q: Nuxt3 with vue-plyr for YouTube - Document is not defined Reference Error I'm trying to implement the vue-plyr with a new Nuxt3 application, so that I can embed customized YouTube and Vimeo videos into the pages.
I have followed the instructions for Nuxt (Vue 2.x) at the bottom of the vue-plyr npm page to use the component in Nuxt, by creating a file in the plugins directory and wrapping the component in a <ClientOnly> tag, but I am still getting an error.
/plugins/vue-plyr.ts
import VuePlyr from 'vue-plyr/dist/vue-plyr.ssr'
import 'vue-plyr/dist/vue-plyr.css'

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.use(VuePlyr, { plyr: {} })
})

nuxt.config.ts
import { defineNuxtConfig } from 'nuxt'

// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
    plugins: [
        { src: '~/plugins/vue-plyr', mode: 'client' }
    ]
})

app.vue
<template>

        Video
        <ClientOnly>
          <vue-plyr>

          </vue-plyr>
        </ClientOnly>

</template>

Error
ReferenceError: document is not defined
    at C:\Users\benm\Documents\Coding\My Projects\yt-test\node_modules\vue-plyr\dist\vue-plyr.ssr.js:5913:11
    at Object.<anonymous> (C:\Users\benm\Documents\Coding\My Projects\yt-test\node_modules\vue-plyr\dist\vue-plyr.ssr.js:5924:2)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at ModuleWrap.<anonymous> (internal/modules/esm/translators.js:199:29)
    at ModuleJob.run (internal/modules/esm/module_job.js:152:23)
    at async Loader.import (internal/modules/esm/loader.js:166:24)
    at async __instantiateModule__ (file:///C:/Users/benm/Documents/Coding/My%20Projects/yt-test/.nuxt/dist/server/server.mjs:4156:3)

A: i found a way to get it working
so in your plugin folder create a file called
plyr.client.ts its al about the .client.ts
add this as its contents

const VuePlayer = VuePlyr;

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.use(VuePlayer, { plyr: {} });
});

in nuxt.config.ts add
 css: ["@/assets/css/main.scss", "~/node_modules/vue-plyr/dist/vue-plyr.css"],
so here you add the css of the node module and then you can use this in your pages/component
        <vue-plyr>

        </vue-plyr>
      </ClientOnly>```


text: Q: React Material Dropdown size I am using the Autocomplete from here: https://material-ui.com/components/autocomplete/#autocomplete. It's a fantastic control, but extends pretty far downwards on mobile (which causes it to show behind the keyboard). Is there a way to make such a control display only 3 items, based on if device type is mobile?


text:
Q: matlab: Issue reading excel binary (.xlsb) file I am trying to read in (MATLAB 7.14.0.739 (R2012a), Ubuntu 12.04, filesize ~2MB) a binary excel file containing multiple sheets but get the following error:
[status,sheets,xlFormat] = xlsfinfo('633933_2014-07-04_11-34-27.xlsb')

status =
 ''

sheets =
Unreadable Excel file: File contains unexpected record length.  Try
  saving as Excel 98.
xlFormat =
 ''

I have a large number of these binary files so I don't want to have to resave them to another format if possible.

A: The documentation clearly states that the support for xlsb is limited to windows systems having excel installed.
You may try to find some 3rd party so, python or java library which can read xlsb but I am not aware of any. Otherwise you have to switch to a different format.


text:
Q: How can remove or Ignore variable of Swagger in spring boot (Swagger 3.0) I have some problem when I using swagger 3.0  in Spring boot
I need to remove some of variables in swagger but @ApiIgnore and @Hidden is not working
It still showing like blow , even if I put @ApiIgnore and @Hidden..
kindly help me
Thank you.

A: @ApiModelProperty(hidden = true)


text:
Q: Exclude double quotes (") from being turned into " Don't know if this has been answered yet, but I'll give it a shot.
Supposedly I have a string like this:
var x = '"Hello" & good morning';

And i use .replace() to turn the special characters to ASCII, like so:
x.replace(/(\r\n|\n|\r)/gm,"");

It will appear as:
"Hello" & good morning

But I want it to print as:
"Hello" & good morning

Any help is appreciated. Thanks!

A: Try following snippet:
Input: '"Hello" & good morning';
Output: "Hello" & good morning

var x = '"Hello" & good morning';
var decodeHtmlEntity = function(x) {
  return x.replace(/&#(\d+);/g, function(match, dec) {
    return String.fromCharCode(dec);
  });
};
alert(decodeHtmlEntity(x));

A: Use this code
function myFunction(a, b) {
   var x = '\"Hello\" & good morning';
x.replace(/(\r\n|\n|\r)/gm,"");

}

A: Got it.
x.replace(/(\r\n|\n|\r)/gm,"").replace(/"/g, '"');

And I almost missed it. Thanks for those who helped.

A: This error arises for example when exporting in flask-python or ninja-python render_template('./mytemp.html',var_1 =' "hello" ') a variable var_1 to your html template mytemp.html, so that in the html the double quotes appears as &#34 when substituting {{var_1}}, i.e. &#34hello&#34. If this is your case, this can be subsaned simply using the safe operator in your html template mytemp.html (of course inside javascript),
var myvar = {{var_1 | safe}}

As simple as that.


text:
Q: Unable to import hurry.filesize module in Python? I have using Python 2.6 with Django 1.4. I am able to import in python shell as:
from hurry.filesize import alternative

I am also able to import in Django shell as:
./manage.py shell

from hurry.filesize import alternative

But I get error while using it in the real Django project in the same machine. What's the problem?


text:
Q: In Blazor WebAssembly in a component, how can I make DateTime.ToString use the date format of the current culture, assuming the culture is correct? I have temporarily set my browser language and locale to English - United Kingdom even though I am in the United States.  I have removed "en-US" and now have "en-GB" as my only language preference.
In my Blazor WebAssembly site, on a component, I have a property that returns a string: myDate.ToString("d") + System.Globalization.CultureInfo.CurrentCulture.DisplayName; that renders on my page as 6/27/2020en (GB), where myDate is a DateTime set to June 27, 2020 at 00:00:00.000.  My Blazor site has app.UseRequestLocalization(...) middleware set up.
Isn't is supposed to show the date in UK format, namely 27/06/2020? I can only guess that ShortDatePattern isn't getting properly set from CultureInfo.CurrentCulture.  What could it be?
UPDATE: All WebAssembly component outputs show me that DateTimeFormatInfo.CurrentInfo.ShortDatePattern == "M/d/yyyy" even though CultureInfo.CurrentCulture.Name == "en-GB".  Why might that be?  What sets ShortDatePattern from the culture and can I "re-initialize" it?
An explicit call to myDate.ToString("d", System.Globalization.CultureInfo.GetCultureInfo("en-GB")); still strangely outputs the M/d/yyyy format (U.S. format). Why might that be?
UPDATE 2:  I created a minimal example: File-New Project, Blazor Web Assembly, .NET 5 ASP.NET Core hosted.  I replaced App.Razor with the following:
<div> current culture @(System.Globalization.CultureInfo.CurrentCulture.Name) </div>
<div> current date format @(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern) </div>
<div> today @DateTime.Now.ToString("d") </div>

That results in (unexpectedly):

Firefox browser settings (Edge and Chrome are similar and show the same issue):

That results in sending Accept-Language: en-GB,en-US;q=0.7,en;q=0.3--which seems to be the correct way to "prefer en-GB" and results in CultureInfo.CurrentCulture having the correct value.
I've tried it with Microsoft.AspNetCore.Components.WebAssembly.* nuget packages version 5.0.9, 5.0.11 - both show the same incorrect result.
UPDATE 3: The same minimal project in 6.0.0-rc.1 works and gives the right date format!  Is this really a Blazor 5 bug that they never fixed?

A: For .NET 6+, this seems to be fixed.
For .NET 5, I could not find the root cause, so I needed to code this workaround, which needs to be called explicitly when needed. Obviously this is undesirable if we can find a better solution to allow the use of DateTime.ToString as intended.
/// <summary>
/// Returns a short date-only string from a date/time value, based on the user's current culture.
/// </summary>
public static string ToLocalShortDate(this DateTime value)
{
    // this is needed because I can't get localization to work -- see https://stackoverflow.com/q/69542125/7453
    //   (if we can fix, better to use DateTime.ToString("d"))

    string format;
    // countries taken from https://en.wikipedia.org/wiki/Date_format_by_country
    if (CurrentCulture.Name.EndsWithAny("US", "CA", "ZA", "KE", "GH", "en"))
        format = "MM/dd/yyyy";
    else if (CurrentCulture.Name.EndsWithAny("CN", "JP", "KR", "KP", "TW", "HU", "MN", "LT", "BT"))
        format = "yyyy-MM-dd";
    else format = "dd/MM/yyyy";

    return value.ToString(format);
}

/// <summary>
/// Returns true if and only if a string ends with any of some strings.
/// The value will not match a null reference.
/// </summary>
public static bool EndsWithAny(this string value, params string[] allowedValues) =>
    allowedValues != null && value != null && allowedValues.Any(s => CurrentCulture.Name.EndsWith(s));


text:
Q: php with two class my sample is good or not?
I have a good connection to the database, or too should be in the class?
Thanks
<?php
mysql_connect('localhost','root','admin');
mysql_select_db('test');

class UserDisplay
{
    function getDisplayName()
    {
        $sql = 'select first_name, last_name, display_name from users where user_id = "3"';
        $results = mysql_query($sql);
        $row = mysql_fetch_array($results);
        $this->user_id = $user_id;

        return $this->user_id;
    }
}

class UserInsert

    function InsertName($name)
    {
        mysql_query("INSERT INTO Persons (first_name)VALUES ('".$name."')");
    }
}

$userD = new UserDisplay();
echo "User known as: " . $userD->getDisplayName() . "\n";

$userI = new UserInsert();
$userI->InsertName("Peter");
?>

A: You should merge those classes into a single User class, then select the user array from the database in the constructor and store it in a class variable.
You would also ideally pass in the mysql connection to that class so that it doesn't always just use the default connection. The mysql functions all have a "link identifier" parameter, and it's considered good practice to use it if you aren't using an OO interface (like mysqli's OO class).

A: Your sample is not really ideal. Classes should not depend on or modify any external resources, except whatever has been passed to them through arguments / properties / or method calls.

A: Probably be better off just making them functions, instead of wrapping them up in classes. Extract all of it, except the last into it's own php file. You forgot to extract display name from $user
// myFunctions.php
<?php
function connectDb() {
    mysql_connect('localhost', 'root', 'admin');
    mysql_select_db('test');
}

function closeDb() {
    mysql_close();
}

function displayName() {
    $sql = 'select first_name, last_name, display_name from users where user_id = "3"';
    $results = mysql_query($sql);
    $user = mysql_fetch_array($results);
    return $user['display_name'];
}

function insertFirstName($name) {
    mysql_query("INSERT INTO Persons (first_name)VALUES ('" . $name . "')");
}
?>

// index.php
<?php
require_once 'myFunctions.php';

connectDb();
echo "User known as: " . displayName() . "\n";
insertFirstName("Peter");
closeDb();
?>

But if you insist on using classes:
// User.php
<?php
class User {

    private function connectDb() {
        mysql_connect('localhost', 'root', 'admin');
        mysql_select_db('test');
    }

    private function closeDb() {
        mysql_close();
    }

    function displayName() {
        $this->connectDB();

        $sql = 'select first_name, last_name, display_name from users where user_id = "3"';
        $results = mysql_query($sql);
        $user = mysql_fetch_array($results);

        $this->closeDB();

        return $user['display_name'];
    }

    function insertFirstName($name) {
        $this->connectDB();
        mysql_query("INSERT INTO Persons (first_name)VALUES ('" . $name . "')");
        $this->closeDB();
    }
}
?>

// index.php
<?php
require_once 'User.php';

$user = new User;
echo "User known as: " . $user->displayName() . "\n";
$user->insertFirstName("Peter");
?>

Actually not bad. abstracted out the db connection and close.


text:
Q: iCE40 IceStorm FPGA Flow: Bi-directional IO pins Using the iCE40 FOSS IceStorm FPGA flow: how does one write Verilog for a 3-state I/O pin (like a bidirectional data bus pin) using yosys/iceStorm?

A: Currently there is only limited support for inferring nontrivial IO buffers from behavioral code. So the best way of creating bidirectional IO  buffers is by manually instantiating an SB_IO cell. For example:
SB_IO #(
    .PIN_TYPE(6'b 1010_01),
    .PULLUP(1'b 0)
) raspi_io [8:0] (
    .PACKAGE_PIN(iopin),
    .OUTPUT_ENABLE(dout_en),
    .D_OUT_0(dout),
    .D_IN_0(din)
);

(With iopin being the top-level module port.)
See the Lattice iCE40 technology library documentation for more details on SB_IO and other iCE40 primitives.


text:
Q: $(window).load() with ajax inside I'm trying to retrieve all the data inside the database when the page is loaded but when I try to click the refresh button nothing was returned, do you have any idea why? Here is my code:
      $(window).load(function (){
        $.ajax({
            url: 'get.php',
            dataType: 'json',
            success: function (data){
               $.each(data, function(i,item) {
                 $('#info').append("
 you are:"+data[i].username+"

 your  message  is:"+data[i].msg);
               })
             }
        });

      });

A: seems like the ajax is not returning before the function gets executed.
Edit:
   $(window).load(function (){
      $.ajax({
        url: 'get.php',
        dataType: 'json',
        type: 'POST', //u missed this line.
        success: function (data){
          var data_new = jQuery.parseJSON(data);
          $.each(data_new, function(i, item) {
           $('#info').append("
 you are:" + data_new.username +"

 your  message   is:"+data_new.msg);
           });

         }
    });

  });

A: New answer posted here.
Change your php code as below
if(isset($_POST['username']) && isset($_POST['msg'])){
  $username = $_POST['username'];

  $msg = $_POST['msg'];
}


text:
Q: How to filter in Graphql GitHub API by MergeableState The following code block returns a list of pull requests with their mergeability status such as 'MERGEABLE', 'CONFLICTING', etc.
Is there any way to filter inline by mergeablestate?
I can filter the result obtained after this using js or anything else. I wanted to understand how to do it in a Graphql script. Looked up the docs could not find a way.
{
      repository(owner: "rikesh_kamra", name: "git-sticker") {
        pullRequests(first: 1, states: [OPEN]) {
          nodes {
            id
            number
            changedFiles
            deletions
            mergeable
            author {
              url
            }
          }
        }
      }
    }

I tried
pullRequests(first: 1, states: [OPEN], mergeable: [MERGEABLE))

But got an error saying mergeable is not a valid argument for pullRequests.


text:
Q: Can Present perfect continuous and Simple Past be used together in one sentence? Take a look at these sentences:

I knew that something terrible was happening to my daughter and husband.
I knew that something terrible has been happening to my daughter and husband.

Which one would be correct?

Also, in this sentence:

At 21 years old, a little voice inside his head told him to fight harder than he had ever done before in order to get healthy.

Why is it "Had ever done before" instead of "Has ever done before" ?

A: The present perfect continuous is used in various ways, but in this context the expected meaning is "occurring for some time, including right now".

(Up to the present moment, and ongoing) Something terrible has been happening to my daughter and her husband.

This makes it odd to use with the past tense, because we can't reconcile something known in the past with something that is happening now.  Instead you need to use the past perfect continuous:

I knew that (up to that past moment, and ongoing) something terrible had been happening to my daughter and her husband.

This explains why your second sentence uses the past perfect, because the action takes place in the past, when he was 21 years old.


text:
Q: how can I add a permanent character at the beginning of an input field in uiAlert Popup? When user presses a button in my app I show him the alert view with an input text field there. I use the following code for that:
func addTapped(sender: UIBarButtonItem) {

    let alertController = UIAlertController(title: "", message: "Write a #name of a tag that you want to follow", preferredStyle: .Alert)

    let confirmAction = UIAlertAction(title: "Confirm", style: .Default) { (_) in
        if let field = alertController.textFields![0] as? UITextField {

            if(field.text?.characters.count > 0) {
                print("user put some data inside")
            } else {
                print("user did not put anything")
            }

        } else {
            // user did not fill field

        }
    }

    let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) { (_) in }

    alertController.addTextFieldWithConfigurationHandler { (textField) in
        let attributedString = NSMutableAttributedString(string: "C-TAD-")
        attributedString.addAttribute(NSForegroundColorAttributeName, value: UIColor.lightGrayColor(), range: NSMakeRange(0,6))
        textField.attributedText = attributedString
    }

    alertController.addAction(confirmAction)
    alertController.addAction(cancelAction)

    self.presentViewController(alertController, animated: true, completion: nil)

}

It works well, when user runs the app he sees:

but this placeholder text inside is removable. I would like to prevent that and always show this text there, so basically lock the delete option on it.
How can I lock the possibility of removing those first letters?

A: Following maddy's advice I was able to solve this problem. I added
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
        //This makes the new text black.
        textField.typingAttributes = [NSForegroundColorAttributeName:UIColor.blackColor()]
        let protectedRange = NSMakeRange(0, 6)
        let intersection = NSIntersectionRange(protectedRange, range)
        if intersection.length > 0 {

            return false
        }
        return true
    }

method and set up a delegate to the textfield in the addTextFieldWithConfigurationHandler - that did the trick :)

A: A UITextField have a leftView and rightView that you can customise.  By default the leftView is never displayed.  You can add a label as the leftView or as a subview of the leftView and set the left view to Always show.
Try this code:
    let leftLabel = UILabel(frame: CGRectMake(0,0,60,21))
    leftLabel.text = "C-TAD-"
    leftLabel.textColor = .lightGrayColor()

    textField.leftView = leftLabel
    textField.leftViewMode = .Always


text:
Q: Image background which stick to top React Native I want to achieve the following view, where i have a blue image which is added as a background sticking to the top of the container. Any idea on how this can be achieved in React Native?
P.S. I am using Native Base too in the project

A:     import * as React from 'react';
    import { View, Image, Dimensions } from 'react-native';
    const windowWidth = Dimensions.get('window').width;
    const windowHeight = Dimensions.get('window').height;
    export default function App() {
      return (
        <View
          style={{
            flex: 1,
            backgroundColor: '#ecf0f1',
          }}>
          <Image
            resizeMode={'contain'}
            source={{
              uri:
                'https://loremflickr.com/cache/resized/65535_51113407033_7bed78119e_z_640_360_nofilter.jpg',
            }}
            style={{ width: windowWidth, height: 300, position: 'absolute' }}
          />
          <View style={{ flex: 1, justifyContent: 'flex-end', paddingBottom: 10 }}>
            <View
              style={{
                width: windowWidth * 0.8,
                height: 350,
                backgroundColor: 'white',
                alignSelf: 'center',
              }}
            />
          </View>
        </View>
      );
    }


text:
Q: the best structure for a forum oop mvc with php? I am developing a forum in php oop in mvc , but I got a question this is my structure, so where do I must write the set and get methods of each model?, I begin to put the clasess setgetThread, and setgetReply in the controller but I dont sure, can you give some hints, or clarify me if I am doing a goo practice??, I am new in mvc, and I am trying to understand
Controller:
ControllerThread,
ControllerReply
Model:
Thread,
Reply
View:
Formthread,
FormReply,
Index

A: This question cant be answered exactly.
It depends on style and convention.
Best practices I know is to "keep your controller as skinny as possible" and have a "fat model" instead.
The Model should contain business logic and should be fully operational, but on an environment independent state. Which means for example, dont process HTML there. Just exchange defined data objects.
The controller is responsible to map all the urls to the right place and everything.
Finally the view transforms the data from the model into a form that the user can view (e.g. HTML).
Sometimes it is convention to exchange only data between view/controller or model/controller. I personally see no reason why not to let the model interact with the controller, it brings big advantages like pre processing of data etc.
So to drill it down to your question:
I think your controller should load the model and set the thread.
Then then controller should set the correct view in your presentation layer, which then fetches the posts from the model and dispalys them in a nice form.


text:
Q: Match {N,M} chars in Parboiled How do I write a rule for

*

*at least N chars - regex [a-z](2,}

*at most N chars - regex [a-z](,5}

*from N to M chars - regex [a-z]{3,10}
in Parboiled?

A: You might be looking for the times combinator.  You can either use times with a single Int (meaning repeat the rule exactly n times) or with an (Int, Int) (meaning repeat the rule between n and m times).  You can use times together with oneOrMore, zeroOrMore, ~, and ! for the desired effects:
//Matches regex "a{n,}"
rule {
     n.times("a") ~ zeroOrMore("a") //match on n "a"s followed by zero or more "a"s (so at least n "a"s)
}

//Matches regex "a{,m}"
rule {
    !(m.times("a") ~ oneOrMore("a")) //do not match on m "a"s followed by one or more "a" (so at most m "a"s)
}

//Matches regex "a{n, m)"
rule {
     (n to m).times("a") ~ EOI
}


text:
Q: Access JSON column How can I access values in the status and date columns stored as JSON?
Please, have a look at an example row below.
{"1":{"status":true,"date":"2022-03-30"},"3":{"status":true,"date":"2022-03-30"}}

A: Demo:
set @j = '{"1":{"status":true,"date":"2022-03-30"},"3":{"status":true,"date":"2022-03-30"}}';

select json_extract(@j, '$."1".status') as status;
+--------+
| status |
+--------+
| true   |
+--------+

In this case, it may be unexpected that you need to put double-quotes around "1" to use it in a JSON path.


text:
Q: Could not load file or assembly 'Interop.CrystalActiveXReportViewerLib105, Version=10.5.0.0, Culture=neutral, PublicKeyToken=null' Could not load file or assembly
Interop.CrystalActiveXReportViewerLib105, Version=10.5.0.0, Culture=neutral, PublicKeyToken=null.

How to fix it?
I'm very tired about this problem. please help me!!!
when i load application AxCrystalActiveXReportViewer1 has been error

A: Possibilities:
1. It requires another dll that is not referenced.
2. Check the .net framework that your app is using and that of the dll(which is used to build it).


text:
Q: Displaying a selected object as string in vuejs Below is my html code that am using to implement select2
<!DOCTYPE html>

    <title>department</title>

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<link href="https://cdn.jsdelivr.net/npm/select2@4.0.12/dist/css/select2.min.css" rel="stylesheet" />

                    Department*
                        <select v-model="department"   class="form-control select2" >
                            <option> </option>
                            <option  v-for="department in departmentData" v-bind:value="department">{{department.departmentName}}</option>
                        </select>

Selected{{department}}

My script section is as follows

I need to display the object as a string. As it is, an getting [object Object].I Have tried .text() but its giving the name of the department only. I my case i need the whole object but as a string like { "id": 5, "departmentCode": "ARC", "departmentName": "Architecture" }. Please help out. Regards.

A: v-bind:value="department.id"

const selectedValue = <value from select>
const selectedDepartment = this.departmentData.find(x => x.id === selectedVal)


text:
Q: Best Practices for Content Types in SharePoint Recently, we came across a severe problem in production farm with the Content Types. I would like to explain the background of this problem first.
We have nice working feature for Content Types installation in production and test farms. We developed  and deployed (using wsps) this SharePoint feature in Visual studio. We are using the publishing pages using page layouts and Content Types to help content editors to quickly publish the web pages. Unfortunately, some Content Types and site columns have been manually updated/added by some people in the production, so whenever I (developer) make some changes to the existing Content Types (using Visual Studio and feature activation/deactivation) , SharePoint removes one or two columns (during feature activation/deactivation) from Content Types; or the columns which have not been added in a best practice way. I think the best practice is to update Content Types using Visual Studio.
Now, I wish to ensure that site columns shouldn't get removed from Content Types upon feature activation/deactivation.
Note: Our feature for Content Type activation/deactivation doesn't hold any activation dependencies in the feature.xml

A: Recommended Approach
Based on all these factors, my suggestion would be to:
• Create two Features: one for the original markup and one for making changes. (Or you can put them in the same Feature; I just want to differentiate between where you do what.)
• The original Feature should contain the CAML for Site Columns and Content Types. This ensures the IDs have been assigned ahead of type and remain constant.
• If you want to update a Site Column by changing nearly anything about it except its Field type, do it using a Feature Receiver. By doing this, you can call the Update method and pass in a boolean indicating if you want all the existing assets in the site that inherit from this to update to, (something you couldn't do via the CAML.)
• You can also add an existing Site Column (that you provisioned via the CAML feature) to an existing Content Type (that was provisioned via the CAML feature). This is helpful if the Column was not part of that Content Type before, etc.
• In a scenario like the one I just mentioned in the last bullet point, it's necessary to deactivate and reactive the CAML feature (to provision the new assets) before calling your Feature Receiver. What will this mean for the site? Since all the Site Columns and Content Types in the lists in the site are using the same ID's as the ones provisioned in the Site Collection root, removing its parent from the Site Collection won't change that. It might leave it orphaned temporarily, (i.e. there will be no relationship between that item and an item in the Site Collection root, but it will function the same way it always has, since it's really a fully-functioning copy of the original item) until you reactivate the Feature that puts the item back in the Site Collection. It's like the parents are going on vacation when you deactivate the Feature, and are coming back home when you activate the Feature again.
You have a choice when it comes to how you maintain the CAML and the Feature Receiver, since you have two scenarios: existing Site Collections and new ones.
• You could make a policy that every time you write code in your Feature Receiver to update a Site Column or Content Type, you have to make the change in your CAML as well. That would mean that every time you activated the CAML Feature in a "fresh" Site Collection, the CAML would be up-to-date and accurate; there would be no need to run the "updater" feature. (In your Feature Receiver, you should make sure you do some extra checking to make sure a Site Column doesn't already belong to a Content Type before adding it, etc. in case that change is already in place before the code executes.) This approach means you only have to execute one Feature when creating a new Site Collection, but it also means you're maintaining changes in two places: in your Feature Receiver for making changes to existing sites, and in your CAML for new sites. It's a cleaner approach, but also contains an element of redundancy, which always leaves room for human error.
• The other approach is to simply assume that every time the base CAML feature is activated, you're always going to execute the Feature Receiver. This approach says the only time you'd change the CAML is to add a new Site Column or new Content Type; otherwise, all the changes happen in the Feature Receiver. This approach reduces redundancy, but also means your Feature Receiver code could get quite large with all your changes over time, and it could leave your CAML as very much "legacy" over time.
Src: http://blog.beckybertram.com/Lists/Posts/Post.aspx?List=eb3e1762%2Dbab0%2D4e96%2D8bc5%2Dd67d6e6bfd44&ID=18

A: Updating Content Types is still one of the underdeveloped portions of Sharepoint which sometimes causes trouble, especially in Content Deployment scenarios.
The best thing in your case would be to always avoid making any changes to content types by hand (using UI)
Whenever you are installing the content type, make sure that you remove the previous one and then install the new one. (Sometimes its not possible due to pages being already created out of it).

A: My current approach to deploying content types is to do as much as possible using code rather than CAML. That way it is easy to fully control the logic of updates, including ensuring that changes made manually don't cause conflicts. I have the structure defined as attributes on an interface I also use for strongly typed list access, but there are several other ways you could do it.
The only piece that isn't available in the API is setting a specific content type ID, so you need to have a caml file for that, but it's a small/simple file, doesn't try to make updates and is only referenced from a feature that will also run the update code.