text:
Q: "Cover" image without knowing the width and the height of the block Below is my code:

.background{
    margin: 0;
    padding: 0;
    width:100%;
    height:100%;
    position: absolute;
    background: url('https://dummyimage.com/600x400/000/fff') no-repeat center bottom / cover;
}

 #subimage{
    background: url("https://dummyimage.com/600x400/000/fff") no-repeat bottom / cover;

  position: absolute;
  left: 24.5%;
  top: 28.3%;
  width:??
  height: ??
}
<!DOCTYPE html>

    <meta charset="UTF-8">
    <link rel="stylesheet" href="css/main.css">

I don't know the size of the image, so I don't know the size of the block (if possible, I can use the img tag, but the block is more suitable for my task).
It is necessary to obtain the "native" image size, as the cover does, but without knowing the width and height of the block;

A: May be this is helpful to you.
I used background as a base, without giving it any height but did that with padding-bottom. and then smartly put the subimage over it, and yes it is responsive in all the screens

.background{
margin: 0;
    padding: 0;
    width: 100%;
    padding-bottom: 85%;
    position: relative;
    background: url(https://i.ibb.co/bX8rPqr/mac-computer-screen-png-apple-mac-computer-screen-png-1122.png) no-repeat center bottom / cover;
    background-size: contain;
}

 #subimage{
background: url(https://dummyimage.com/600x400/000/fff) no-repeat bottom / cover;
    position: absolute;
    background-size: cover;
    z-index: 12;
    width: 92%;
    height: 61.9%;
    left: 4.1%;
    bottom: 28.6%;
}


text:
Q: Ordering columns in Microsoft SQL Server when they contain html tags I have several columns in a SQL Server database like this:
Column1                       Column2
Item1
5424

Item2
3424

Item3
8424

Item4
6424

I would like to reorder them using ORDER BY based on the value inside of >*
, so that the output looks like this:
Column1                       Column2
Item2
3424

Item1
5424

Item4
6424

Item3
8424

I am using the following code to extract the values from the database:
SELECT
    Table1_1.F1 AS Column1, Table2_1.1PrisHTML AS Column2
FROM
    Table2 AS Table2_1
CROSS JOIN
    Table1 AS Table1_1

UNION ALL

SELECT
    Table1_1.L1, Table2_1.2PrisHTML
FROM
    Table2 AS Table2_1
CROSS JOIN
    Table1 AS Table1_1

UNION ALL

SELECT
    Table1_1.M1, Table2_1.3PrisHTML
FROM
    Table2 AS Table2_1
CROSS JOIN
    Table1 AS Table1_1

UNION ALL

SELECT
    Table1_1.T1, Table2_1.4PrisHTML
FROM
    Table2 AS Table2_1
CROSS JOIN
    Table1 AS Table1_1

Anybody have any suggestions?
Edit:
I DO have the values in a separate column, called Column3 which I can use for sorting. But I do not want to display this column. Any suggestions?

A: Just add an Order By clause at the end of your SQL queries.  No need to add it to the select query.
I'd do it like this:
    SELECT Column1, Column2
    FROM
    (
    SELECT Table1_1.F1 AS Column1, Table2_1.1PrisHTML AS Column2, Column3
    FROM     Table2 AS Table2_1 CROSS JOIN
                      Table1 AS Table1_1
    UNION ALL
    SELECT Table1_1.L1 AS Column1, Table2_1.2PrisHTML AS Column2, Column3
    FROM     Table2 AS Table2_1 CROSS JOIN
                      Table1 AS Table1_1
    UNION ALL
    SELECT Table1_1.M1 AS Column1, Table2_1.3PrisHTML AS Column2, Column3
    FROM     Table2 AS Table2_1 CROSS JOIN
                      Table1 AS Table1_1
    UNION ALL
    SELECT Table1_1.T1 AS Column1, Table2_1.4PrisHTML AS Column2, Column3
    FROM     Table2 AS Table2_1 CROSS JOIN
                      Table1 AS Table1_1
    )
    ORDER BY Column3

redpajama_set_name: RedPajamaStackExchange


text:
Q: Configure a group of type registrations at one time In my code, currently types are registered with lots of duplicated code, e.g.
builder.RegisterType<UserViewModelValidation>()
    .As<IValidator<UserViewModel>>()
    .PropertiesAutowired().InstancePerLifetimeScope();

builder.RegisterType<RoleValidation>()
    .As<IValidator<Role>>()
    .PropertiesAutowired().InstancePerLifetimeScope();

Instead of having to configure each of these registrations one by one, is there a way to configure a group of them?
So in the above code, it's specifically the PropertiesAutowired() function and InstancePerLifetimeScope() function which is generic to a group of type registrations.

A: You can create a custom extension method that will do what you want.
public static class RegistrationExtensions
{
    public static IRegistrationBuilder<TValidator, ConcreteReflectionActivatorData, SingleRegistrationStyle>
        RegisterValidator<TValidator, TViewModel>(this ContainerBuilder builder)
    {
        return builder.RegisterType<TValidator>()
                      .As<IValidator<TViewModel>>()
                      .PropertiesAutowired()
                      .InstancePerLifetimeScope();
    }
}

And then register your type like this :
builder.RegisterValidator<UserViewModelValidation, UserViewModel>();
builder.RegisterValidator<RoleValidation, Role>();

A: In addition to Cyril's answer, I created some additional extensions for registering types in my application using Autofac.
public static IRegistrationBuilder<T, ConcreteReflectionActivatorData, SingleRegistrationStyle>
    RegisterInstance<T, TServiceType>(this ContainerBuilder builder)
{
    return builder.RegisterType<T>().As<TServiceType>().InstancePerLifetimeScope();
}

public static IRegistrationBuilder<T, ConcreteReflectionActivatorData, SingleRegistrationStyle>
    RegisterAutowiredInstance<T>(this ContainerBuilder builder)
{
    return builder.RegisterType<T>().PropertiesAutowired().InstancePerRequest();
}

public static IRegistrationBuilder<object, ReflectionActivatorData, DynamicRegistrationStyle>
    RegisterGenericInstance(this ContainerBuilder builder, Type type, Type serviceType)
{
    return builder.RegisterGeneric(type).As(serviceType).InstancePerRequest();
}

Usage examples:
builder.RegisterInstance<UnitOfWork, IUnitOfWork>();
builder.RegisterAutowiredInstance<Authorize>();
builder.RegisterGenericInstance(typeof(EntityBaseRepository<>), typeof(IEntityBaseRepository<>));

Helps to reduce the amount of redundant code and typing when registering new types.


text:
Q: disabled fields not storing in database PHP / MYSQL here is the screenshot where i am stuck:

the disabled fields row are not being stored to database after submit button please help !
Also, sometimes ago it use to work but now no more.. I am really stuck what the issue is and i have not made any such changes that create such issue..
before it used to store these stuffs, when fields are disabled:
ID, website, comapny type.
but now they are not working.. please help !

A: If you use disabled property, value of the field will not be submitted along with form.
What you have to do is use readonly attribute.

From https://stackoverflow.com/a/7730719/1288198:
read more about this in this great article or the definition by w3c. to quote the important part:

Key Differences
The Disabled attribute

*

*Values for disabled form elements are not passed to the processor method. The W3C calls this a successful element.(This works similar to
  form check boxes that are not checked.)

*Some browsers may override or provide default styling for disabled form elements. (Gray out or emboss text) Internet Explorer
  5.5 is particularly nasty about this.

*Disabled form elements do not receive focus.

*Disabled form elements are skipped in tabbing navigation.

  The Read Only Attribute

*

*Not all form elements have a readonly attribute. Most notable, the <SELECT> , <OPTION> , and <BUTTON> elements do not have readonly
  attributes (although thy both have disabled attributes)

*Browsers provide no default overridden visual feedback that the form element is read only. (This can be a problem… see below.)

*Form elements with the readonly attribute set will get passed to the form processor.

*Read only form elements can receive the focus

*Read only form elements are included in tabbed navigation.

A: Try use
<INPUT NAME="name" VALUE="Hi There" READONLY>

instead of
<INPUT NAME="name" VALUE="Hi There" DISABLED>

A: Get Input fields are readonly to prevent changes and getting values in $_POST.
In select tag use disabled and put hidden field for it.

A: yes you can not insert disabled field, you have to make your form readonly as answered above by deepu
use
<input type='text' name='test' readonly="readonly" />

A: Never mind i got the answer.. !
i just restarted sql and did some tweaks and that works !


text:
Q: if else statement not working in loop #c #include <stdio.h>
#include <stdlib.h>

int main()
{
    int a, itemAmount, totalFee = 0, rate[10], fee[6] = {7, 3, 5, 2, 3};
    char item[6][50], inputItem[50];

    strcpy(item[0], "Rice Cooker");
    strcpy(item[1], "Radio");
    strcpy(item[2], "Iron");
    strcpy(item[3], "Charger");
    strcpy(item[4], "Kettle");

    printf("Amount of item: ");
    scanf("%i", &itemAmount);

    for(int a = 0; a < itemAmount; a++){
        printf("\n%i) Item : ", a+1);
        scanf("%s", &inputItem);
        strcpy(item[a], inputItem);

        if(item[a] == item[0]){
            rate[a] = fee[0];
        }else if(item[a] == item[1]){
            rate[a] = fee[1];
        }else if(item[a] == item[2]){
            rate[a] = fee[2];
        }else if(item[a] == item[3]){
            rate[a] = fee[3];
        }else{
            rate[a] = fee[4];
        }

        totalFee = totalFee + rate[a];
    }

    printf("\n%i", totalFee);
}

I want to add all of the items' rate at the end but when I run it, all of the items's rate are 7 instead of the following:
Rice Cooker: 7
Radio: 3
Iron: 5
Charger: 2
Kettle: 3
For example, if I enter two items, which are Radio and Kettle, the total rate went to 10. It is wrong because the radio(3) and kettle(3), should be 6 if they're added up.
I'm now learning array and I'm very new to programming please help me :)


text:
Q: Laravel validator - how to return only errors for certain fields? I have one form in Laravel in which I have a couple of fields marked as "required" in the validation rules of the controller. When the field is empty, Laravel highlights that field with a red border and adds the is-invalid CSS class (which is good). When the field is filled with anything, it adds a green border and is-valid CSS class.
However, for some fields, I would like to hide the green border when they're filled with something (success response) and only show the red border (failed response) when they're empty.
Is there a way to silence the success response for some fields in the validator rules / controller?

A: Your JavaScript code is adding a css class to your inputs like: 'is-valid', 'valid', 'other-valid-class'.
Just control by JavaScript when add the is-valid class.
Check your Script insert in the blade or the @section('scripts').
If in the controller your validations return a fail (on these input) should be shown as red border.


text:
Q: Physical memory location of uninitialised memory location in C program? I have read that the uninitialized global variables in C will occupy the .bss section of the memory. Also it is just a place holder and doesn't occpy any space in object file.
My question is, once the uninitialised global variable is assigned with some value, where will it will get stored in physical memory?
For example:
int a[100];

int main()
{
    a[10] = 25;
}

In the above program, where will the memory location be allocated?

A: Where the global variables will be stored is implementation defined, the C standard does not define where it should be saved.
The C Standard does not even mention Bss segment or Data segment it only defines the behavior such variables must show.

A: I think your misunderstanding is thinking that BSS is "permanently zero" memory. It's just a section of the program load mapping that's implicitly zero and thus avoids having any physical storage on disk, but otherwise it's a standard private writable mapping, and takes on physical existence as soon as it's written to.
If you're thinking about it moving, perhaps you're confusing virtual and physical addresses. The virtual address of an object in C never changes, and the physical address is never visible to you and should never matter.


text:
Q: retrieving an item from array always returns -1 I'm trying to get pull a value from an array based on the index and I can't get it to work for some reason. Keeps returning -1
$alphabet =  [char[]]([char]'a'..[char]'z')
$AZ = 'A'..'Z

##Option 1
[array]::indexof($AZ, 2)

##Option 2
$AZ.IndexOf( 2 )

both of these options return -1
I should say I tried following this article.
https://devblogs.microsoft.com/scripting/find-the-index-number-of-a-value-in-a-powershell-array/

A: Hope this helps you identify the problem:
PS /> [char[]]$alphabet = 'a'..'z'
PS /> [array]::IndexOf($alphabet,'f') #=> Returns -1
PS /> [array]::IndexOf($alphabet,[char]'f') #=> Returns 5
PS /> $alphabet.IndexOf('f') #=> Returns -1
PS /> $alphabet.IndexOf([char]'f') #=> Returns 5

PS /> ([char]'f').Equals([string]'f') #=> Returns false, here is your hint


text:
Q: Laravel Email Verification 5.7 using REST API How to remake Laravel 5.7 Email Verification for Rest API?
Or is it worth doing everything from scratch?

A: This case works for me. Full project code here.
1) Redesigned VerificationController controller
Removed redirects and made response()->json(...) responses.
<?php

namespace App\Http\Controllers\API\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\VerifiesEmails;
use Illuminate\Http\Request;
use Illuminate\Auth\Events\Verified;

class VerificationController extends Controller
{
    use VerifiesEmails;

    /**
     * Show the email verification notice.
     *
     */
    public function show()
    {
        //
    }

    /**
     * Mark the authenticated user's email address as verified.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function verify(Request $request)
    {
        // ->route('id') gets route user id and getKey() gets current user id()
        // do not forget that you must send Authorization header to get the user from the request
        if ($request->route('id') == $request->user()->getKey() &&
            $request->user()->markEmailAsVerified()) {
            event(new Verified($request->user()));
        }

        return response()->json('Email verified!');
//        return redirect($this->redirectPath());
    }

    /**
     * Resend the email verification notification.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function resend(Request $request)
    {
        if ($request->user()->hasVerifiedEmail()) {
            return response()->json('User already have verified email!', 422);
//            return redirect($this->redirectPath());
        }

        $request->user()->sendEmailVerificationNotification();

        return response()->json('The notification has been resubmitted');
//        return back()->with('resent', true);
    }

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
        $this->middleware('signed')->only('verify');
        $this->middleware('throttle:6,1')->only('verify', 'resend');
    }
}

2) Added my Notification:
I made it so that the link in the email message led to my frontend and contained a temporarySignedRoute link for the request.
use Illuminate\Auth\Notifications\VerifyEmail as VerifyEmailBase;

class VerifyEmail extends VerifyEmailBase
{
//    use Queueable;

    /**
     * Get the verification URL for the given notifiable.
     *
     * @param  mixed  $notifiable
     * @return string
     */
    protected function verificationUrl($notifiable)
    {
        $prefix = config('frontend.url') . config('frontend.email_verify_url');
        $temporarySignedURL = URL::temporarySignedRoute(
            'verification.verify', Carbon::now()->addMinutes(60), ['id' => $notifiable->getKey()]
        );

        // I use urlencode to pass a link to my frontend.
        return $prefix . urlencode($temporarySignedURL);
    }
}

3) Added config frontend.php:
return [
    'url' => env('FRONTEND_URL', 'http://localhost:8080'),
    // path to my frontend page with query param queryURL(temporarySignedRoute URL)
    'email_verify_url' => env('FRONTEND_EMAIL_VERIFY_URL', '/verify-email?queryURL='),
];

4) Added to User model:
use App\Notifications\VerifyEmail;

and
/**
 * Send the email verification notification.
 *
 * @return void
 */
public function sendEmailVerificationNotification()
{
    $this->notify(new VerifyEmail); // my notification
}

5) Added routes
The following routes are used in Laravel:
// Email Verification Routes...
Route::get('email/verify', 'Auth\VerificationController@show')->name('verification.notice');
Route::get('email/verify/{id}', 'Auth\VerificationController@verify')->name('verification.verify');
Route::get('email/resend', 'Auth\VerificationController@resend')->name('verification.resend');

They are added to the application if used Auth::routes();.
As far as I understand the email/verify route and its method in the controller are not needed for Rest API.
6) On my frontend page /verify-email(from frontend.php config) i make a request to the address contained in the parameter queryURL
The received URL looks like this:
"http://localhost:8000/api/email/verify/6?expires=1537122891&signature=0e439ae2d511f4a04723a09f23d439ca96e96be54f7af322544fb76e3b39dd32"

My request(with Authorization header):
await this.$get(queryURL) // typical get request

The code perfectly verify the email and I can catch the error if it has already been verified. Also I can successfully resend the message to the email.
Did I make a mistake somewhere? Also I will be grateful if you improve something.

A: I tried Илья Зеленько answer but I must modify VerificationController construct method as follow
public function __construct()
{
    $this->middleware('auth')->except(['verify','resend']);
    $this->middleware('signed')->only('verify');
    $this->middleware('throttle:6,1')->only('verify', 'resend');
}

otherwise laravel need autentication to access verify and resend routes


text:
Q: how to detect file if exist in python how can i detect if a specifics files exist in directory ?
example:
i want to detect if (.txt) files exist in directory (dir)
i tried with this :
import os.path
from os import path

def main():

   print ("file exist:"+str(path.exists('guru99.txt')))
   print ("File exists:" + str(path.exists('career.guru99.txt')))
   print ("directory exists:" + str(path.exists('myDirectory')))

if __name__== "__main__":
   main()

but all this functions you must to insert the complete file name with format(.txt)
Thank you !

A: to check if a specific file exists:
import os
os.path.exists(path_to_file)

will return True if it exists, False if not
to check if ANY .txt files exist:
import glob
    if glob.glob(path_to_files_'*.txt'):
        print('exists')
    else:
        print('doesnt')

A: from glob import glob
files = glob('*.txt')
print(len(files)) # will return the number of .txt files in the dir
print(files) # will return all the .txt files in the dir


text:
Q: How to create custom textbox in windows phone 7? Is it possible to handle the sip by creating the custom textbox.
I want to create a custom textbox --> create the got focus event--> On focus of my custom textbox instead of SIP my custom keypad should open.
Requirements:

*

*How to create custom textbox?

*Open the custom Keypad instead of SIP

*Get the cursor in the textfield.

A: The display of the SIP is handled by the operating system and will always be on top of the visual tree of any application. If you want to provide a custom SIP, you will need to provide an alternative input control, because the display of the native SIP is tied to input controls (such as TextBox, PasswordBox, etc.). You may find this article about creating a Bulgarian keyboard useful.
To create a custom TextBox you could start by inheriting from TextBox itself, but you may find yourself fighting against the default implementation, so you may just want to inherit from Control instead.
To open the custom SIP instead of the default SIP, you'll need to tie this into an event on your custom TextBox and this is one of the places where inheriting from Control will probably make your life easier, because if you inherit from TextBox, then as soon as it receives focus the default SIP will show. You will probably want to make the SIP part of the ControlTemplate for the PhoneApplicationFrame so that you can guarantee that it is above the page content.
To get a cursor in your custom TextBox you'll need to handle the display of a caret yourself and update it as the user types on your custom SIP.
This is an awful lot of work to achieve something that sounds simple, which I suspect is why noone has done it yet :) I would definitely recommend requesting it as a feature on the official WP7 Dev UserVoice forum


text:
Q: Why is "the" dropped in "I go to school by bus"? Why is the dropped in "I go to school by bus"? Why isn't it "I go to the school by the bus" if both school and bus are countable? Does the rule that a countable noun must have an article have an exception here?

A: There are a number of cases where nouns are not preceded by any article ('the zero article'). They include meals and places as institutions, times of the day, days, months and seasons and, as here, means of transport and communication. We speak of going by air, car, horse or rail and sending by mail, post or e-mail.

A: School without an article means the school as an educational system. It's sort of like an abstract noun, I think.
A/the school places more importance on the physical aspect of school. (Not necessarily the case for "the".)

*

*

He is in school.

= He is a student.

*

He is in the school.

= He is in a school building.

A: I'll try to answer only the part about by bus. Adjunct prepositional phrases beginning with by, when they have the function of indicating manner/means, seem to require mass nouns, or derived nouns which behave like mass nouns in not needing an article.
I can think of three major categories of nouns appearing in the manner/means by-prepositional phrase. The first is gerundive verb phrases. Gerundive verb phrases can have two variants, one with no article, and an unmarked object, and another with an article, and the object "demoted" to an of-prepositional phrase. Note that only the article-less version is grammatical.

Columbo solved the crime by tricking the suspect.
  *Columbo solved the crime by the tricking of the suspect.
  Dawn hurt her knee by tripping over a rock.
  Barney ruined his chances for college by drinking heavily.

The second category is deverbal nouns formed with the sundry latinate nominalizing suffixes:

Mason got money by litigation.
  The iron rusts by oxidation.
  Johnson gained agreement for his plans by deceit.
  The home's value was determined by appraisal.

The third category is underived mass nouns:

Thomas can tell by smell whether the cookies are done.
  Thomas made cookies by hand.
  Thomas can recite the Koran by heart.
  Thomas obtained signatures by force.

I think phrases like by bus and by foot would fall into this latter category. Though these nouns might not seem like mass nouns when you reflect on their referents, they are acting as mass nouns grammatically, because this particular construction only works with article-less noun phrases. To see that by bus contains a mass noun, compare it with the following odd-sounding sentence.

??Thomas goes to work by MARTA.

(MARTA: = metropolitan atlanta rapid transit authority)
The noun MARTA is just too specific to fit into the "grinder", but more general-sounding nouns like bus, horse, foot, car, etc., can do it.

A: The first answer is ok but let me add something. When we talk about the primary purpose of the institute or building where we go for our job or work, we do not use the article a or the. If one visits the place or institute other than the primary purpose, and article is used.
For example: A doctor goes to clinic. However, if his friend comes to see him there, the sentence would be: The doctor's friend visited him in the clinic, or, My father goes to the school to see my teachers, etc.

A:
Why the is dropped in I go to school by bus instead of I go to the
  school by the bus.wherein school and bus are countable?

Why, is because it is not necessary to use the word the, when talking in a general sense. It is the same reason why people don't normally use it when talking about other situations, like going to university, going to hospital (although Americans make an exception for going to hospitals, so it is worth also seeing my answer here Is there a reason the British omit the article when they "go to hospital"?) or going to work. Use of the word 'the', means that the sentence is in a particular sense. A reference to one, particular example. "I go to the school by the bus" will mean going to one, particular school and travelling on one, particular bus.
If what you mean is attending a school in the general sense, without a particular need to say which one; then saying "I go to school", will be sufficient. If you also mean that you travel there on a bus or buses, but do not have a particular need to say which bus or buses; then saying "by bus", will be sufficient.
Saying "I go to the school" will mean going to one, particular school. Saying "I go to the school by the bus" will mean going on one, particular bus.
Saying "I go to the school by the bus" would only make sense if you have already said which, particular school and bus, you are talking about.
Basically, the word the is not used when talking in the general sense, because it gives the wrong impression, which is that you are talking in the particular sense. Using it would therefore be unnecessary and make your exact meaning, unclear.
It is not a case of the word 'the' being dropped. It is a case of it being unnecessary and giving a different meaning from what you intended.


text:
Q: How to make sidebar work with custom javascript I have a sidebar menu that I'm trying to integrate with a Laravel PHP app. The sidebar appears fine on the display page when I run the app, but the animation, dropdown, and toggle do not work when the application is run.
The HTML has no problems:

                Brand

            Home

            About

            Events

            Team

            Works

Dropdown heading

Action

Another action

Something else here

Separated link

One more separated link

            Services

            Contact

            Follow me

    <button type="button" class="hamburger is-closed" data-toggle="offcanvas">

    </button>

The CSS is also working with the sidebar
    body {
position: relative;
overflow-x: hidden;
 }
body,
html { height: 100%;}
.nav .open > a,
.nav .open > a:hover,
.nav .open > a:focus {background-color: transparent;}

/*-------------------------------*/
/*           Wrappers            */
/*-------------------------------*/

#wrapper {
padding-left: 0;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}

#wrapper.toggled {
padding-left: 220px;
}

#sidebar-wrapper {
z-index: 1000;
left: 220px;
width: 0;
height: 100%;
margin-left: -220px;
overflow-y: auto;
overflow-x: hidden;
background: #1a1a1a;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}

#sidebar-wrapper::-webkit-scrollbar {
display: none;
}

#wrapper.toggled #sidebar-wrapper {
width: 220px;
}

#page-content-wrapper {
width: 100%;
padding-top: 70px;
}

#wrapper.toggled #page-content-wrapper {
position: absolute;
margin-right: -220px;
}

/*-------------------------------*/
/*     Sidebar nav styles        */
/*-------------------------------*/

.sidebar-nav {
position: absolute;
top: 0;
width: 220px;
margin: 0;
padding: 0;
list-style: none;
}

.sidebar-nav li {
position: relative;
line-height: 20px;
display: inline-block;
width: 100%;
}

.sidebar-nav li:before {
content: '';
position: absolute;
top: 0;
left: 0;
z-index: -1;
height: 100%;
width: 3px;
background-color: #1c1c1c;
-webkit-transition: width .2s ease-in;
-moz-transition:  width .2s ease-in;
-ms-transition:  width .2s ease-in;
transition: width .2s ease-in;

}
.sidebar-nav li:first-child a {
color: #fff;
background-color: #1a1a1a;
}
.sidebar-nav li:nth-child(2):before {
background-color: #ec1b5a;
}
.sidebar-nav li:nth-child(3):before {
background-color: #79aefe;
}
.sidebar-nav li:nth-child(4):before {
background-color: #314190;
}
.sidebar-nav li:nth-child(5):before {
background-color: #279636;
}
.sidebar-nav li:nth-child(6):before {
background-color: #7d5d81;
}
.sidebar-nav li:nth-child(7):before {
background-color: #ead24c;
}
.sidebar-nav li:nth-child(8):before {
background-color: #2d2366;
}
.sidebar-nav li:nth-child(9):before {
background-color: #35acdf;
}
.sidebar-nav li:hover:before,
.sidebar-nav li.open:hover:before {
width: 100%;
-webkit-transition: width .2s ease-in;
-moz-transition:  width .2s ease-in;
-ms-transition:  width .2s ease-in;
transition: width .2s ease-in;

}

.sidebar-nav li a {
display: block;
color: #ddd;
text-decoration: none;
padding: 10px 15px 10px 30px;
}

.sidebar-nav li a:hover,
.sidebar-nav li a:active,
.sidebar-nav li a:focus,
.sidebar-nav li.open a:hover,
.sidebar-nav li.open a:active,
.sidebar-nav li.open a:focus{
color: #fff;
text-decoration: none;
background-color: transparent;
}

.sidebar-nav > .sidebar-brand {
height: 65px;
font-size: 20px;
line-height: 44px;
}
.sidebar-nav .dropdown-menu {
position: relative;
width: 100%;
padding: 0;
margin: 0;
border-radius: 0;
border: none;
background-color: #222;
box-shadow: none;
}

/*-------------------------------*/
/*       Hamburger-Cross         */
/*-------------------------------*/

.hamburger {
position: fixed;
top: 20px;
z-index: 999;
display: block;
width: 32px;
height: 32px;
margin-left: 15px;
background: transparent;
border: none;
}
.hamburger:hover,
.hamburger:focus,
.hamburger:active {
outline: none;
}
.hamburger.is-closed:before {
content: '';
display: block;
width: 100px;
font-size: 14px;
color: #fff;
line-height: 32px;
text-align: center;
opacity: 0;
-webkit-transform: translate3d(0,0,0);
-webkit-transition: all .35s ease-in-out;
}
.hamburger.is-closed:hover:before {
opacity: 1;
display: block;
-webkit-transform: translate3d(-100px,0,0);
-webkit-transition: all .35s ease-in-out;
}

.hamburger.is-closed .hamb-top,
.hamburger.is-closed .hamb-middle,
.hamburger.is-closed .hamb-bottom,
.hamburger.is-open .hamb-top,
.hamburger.is-open .hamb-middle,
.hamburger.is-open .hamb-bottom {
position: absolute;
left: 0;
height: 4px;
width: 100%;
}
.hamburger.is-closed .hamb-top,
.hamburger.is-closed .hamb-middle,
.hamburger.is-closed .hamb-bottom {
background-color: #1a1a1a;
}
.hamburger.is-closed .hamb-top {
top: 5px;
-webkit-transition: all .35s ease-in-out;
}
.hamburger.is-closed .hamb-middle {
top: 50%;
margin-top: -2px;
}
.hamburger.is-closed .hamb-bottom {
bottom: 5px;
-webkit-transition: all .35s ease-in-out;
}

.hamburger.is-closed:hover .hamb-top {
top: 0;
-webkit-transition: all .35s ease-in-out;
}
.hamburger.is-closed:hover .hamb-bottom {
bottom: 0;
-webkit-transition: all .35s ease-in-out;
}
.hamburger.is-open .hamb-top,
.hamburger.is-open .hamb-middle,
.hamburger.is-open .hamb-bottom {
background-color: #1a1a1a;
}
.hamburger.is-open .hamb-top,
.hamburger.is-open .hamb-bottom {
top: 50%;
margin-top: -2px;
}
.hamburger.is-open .hamb-top {
-webkit-transform: rotate(45deg);
-webkit-transition: -webkit-transform .2s cubic-bezier(.73,1,.28,.08);
}
.hamburger.is-open .hamb-middle { display: none; }
.hamburger.is-open .hamb-bottom {
-webkit-transform: rotate(-45deg);
-webkit-transition: -webkit-transform .2s cubic-bezier(.73,1,.28,.08);
}
.hamburger.is-open:before {
content: '';
display: block;
width: 100px;
font-size: 14px;
color: #fff;
line-height: 32px;
text-align: center;
opacity: 0;
-webkit-transform: translate3d(0,0,0);
-webkit-transition: all .35s ease-in-out;
}
.hamburger.is-open:hover:before {
opacity: 1;
display: block;
-webkit-transform: translate3d(-100px,0,0);
-webkit-transition: all .35s ease-in-out;
}

/*-------------------------------*/
/*            Overlay            */
/*-------------------------------*/

.overlay {
position: fixed;
display: none;
width: 100%;
height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(250,250,250,.8);
z-index: 1;
}

Javascript is the part of the program that is not working.
$(document).ready(function () {
var trigger = $('.hamburger'),
    overlay = $('.overlay'),
    isClosed = false;

trigger.click(function () {
    hamburger_cross();
});

function hamburger_cross() {

    if (isClosed == true) {
        overlay.hide();
        trigger.removeClass('is-open');
        trigger.addClass('is-closed');
        isClosed = false;
    } else {
        overlay.show();
        trigger.removeClass('is-closed');
        trigger.addClass('is-open');
        isClosed = true;
    }
}

$('[data-toggle="offcanvas"]').click(function () {
    $('#wrapper').toggleClass('toggled');
});
});

This is the code that I have for the master.blade.php file in my Laravel app
<!DOCTYPE HTML>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>@yield('title')</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link rel="stylesheet" href="{{ URL::asset('src/css/app.css') }}">
    <link rel="stylesheet" href="{{ URL::asset('src/css/components/sidebar.css') }}">

            @include('layouts.partials.sidebar')

            @yield('content')

How do I organize the javascript files in master.blade.php file to make the sidebar work?


text:
Q: How to make a dictionary within a dictionary in MySQLPython? I have the below code:
import MySQLdb
import sys
import pprint

connect = MySQLdb.connect(host = "127.8.2.3", port=3377, user = "root",  db="data1")
with connect:

    cur = connect.cursor()
    cur.execute("SELECT familynames,names FROM data1.files")

    rows = cur.fetchall()
pprint.pprint(rows)

I want to create a big dictionary which has "family names" as key and "names" as the value.Further, the value of the big dict(names), should again be a dict itself with key=names and value= number of identical names under the same family name.
I have tried the DictCursor  function of MySQLPython but it is not capable of creating dict within dict.
I also have tried to make a loop over each item of the big dict to split and create another smaller dict(for values of the big dict) but since the returned result of the cur.execute is a Tuple that is not possible as well.
Can someone help me in this regards?

A: You need to do some processing to get that structure. I'd use itertools.groupby to get your rows grouped by family name, then a collections.Counter() to create the inner mapping you need.
groupby requires that you sorted the data, so the query needs a ORDER BY clause too:
from collections import Counter
from itertools import groupby
from operator import itemgetter
import pprint

import MySQLdb

familynames = {}

connection = MySQLdb.connect(host="127.8.2.3", port=3377, user="root",  db="data1")
with connection:
    cur = connect.cursor()
    cur.execute("SELECT familynames, names FROM data1.files ORDER BY familynames")

    for familyname, names in groupby(cur, key=itemgetter(0)):
        familynames[familyname] = Counter(row[1] for row in names)

pprint.pprint(familynames)

The groupby function groups the rows on the first element of each row (the familynames column), so looping over the names iterable will only yield rows where familynames has the same value.
We then feed the names (second column in each row) to the Counter(), which results in name keys with a count for each name as the value.


text:
Q: Count columns and sum I am very new to the SQL, and I have a table with id (question id) and risk areas (risk1, risk2, and risk3).
+----+-------+------+------+
| id | risk1 | risk2| risk3|
+----+-------+------+------+
| 0  |   h   |   l  |   h  |
| 1  |   m   |   l  |   l  |
| 2  |   h   |   h  |   h  |
| 3  |   l   |   l  |   h  |
+----+-------+------+------+

My aim is to calculate the sum of 'h' for individual ids. For example the query should return '2' for id=0, '0' for id=1, '3' for id=2, and '1' for id=3. Any suggestion will be appreciated.

A: One way:
SELECT
    id,
    IF(COALESCE(risk1, '') = 'h', 1, 0) +
    IF(COALESCE(risk2, '') = 'h', 1, 0) +
    IF(COALESCE(risk3, '') = 'h', 1, 0) AS h_sum
FROM yourTable
ORDER BY id;

Just for fun, here is more exotic way of doing this, using string manipulation:
SELECT
    id,
    3 - LENGTH(REPLACE(CONCAT(risk1, risk2, risk3), 'h', '')) AS h_sum
FROM yourTable
ORDER BY id;

Demo
To make the second approach also be NULL safe, just use COALESCE(risk1, '') in place of risk1 (and the same for the other columns).

A: MySQL treats boolean expressions as numbers, so this is easy to express:
select id,
       ( (risk1 = 'h') + (risk2 = 'h') + (risk3 = 'h') ) as num_hs
from t;

Note:  This assumes that none of the values are NULL which appears to be the case with your data.

A: A more conventional (we could say 'better') solution might be as follows:
DROP TABLE IF EXISTS my_table;

CREATE TABLE my_table
(id INT NOT NULL
,risk_no INT NOT NULL
,risk_type CHAR(1) NOT NULL
,PRIMARY KEY(id,risk_no)
);

INSERT INTO my_table VALUES
(1,1,'h'),
(2,1,'m'),
(3,1,'h'),
(4,1,'l'),

(1,2,'l'),
(2,2,'l'),
(3,2,'h'),
(4,2,'l'),

(1,3,'h'),
(2,3,'l'),
(3,3,'h'),
(4,3,'h');

SELECT id, COUNT(*) total FROM my_table WHERE risk_type = 'h' GROUP BY id;
+----+-------+
| id | total |
+----+-------+
|  1 |     2 |
|  3 |     3 |
|  4 |     1 |
+----+-------+

or
SELECT id, SUM(risk_type = 'h') total FROM my_table GROUP BY id;
+----+-------+
| id | total |
+----+-------+
|  1 |     2 |
|  2 |     0 |
|  3 |     3 |
|  4 |     1 |
+----+-------+

A: A simple [verbose] query is:
select
  id,
  case when risk1 = 'h' then 1 end +
  case when risk2 = 'h' then 1 end +
  case when risk3 = 'h' then 1 end as sum_h
from t


text:
Q: 403 Invalid scope claims/roles I've seen this question asked before, but I'm reproducing all the steps and at loss of where the issue is.

*

*I have an app in Graph with requested app permission Reports.Read.All
(Admin). No other permissions requested.

*The admin has authorised this app (client credentials flow)

*I'm getting a token via client credentials flow

*However, any API call
to the Reports results in 403 Invalid scope claims/roles (e.g.
https://graph.microsoft.com/v1.0/reports/getEmailActivityUserCounts(period='D7') with Authorization: Bearer token)

*When I'm decoding the token, it has no reference to the scope whatsoever.

What am I doing wrong?

A: Resolved: I needed to register the app with Azure AD and not Graph.


text:
Q: Disable new blockquote contenteditable Disable new blockquote if Enter keypress on COntentent editable
javascript or jQuery
HTML

This is a paragraph. Lorem Ipsum...

This is a blockquote. Enter here

CSS
blockquote {
    background: beige;
    padding: 10px;
    border: 2px dashed #dadada;
}

Snippet

blockquote {
    background: beige;
    padding: 10px;
    border: 2px dashed #dadada;
}

This is a paragraph. Lorem Ipsum...

This is a blockquote. Enter here

A: Ans based on This old so ans.. Slightly modified for ans.

$('#demo').keypress(function(e) {
  var key = e.which;
  if (key == 13) // the enter key code
  {
    var input = document.getElementById('demo');

    if (whichTag("blockquote")) {

      document.execCommand('InsertParagraph');
      document.execCommand('Outdent');

    }
  }
});

function whichTag(tagName) {

  var sel, containerNode;
  var tagFound = false;

  tagName = tagName.toUpperCase();

  if (window.getSelection) {

    sel = window.getSelection();

    if (sel.rangeCount > 0) {
      containerNode = sel.getRangeAt(0).commonAncestorContainer;
    }

  } else if ((sel = document.selection) && sel.type != "Control") {

    containerNode = sel.createRange().parentElement();

  }

  while (containerNode) {

    if (containerNode.nodeType == 1 && containerNode.tagName == tagName) {

      tagFound = true;
      containerNode = null;

    } else {

      containerNode = containerNode.parentNode;

    }

  }

  return tagFound;
}
blockquote {
  background: beige;
  padding: 10px;
  border: 2px dashed #dadada;
}

This is a paragraph. Lorem Ipsum...

This is a blockquote. Enter here


text:
Q: Adding progress bar to calculation I have a class that does a complex calculation which may take a long time. I'd like to add a progress bar with Abort button. However, I would like to avoid mixing calculation code with GUI code if possible.
Are there any good design patterns for this?

A: The relevant design pattern is the Observer pattern: your class doing a calculation is the "subject", it maintains a list of Observers, implementing a common Observer interface, and when its state changes (i.e. the amount of progress has changed), it notifies each observer via an update() call.


text:
Q: Jquery slide-out bottom-top mouseover menu problem on loading a new page i'm struggling with converting a menu from mootools to jquery. there are various reasons why i have to switch the js framework and i need some help here because i quite new to jquery.
first the working mootools version on the live site: http://www.kieleconomcis.de
as you can see the menu moves up on hover, reveals the sub menu and stays up when you click a link and load the page.
now that i have to convert this into jquery i also want to be able to control the heigth of each menu individually, so it a) looks more like a bar graph and b) i can place 4 submenus :)
i played around, copy&pasted, tried&errored and ended up with this fiddle here.
my problem is - i guess - that i have a $('div.nav_body').hide(); but i need to tell it that it has to ignore the effect if the element before it has an id="visible"
here is some of the code so you can see what i need to trigger:

Über uns

thanks for any adice.

A: You can check if it's parent h4 has it's id set to visible
if ($('div.nav_body').parent('h4').attr('id') == 'visible')

A: Using the :not() and :has() selector works:
$('div.nav_container:not(:has(#visible)) .nav_body').hide();

The filter() method works as well:
$('div.nav_body').filter(function () {
    return !$(this).prev().is("#visible");
}).hide();

Or use .not() to remove the one submenu from the to-be-hidden items:
$('div.nav_body').not($("#visible").next()).hide();

I tested all three in your fiddle. I can't really say which one I like best, though.


text:
Q: Xamarin Forms Navigation Page bar with only text (no icon) How can I disable the xamarin icon in the navigation page bar and set the title?

A: We can access the ActionBar Icon and set it to transparent in the Android Project, Code:
protected override void OnCreate (Bundle bundle)
{
    base.OnCreate (bundle);
    global::Xamarin.Forms.Forms.Init (this, bundle);
    LoadApplication (new App ());
    this.ActionBar.SetIcon ((int)Android.Graphics.Color.Transparent));
}

Page has a title property that can be set. You can do it in the constructor something like this:
 this.Title = "my page";

A: You can use this to remove the icon.
ActionBar.SetIcon(Android.Resource.Color.Transparent);

And to set the title you can use the code in C#
this.Title="mypage"

or for Xaml put the below attribute in the ContentPage node
Title="mypage"


text:
Q: web-part permission I'm using SharePoint 2007, Custom list.
I have created 3 different view on one list,
and a custom permission.
in the home page each list-view appear in different wep-part.
In each web-part I defined the advanced target audiences from Distribution/Security Sharepoint groups. (in order that each group will see only one web-part).
is it possible to define for each group a permission level (the custom permission level)?
(in order to limit the group ability on the web-part)
P.S.
is it possible to do it without using sharpoint designer?

A: It is a common misconception to think that target audience has to do with permissions. Target audiences are ment to push out information to certain audiences, but there are no security involved.
Target audience can be used to determine conditional rendering of OOB webparts, rendering of list items in list view webparts (if audience is enabled on list items), personalization links and more.
The best performing way to use them, is to create target audience rules and compile them. These rules look either on security group membership or user profile property values.
Read more here


text:
Q: How do I catch a connection failure to a nonexistant Rose::DB database? My Perl application uses Rose::DB, Rose::DB::Object (ORM) and Tk on Windows XP. I need to check whether the database connection information (host, port, database name, user, password) leads to a valid connection. If I call $db->connect and use e.g. a nonexistant host for testing, Rose::DB says:
DBI connect('dbname=my_db;host=192.168.70.85;port=5432','postgres',...) failed: could not connect to server: No route to host (0x00002751/10065)
How do I catch this and create a new message for my application? Is this a question about try/catch in general?
Thank you for your help!

A: A solution that seems to work so far was posted to me from John:

    my $ok = eval { $db->connect };
if(!$ok || $@) { # Connection failed }


text:
Q: How to force Ionic to show only menu icon on every page? How to force Ionic to show only menu icon?
In Android, I only want to show menu icon for every page. However, in IOS, I want standard navigation (i.e. back button for inner pages).
Is it possible?
Any help is appreciated.
Edit:
Menu.html
<ion-side-menus enable-menu-with-back-views="isAndroid">
    <ion-side-menu-content >
        <ion-nav-bar class="bar-stable">
            <ion-nav-back-button></ion-nav-back-button>
            <ion-nav-buttons side="left">
                <button class="button button-icon button-clear ion-navicon" menu-toggle="left"></button>
            </ion-nav-buttons>
        </ion-nav-bar>
        <ion-nav-view name="featureContent"></ion-nav-view>
    </ion-side-menu-content>
    <ion-side-menu side="left">
        <ion-content>
           ...
        </ion-content>
    </ion-side-menu>
</ion-side-menus>

Home.html
<ion-view hide-back-button="isAndroid">
    <ion-content class="home">
        ...
    </ion-content>
</ion-view>

A: you can use ionic.Platform:
$scope.isIOS = ionic.Platform.isIOS();

for example:
<ion-nav-bar class="homler-nav-bar-with-tabs transparent opposite-direction">
    <ion-nav-back-button ng-show="isIOS" class="button-icon icon-top_button_back light">
    </ion-nav-back-button>
     <ion-nav-buttons side="left">
       <button ng-if="isIOS" class="button button-icon button-clear ion-navicon" menu-toggle="left"></button>
       <button ng-if="!isIOS" style="display: block" class="button button-icon button-clear ion-navicon" menu-toggle="left"></button>
     </ion-nav-buttons>


text:
Q: Installing Devise - ArgumentError Being a RoR beginner since a week, I've been trying to install the Devise gem via Railscast Episode 209 and alternatively via the Devise documentation. However, after several hours of trial and error I can't seem to overcome the following error:
/usr/local/rvm/gems/ruby-2.3.0/gems/activemodel-4.2.2/lib/active_model/validations/format.rb:39:in `check_options_validity': The provided regular expression is using multiline anchors (^ or $), which may present a security risk. Did you mean to use \A and \z, or forgot to add the :multiline => true option? (ArgumentError)
This comes up right after:
rake db:migrate

The routes.db file:
Rails.application.routes.draw do
  devise_for :users
  get 'users/new'

  root  'static_pages#home'
  get 'home'        => 'static_pages#home'
  get 'over'        => 'static_pages#over'
  get 'contact'     => 'static_pages#contact'
  get 'signup'      => 'users#new'
end

And user.rb:
class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :lockable, :timeoutable and :activatable
  devise :database_authenticatable, :registerable, :confirmable,
         :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation
end

After commenting devise_for :users the error disappears.
I've tried:

*

*going through all StackOverflow and GitHub threads containing this ArgumentError, but they don't resemble my situation

*creating a table Users before the commando rails generate devise User as suggested somewhere, but that doesn't do the trick either.

*search for RegExp tests, but I can't find them in my code.
Can anyone get me going again? How do I know where the error comes from based on the output?
Thanks all for your help!


text:
Q: Mysql DataAdapter Update Method - Doesn't Save Changes I'm using MySQL in vb.net
Datagridview displayed correctly and everything works properly, the problem arises when I try to update the changes in the database with the update (method)
By default the data is updated in memory "is erased students with ID =" 2 ""
But in the database is not updated, I'm reading the documentation and should work with update
datosAlumnos.Update(ds, "alumnos")
Imports MySql.Data.MySqlClient
    Public Class Form1
        Dim con As New MySqlConnection
        Dim stringCon As String = "server=localhost; user id=root; password=; database=centroeducativo"
        Dim listViewAlumnos As New ListBox()

        Dim ds As New DataSet()
        Private Sub Form1_Load(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles MyBase.Load
            Try
                con.ConnectionString = stringCon
                con.Open()
                Dim datosTablas As New MySqlDataAdapter("SHOW TABLES", con)
                Dim datosAlumnos As New MySqlDataAdapter("SELECT * FROM alumnos ORDER BY Nombre", con)
                Dim datosAsignaturas As New MySqlDataAdapter("SELECT * FROM asignaturas", con)
                Dim datosMatriculas As New MySqlDataAdapter("SELECT * FROM matriculas", con)

                datosTablas.Fill(ds, "tablas")
                datosAlumnos.Fill(ds, "alumnos")
                datosAsignaturas.Fill(ds, "asignaturas")
                datosMatriculas.Fill(ds, "matriculas")

                con.Close()

                Dim tabla As DataTable
                tabla = ds.Tables("tablas")
                Dim fila As DataRow
                Me.ListBox1.Items.Clear()
                For Each fila In tabla.Rows

                    Me.ListBox1.Items.Add(fila.Item("Tables_in_centroeducativo"))
                Next
                Dim filaBorrada As DataRow() = ds.Tables("alumnos").Select("id=2")
                filaBorrada(0).Delete()
                datosAlumnos.Update(ds, "alumnos")
            Catch ex As Exception

            End Try
        End Sub

    Private Sub formularioTabla(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        Dim curItem As String = ListBox1.SelectedItem.ToString()
        Select Case curItem
            Case "alumnos"
                FormularioAlumno()
            Case "asignaturas"
                FormularioAsignaturas()
            Case "matriculas"
                FormularioMatriculas()
            Case Else
                MsgBox("none")
        End Select
    End Sub

    Private Sub FormularioAlumno()
        Panel1.Controls.Clear()
        Dim dv As DataView = ds.Tables("alumnos").DefaultView
        con.Close()
        Dim DataGridView As New DataGridView()
        Panel1.Controls.Add(DataGridView)
        DataGridView.AutoSize = True
        DataGridView.DataSource = dv
        DataGridView.Columns("id").Visible = False
    End Sub
End Class

A: It seems you forget to set InsertCommand, UpdateCommand and specially Deletecommand.
To make a data adapter update data, it should have those commands. You can set those commands manually or using a MySqlCommandBuilder.
Dim myConn As New MySqlConnection("Connection String")
Dim myDataAdapter As New MySqlDataAdapter()
myDataAdapter.SelectCommand = New MySqlCommand("Select Query", myConn)
Dim myCommandBuilder As MySqlCommandBuilder = New MySqlCommandBuilder(myDataAdapter)


text:
Q: Migrate Visual Composer to Thrive Architect Is there a way to migrate content made with visual composer to thrive architect? I could not find any script or plugin.
Or can I use visual composer and thrive on one installation and migrate the content manually? For example: On the post X I am using only visual composer and on the post Y Thrive.

A: Both Editor (like Visual Composer and Thrive Plugin) are not possible to installation in one website url as you are asking here.
Get the more details, you can follow the link -
Visual Composer and Thrive Content Builder – Which is the Best WordPress Page Builder Plugin?


text:
Q: How to set in the Table methods field's properties from code? I want to set field properties , in table method from code.
I would like to do as a Form
in modifiedField Table method, I wolud like to insered look like this code:
if(this.FieldControl == "valueToBlock")
{
    // I want to set here the field property
    //this.Field_II allowEdit(false);
}

It's possible to set the property from code in Table method ?
thanks community,
enjoy!

A: You can use dataSource result on the buffer. The result is FormDataSource if buffer source is from client form.
If record changes you have to re-calculate this (create new method and call it from the table modifiedFiled and form DS active).
public void modifiedField(FieldId _fieldId)
{
    FormDataSource fds;
    super(_fieldId);
    switch (_fieldId)
    {
        case fieldNum(TableName,FieldI):
            if (this.isFormDataSource())
            {
                fds = this.dataSource();
                fds.object(fieldNum(MyTable, Field_II)).allowEdit(this.Field_I != "valueToBlock");
            }
            break;
    }
}


text:
Q: Array buffer and winapi Context :

*

*Windows 10

*WinAPI and C code

Question :
I have a buffer of pixel represented as uint8_t buffer[width * height * PIXEL_SIZE] that i would like to regularly modify the content data and redraw the buffer into the window.
I'm encoutering two issues with the winapi with which one i'm lost :

*

*How do i print a buffer of pixel onto the window ?

*How do i redraw later in the code the dame modifies buffer ?

I have made many researchs but no code snippet have successfully helped me to solve my issue.
Here is a not working code sample in order to show what i would like to archieve with the elements of code i have:
new_image.c
// Global variables
static HDC      hdc;
static HDC      context_hdc;
static HBITMAP  hDib;
static HGDIOBJ  obj;

static void     set_bmi_object(BITMAPINFO *bmi, int width, int height) {
    memset(bmi, 0, sizeof(BITMAPINFO));

    bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    bmi->bmiHeader.biWidth = width;
    bmi->bmiHeader.biHeight = -height;
    bmi->bmiHeader.biPlanes = 1;
    bmi->bmiHeader.biBitCount = 32;
    bmi->bmiHeader.biCompression = BI_RGB;
}

// Allocate a new image buffer
void             *new_image(HWND hwnd, int width, int height)
{
    BITMAPINFO  bmi;
    BYTE        *bits = NULL;
    void        *buffer;

    if (NULL == (buffer = (char*)malloc(width * height * PIXEL_SIZE)))
        return (NULL);

    set_bmi_object(&bmi, width, height);

    hdc = GetDC(hwnd);

    hDib = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**)(&bits),
                            NULL, 0);

    if (hDib != NULL) {
        context_hdc = CreateCompatibleDC(hdc);
        if (context_hdc == NULL) {
            DeleteObject(hDib);
        } else {
            obj = SelectObject(context_hdc, hDib);
            CopyMemory(bits, buffer, width * height * sizeof(PIXEL_SIZE));
        }
    }

    return (newimg);
}

// Print the buffer of pixel on the window
void             put_image_to_window(HWND hwnd, void *buffer, int x, int y)
{
    (void)hwnd;

    // Void buffer because i should use directly HDCcontext_hdc linked to HGDIOBJ   obj ?
    (void)buffer;

    BitBlt(hdc, // destination
        x,
        y,
        500, // width of the region
        500, // height
        context_hdc, // source
        0,   // x
        0,   // y
        SRCCOPY);

    UpdateWindow(hwnd);
}

main.c
static const char g_szClassName[] = "myWindowClass";

static void paint(HWND hwnd) {
    PAINTSTRUCT ps;
    HDC hdc = BeginPaint(hwnd, &ps);
    EndPaint(hwnd, &ps);
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg)
    {
        case WM_CLOSE:
            DestroyWindow(hwnd);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    case WM_PAINT:
        paint(hwnd);
    return DefWindowProc(hwnd, msg, wParam, lParam);
}

int main(void) {
    MSG             Msg;
    HINSTANCE       hInstance;
    HWND            hwnd;
    STARTUPINFOA    startup_info;
    WNDCLASSEX      wc;
    HWND            hwnd;

    GetStartupInfoA(&startup_info);

    hInstance = GetModuleHandle(NULL);

    memset(&wc, 0, sizeof(wc));

    // Registering the Window Class
    wc.cbSize = sizeof(WNDCLASSEX);
    // ... etc
    wc.lpszClassName = TEXT(g_szClassName);

    if (!RegisterClassEx(&wc)) {
        return (-1);
    }

    hwnd = CreateWindowEx(
        WS_EX_CLIENTEDGE,
        g_szClassName,
        "Title,
        WS_OVERLAPPEDWINDOW | WS_VISIBLE,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        500,
        500,
        NULL,
        NULL,
        hInstance,
        NULL);

    if (hwnd == NULL) {
        return (-1);
    }

    ShowWindow(hwnd, startup_info.wShowWindow);

    image = new_image(hwnd, 500, 500);

    put_image_to_window(hwnd, image, 0, 0);

    UpdateWindow(hwnd);

    // The Message Loop
    while (GetMessage(&Msg, NULL, 0, 0)) {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }

    return (Msg.wParam);
}

Here is in new_image.c

*

*a function new_image that returns a pointer on a buffer of pixels,

*a function put_image_to_window that display the buffer of pixels on the window.

A:
CopyMemory(bits, buffer, width * height * sizeof(PIXEL_SIZE));

Usage of sizeof operator is not correct. A bitmap can be 1, 4, 8, 16, 24, or 32 bit. A 32-bit bitmap has 4 bytes per pixel. If PIXEL_SIZE is declared as int32_t then by coincidence you get the right size. Otherwise use the correct formula to calculate size.
Also, there is no point in copying buffer to bits. You can use bits directly. bits will be valid as long as you have not destroyed hDib

hdc = GetDC(hwnd);

A call to GetDC should end with ReleaseDC, otherwise you may end up with resource leak. Windows device context is not meant to be stored as a constant. Use it as temporary value instead.
You also have declared HDC context_hdc as global variable. This is okay for memory device context, but it's not necessary. The only global variable you need is hDib and perhaps buffer
#include <windows.h>

static const char g_szClassName[] = "myWindowClass";
static HBITMAP  hDib;

BYTE *new_image(int width, int height)
{
    BITMAPINFO bmi;
    memset(&bmi, 0, sizeof(BITMAPINFO));
    bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    bmi.bmiHeader.biWidth = width;
    bmi.bmiHeader.biHeight = -height;
    bmi.bmiHeader.biPlanes = 1;
    bmi.bmiHeader.biBitCount = 32;
    bmi.bmiHeader.biCompression = BI_RGB;

    BYTE *buffer;
    HDC hdc = GetDC(HWND_DESKTOP);
    hDib = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**)(&buffer), NULL, 0);
    ReleaseDC(HWND_DESKTOP, hdc);
    return buffer;
}

static void paint(HWND hwnd)
{
    PAINTSTRUCT ps;
    HDC hdc = BeginPaint(hwnd, &ps);

    if(hDib)
    {
        HDC context_hdc = CreateCompatibleDC(hdc);
        HGDIOBJ old_obj = SelectObject(context_hdc, hDib);
        BitBlt(hdc, 0, 0, 500, 500, context_hdc, 0, 0, SRCCOPY);
        SelectObject(context_hdc, old_obj);
        DeleteDC(context_hdc);
    }

    EndPaint(hwnd, &ps);
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    case WM_PAINT:
        paint(hwnd);
        break;
    case WM_MOUSEMOVE:
    {
        if(hDib)
        {
            //draw something
            HDC context_hdc = CreateCompatibleDC(NULL);
            HGDIOBJ old_obj = SelectObject(context_hdc, hDib);

            SetDCBrushColor(context_hdc, RGB(255, 0, 0));
            int x = (int)(short)LOWORD(lParam);
            int y = (int)(short)HIWORD(lParam);
            RECT rc = { x, y, x + 10, y + 10};
            FillRect(context_hdc, &rc, (HBRUSH)GetStockObject(DC_BRUSH));

            SelectObject(context_hdc, old_obj);
            DeleteDC(context_hdc);

            InvalidateRect(hwnd, NULL, FALSE);
        }
        break;
    }
    }
    return DefWindowProc(hwnd, msg, wParam, lParam);
}

int main(void) {
    MSG             Msg;
    HINSTANCE       hInstance;
    HWND            hwnd;
    STARTUPINFOA    startup_info;
    WNDCLASSEX      wc;

    GetStartupInfoA(&startup_info);
    hInstance = GetModuleHandle(NULL);
    memset(&wc, 0, sizeof(wc));
    wc.cbSize = sizeof(WNDCLASSEX);
    wc.lpfnWndProc = WndProc;
    wc.hInstance = hInstance;
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    wc.lpszClassName = TEXT(g_szClassName);
    RegisterClassEx(&wc);

    hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, g_szClassName, "Title",
        WS_OVERLAPPEDWINDOW | WS_VISIBLE,
        CW_USEDEFAULT, CW_USEDEFAULT,
        500, 500, NULL, NULL, hInstance, NULL);

    BYTE* image = new_image(500, 500);

    ShowWindow(hwnd, SW_SHOW);//startup_info.wShowWindow);
    UpdateWindow(hwnd);
    while(GetMessage(&Msg, NULL, 0, 0))
    {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }

    if (hDib)
        DeleteObject(hDib);

    return (Msg.wParam);
}

A: Solution
Thanks to the answers from @RemyLebeau @IInspectable @Raymond Chen and @BarmakShemirani answers, here is a solution.
Now i successfully update the window according to buffer obtained with the CreateDIBSection() function, without passing through the WM_PAINT event.
I use the UpdateLayeredWindow() function to update the window's pixels.
Here is the solution code :
new_image.c
// global variables
static HBITMAP hDib;

static void     set_bmi_object(BITMAPINFO *bmi, int width, int height) {
    memset(bmi, 0, sizeof(BITMAPINFO));

    bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    bmi->bmiHeader.biWidth = width;
    bmi->bmiHeader.biHeight = -height;
    bmi->bmiHeader.biPlanes = 1;
    bmi->bmiHeader.biBitCount = 32;
    bmi->bmiHeader.biCompression = BI_RGB;
}

// Allocate a new image buffer
void             *new_image(HWND hwnd, int width, int height)
{
    BITMAPINFO  bmi;
    void        *buffer;
    HDC         hdc;

    set_bmi_object(&bmi, width, height);

    hdc = GetDC(hwnd);

    hDib = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**)(&buffer), NULL, 0);

    ReleaseDC(instance->win_list->hwnd, hdc);

    return (buffer);
}

// Print the buffer of pixel on the window
void             put_image_to_window(HWND hwnd, void *buffer, int x, int y)
{
    HDC                     hdc;
    HDC                     context_hdc;
    HGDIOBJ                 old_obj;

    hdc = GetDC(hwnd);

    context_hdc = CreateCompatibleDC(hdc);

    old_obj = SelectObject(context_hdc, hDib);

    BitBlt(hdc,
        0,
        0,
       500,
       500,
       context_hdc,
       0,
       0,
       SRCCOPY);

    SelectObject(context_hdc, old_obj);

    DeleteDC(context_hdc);
    ReleaseDC(hwnd, hdc);

    // Call UpdateLayeredWindow
    BLENDFUNCTION blend = {0};
    blend.BlendOp = AC_SRC_OVER;
    blend.SourceConstantAlpha = 128;// half transparent
    blend.AlphaFormat = AC_SRC_ALPHA;
    POINT ptLocation = {x, y};
    SIZE szWnd = {500, 500};
    POINT ptSrc = {0, 0};
    UpdateLayeredWindow(hwnd, hdc, &ptLocation, &szWnd, context_hdc, &ptSrc, 0, &blend, ULW_ALPHA);
}

main.c
static const char g_szClassName[] = "myWindowClass";

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg)
    {
        case WM_CLOSE:
            DestroyWindow(hwnd);
        break;
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
    }
    return DefWindowProc(hwnd, msg, wParam, lParam);
}

int main(void) {
    MSG             Msg;
    HINSTANCE       hInstance;
    HWND            hwnd;
    STARTUPINFOA    startup_info;
    WNDCLASSEX      wc;
    HWND            hwnd;

    GetStartupInfoA(&startup_info);

    hInstance = GetModuleHandle(NULL);

    memset(&wc, 0, sizeof(wc));

    // Registering the Window Class
    wc.cbSize = sizeof(WNDCLASSEX);
    // ... etc
    wc.lpszClassName = TEXT(g_szClassName);

    if (!RegisterClassEx(&wc)) {
        return (-1);
    }

    hwnd = CreateWindowEx(
        WS_EX_CLIENTEDGE,
        g_szClassName,
        "Title,
        WS_OVERLAPPEDWINDOW | WS_VISIBLE,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        500,
        500,
        NULL,
        NULL,
        hInstance,
        NULL);

    if (hwnd == NULL) {
        return (-1);
    }

    ShowWindow(hwnd, startup_info.wShowWindow);

    image = new_image(hwnd, 500, 500);

    put_image_to_window(hwnd, image, 0, 0);

    // The Message Loop
    while (GetMessage(&Msg, NULL, 0, 0)) {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }

    return (Msg.wParam);
}

Here is a must read that @IInspectable gave, for WinAPI beginners like me : Painting and Drawing.
Should have read this before questionning ...


text:
Q: How to Upload file and Generate Share link in Onedrive without signin Page popup I have implemented the Onedrive api in asp.net mvc and file is getting upload and also retrieval share link url..But issue is that if i logout the microsoft account then it redirect to signing page of microsoft..
Need some idea that how we can authenticate and get access token without login microsoft signing page


text:
Q: jQuery get JSON response is empty I'm trying to get a simple jQuery get JSON call to work.  Neither my success handler non error handler seems to be getting called.  Firebug also shows the data body as empty.
The server is a very basic bit of code running under web.py.  I've tested the server by connecting to it with lynx and it downloads the json data OK.
Here's the jQuery:

$(document).ready(function() {
    $.ajax({
        url: 'http://localhost:8080/settings.json',
        cache: false,
        success: function(json){
            alert('json success ' + json);
        },
        error: function(xhr, textStatus, errorThrown) {
            alert(xhr.statusText);
        }
    });
});

JSON data is:
{"netmask": "255.255.0.0", "ipaddress": "192.168.1.153"}

A: You can't make a request to another domain (that rule includes a different port) with an XmlHttpRequest, this is blocked by the same origin policy.
The result of trying to do this is an empty response, so you can't see the content.  This is just a rule in place for security purposes...if you're connecting to the same host and port, it's a non-issue.

A: You can set up a reverse proxy in Apache that will make a remote data source look like it's coming from a local domain. I've written a blog post about how to do this:
http://senchabits.wordpress.com/2012/09/17/problem-accessing-json-data-from-a-local-data-source-is-not-permitted/

A: I've found a workaround to get an error callback with an empty response in cross domain requests.
In this example I'm using Zepto, a light-weight version of jQuery, but I assume that this works fine in jQuery too.
First of all, you must use these parameters to do a cross domain request:
$.ajax({
    url: url,
    type: 'GET',
    dataType: 'jsonp',
    contentType: 'application/x-javascript',
    crossDomain: true,
    success: function (data, status) { /* ... */ }
    error: function () { /* ... */ }
    // ...

Now, the $.ajax function internally use the $.ajaxJSONP for crossdomain requests. This is the original Zepto $.ajaxJSONP function:
  $.ajaxJSONP = function(options){
    var callbackName = 'jsonp' + (++jsonpID),
      script = document.createElement('script'),
      abort = function(){
        $(script).remove()
        if (callbackName in window) window[callbackName] = empty
        ajaxComplete('abort', xhr, options)
      },
      xhr = { abort: abort }, abortTimeout

    if (options.error) script.onerror = function() {
      xhr.abort()
      options.error()
    }

    window[callbackName] = function(data){
      clearTimeout(abortTimeout)
      $(script).remove()
      delete window[callbackName]
      ajaxSuccess(data, xhr, options)
    }

    serializeData(options)
    script.src = options.url.replace(/=\?/, '=' + callbackName)
    $('head').append(script)

    if (options.timeout > 0) abortTimeout = setTimeout(function(){
        xhr.abort()
        ajaxComplete('timeout', xhr, options)
      }, options.timeout)

    return xhr
  }

My workaround is very simple and consists on an interval called few times on the script.onload event handler, in order to verify that the callback function was called.
This is my version of the $.ajaxJSONP function:
$.ajaxJSONP = function(options){
    var called = false, // Flag to check that callback was called
        callbackName = 'jsonp' + (++jsonpID),
        script = document.createElement('script'),
        abort = function(){
            $(script).remove()
            if (callbackName in window) window[callbackName] = empty
            ajaxComplete('abort', xhr, options)
        },
        xhr = { abort: abort }, abortTimeout

    if (options.error) {
        script.onerror = function() {
            xhr.abort()
            options.error()
        };

        // IMPORTANT!!!
        script.onload = function () {
            var times = 0;

            var interval = setInterval(function () {
                // After 5 intervals, if the callback wasn't called, returns an error
                if (times++ == 5) {
                    clearInterval(interval);

                    if (!called) {
                        options.error();
                    }
                } else if (called) {
                    clearInterval(interval);
                }
            }, 100);
        };
    }

    window[callbackName] = function(data){
        // Setting the "called" flag to true
        called = true;
        clearTimeout(abortTimeout)
        $(script).remove()
        delete window[callbackName]
        ajaxSuccess(data, xhr, options)
    }

    serializeData(options)
    script.src = options.url.replace(/=\?/, '=' + callbackName)
    $('head').append(script)

    if (options.timeout > 0) abortTimeout = setTimeout(function(){
        xhr.abort()
        ajaxComplete('timeout', xhr, options)
    }, options.timeout)

    return xhr
}

Note: If you are interested in the server side behavior, please see the beginning of this tutorial: http://phonegap.com/2011/07/20/making-jsonp-calls-with-zepto-on-android-device/


text:
Q: Android Studio Kotlin: RecyclerView with multiple viewtypes with different data I am creating a RecyclerView that contains multiple view types. The First viewType (ViewType1) takes a productName, price and quantity. While the second viewType (ViewType2) takes productName, price and quantity, topping1, topping2, topping3, topping 4.
However, when adding entries to the recyclerview I am recieving an error for no value passed for the parameters topping1 to 4:
list.add(DataModel("American","1","12.50", ItemAdapter.NO_TOPPING))  //Error recieved for missing params
list.add(DataModel("Romana","1","12.50", "Pepperoni", "Aubergine", "Ex Mozz.", "Salami", ItemAdapter.TOPPINGS_4))

It is expecting it to be ViewType2 while it is ViewType1. How can I change it so that ViewType1 does not need to include empty parameters and only needs to pass the data parameters productName, productPrice & productQuantity.
MainActivity.kt
package com.example.multiplerecyclerview

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import kotlinx.android.synthetic.main.activity_main.*

import kotlinx.android.synthetic.main.item_custom_row.view.*

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        //Set the LayoutManager that this RecyclerView will use.
        recycler_view_items.layoutManager = LinearLayoutManager(this)

        // Adapter class is initialized and list is passed in the param.
        val itemAdapter = ItemAdapter(this, getItemsList())

        //adapter instance is set to the recyclerview to inflate the items.
        recycler_view_items.adapter = itemAdapter
    }

    private fun getItemsList(): ArrayList<DataModel> {
        val list = ArrayList<DataModel>()

        list.add(DataModel("Romana","1","12.50", "Pepperoni", "Aubergine", "Ex Mozz.", "Salami", ItemAdapter.TOPPINGS_4))
        list.add(DataModel("American","1","12.50", ItemAdapter.NO_TOPPING))

        return list
    }
}

DataModel.kt
package com.example.multiplerecyclerview

class DataModel(val itemName: String, val itemQuantity: String, val itemPrice: String, val topping1: String,  val topping2: String,  val topping3: String,  val topping4: String, val viewType: Int) {
}

ItemAdapter.kt
package com.example.multiplerecyclerview

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.synthetic.main.item_custom_row.view.*
import kotlinx.android.synthetic.main.item_custom_row4.view.*

class ItemAdapter(val context: Context, val items: ArrayList<DataModel>) :
    RecyclerView.Adapter<RecyclerView.ViewHolder>() {

    companion object {
        const val NO_TOPPING = 1
        const val TOPPINGS_4 = 4
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {

        if(viewType == NO_TOPPING) {
            return ViewHolder(
                LayoutInflater.from(context).inflate(
                    R.layout.item_custom_row,
                    parent,
                    false
                )
            )
        } else if (viewType == TOPPINGS_4) {
            return ViewHolder4(
                LayoutInflater.from(context).inflate(
                    R.layout.item_custom_row4,
                    parent,
                    false
                )
            )
        } else {
            return ViewHolder(
                LayoutInflater.from(context).inflate(
                    R.layout.item_custom_row,
                    parent,
                    false
                )
            )
        }
    }

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        val item = items.get(position)

        if(holder is ViewHolder) {

            holder.productQuantity.text = item.itemName
            holder.productName.text = item.itemName
            holder.productPrice.text = item.itemPrice

        } else if(holder is ViewHolder4) {

            holder.productQuantity4.text = item.itemName
            holder.productName4.text = item.itemName
            holder.productPrice4.text = item.itemPrice

            holder.topping1.text = item.topping1
            holder.topping2.text = item.topping2
            holder.topping3.text = item.topping3
            holder.topping4.text = item.topping4
        }

    }

    override fun getItemViewType(position: Int): Int {
        return items[position].viewType
    }

    override fun getItemCount(): Int {
        return items.size
    }

    class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        val productQuantity = view.productQuantityView
        val productName = view.productNameView
        val productPrice = view.productPriceView
    }

    class ViewHolder4(view: View) : RecyclerView.ViewHolder(view) {
        val productQuantity4 = view.productQuantityView4
        val productName4 = view.productNameView4
        val productPrice4 = view.productPriceView4

        val topping1 = view.topping1View
        val topping2 = view.topping2View
        val topping3 = view.topping3View
        val topping4 = view.topping4View
    }
}

item_custom_row
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/cardViewItem1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:padding="10dp"
    android:layout_margin="4dp"
    app:cardElevation="10dp"
    app:cardCornerRadius="8dp"
    app:cardPreventCornerOverlap="false">

    <RelativeLayout
        android:layout_width="400dp"
        android:layout_height="wrap_content"
        android:padding="12dp">

        <TextView
            android:id="@+id/productQuantityView"
            android:layout_width="wrap_content"
            android:layout_height="45dp"
            android:layout_marginLeft="10dp"
            android:layout_marginEnd="15dp"
            android:text="1"
            android:textColor="#881b32"
            android:textSize="25sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/productNameView"
            android:layout_width="wrap_content"
            android:layout_height="46dp"
            android:layout_marginEnd="10dp"
            android:layout_toEndOf="@+id/productQuantityView"
            android:text="12'' Killiney Beach"
            android:textColor="#881b32"
            android:textSize="20sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/productPriceView"
            android:layout_width="wrap_content"
            android:layout_height="52dp"
            android:layout_marginEnd="20dp"
            android:layout_toEndOf="@id/productNameView"
            android:text="14.50"
            android:textColor="#fcac52"
            android:textSize="18sp"
            android:textStyle="bold" />

    </RelativeLayout>

</androidx.cardview.widget.CardView>

item_custom_row4
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/cardViewItem4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_margin="4dp"
    app:cardElevation="10dp"
    app:cardCornerRadius="8dp"
    app:cardPreventCornerOverlap="false">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="12dp">

        <TextView
            android:id="@+id/productQuantityView4"
            android:layout_width="wrap_content"
            android:layout_height="45dp"
            android:layout_marginLeft="10dp"
            android:layout_marginEnd="15dp"
            android:text="1"
            android:textColor="#881b32"
            android:textSize="25sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/productNameView4"
            android:layout_width="wrap_content"
            android:layout_height="46dp"
            android:layout_marginEnd="10dp"
            android:layout_toEndOf="@+id/productQuantityView4"
            android:text="12'' Killiney Beach"
            android:textColor="#881b32"
            android:textSize="20sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/productPriceView4"
            android:layout_width="wrap_content"
            android:layout_height="52dp"
            android:layout_marginEnd="20dp"
            android:layout_toEndOf="@id/productNameView4"
            android:text="14.50"
            android:textColor="#881b32"
            android:textSize="18sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/topping1View"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_marginStart="20dp"
            android:layout_marginTop="3dp"
            android:layout_toEndOf="@+id/productPriceView4"
            android:text="Pepperoni"
            android:textColor="#fcac52"
            android:textSize="14sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/topping2View"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/topping1View"
            android:layout_marginStart="20dp"
            android:layout_marginTop="13dp"
            android:layout_toEndOf="@+id/productPriceView4"
            android:text="Aubergine"
            android:textColor="#fcac52"
            android:textSize="14sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/topping3View"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_marginStart="20dp"
            android:layout_marginTop="3dp"
            android:layout_toEndOf="@+id/topping1View"
            android:text="Semi Dried Tomatos"
            android:textColor="#fcac52"
            android:textSize="14sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/topping4View"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/topping1View"
            android:layout_marginStart="20dp"
            android:layout_marginTop="13dp"
            android:layout_toEndOf="@+id/topping2View"
            android:text="Smoked Applewood"
            android:textColor="#fcac52"
            android:textSize="14sp"
            android:textStyle="bold" />

    </RelativeLayout>

</androidx.cardview.widget.CardView>

A: Assign default values to your parameters:
class DataModel(val itemName: String,
val itemQuantity: String,
val itemPrice: String,
val topping1: String = "",
val topping2: String = "",
val topping3: String = "",
val topping4: String = "",
val viewType: Int) {
    }

you can refactor this to be a data class
data class DataModel(val itemName: String,
val itemQuantity: String,
val itemPrice: String,
val topping1: String = "",
val topping2: String = "",
val topping3: String = "",
val topping4: String = "",
val viewType: Int)

you could also make use of nullable variables here, since they are potentially null:
data class DataModel(val itemName: String,
val itemQuantity: String,
val itemPrice: String,
val topping1: String? = null,
val topping2: String? = null,
val topping3: String? = null,
val topping4: String? = null,
val viewType: Int)

Then, because kotlin has named arguments, you can do this:
  val foo = DataModel("American","1","12.50", viewType = ItemAdapter.NO_TOPPING )


text:
Q: Adjust Datetime column on x-axis of matplotlib in time series dataset I'm working with time-series dataset, this dataset has a timestemp column which I set as the index column of the dataset, it has the vale of date and time also in the form as:
15/5/17 7:51 so when I display a plot the date and time on x-axis make this this graph very difficult to understand.
Here's what I have tried to adjust the date and time on x-axis:
fig, ax = plt.subplots(figsize=(17, 4))
ax.plot(data,
        '-o',
        color='purple')
ax.set(xlabel="Date",
       title="Blood gclucose and heart rate distribution")

# Format the x axis
ax.xaxis.set_major_locator(mdates.WeekdayLocator(interval=0))
ax.xaxis.set_major_formatter(DateFormatter("%m/%d"))

plt.show()

But it's not displaying any date on the x-axis, what can be wrong? and what I can do to make this datetime on x-axis more readable?


text:
Q: Short story involving wearable computers I remember reading a short story a number of years ago (2000-2008) that involved a character wearing a computer like a crown on their head. They were able to query searches and know the results, and I think I also remember there being some description of a map-like program where they were able to look down at their location from the sky and routes would appear from their location to their destination.
I've looked through similar questions posted here and didn't find anything like it. It's not "Norbert and the System". I think I remember the main character being a woman?

A: The "computer as a crown" reminds me of the ROM from Spider Robinson's novel Time Pressure.
The character with the crown was sent back in time as a pilot test for a system that was intended to eventually save the entire human race, from the beginning up to the point time travel was invented (no need after that, they just save people as they live).  The crown connected directly to her brain, but when she first arrived she had amnesia due to an unforeseen collision on arrival (came out in the same place as a big tree).
In an early scene, the narrator character notices the traveler getting more and more agitated, and realizes it's because she's never had coffee before; hence the caffeine is having much stronger effects, with less ability to compensate, than it would in him or any of his contemporaries.


text:
Q: android app run onPreDraw infinitely Step 1. Create a new app with Navigation Drawer template.

Step 2. Add a customized button and override the onMeasure method.
@CoordinatorLayout.DefaultBehavior(MyButton.Behavior.class)
public class MyButton extends android.support.v7.widget.AppCompatButton {

private ViewTreeObserver.OnPreDrawListener mPreDrawListener;

public MyButton(Context context) {
    super(context);
}

public MyButton(Context context, AttributeSet attrs) {
    super(context, attrs);
}

public MyButton(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    if (mPreDrawListener == null) {
        mPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                offsetTopAndBottom(50);
                return true;
            }
        };

        ViewParent p = getParent();
        if (p instanceof View) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                ((View)p).getViewTreeObserver().addOnPreDrawListener(mPreDrawListener);
            }
        }
    }
}

public static class Behavior extends CoordinatorLayout.Behavior<MyButton> {

    @Override
    public boolean onLayoutChild(CoordinatorLayout parent, MyButton child, int layoutDirection) {
        final List<View> dependencies = parent.getDependencies(child);
        return super.onLayoutChild(parent, child, layoutDirection);
    }

    @Override
    public void onAttachedToLayoutParams(@NonNull CoordinatorLayout.LayoutParams lp) {
        if (lp.dodgeInsetEdges == Gravity.NO_GRAVITY) {
            // If the developer hasn't set dodgeInsetEdges, lets set it to BOTTOM so that
            // we dodge any Snackbars
            lp.dodgeInsetEdges = Gravity.BOTTOM;
        }
    }
}

}
Step 3. Use MyButton in app_bar_main layout.

Step 4. Set a breakpoint in onPreDraw and then I could see it will be executed infinitely. If I comment the offsetTopAndBottom(50), everything goes fine.

I also trace the source code and find app receive vsync signal again and again which cause the onVsync function in Choreographer.java run infinitely. Why this happens?
Update
If I set a breakpoint as below and comment onPreDraw, this breakpoint finally will not be reached, otherwise, it can be reached always.

A: The callback onPreDraw() is called before each frame is drawn. Since you normally keep on drawing frames (~60fps), it is normal that it is called "infinitely".
To avoid this behavior, the usual pattern is to remove the listener as first statement in onPreDraw():
view.getViewTreeObserver().removeOnPreDrawListener(this);

where view is the downcasted parent in your case.
You can see example code in this video. The engineers are part of the Android Framework team.


text:
Q: Window doesn't get focus when using Qt::X11BypassWindowManagerHint flag I need to create window, which always stays on top without borders and controls. So I did this:
MainWindow window;
window.show();

Where MainWindow class looks like this:
MainWindow::MainWindow(QWidget *parent) : QWidget(parent,
Qt::Window | Qt::WindowStaysOnTopHint
| Qt::X11BypassWindowManagerHint | Qt::FramelessWindowHint) {

}

void MainWindow::keyPressEvent(QKeyEvent *event){
    if(event->key() == Qt::Key_Escape){
        QApplication::exit();
    } else
        QWidget::keyPressEvent(event);
}

Which works, but not perfectly. After program is launched, the windows doesn't have focus, so you must first click on it.If I remove Qt::X11BypassWindowManagerHint, window gains the focus, but than it doesn't show at all workspaces (desktops).
Question 1: What does Qt::X11BypassWindowManagerHint actually do?
Question 2: How do I get this working?

A: So I managed to dig through the docs.
Question 1: Qt::X11BypassWindowManagerHint results in window without border and no control from window manager at all (only at X11!).
Question 2: To get focus and enable keyboard input, it is necessary to call QWidget::activateWindow().


text:
Q: Which of these sets are subspaces of $P_3$? Which of the following sets is a subspace of $P_{3}$?
a. $\{ a_0 + a_1t + a_2t^2 + a_3t^3 \ | \ a_1 = 0 \text{ and } a_2 = a_3 \}$
b. $\{ a_0 + a_1t + a_2t^2 + a_3t^3 \ | \ a_1 = 1 \text{ and } a_2 = 2a_3 \}$
c. $\{ a_0 + a_1t + a_2t^2 + a_3t^3 \ | \ a_1 = a_2^2 \}$
d. $\{ a_0 + a_1t + a_2t^2 + a_3t^3 \ | \ a_0 + 2a_1 - 3a_2 = 2 \}$
I am confused about this question because aren't all of these subspaces of $P_3$? All of these polynomials have a degree of less than or equal to 3, so shouldn't they all be entirely contained in the set $P_3$?

A: They are all subsets of $P_3$, if that's your notation for the polynomials of degree $\le 3$, but they are not all linear subspaces.  For a subset $S$ of a vector space to be a linear subspace, it needs two things to be true:

*

*For every $u$ and $v$ in $S$, $u + v$ is also in $S$.

*For every $u$ in $S$ and every scalar $a$, $a u$ is also in $S$.

A: Official Answer (from key):
The answer to this question is A because it satisfies the two conditions give above.
-SmileyChimpy


text:
Q: Nginx follow redirect and reverse proxy last location I'm trying to reverse proxy an URL that have a N redirect 301 inside.
I want to follow all the pages and then reverse proxy the last page (fourth-url.php).
Is something douable with Nginx?
This is the scenario
FIRST URL:
http://first-domain.com/first-url.php
REDIRECT TO
http://first-domain.com/second-url.php
REDIRECT TO
http://first-domain.com/third-url.php
REDIRECT TO  (last one)
http://first-domain.com/fourth-url.php
This is the file configuration that I've made until now:
server {

  set $base_url 'http://first-domain.com';
  set $page 'first-url.php'

  location /myserver {
     resolver 8.8.8.8;
     proxy_set_header X-Real-IP  $remote_addr;
     proxy_set_header X-Forwarded-For $remote_addr;
     proxy_set_header Host $host;
     proxy_pass $base_url/$page;
     proxy_intercept_errors on;
     error_page 301 302 307 = @handle_redirect;
  }

  location @handle_redirect {
     resolver 8.8.8.8;
     set $saved_redirect_location $upstream_http_location;
     proxy_set_header X-Real-IP  $remote_addr;
     proxy_set_header X-Forwarded-For $remote_addr;
     proxy_set_header Host $host;
     proxy_pass $base_url/$saved_redirect_location;
     proxy_intercept_errors on;
     error_page 301 302 307 = @handle_redirect;
  }
}

This should work as recursive function, but maybe I am missing an if statement or the last part.
Actually it works like this:
http://first-domain.com/first-url.php [OK]
http://first-domain.com/second-url.php [OK]
then nginx stop everything and return:
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: unspecified
ERROR: Redirection (302) without location.

Side note: first-url.php, second-url.php, etc … contain just a simple line of code to make the redirect:
header("Location: second-url.php");

Any hints/ideas appreciated.

A: Solution: Add recursive_error_pages directive.
server {
...
proxy_intercept_errors on;
recursive_error_pages on;
error_page 301 302 303 307 308 = @handle_redirect;
...
}

Additionally, according to nginx recursion limited, you do not have to worry about circular redirection problem since nginx set the recursion limitation to 10.


text:
Q: drawImage method of canvas is not working The drawimage method is not working. Is there any error in this code?
html:
<body>
<div id="container">
        <canvas id="canvas" width="700" height="350"></canvas>
</div>
</body>

javascript:
function init()
{
var canvas = document.getElementById('canvas');
var ctx    = canvas.getContext('2d');
var chop   = new Image();
chop.src   = "chopper.png";

ctx.drawImage(chop,10,10,200,200);
};

window.onload = function() {init()};

A: There's a big error in the code.
The JS won't wait for the image to finish downloading before it tries to draw it.
The window.onload won't guarantee that all async calls are done, either.
var img = new Image();
img.onload = function () { ctx.drawImage(img, ...); };
img.src = "...";

That will now work, regardless of whether the window has done loading or not... (it will have, unless the image is cached).

A: You need to wait until the image is loaded to draw it:
var chop = new Image();

chop.onload = function() {
    ctx.drawImage(chop,10,10,200,200);
};

chop.src = "chopper.png";


text:
Q: curl ok, RestTemplate fails This works:
curl --verbose -H "Content-Type: application/json" --data "{\"parm1\":\"1\",  \"parm2\":\"1\"}" http://server:8080/service/meth

and returns:
{"success":true,"errorMessage":null}

This fails:
    RestTemplate restTemplate = new RestTemplate();
    HttpHeaders headers = new HttpHeaders();

    headers.setContentType(MediaType.APPLICATION_JSON);

    MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
    map.add("parm1", "1");
    map.add("parm2", "1");

    HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(map, headers);

    String response = (String) restTemplate.postForObject("http://server:8080/service/meth",
                                                          request,
                                                          String.class);

with 500 Internal Server Error
I'm using springframework-boot 1.3.3.RELEASE and java 1.8 and am at a loss as to what's wrong.  The server side log shows no errors other than 500
Has anyone been faced with a Spring RestTemplate call that mysteriously failed?  How did you approach diagnosing the problem?


text:
Q: Jena Effects of Different Entailment Regimes I am trying sparql and the use of entailment.
As a example i used http://www.w3.org/TR/2010/WD-sparql11-entailment-20100126/#t112
i try to put them in jena.

     OntClass book1= model.createClass(NS+"book1");
     OntClass book2=model.createClass(NS+"book2");
     OntClass book3=model.createClass(NS+"book3");
     OntClass publication=model.createClass(NS+"publication");
     OntClass article=model.createClass(NS+"article");
     OntClass mit=model.createClass(NS+"MIT");

     ObjectProperty a = model.createObjectProperty(NS+"a");
     ObjectProperty publishes = model.createObjectProperty(NS+"publishes");

     book1.addProperty(a, publication);
     book2.addProperty(a, article);
     publication.addSubClass(article);

     publishes.addRange(publication);
     mit.addProperty(publishes, book3);

where model is type OntModel.
and i used the query similar to the problem
     "PREFIX table: "I have correct namespace here"+
     "SELECT *"+
    "WHERE"+
    "{"+
    " ?x ?y table:publication  ."+
    "}";
The model was created like this. Hope OntModelSpec is ok.
OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_RDFS_INF, null);
i get as results from query

 x                                                           y
| http://www.example.com/ontologies/sample.owl#publishes   | rdfs:range                                       |
| http://www.example.com/ontologies/sample.owl#article     | rdfs:subClassOf                                  |
| http://www.example.com/ontologies/sample.owl#book1       | http://www.example.com/ontologies/sample.owl#a |
| http://www.example.com/ontologies/sample.owl#publication | rdfs:subClassOf                                  |
| http://www.example.com/ontologies/sample.owl#book3       | rdf:type                                         |

Can anyone give me a example, with and without entailment, so a cant try code, can get the results right.

A: Your ontology looks a bit fishy.
book1, book2, book3 and mit are not classes, they are individuals. You should use model.createIndividual(NS + "bookX", publication) for the books, and create a class for "organization" or similar, and then create mit as an individual of that class. Note that createIndividual already takes care of assigning the type to the individual, so you don't need to mess around with your "a" property. You should fix these things first and then try again and update your question.
About entailment: Look at the last line of your query result. You didn't say anywhere that book3 is a book, but the statement is there anyways. That's because it was entailed by the other statements, and that's why the RDFS inference engine makes the statement visible when you query the model. The statement is entailed because of the range on publishes: Everything that's being published is entailed to be of type publication.