text:
Q: RxJava : Reduce not working as expected I'm trying to load a user object in parallel.
    final User user = new User();
    final Observable<User> userObs = Observable.just("NAMES", "ADDRESSES", "CURRENT_ADDRESS")
            .flatMap(field -> getOrchestrator(user, field))
            .scan(new User(), (finalUser, event) -> {
                finalUser = event;
                return finalUser;
            });

Scan does emit three user object, where as the reduce does not emit any items at all? what am I doing wrong here.
    final User user = new User();
    final Observable<User> userObs = Observable.just("NAMES", "ADDRESSES", "CURRENT_ADDRESS")
            .flatMap(field -> getOrchestrator(user, field))
            .reduce(new User(), (finalUser, event) -> {
                finalUser = event;
                return finalUser;
            });

The getOrchestrator returns Observable. Any help will be appreciated.
Below is the complete code snippet
public class Orchestrator {
    private String userId;

    public Orchestrator(final String userId) {
        this.userId = userId;
    }

    public static void main(final String[] args) throws Exception {
        final User user = new User();
        final Observable<User> userObs = Observable.just("NAMES", "ADDRESSES", "CURRENT_ADDRESS")
                .flatMap(field -> getOrchestrator(user, field))
                .scan(new User(), (finalUser, event) -> {
                    finalUser = event;
                    return finalUser;
                });

        userObs.subscribeOn(Schedulers.io()).subscribe(result -> {
            System.out.println(result.toString());
        });

        TimeUnit.SECONDS.sleep(10);

    }

    private static Observable<User> getOrchestrator(final User user, final String fieldName) {
        switch (fieldName) {
            case "CURRENT_ADDRESS":
                return new AddressOrchestrator().getCurrentAddress(user.getUserId())
                        .map(currentAddress -> {
                            user.setAddress(currentAddress);
                            try {
                                TimeUnit.MILLISECONDS.sleep(200);
                            }
                            catch (final InterruptedException e) {

                            }
                            return user;
                        });
            case "ADDRESSES":
                return new AddressOrchestrator().getAddresses(user.getUserId())
                        .map(addresses -> {
                            user.setAddresses(addresses);
                            try {
                                TimeUnit.MILLISECONDS.sleep(200);
                            }
                            catch (final InterruptedException e) {

                            }
                            return user;
                        });

            case "NAMES":
                return new NameOrchestrator().getNames(user.getUserId())
                        .map(names -> {
                            user.setNames(names);
                            try {
                                TimeUnit.MILLISECONDS.sleep(200);
                            }
                            catch (final InterruptedException e) {

                            }
                            return user;
                        });
        }
        return null;
    }

    public User getUser() {
        final Random r = new Random();
        if (r.nextInt(3) % 2 == 0) {
            return new User();
        }
        throw new RuntimeException();
    }
}

Each orchestrator returns Observable.
public class AddressOrchestrator {

    public Observable<List<Address>> getAddresses(final String userId) {
        return Observable.create(s -> {
            final Address currentAddress = this.getBaseAddress(userId);
            final Address anotherAddress = this.getBaseAddress(userId);
            anotherAddress.setState("NE");
            s.onNext(Arrays.asList(currentAddress, anotherAddress));
        });

    }

    public Observable<Address> getCurrentAddress(final String userId) {
        return Observable.create(s -> s.onNext(this.getBaseAddress(userId)));
    }

    public Address getBaseAddress(final String userId) {
        final Address address = new Address();
        address.setLine1("540 Caddo Lake Dr");
        address.setCity("Georgetown");
        address.setCountry("USA");
        address.setState("TX");

        return address;
    }
}

public class NameOrchestrator {

    public Observable<List<Name>> getNames(final String userId) {
        return Observable.create(s -> {
            final Name name = new Name();
            name.setName("Vanchi");
            final Name formerName = new Name();
            formerName.setName("Vanchinathan");
            s.onNext(Arrays.asList(name, formerName));
        });
    }
}

A: Your orchestrations which you create using Observable.create (a big red flag unless you really know what you're doing) do not terminate. This leads to infinite streams (in the sense that a complete event is never emitted). What you need it something like
public Observable<List<Address>> getAddresses(final String userId) {
        return Observable.create(s -> {
            final Address currentAddress = this.getBaseAddress(userId);
            final Address anotherAddress = this.getBaseAddress(userId);
            anotherAddress.setState("NE");
            s.onNext(Arrays.asList(currentAddress, anotherAddress));
            s.onCompleted();
        });

Note the onCompleted being called. This will fix your superficial problems but you're better off getting rid of the Observable.create in the first place and using something like Observable.defer.

A: That is happening because scan emits all upstream items while reduce will emit only if stream is completed.
Replace
public Observable<Address> getCurrentAddress(final String userId) {
    return Observable.create(s -> s.onNext(this.getBaseAddress(userId)));
}

with
public Observable<Address> getCurrentAddress(final String userId) {
    return Observable.fromCallable(() -> this.getBaseAddress(userId));
}

and
public Observable<List<Address>> getAddresses(final String userId) {
    return Observable.create(s -> {
        final Address currentAddress = this.getBaseAddress(userId);
        final Address anotherAddress = this.getBaseAddress(userId);
        anotherAddress.setState("NE");
        s.onNext(Arrays.asList(currentAddress, anotherAddress));
    });
}

with
public Observable<List<Address>> getAddresses(final String userId) {
    return Observable.fromCallable(() -> this.getBaseAddress(userId))
            .zipWith(Observable.fromCallable(() -> this.getBaseAddress(userId))
                    .map(address -> address.setState("NE")),
                    (currentAddress, anotherAddress) -> Arrays.asList(currentAddress, anotherAddress));
}

and change your setAddress() method to this
public Address setState(String state) {
    this.state = state;
    return this;
}

fromCallable() is a better way to create an Observable that emits at most one element, because it handles errors and backpressure for you.


text:
Q: Scala how do i modify values in a Map[String, List[String, Set[String]]] I have a Map of type Map[String, List[(String, Set[String]])]
eg : Map(ABC -> List((ABC, Set(X)))
I need to update it to Map[String, Set[String]]
Output : Map(ABC -> Set(X))
Mainly need to remove the List[String] Part from values.

A: For example you can do .mapValues
val m: Map[String, List[(String, Set[String])]] =
  Map("ABC" -> List(("ABC", Set("X"))))

// taking the set from the head of list, ignoring second "ABC"
val m1: Map[String, Set[String]] = m.view.mapValues(_.head._2).toMap
// Map(ABC -> Set(X))

// combining into union the sets from the whole list, ignoring second "ABC"
val m2: Map[String, Set[String]] =
  m.view.mapValues(_.map(_._2).fold(Set())(_ union _)).toMap
// Map(ABC -> Set(X))

// ignoring first "ABC"
val m3: Map[String, Set[String]] = m.values.flatten.toMap
// Map(ABC -> Set(X))

(m3 is courtesy of @Philluminati)
https://www.scala-lang.org/api/current/scala/collection/immutable/Map.html
https://docs.scala-lang.org/overviews/collections-2.13/maps.html

redpajama_set_name: RedPajamaStackExchange


text:
Q: 'Could not find a part of the path ...' error in asp.net mvc application I have reviewed the other posts about this topic and haven't found a solution. This exception is thrown on the production server in an Azure Web App, but not on a local development machine.
     public async Task<ActionResult> ProcessConfigFile(int projectModelId, HttpPostedFileBase file)
      {
        string dateTimeStamp = DateTime.Now.ToString("yyyyMMddHHmmssffff");

        string fileLocation = Server.MapPath("~/App_Data/") + dateTimeStamp + projectModelId.ToString() + Request.Files["file"].FileName;

        //save file in fileLocation
        Request.Files["file"].SaveAs(fileLocation);

          //other work....
      }

A: The problem was that the App_Data folder that shows up in Visual Studio was empty,  and subsequently had never been published to the server in Azure, even though it exists in the directory on my local development hard drive.
Once I added a meaningless .txt file to the App_Data folder, the folder was created on the production server and everything works.


text:
Q: AWS Cognito client SDK v3 returns 'byteLength' of undefined when running Admin disable user command I am trying to disable users from my node JS backend using the AWS SDK v3. everything works normally except for the disable/enable user command.
I have tried everything I know but here is my code snippet:
const aws_creds = {
  accessKeyId: process.env.ACCESS_KEY_ID,
  secretAccessKey: process.env.SECRET_ACCESS_KEY,
};
const cognitoConfig = {
  region: process.env.REGION,
  credentials: aws_creds,
};

const cognito_v3 = new CognitoIdentityProviderClient(cognitoConfig);

Then in my route I am running this try / catch block
try {
    if (status === "enable") {
      const enableUserCommand = new AdminEnableUserCommand(userDetails);
      const enableUserResults = await cognito_v3.send(enableUserCommand);
      return res.status(200).json(enableUserResults);
    }
    const disableUserCommand = new AdminDisableUserCommand(userDetails);
    const disableUserResults = await cognito_v3.send(disableUserCommand);
    return res.status(200).json(disableUserResults);
  } catch (err) {
    console.log(err);
    return res.status(400).json(err);
  }

However, the err console log returns this:
TypeError: Cannot read property 'byteLength' of undefined
    at Object.fromArrayBuffer (C:\Users\SER-01\Documents\ctr\simsim\simsim-backend\lambdas\simsim-auth\node_modules\@aws-sdk\util-buffer-from\dist\cjs\index.js:6:60)
    at castSourceData (C:\Users\SER-01\Documents\ctr\simsim\simsim-backend\lambdas\simsim-auth\node_modules\@aws-sdk\hash-node\dist\cjs\index.js:29:31)
    at Hash.update (C:\Users\SER-01\Documents\ctr\simsim\simsim-backend\lambdas\simsim-auth\node_modules\@aws-sdk\hash-node\dist\cjs\index.js:12:26)
    at hmac (C:\Users\SER-01\Documents\ctr\simsim\simsim-backend\lambdas\simsim-auth\node_modules\@aws-sdk\signature-v4\dist\cjs\credentialDerivation.js:60:10)
    at Object.getSigningKey (C:\Users\SER-01\Documents\ctr\simsim\simsim-backend\lambdas\simsim-auth\node_modules\@aws-sdk\signature-v4\dist\cjs\credentialDerivation.js:32:29)
    at SignatureV4.getSigningKey (C:\Users\SER-01\Documents\ctr\simsim\simsim-backend\lambdas\simsim-auth\node_modules\@aws-sdk\signature-v4\dist\cjs\SignatureV4.js:139:39)
    at SignatureV4.signRequest (C:\Users\SER-01\Documents\ctr\simsim\simsim-backend\lambdas\simsim-auth\node_modules\@aws-sdk\signature-v4\dist\cjs\SignatureV4.js:98:73)
    at async C:\Users\SER-01\Documents\ctr\simsim\simsim-backend\lambdas\simsim-auth\node_modules\@aws-sdk\middleware-signing\dist\cjs\middleware.js:14:22
    at async StandardRetryStrategy.retry (C:\Users\SER-01\Documents\ctr\simsim\simsim-backend\lambdas\simsim-auth\node_modules\@aws-sdk\middleware-retry\dist\cjs\defaultStrategy.js:56:46)
    at async C:\Users\SER-01\Documents\ctr\simsim\simsim-backend\lambdas\simsim-auth\node_modules\@aws-sdk\middleware-logger\dist\cjs\loggerMiddleware.js:6:22
    at async C:\Users\SER-01\Documents\ctr\simsim\simsim-backend\lambdas\simsim-auth\src\routes\auth.js:232:33 {
  '$metadata': { attempts: 1, totalRetryDelay: 0 }
}

Any idea why?


text:
Q: Magento 2: How To Disable Button On Form Submit? I'm trying to disable button after submitting form, but i'm facing some issue, when i submit black field it validate the form and disable the button... but i want to disable it on form submit successfully....go through many answers but could not succeed.
Here is my phtml file:
<form class="form quote"
      action="<?php /* @escapeNotVerified */ echo $block->getUrl("partsquote/index/QuotePost", array("_secure" => true));?>"
      id="drawpad-form"
      method="post"
      data-hasrequired="<?php /* @escapeNotVerified */ echo __('* Required Fields') ?>"
      data-mage-init='{"validation":{}}' enctype="multipart/form-data">

    <?php echo $block->getBlockHtml('formkey')?>
    <fieldset class="fieldset">

                <?php /* @escapeNotVerified */ echo __('Your Name') ?>

                    <input name="name" id="quote_name" title="<?php /* @escapeNotVerified */ echo __('Your Name') ?>" placeholder="<?php /* @escapeNotVerified */ echo __('Your Name') ?>" value="" class="input-text" type="text" data-validate="{required:true}"/>

                <?php /* @escapeNotVerified */ echo __('Your Email') ?>

                    <input name="email" id="quote_email" title="<?php /* @escapeNotVerified */ echo __('Your Email') ?>" placeholder="<?php /* @escapeNotVerified */ echo __('Your Email') ?>" value="" class="input-text" type="email" data-validate="{required:true, 'validate-email':true}"/>

            <?php /* @escapeNotVerified */ echo __('Your State / Province') ?>

                <select name="state" id="quote_state" class="required-entry validate-state" title="Your State / Province" aria-required="true">
                    <option value="" selected="selected">Please Select State / Province</option>
                    <?php foreach($block->getRegionCollection() as $region): ?>
                        <option value="<?php echo $region->getName(); ?>"><?php echo $region->getName(); ?></option>
                    <?php endforeach; ?>
                </select>

                <?php /* @escapeNotVerified */ echo __('Your Phone Number') ?>

                    <input name="phone" id="quote_phone" title="<?php /* @escapeNotVerified */ echo __('Your Phone Number') ?>" value="" placeholder="<?php /* @escapeNotVerified */ echo __('Your Phone Number') ?>" class="input-text" type="number" data-validate="{required:true}"/>

                <?php /* @escapeNotVerified */ echo __('Product Voltage/Wattage') ?>

                    <input name="product" id="quote_product" title="<?php /* @escapeNotVerified */ echo __('Product Voltage/Wattage') ?>" placeholder="<?php /* @escapeNotVerified */ echo __('Product Voltage/Wattage') ?>" value="" class="input-text" type="text"/>

            <?php /* @escapeNotVerified */ echo __('Your Message') ?>

                <textarea name="message" id="quote_message" title="<?php /* @escapeNotVerified */ echo __('Your Message') ?>" class="input-text" cols="5" rows="3" data-validate="{required:true}" placeholder="<?php /* @escapeNotVerified */ echo __('Your Message') ?>"></textarea>

    </fieldset>

            <input type="hidden" name="image" id="quote_image" value="" />
            <input type="hidden" name="productName" id="productName" value="<?php echo $productName; ?>" />
            <button type="submit" id="submit" title="<?php /* @escapeNotVerified */ echo __('Submit') ?>" class="action submit primary">
                <?php /* @escapeNotVerified */ echo __('Submit') ?>
            </button>

</form>

A: My problem was solved when I add bind section to my script file.
I did this 2 steps :
1 - Disable button and prevent double submitting :
$('form').submit(function () {
    $(this).find(':submit').attr('disabled', 'disabled');
});

2 - Enable submit button if validation error occurred :
$("form").bind("invalid-form.validate", function () {
    $(this).find(':submit').prop('disabled', false);
});

A: Try this approach:
            jQuery('#form').on('submit', function () {
                if (jQuery(this).data('form_is_invalid')) {
                    jQuery(this).data('form_is_invalid', false);
                } else {
                    jQuery(this).find('.submit').prop('disabled', true);
                }
            }).on('invalid-form.validate', function () {
                jQuery(this).data('form_is_invalid', true);
            });

And if you have access to jQuery validate initialization, you can use submitHandler.


text:
Q: Multilevel Dropdown Bootstrap 4, Submenu align to top of Parent Dropdown Recently working on a project using Bootstrap 4.4,
Its an eCommerce grocery store, Departments have Categories & Sub Categories, So the Main goes very tall using default code,
For reference: Dropdown look like this
Now it's not looking good in my case, so I want all submenu to align to the top of the parent menu
For Reference: What I want to do
I think you understand what I want,
Also, on mobile its hide in the bottom

$(function() {
  $("ul.dropdown-menu [data-toggle='dropdown']").on("click", function(event) {
    event.preventDefault();
    event.stopPropagation();
    //method 2: remove show from all siblings of all your parents
    $(this).parents('.dropdown-submenu').siblings().find('.show').removeClass("show");
    $(this).siblings().toggleClass("show");
    //collapse all after nav is closed
    $(this).parents('li.nav-item.dropdown.show').on('hidden.bs.dropdown', function(e) {
      $('.dropdown-submenu .show').removeClass("show");
    });
  });
});
.dropdown-submenu {
  position: relative;
}

.dropdown-submenu>.dropdown-menu {
  top: 0;
  left: 100%;
}

.dropdown-submenu>a:after {
  font-family: "Font Awesome 5 Free" !important;
  font-weight: 900;
  content: "\f054" !important;
  border: none;
  position: absolute;
  right: 10px;
  top: 5px;
}

.dropdown-menu>li {
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.dropdown-menu>li:last-child {
  border-bottom: none;
}

.dropdown-item.active,
.dropdown-item:active {
  background-color: #f70000 !important;
  color: #fff !important;
}

.dropdown-item.dropdown-toggle:hover {
  color: #f70000;
}

.dropdown-item:hover {
  color: #f70000;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" />

<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css" rel="stylesheet" />

    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">

  </button>

          AISLES

              Grocery & Pets

                  Fresh Products

Fruits

Vegetables

Organic Vegetables

Meat & Poultry

                  Frozen

Chicken

Bread & Dough

Desserts & Toppings

Fruits & Vegetables

Seafood

Fries

                  Dairy

Food Staples

Breakfast

Beverages

Bread & Bakery

Baking & Cooking

Chocolates & Snacks

Desserts

Laundry & Household

Candies & Bubble Gum

Pet Care

                  Food Staples

Instant Meals

Ready-to-Eat

Sauces & Pickles

Spices & Recipes

Canned & Jarred Food

Chocolates & Snacks

Noodles & Pasta

Laundry & Household

Sugar & Salt

Pet Care

Beans & Pulses

Gluten Free

Soups & Stocks

Honey

                  Breakfast

Eggs

Honey

Cereals

Muesli

Canned & Jarred Food

Jams & Spreads

Noodles & Pasta

Oatmeals & Porridge

                  Bread & Bakery

Cakes

Bread & Buns

Wraps & Pittas

                  Baking & Cooking

Home Baking

Flours & Meals

Nuts & Seeds

Cooking Oil

Olive Oil

Rice

Salad Dressings

                  Chocolates & Snacks

Snacks

Biscuits

Wafers

Chocolates

Popcorn

Chips & Crisps

Salsas & Dips

Panwaari

Dry Fruits & Dates

Mouth Fresheners

                  Desserts

Traditional

Jelly & Custard

Syrups

                  Laundry & Household

Laundry

Shoe Care

Air Fresheners

Cloths & Dusters

Tissue & Toilet Rolls

Household Cleaners

Repellents & Insecticides

Trash Bags

                  Candies & Bubble Gum

Bubble Gum

Candies & Jellies

Marshmallows

                  Pet Care

Dog Food

Cat Food

Bird Food

Litter

Pet Grooming

              Health & Beauty

                  Fragrances

Men Perfumes

Men Deodorants

Women Perfumes

Women Deodorants

Body Mists

                  Hair Care

Shampoo & Conditioner

Hair Styling

Hair Loss Products

Hair Color

Hair Oils

Hair & Scalp Treatments

Styling Tools

Masks

                  Makeup

Eyes

Lips

Face

Nails

Makeup Removers

Tools & Brushes

                  Skin Care

Creams & Lotions

Facial Cleansers

Scrubs & Exfoliators

Sunscreens

Face Wash

Anti-Aging Products

Treatments & Masks

Face Whitening

Facial Masks

Powders

Face Mists

                  Bath & Body

Hand Wash & Sanitizer

Bath and Body Accessories

Nursing Products

Body Wash & Body Soap

Body Oils

Shower Gels & Creams

Eye Care

                  Feminine Care

Epilators

Tampons

Sanitary Napkins

Feminine Washes

Shaving

                  Men's Care

Shaving

Shavers & Timmers

                  Personal Care

Lip Care

Foot & Hand Care

Oral Hygiene

Hair Removal

Adult Diapers & Wipes

Beauty Tools

Massagers

Ear Care

                  Sexual Wellness

Condoms

Lubricants & Gels

              Phones & Tablets

Smartphones

Tablets

Chargers & Cables

Power Banks

Handsfree & Handset

                  Landline Phones

Corded

Cordless

              Electronic Accessories

                  Audio

Headphones & Headsets

Speakers

Batteries & Chargers

Light Bulbs & Lamps

              TV & Home Appliances

                  Video

Streaming Players

LCD & LED Televisions

                  Kitchen Appliances

Juicers

Toasters

Coffee & Tea

Microwave & Ovens

Blenders & Mixers

Dispensers & Purifiers

Cooking & Baking

Iron & Steamers

Household Cleaners

Air Purifiers

              Computing & Gaming

                  Games

Xbox

Nintendo

PlayStation

Laptops

Consoles & Accessories

                  Peripherals & Accessories

Laptop Bags & Sleeves

Printers

Memory Cards

USB Drives

Hard Drives

Networking

Keyboards

Thanks!!

A: It's just because of position: relative.
EXPLAINATION
added position: relative CSS to the .dropdown-item class because your ::after CSS not works without position: relative.
Removed position: relative CSS from the .dropdown-submenu class because Its calculate top from its height.

$(function() {
  $("ul.dropdown-menu [data-toggle='dropdown']").on("click", function(event) {
    event.preventDefault();
    event.stopPropagation();
    //method 2: remove show from all siblings of all your parents
    $(this).parents('.dropdown-submenu').siblings().find('.show').removeClass("show");
    $(this).siblings().toggleClass("show");
    //collapse all after nav is closed
    $(this).parents('li.nav-item.dropdown.show').on('hidden.bs.dropdown', function(e) {
      $('.dropdown-submenu .show').removeClass("show");
    });
  });
});
.dropdown-submenu {
  /*position: relative;*/
}

.dropdown-item {
  position: relative;
}

.dropdown-submenu>.dropdown-menu {
  top: 0;
  left: 100%;
}

.dropdown-submenu>a:after {
  font-family: "Font Awesome 5 Free" !important;
  font-weight: 900;
  content: "\f054" !important;
  border: none;
  position: absolute;
  right: 10px;
  top: 5px;
}

.dropdown-menu>li {
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.dropdown-menu>li:last-child {
  border-bottom: none;
}

.dropdown-item.active,
.dropdown-item:active {
  background-color: #f70000 !important;
  color: #fff !important;
}

.dropdown-item.dropdown-toggle:hover {
  color: #f70000;
}

.dropdown-item:hover {
  color: #f70000;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" />

<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css" rel="stylesheet" />

    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">

  </button>

          AISLES

              Grocery & Pets

                  Fresh Products

Fruits

Vegetables

Organic Vegetables

Meat & Poultry

                  Frozen

Chicken

Bread & Dough

Desserts & Toppings

Fruits & Vegetables

Seafood

Fries

                  Dairy

Food Staples

Breakfast

Beverages

Bread & Bakery

Baking & Cooking

Chocolates & Snacks

Desserts

Laundry & Household

Candies & Bubble Gum

Pet Care

                  Food Staples

Instant Meals

Ready-to-Eat

Sauces & Pickles

Spices & Recipes

Canned & Jarred Food

Chocolates & Snacks

Noodles & Pasta

Laundry & Household

Sugar & Salt

Pet Care

Beans & Pulses

Gluten Free

Soups & Stocks

Honey

                  Breakfast

Eggs

Honey

Cereals

Muesli

Canned & Jarred Food

Jams & Spreads

Noodles & Pasta

Oatmeals & Porridge

                  Bread & Bakery

Cakes

Bread & Buns

Wraps & Pittas

                  Baking & Cooking

Home Baking

Flours & Meals

Nuts & Seeds

Cooking Oil

Olive Oil

Rice

Salad Dressings

                  Chocolates & Snacks

Snacks

Biscuits

Wafers

Chocolates

Popcorn

Chips & Crisps

Salsas & Dips

Panwaari

Dry Fruits & Dates

Mouth Fresheners

                  Desserts

Traditional

Jelly & Custard

Syrups

                  Laundry & Household

Laundry

Shoe Care

Air Fresheners

Cloths & Dusters

Tissue & Toilet Rolls

Household Cleaners

Repellents & Insecticides

Trash Bags

                  Candies & Bubble Gum

Bubble Gum

Candies & Jellies

Marshmallows

                  Pet Care

Dog Food

Cat Food

Bird Food

Litter

Pet Grooming

              Health & Beauty

                  Fragrances

Men Perfumes

Men Deodorants

Women Perfumes

Women Deodorants

Body Mists

                  Hair Care

Shampoo & Conditioner

Hair Styling

Hair Loss Products

Hair Color

Hair Oils

Hair & Scalp Treatments

Styling Tools

Masks

                  Makeup

Eyes

Lips

Face

Nails

Makeup Removers

Tools & Brushes

                  Skin Care

Creams & Lotions

Facial Cleansers

Scrubs & Exfoliators

Sunscreens

Face Wash

Anti-Aging Products

Treatments & Masks

Face Whitening

Facial Masks

Powders

Face Mists

                  Bath & Body

Hand Wash & Sanitizer

Bath and Body Accessories

Nursing Products

Body Wash & Body Soap

Body Oils

Shower Gels & Creams

Eye Care

                  Feminine Care

Epilators

Tampons

Sanitary Napkins

Feminine Washes

Shaving

                  Men's Care

Shaving

Shavers & Timmers

                  Personal Care

Lip Care

Foot & Hand Care

Oral Hygiene

Hair Removal

Adult Diapers & Wipes

Beauty Tools

Massagers

Ear Care

                  Sexual Wellness

Condoms

Lubricants & Gels

              Phones & Tablets

Smartphones

Tablets

Chargers & Cables

Power Banks

Handsfree & Handset

                  Landline Phones

Corded

Cordless

              Electronic Accessories

                  Audio

Headphones & Headsets

Speakers

Batteries & Chargers

Light Bulbs & Lamps

              TV & Home Appliances

                  Video

Streaming Players

LCD & LED Televisions

                  Kitchen Appliances

Juicers

Toasters

Coffee & Tea

Microwave & Ovens

Blenders & Mixers

Dispensers & Purifiers

Cooking & Baking

Iron & Steamers

Household Cleaners

Air Purifiers

              Computing & Gaming

                  Games

Xbox

Nintendo

PlayStation

Laptops

Consoles & Accessories

                  Peripherals & Accessories

Laptop Bags & Sleeves

Printers

Memory Cards

USB Drives

Hard Drives

Networking

Keyboards


text:
Q: Can radgrid maskedcolumn display masked data in standard view? I have a masked radgrid column for a phone number on a bigint column.
The mask appropriately masks the edit form.
It does not mask the data in the standard grid view.
I understand that this is the intended behavior... however I'd like it to mask the displayed data too.
Any ideas?
EDIT: That is to say, as a standard grid item, I'd like to also appear in the mask.

A: I think I get your point to show that the input is masked in non-editable grid cell - simply include the characters from the phone mask when you update the grid source (as part of the text content). That should do the trick.

A: I resolved this by creating two columns in the grid, one being a formatted string and the other not (but only displaying the appropriate one).


text:
Q: What is the minimal feature space dimension for an input to be linearly saparable? I would like to know what methods exists to determine for certain feature-space-mapping-functions and a related finite number of inputs the minimal dimension of the feature space to make the inputs linearly separable?

A: tl;dr
For a binary classification problem, if you have $2n$ data points that aren't rank-deficient, $n$ of each class, then they are guaranteed to be linearly separable if they have greater than or equal to $2n-1$ dimensions.  Otherwise, they may or may not be depending on their arrangement in space.
the gory details
To see that this is the case, note that if we have exactly $2n-2$ dimensions, then if none of the $n$ points in each class are co-($n-1$)-planar, they all lie on a uniquely-determined ($n-1$)-plane.  If the two ($n-1$)-planes for our two classes are not parallel, then they will intersect somewhere at a $0$-plane (a point).  We can see this by noting that each ($n-1$)-plane has $n-1$ basis vectors in ($2n-2$)-space.  Putting the two together, we get $2n-2$ basis vectors, which leaves no directions in which they can be parallel.
By putting some of the points from each class in their respective hyperplanes on either side of the intersection, we obtain a situation where a single hyperplane cannot possibly separate them.  In 2D, this arrangement is equivalent to the well-known xor problem.
However, if we have $2n-1$ dimensions, we can construct a decision surface easily using the hyperplanes previously described.  Specifically, these $n-1$-planes no longer intersect in the same way that two lines in 2D definitely intersect unless they are parallel, but two lines in 3D definitely don't intersect unless the four points describing them are all co-planar.  We can obtain a hyperplane that not only separates the data, but separates the entire (n-1)-planes containing the original data.
One way to obtain said hyperplane is to note that each of the ($n-1$)-planes representing our two classes of data have ($n-1$) basis vectors in ($2n-1$) space.  If we put the basis vectors for these two ($n-1$)-planes together, we get ($2n-2$) vectors, which leaves one dimension in which they can be parallel.  By simply taking that vector to be the normal vector of our separating hyperplane, we obtain a hyperplane capable of perfectly separating our data.


text:
Q: The controllers namespace must start with your application namespace: App I found this error when wanting to publish my namespace in the file voyager.php with the instruction, `php artisan voyager:controllers
route:

voyager.php
'controllers' => [
    'namespace' => 'TCG\\Voyager\\Http\\Controllers',
    'namespace' => 'App\\Http\\Controllers\\Voyager',
],

error message:
**The controllers namespace must start with your application namespace: App</error>**

I have applied these commands
composer dumpautoload
php artisan config:cache
php artisan cache:clear
composer update

install and uninstall voyager
I use the version of laravel 5.5
Also insert the provider
TCG\Voyager\VoyagerServiceProvider::class,

A: Change
'namespace' => 'TCG\\Voyager\\Http\\Controllers',
To
'namespace' => 'App\\Http\\Controllers\\Voyager',
For detail visit GitHub Issue, GitHub Issue 2

A: Please try to following

*

*php artisan optimize

*php artisan voyager:controllers
You will be success.

A: You can use your own Controller by extending Voyager's Controllers. To do it, first define your controller Namespace at
config/voyager.php :
    'controllers' => [
        'namespace' => 'App\\Http\\Controllers\\Voyager',
    ],

then run php artisan voyager:controllers, voyager will now use the child controllers which will be created at
App/Http/Controllers/Voyager

A: Just clear the cache after change the namespace
php artisan config:cache


text:
Q: Nested for loops extending existing list Explain this code to me. This is a program to print integer inputs as outputs in letters. if i input 35 then output will be thirty five. i understood most of it but want to know how tens take the value from
twenty thirty forty fifty sixty seventy eighty ninety

The code is:
num = int(input("Enter the number:"))
numbers = ("zero one two three four five six seven eight nine".split())
numbers.extend("ten eleven twelve thirteen fourteen fifteen sixteen".split())
numbers.extend("seventeen eighteen nineteen".split())
numbers.extend(tens if ones == "zero" else (tens + " " + ones)
    for tens in "twenty thirty forty fifty sixty seventy eighty ninety".split()
    for ones in numbers[0:10])

print(numbers[num])

A: The two main concept that you see in the last line are list comprehension and nested loops. Have a look.
for understanding better what is going on, we're going to split that line in simplier part:
TENS
for tens in "twenty thirty forty fifty sixty seventy eighty ninety".split():
    print(tens)

OUTPUT: twenty thirty forty fifty sixty seventy eighty ninety

the previous for loop correspond to this in list comprehension:
(tens for tens in "twenty thirty forty fifty sixty seventy eighty ninety".split())

without print, returns a generator. if you want to see the result:
print(list(tens for tens in "twenty thirty forty fifty sixty seventy eighty ninety".split()))

ONES
numbers = ("zero one two three four five six seven eight nine".split())
for ones in numbers[0:10]:
    print(ones)

OUTPUT: zero one two three four five six seven eight nine

the previous for loop correspond to this in list comprehension:
    (ones for ones in numbers[0:10])

MERGE FOR LOOPS
we can merge them:
for tens in "twenty thirty forty fifty sixty seventy eighty ninety".split():
    for ones in numbers[0:10]:
        print(tens + " " + ones)
OUTPUT: twenty zero
twenty one
twenty two
twenty three
twenty four
twenty five
twenty six
twenty seven
twenty eight
twenty nine
thirty zero
thirty one
thirty two
[...]

since we don't like very much twenty zero, we are going to add a clause:
for tens in "twenty thirty forty fifty sixty seventy eighty ninety".split():
    for ones in numbers[0:10]:
        if ones == "zero":
            print(tens)
        else:
            print(tens + " " + ones)
OUTPUT:
twenty
twenty one
twenty two
twenty three
twenty four
[...]

And this is the same behaviour with list comprehension:
(tens if ones == "zero" else (tens + " " + ones) for tens in "twenty thirty forty fifty sixty seventy eighty ninety".split() for ones in numbers[0:10])

which returns a list (*generator) that will be extended to your numbers list.
At last, the number that you input correspond to the index of the word in the list


text:
Q: Variance: best-subset vs forward-stepwise regression In Hastie's Elements of Statistical Learning, in the chapter about linear regression, it is stated that

A price is paid in variance for selecting the best subset of each size; forward-stepwise is a more constrained search, and will have lower variance but perhaps more bias.

This seems intuitive, as best-subset can result in overfitting. Nevertheless, I don't know how to prove mathematically that the model obtained with forward-stepwise has lower variance than the one given by best-subset. Can this be proven, or are the authors just providing some heuristics ?

A: When it comes to the residual variance, a model selected via best subset will trivially better, because the best model is the one which minimizes the residual standard errors for a specific model size.
Thus it is pretty clear that the authors are referring to the variability in which model is selected. This variance is not well defined in the paragraph. Intuitively, but subset selection considers a larger set of models and therefore is more variable to the step-wise procedure which only considers a single model of every size. On the other hand, step-wise selection might not have the correct model in its solution path which is where the bias would come from.


text:
Q: Gson ClassCastException (LinkedTreeMap) Using Gson to deserialize objects of a parameterized class Container<T>, results in the java.lang.ClassCastException for certain values of T, e.g. for a simple Record type consisting of String and List<String> fields:
com.google.gson.internal.LinkedTreeMap cannot be cast to Record

Interestingly enough, the same code works when calling the fromJson() method inline, i.e. the following statement does return a valid value:
Container<Record> value = new Gson().fromJson(
  json, new TypeToken<Container<Record>>(){}.getType());

The definition of Container<T> is simple, too:
public class Container<T> {
  private static final Gson PARSER = new Gson();
  private String id;
  private List<T> content;
  private Object data;
  public static <T> Container<T> deserialize(String json, Class<T> type) {
    return PARSER.fromJson(json, new TypeToken<Container<T>>(){}.getType());
  }
}

Changing the deserialize() method to non-static does not resolve the issue.
Any ideas?

A: You want ParameterizedType my solution is create
    public static <T> Container<T> deserialize(String json, Class<T> clazz) {
        Type type = TypeToken.getParameterized(Container.class,clazz).getType();
        return new Gson().fromJson(json, type);
    }

problem is T because Java does not know what i kind and generate Type of T
    public static <T> Container<T> sec(String json, Class<T> clazz) {
        Type type1 = new TypeToken<Container<T>>() { }.getType();
        Type type = TypeToken.getParameterized(Container.class,clazz).getType();
        System.out.println(type1);   //==>pl.jac.container.Container<T>
        System.out.println(type);    //==>pl.jac.container.Container<pl.jac.container.Record>
        return new Gson().fromJson(json, type);
    }

this is test for more example to correct run
test testContainerRecord2 is for your problem
import java.lang.reflect.Type;
import org.junit.Test;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import static org.junit.Assert.assertEquals;

public class ContainerTest {

    @Test
    public void testContainerRecord() {
        //given
        String json = "{\"id\":\"new ID\",\"content\":[{\"id\":\"50e0300a-6668-42b3-a474-81a6a08f773f\"},{\"id\":\"f0bee3f3-2c40-4b44-8608-a6fedb226b7a\"}],\"data\":\"AAAAAAAA\"}";
        //when

        Container<Record> containerRecord = Container.deserializeClass(json, ContainerRecord.class);
        //then
        assertEquals("50e0300a-6668-42b3-a474-81a6a08f773f", containerRecord.content.get(0).id);
        assertEquals("f0bee3f3-2c40-4b44-8608-a6fedb226b7a", containerRecord.content.get(1).id);
    }

    @Test
    public void testContainerRecord2() {
        //given
        String json = "{\"id\":\"new ID\",\"content\":[{\"id\":\"50e0300a-6668-42b3-a474-81a6a08f773f\"},{\"id\":\"f0bee3f3-2c40-4b44-8608-a6fedb226b7a\"}],\"data\":\"AAAAAAAA\"}";
        //when

        Container<Record> containerRecord = Container.deserialize(json, Record.class);
        //then
        assertEquals("50e0300a-6668-42b3-a474-81a6a08f773f", containerRecord.content.get(0).id);
        assertEquals("f0bee3f3-2c40-4b44-8608-a6fedb226b7a", containerRecord.content.get(1).id);
    }

    @Test
    public void testGenericWithType() {
        //given
        String json = "{\"id\":\"new ID\",\"content\":[{\"id\":\"50e0300a-6668-42b3-a474-81a6a08f773f\"},{\"id\":\"f0bee3f3-2c40-4b44-8608-a6fedb226b7a\"}],\"data\":\"AAAAAAAA\"}";
        //when
        Type type = new TypeToken<Container<Record>>() {
        }.getType();

        Container<Record> containerRecord = Container.deserializeType(json, type);
        //then
        assertEquals("50e0300a-6668-42b3-a474-81a6a08f773f", containerRecord.content.get(0).id);
        assertEquals("f0bee3f3-2c40-4b44-8608-a6fedb226b7a", containerRecord.content.get(1).id);
    }

    @Test
    public void testRecord() {
        //given
        String json = "{\"id\":\"new ID\",\"content\":[{\"id\":\"50e0300a-6668-42b3-a474-81a6a08f773f\"},{\"id\":\"f0bee3f3-2c40-4b44-8608-a6fedb226b7a\"}],\"data\":\"AAAAAAAA\"}";
        //when
        ContainerRecord containerRecord = new Gson().fromJson(json, ContainerRecord.class);
        //then
        assertEquals("50e0300a-6668-42b3-a474-81a6a08f773f", containerRecord.content.get(0).id);
        assertEquals("f0bee3f3-2c40-4b44-8608-a6fedb226b7a", containerRecord.content.get(1).id);
    }

    @Test
    public void testRecordWithType() {
        //given
        String json = "{\"id\":\"new ID\",\"content\":[{\"id\":\"50e0300a-6668-42b3-a474-81a6a08f773f\"},{\"id\":\"f0bee3f3-2c40-4b44-8608-a6fedb226b7a\"}],\"data\":\"AAAAAAAA\"}";
        //when
        Type type = new TypeToken<Container<Record>>() {
        }.getType();
        Container<Record> containerRecord = new Gson().fromJson(json, type);
        //then
        assertEquals("50e0300a-6668-42b3-a474-81a6a08f773f", containerRecord.content.get(0).id);
        assertEquals("f0bee3f3-2c40-4b44-8608-a6fedb226b7a", containerRecord.content.get(1).id);
    }

    @Test
    public void testContainerString() {
        //given
        String json = "{\"id\":\"new ID\",\"content\":[\"37c84304-ab80-4f92-8b2a-710b362ecb3f\"],\"data\":\"AAAAAAAA\"}";
        //when
        Type type = new TypeToken<Container<String>>() {
        }.getType();
        Container<String> containerRecord = new Gson().fromJson(json, type);
        //then
        assertEquals("37c84304-ab80-4f92-8b2a-710b362ecb3f", containerRecord.content.get(0));
    }

}

my class Record
public class Record {
    public String id;
}

and my Container
public class ContainerRecord extends Container<Record> {
}

and Container
public class Container<T> {

    public String id;
    public List<T> content;
    public Object data;

    public static <T> Container<T> deserializeClass(String json, Class<? extends Container<T>> type) {
        return new Gson().fromJson(json, type);
    }
    public static <T> Container<T> deserializeType(String json, Type type) {
        return new Gson().fromJson(json, type);
    }

    public static <T> Container<T> deserialize(String json, Class<T> clazz) {
        Type type = TypeToken.getParameterized(Container.class,clazz).getType();
        return new Gson().fromJson(json, type);
    }
}


text:
Q: IE10 - How to display json formatted in response body of network developer tools When monitering network traffic (ajax traffic) in developer tools of IE10. I tried to check the request body. Though it showed me the json text inside the response body. It is not formatted in any way, just one straight line. How can I show it in a formatted view?
Thanks

A: Not exactly an answer, but I tend to keep a http://jsbeautifier.org/ window open for such things.  Get cursor in field, Ctrl+A,  Ctrl+C, go to beautifier window, Ctrl+A, Ctrl+V, click "Beautify Javascript or Html"... the whole keysequence + mouse movements is not immediate, but it is pretty quick.  You could also use Fiddler2 and add a JSON formatter if your company would allow installation of that.

A: If you right-click in the Response Body tab there is an option to word wrap. That makes it possible to see the entire line. However, it still does not format it in a nice JSON format.
(I know this question is almost a year old. But I found this when I had this same question. So thought I would answer with what I found.)


text:
Q: scale Imageview to full screen without straching bitmap. How to scale ImageView to full screen of the device when the bitmap is 240*240 size.
 I have used following code.
  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/layoutBGColor"
     android:clickable="true" >

<ImageView
    android:id="@+id/fullImage"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="fitXY" />

 ------
ImageView  iv = (ImageView)findViewById(R.id.fullImage);
iv..setImageBitmap(bitmap);

the bitmap is 240*240, bitmap is looks stratched.  I have googled this and this but none of them worked. Please suggest me How can I set bitmap in full screen without stratching.

A: Obviously since the image size is smaller than the screen size, then definitely its going to stretch. If you are talking about maintaining the aspect ratio when you stretch the image then try the following piece of code.
<ImageView
    android:id="@+id/fullImage"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:adjustViewBounds="true"
    android:scaleType="fitCenter" />

The trick is to use android:adjustViewBounds.


text:
Q: fatal: unable to get credential storage lock: Permission denied When I try to use git pull or any other command that needs credentials I get asked for them:
Username for 'https://git.private.com': test
Password for 'https://test@git.private.com':
fatal: unable to get credential storage lock: Permission denied

But they are not saved - where can I find the credentials file and delete it? It is not in my home dir.

A: For some reason, git tried to access the .gitconfig of WSL. So I disconnected the mounted virtual disk for WSL and tried again - everything worked flawlessly.
Maybe this will help someone...


text:
Q: luatexja-preset: deluxe option crashes deluxe option for luatexja-preset crashes. For example, when I compile the following code:
\documentclass[12pt,a4paper]{ltjsarticle}
\usepackage[hiragino-pro,deluxe]{luatexja-preset}
\newcommand{\jugem}{寿限無 寿限無 五劫の摺り切れ 海砂利水魚の 水行末 雲来末 風来末 食う寝る所に住む所, Supercalifragilisticexpialidocious! }
\begin{document}
\jugem
\end{document}

it crashes with an error message:
*************************************************
* luatexja-preset warning: "scale"
*
* Japanese fonts will be scaled by 0.92486572265625.
*************************************************
(load luc: /usr/local/texlive/2014/texmf-var/luatex-cache/generic/fonts/otf/ヒラギノ丸ゴ-pro-w4.luc)

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.319 }

?

This does not happen when I use \usepackage[hiragino-pro,deluxe]{luatexja-preset}
 instead.
Here is the complete set of the tex source file, luatex output and the corresponding .log file.
https://gist.github.com/nagae/a8b7f55c78c8798b61b7
Any advice?

A: The problem is in how luatexja-fontspec defines \newjfontfamily when fontspec version 2.4 is available; it's actually the auxiliary package luatexja-fontspec-24.sty that has the problem:
208 \DeclareDocumentCommand \newjfontfamily { m O{} m O{} } {
209   \cs_set_eq:NN \fontspec_set_family:Nnn \ltj_fontspec_set_family:Nnn
210   \newfontfamily #1 [#2] {#3} [#4]
211   \cs_set_eq:NN \fontspec_set_family:Nnn \__ltj_orig_fontspec_set_family:Nnn
212 }

(line numbers added for clarity). It basically redefines the internal command \fontspec_set_family:Nnn to add some code to it, then calls \newfontfamily and finally restores the meaning of \fontspec_set_family:Nnn.
The problem is not in the redefinition of \fontspec_set_family:Nnn, but in the \newfontfamily line, which presupposes this command is defined with
\DeclareDocumentCommand{\newfontfamily}{mO{}mO{}{...}

but it isn't.
A bit of history. In the first versions of fontspec, the command \newfontfamily was defined as
\DeclareDocumentCommand{\newfontfamily}{ m O{} m }{...}

so with a syntax such as
\newfontfamily{\somefont}[<options>]{fontname}

Version 2.4 of fontspec introduced an alternative syntax:
\newfontfamily{\somefont}{fontname}[<options>]

but not defining \newfontfamily to look for two optional arguments. What happens is that if the old syntax is found, it is used. If, instead, no optional argument appears between the two mandatory ones, a trailing optional argument is looked for.
So the code in \newjfontfamily fails, because an optional argument between the two mandatory ones is found and the trailing argument is not looked for. Indeed the error you get is caused by the [ that's out of place and causes LaTeX to start typesetting a paragraph; since it is in the preamble, the error
Missing \begin{document}

is issued.
Note that the deluxe option just triggers the bug: any declaration such as
\newjfontfamily{\somefont}{fontname}[<options>]

in the preamble would produce the same error also without the deluxe option.
In my opinion, the developers of fontspec shouldn't have changed the order of options; but the biggest error is doing the scanning of optional arguments the way it's done now, because it's against the guidelines of LaTeX3 programming.
How to remedy to the bug in luatexja-fontspec-24.sty? The command \newjfontfamily should support both syntaxes, for compatibility with older documents. So we must check for the presence of the optional argument between the two mandatory ones and add of consequence:
\documentclass[12pt,a4paper]{ltjsarticle}
\usepackage{luatexja-fontspec}

% Patch the wrong definition in luatexja-fontspec-24.sty
\ExplSyntaxOn
\DeclareDocumentCommand \newjfontfamily { m o m O{} }
 {
  \cs_set_eq:NN \fontspec_set_family:Nnn \ltj_fontspec_set_family:Nnn
  \IfNoValueTF{#2}
   {% no middle optional argument, use #4
    \newfontfamily {#1} [#4] {#3}
   }
   {% middle optional argument, use it
    \newfontfamily {#1} [#2] {#3}
   }
  \cs_set_eq:NN \fontspec_set_family:Nnn \__ltj_orig_fontspec_set_family:Nnn
 }
\ExplSyntaxOff

\usepackage[hiragino-pro,deluxe]{luatexja-preset}

\newjfontfamily\test[Scale=0.2]{Arial Unicode MS}

\newjfontfamily\testb{Arial Unicode MS}[Scale=2]

\newcommand{\jugem}{寿限無 寿限無 五劫の摺り切れ 海砂利水魚の 水行末 雲来末 風来末
食う寝る所に住む所, Supercalifragilisticexpialidocious! }

\begin{document}

Tiny: {\test 寿限無} --- Huge: {\testb 寿限無}

\jugem

\end{document}

I added definitions of fonts with both syntaxes to show the correct options are chosen.


text:
Q: Execute commands as different user via sudo over SSH in a justfile I have this justfile:
remote:
    #!/usr/bin/env bash
    read -p 'Password:' -s password
    ssh -tt somewhere 'bash -l -s' << 'ENDSSH'
    whoami
    echo "$password" | sudo su someone 'bash -l -s' << 'ENDSUDO'
    whoami
    ENDSUDO
    ENDSSH

It should:

*

*Ask me for a password

*SSH into somewhere

*sudo to change the user

*execute some scripts

What it does:
It asks for a password a second time.
It stucks on input (no error message).
How to solve this problem?
Update
As suggested by @xhienne, this does almost work, but it says, I use the wrong password:
remote:
    #!/usr/bin/env bash
    read -p 'Password:' -s password
    ssh -tt somewhere 'bash -l -s' << 'ENDSSH'
    sudo -S -i -u someone << ENDSUDO
    $password
    whoami
    ENDSUDO
    exit
    ENDSSH

But this does work:
remote:
    #!/usr/bin/env bash
    read -p 'Password:' -s password
    ssh -tt somewhere 'bash -l -s' << 'ENDSSH'
    sudo -S -i -u someone << ENDSUDO
    clear-text-password
    whoami
    ENDSUDO
    exit
    ENDSSH

Update 2
The answer of @xhienne does work.

A: With
echo "$password" | sudo su someone 'bash -l -s' << 'ENDSUDO'
    whoami
ENDSUDO

You are redirecting stdin twice:

*

*once with |

*a second time with <<
Try this:
sudo -S -i -u someone << ENDSUDO
$password
whoami
ENDSUDO

sudo -S will read the password from stdin. sudo -i is a substitute for the ugly sudo su bash -l (but it needs that sudo be properly configured for -u someone)
Note that I removed the quotes around ENDSUDO. Beware of inadvertent substitutions. If you must keep ENDSUDO quoted, then you can try this instead:
{
    echo "$password"
    cat << 'ENDSUDO'
whoami
ENDSUDO
} | sudo -S -i -u someone

A: I believe the following will work, if you only want to run whoami instead of several commands:
#!/usr/bin/env bash
read -s -p 'Password: ' password
ssh somewhere whoami
echo "$password" | ssh somewhere sudo -S -u someone whoami

The -S tells sudo to read the password from stdin.
If you want to run several commands with a here-document, see @xhienne's  answer.


text:
Q: How to build projects to a common directory in a Visual Studio solution? I have C# and C++ projects in Visual Studio's solution.
How to make them build into one common folder?
In C++ projects Output Directory is set to $(SolutionDir)$(Platform)\$(Configuration)\:

But in C# projects it just says bin\release\:

And outputs into $(ProjectDir)bin\release as it usually does in C# projects.
When in C# projects I set Output path to $(SolutionDir)$(Platform)\$(Configuration)\:

It creates folder named $(SolutionDir)$(Platform) inside its project folder:
I would like files from all of my projects to be output to $(SolutionDir)bin\$(Platform)\$(Configuration)\. So on a Debug x86 Build configuration it will be $(SolutionDir)bin\x86\Debug and on a Release x64 Configuration build it will be $(SolutionDir)bin\x64\Release.
I googled it and searched it here on Stackoverflow but I can't find a solution.
The closest thing I found is to use Build Events in C# projects and set output to $(SolutionDir)bin\$(Platform)\$(Configuration)\.
But the problem with this approach is that in C# projects the Platform is always set to Any CPU:

And appropriate target platform is set in another field called Target platform:


text:
Q: precision of double in R I have to calculate the difference between two long variables in R.
Initially, it was stored as text. But when I tried to convert them into numeric or double to calculate the difference, R fails to recognize that the difference is 1.
testVariable1 = as.numeric("233203300000000001")
testVariable2 = as.numeric("233203300000000002")
testVariable2 - testVariable1

Result:

[1] 0

What can I do to solve this issue?
Thanks in advance!

A: library(gmp)

as.bigz("233203300000000002")-as.bigz("233203300000000001")

Big Integer ('bigz') :
[1] 1

A: You could try using the bit64 package:
library(bit64)
##
testVariable1 <- as.integer64("233203300000000001")
testVariable2 <- as.integer64("233203300000000002")
##
R> testVariable2 - testVariable1
#integer64
#[1] 1
R> as.numeric(testVariable2 - testVariable1)
#[1] 1


text:
Q: PHP var to Javascript I have below code that works but it is slow is there any suggestion to improve turnaround.
How can I have it accept only numbers from 1 to 10 and reject alpha
"h**p://mydomai.any/handler.php?msg1=10" ok
"h**p://mydomai.any/handler.php?msg1=14" not ok
"h**p://mydomai.any/handler.php?msg1=HELLO" no ok (now it accepts all)
handler.php
<?php
header("HTTP/1.1 200 OK");
if (isset($_REQUEST['msg1'])) {
    $msg1 = $_REQUEST['msg1'];
    ?>
    <script type="text/javascript" src="https://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="http://signage.me/demo/sendCommand.js"></script>
    <script type="text/javascript">
      $(document).ready(function()
      {
           sendCommand("galaxy.signage.me", "username", "password", "13", "new1", (msg1 = <?php echo (json_encode($msg1)); ?>));
         });
    </script>
    <?php
}
?>

A: is_numeric — Finds whether a variable is a number or a numeric string.
<?php
header("HTTP/1.1 200 OK");
if (isset($_REQUEST['msg1']) && is_numeric($_REQUEST['msg1']) && $_REQUEST['msg1'] >=1 && $_REQUEST['msg1'] <=10 ) {
    $msg1 = $_REQUEST['msg1'];
    ?>
    <script type="text/javascript" src="https://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="http://signage.me/demo/sendCommand.js"></script>
    <script type="text/javascript">
      $(document).ready(function()
      {
           sendCommand("galaxy.signage.me", "username", "password", "13", "new1", (msg1 = <?php echo (json_encode($msg1)); ?>));
         });
    </script>
    <?php
}
?>

A: Use http://php.net/manual/en/function.intval.php to convert $msg1 to an integer and check its value before injecting it in the javascript code.


text:
Q: How to execute a Unix shell script from Windows I've got an AIX script I would like to run from a .NET application. I'm not opposed to kicking off a Windows batch file if that gives me better options.
Most of what I've seen on Google relates to using a tool such as rsh or Plink, or using ssh or telnet. I don't have access to rsh or Plink (although I do have PuTTY and could probably get Plink). I can ssh to the AIX box but telnet is disabled.
I'll need a way of passing the user's credentials.
Can anyone recommend the best way to call a Unix script from a Windows application?

A: Install cygwin.  Include the ssh function.  Set up your ssh keys - private key on windows, public key on the AIX box.  Then you can run "ssh user@aixbox script-on-aix-box.sh".
Best to have the script on AIX, though you can use scp to copy the file to AIX first.  Passing a long command line through ssh is error prone - not due to it being ssh, but because getting escapes properly set up to pass from .NET through ssh to ksh or whatever is running on AIX is just painful.  Best to keep things as simple as possible, preferably just a single command which can then be a script that does multiple things.
To answer your comments, which would take too long for another comment:
(1) Why is it better to use cygwin's ssh utility instead of the Windows ssh utility?
a) I know it better, so I wouldn't know to suggest any windows ssh utility (I didn't even know Windows came with an ssh utility), and b) cygwin's ssh utility stands a better chance of being standard ssh with all the familiarity us unix freaks love.  :-)
(2) What are the keys for? Does that allow cross-platform authentication, or is it just a way of asymmetrically encrypting the password?
The keys allow passwordless access.  If you set up your private key as passwordless (not usually recommended, but if you can keep your machine secure, it works well for automated tools), your tool will be able to just ssh over with no password prompts - this makes things much easier.

A: ssh eximadmin@172.16.12.10 "cat somefile.log"
(where cat somefile.log is replaced with the command that you want to run)
I think the easiest way to do it would be to call your ssh program (whether that be ssh, plink, or something else) from a batch file that is called from your .net app.

A: I second the cygwin suggestion, but one other option that you have is Microsoft's Services for UNIX.

A: What I would do, would be to setup a service (https) interface on the AIX box that the .Net application can run.  This is really a matter of how you want to expose your script on the AIX box.  IMHO Java + Tomcat would be easy enough to get setup on the AIX box, just make sure you limit your exposure, and/or require an authentication ticket for the AIX service.  This isn't so much a .Net question as an architectural decision.
--edit--
As others have suggested, you can use Cygwin as well.  There are SSH components for .Net you can use as well, which may be more transparent for you.  (Commercial and FOSS)


text:
Q: A condition for birational equivalence to projective space Let $f,g\in\mathbb{C}[x_{1},...,x_{n}]$ be coprime homogeneous polynomials of degrees $d$ and $d-1$ over $\mathbb{C}$. Show that $V(f-x_{0}g)$ is a rational variety over $\mathbb{C}$, i.e. birationally equivalent to $\mathbb{P}^{n}_{\mathbb{C}}$.
I have no idea even where to start. Can somebody please give me a detailed explanation?


text:
Q: Receive many entities from DB per one query For EF Core I have a collection of values, e.g. there are IDs of entities of my db's some table, and I want to receive multiple entities that are fit for these ID's.
It can be something like:
List<string> IDs { get; set; }
...
var listofEntities = new List<Foo>();
foreach(var id in IDs)
{
var result = context.Foos.Where(f => f.ID == id).Single();
listofEntities.Add(result);
}

However I think it's very slow approach. Can I get all needed entities per one query to DB?

A: Just use Contains:
List<string> IDs { get; set; }
...
var listofEntities = context.Foos.Where(f => IDs.Contains(f.ID));

A: you can use a join
var query = from foo in context.Foos
    join id in IDs on id equals foo.ID
    select foo;

return await query.ToListAsync();


text:
Q: How to check if a text is all white space characters in client side? How to check if a user input text is all white space characters (space, tab, enter etc) in client side?

A: This question is tagged with jQuery. In jQuery, you can run the following:
if ( $.trim( $('#myInput').val() ) == '' )
    alert('input is blank');

A: Like this...
function isEmpty(str) {
  return str.replace(/^\s+|\s+$/g, '').length == 0;
}

A: If you want to see if a file contains all white space or is empty, I would recommend testing the inversion and inverting the result. That way you don't need to worry about special cases around empty string.
all whitespace is the same as no non-whitespace so:
function isWhitespaceOrEmpty(text) {
   return !/[^\s]/.test(text);
}

If you don't want empty strings you can modify it slightly:
function isWhitespaceNotEmpty(text) {
   return text.length > 0 && !/[^\s]/.test(text);
}

A: /^\s+$/.test(userText)
Change the + to * to include the empty string '' as a positive match.
Edit
More often than not though you need to trim whitespace from user-entered text and simply test if it's non-empty:
userText = userText.replace(/^\s+/, '').replace(/\s+$/, '');
if (userText === '') {
    // text was all whitespace
} else {
    // text has real content, now free of leading/trailing whitespace
}

A: To find whitespace generated by JavaScript and between elements use:
var trimmed = $.trim( $('p').text() );

if ( trimmed === '' ){
    //function...
}

A: This will also work:
var text = "   ";
text.trim().length == 0; //true

A: Josh's answer is very close to this, but according to w3schools (in May 2014) it is as follows:
function isEmpty(str) {
    return str.replace(/^\s+|\s+$/gm,'').length == 0;
}

A: //                      ^ start string
//                      || \s+ white space one or more times
//                      || || $ = end string
//                      || || ||
//                      \/ \/ \/

const isAllWhiteSpace = /^\s+$/.test(myvalue)

A: yo, we can check simply bt trim, as javascript is tagged in question,

console.log('     '.trim() === '')//check for all empty spaces

console.log('     '.trim() === '')//check for all empty tabs

console.log('\n \n'.trim() === '')//check for all empty enter(empty new line)

console.log('         \n'.trim() === '')//check for all spaces, tabs and new line

A: Something that has worked for me:
 $("#example_form").validate({
    rules: {
        example_field: {
            required: {
                depends: function () {
                    $(this).val($.trim($(this).val()));
                    return true;
                }
            }
        },

    },
    messages: { example_field: {required: "Custom Validation Message for example_field"}, }
});

A:

            Password*
            <input type="password" id="password" name="password" class="form-control my-metro-inputs my-metro-input-border my-metro-input-padding" placeholder="password" value="" required onfocusout="passwordChecker(this)">

function passwordChecker(e){
    var pass = document.getElementById('password');
    var passStatus = document.getElementById('pass-status');
    var inValid = /\s/;
    if(pass){
        if(pass.value.length == 0 || pass.value.length < 0){
            pass.classList.remove('my-input-success');
            pass.classList.add('my-input-danger');
            if(passStatus){
                passStatus.innerHTML = " field must not empty or less then Zero ( 0 ) !";

            }
            return false;
        }else if((inValid.test(pass.value))){
            pass.classList.remove('my-input-success');
            pass.classList.add('my-input-danger');
            if(passStatus){
                passStatus.innerHTML = " no whitespaces allowed !";
            }
            return false;
        }else{
            pass.classList.add('my-input-success');
            pass.classList.remove('my-input-danger');
            if(passStatus){
                passStatus.innerHTML = "";
            }
            return true;
        }
    }
    return false;
}
.container-fluid {
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto
}

.container {
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto
}

@media (min-width:768px) {
    .container {
        width: 750px
    }
}

@media (min-width:992px) {
    .container {
        width: 970px
    }
}

@media (min-width:1200px) {
    .container {
        width: 1170px
    }
}

.row {
    margin-right: -15px;
    margin-left: -15px
}

.col-xs-1,
.col-sm-1,
.col-md-1,
.col-lg-1,
.col-xs-2,
.col-sm-2,
.col-md-2,
.col-lg-2,
.col-xs-3,
.col-sm-3,
.col-md-3,
.col-lg-3,
.col-xs-4,
.col-sm-4,
.col-md-4,
.col-lg-4,
.col-xs-5,
.col-sm-5,
.col-md-5,
.col-lg-5,
.col-xs-6,
.col-sm-6,
.col-md-6,
.col-lg-6,
.col-xs-7,
.col-sm-7,
.col-md-7,
.col-lg-7,
.col-xs-8,
.col-sm-8,
.col-md-8,
.col-lg-8,
.col-xs-9,
.col-sm-9,
.col-md-9,
.col-lg-9,
.col-xs-10,
.col-sm-10,
.col-md-10,
.col-lg-10,
.col-xs-11,
.col-sm-11,
.col-md-11,
.col-lg-11,
.col-xs-12,
.col-sm-12,
.col-md-12,
.col-lg-12 {
    position: relative;
    min-height: 1px;
    padding-right: 15px;
    padding-left: 15px
}

.col-xs-1,
.col-xs-2,
.col-xs-3,
.col-xs-4,
.col-xs-5,
.col-xs-6,
.col-xs-7,
.col-xs-8,
.col-xs-9,
.col-xs-10,
.col-xs-11,
.col-xs-12 {
    float: left
}

.col-xs-12 {
    width: 100%
}

.col-xs-11 {
    width: 91.66666667%
}

.col-xs-10 {
    width: 83.33333333%
}

.col-xs-9 {
    width: 75%
}

.col-xs-8 {
    width: 66.66666667%
}

.col-xs-7 {
    width: 58.33333333%
}

.col-xs-6 {
    width: 50%
}

.col-xs-5 {
    width: 41.66666667%
}

.col-xs-4 {
    width: 33.33333333%
}

.col-xs-3 {
    width: 25%
}

.col-xs-2 {
    width: 16.66666667%
}

.col-xs-1 {
    width: 8.33333333%
}

.col-xs-pull-12 {
    right: 100%
}

.col-xs-pull-11 {
    right: 91.66666667%
}

.col-xs-pull-10 {
    right: 83.33333333%
}

.col-xs-pull-9 {
    right: 75%
}

.col-xs-pull-8 {
    right: 66.66666667%
}

.col-xs-pull-7 {
    right: 58.33333333%
}

.col-xs-pull-6 {
    right: 50%
}

.col-xs-pull-5 {
    right: 41.66666667%
}

.col-xs-pull-4 {
    right: 33.33333333%
}

.col-xs-pull-3 {
    right: 25%
}

.col-xs-pull-2 {
    right: 16.66666667%
}

.col-xs-pull-1 {
    right: 8.33333333%
}

.col-xs-pull-0 {
    right: auto
}

.col-xs-push-12 {
    left: 100%
}

.col-xs-push-11 {
    left: 91.66666667%
}

.col-xs-push-10 {
    left: 83.33333333%
}

.col-xs-push-9 {
    left: 75%
}

.col-xs-push-8 {
    left: 66.66666667%
}

.col-xs-push-7 {
    left: 58.33333333%
}

.col-xs-push-6 {
    left: 50%
}

.col-xs-push-5 {
    left: 41.66666667%
}

.col-xs-push-4 {
    left: 33.33333333%
}

.col-xs-push-3 {
    left: 25%
}

.col-xs-push-2 {
    left: 16.66666667%
}

.col-xs-push-1 {
    left: 8.33333333%
}

.col-xs-push-0 {
    left: auto
}

.col-xs-offset-12 {
    margin-left: 100%
}

.col-xs-offset-11 {
    margin-left: 91.66666667%
}

.col-xs-offset-10 {
    margin-left: 83.33333333%
}

.col-xs-offset-9 {
    margin-left: 75%
}

.col-xs-offset-8 {
    margin-left: 66.66666667%
}

.col-xs-offset-7 {
    margin-left: 58.33333333%
}

.col-xs-offset-6 {
    margin-left: 50%
}

.col-xs-offset-5 {
    margin-left: 41.66666667%
}

.col-xs-offset-4 {
    margin-left: 33.33333333%
}

.col-xs-offset-3 {
    margin-left: 25%
}

.col-xs-offset-2 {
    margin-left: 16.66666667%
}

.col-xs-offset-1 {
    margin-left: 8.33333333%
}

.col-xs-offset-0 {
    margin-left: 0
}

@media (min-width:768px) {

    .col-sm-1,
    .col-sm-2,
    .col-sm-3,
    .col-sm-4,
    .col-sm-5,
    .col-sm-6,
    .col-sm-7,
    .col-sm-8,
    .col-sm-9,
    .col-sm-10,
    .col-sm-11,
    .col-sm-12 {
        float: left
    }

    .col-sm-12 {
        width: 100%
    }

    .col-sm-11 {
        width: 91.66666667%
    }

    .col-sm-10 {
        width: 83.33333333%
    }

    .col-sm-9 {
        width: 75%
    }

    .col-sm-8 {
        width: 66.66666667%
    }

    .col-sm-7 {
        width: 58.33333333%
    }

    .col-sm-6 {
        width: 50%
    }

    .col-sm-5 {
        width: 41.66666667%
    }

    .col-sm-4 {
        width: 33.33333333%
    }

    .col-sm-3 {
        width: 25%
    }

    .col-sm-2 {
        width: 16.66666667%
    }

    .col-sm-1 {
        width: 8.33333333%
    }

    .col-sm-pull-12 {
        right: 100%
    }

    .col-sm-pull-11 {
        right: 91.66666667%
    }

    .col-sm-pull-10 {
        right: 83.33333333%
    }

    .col-sm-pull-9 {
        right: 75%
    }

    .col-sm-pull-8 {
        right: 66.66666667%
    }

    .col-sm-pull-7 {
        right: 58.33333333%
    }

    .col-sm-pull-6 {
        right: 50%
    }

    .col-sm-pull-5 {
        right: 41.66666667%
    }

    .col-sm-pull-4 {
        right: 33.33333333%
    }

    .col-sm-pull-3 {
        right: 25%
    }

    .col-sm-pull-2 {
        right: 16.66666667%
    }

    .col-sm-pull-1 {
        right: 8.33333333%
    }

    .col-sm-pull-0 {
        right: auto
    }

    .col-sm-push-12 {
        left: 100%
    }

    .col-sm-push-11 {
        left: 91.66666667%
    }

    .col-sm-push-10 {
        left: 83.33333333%
    }

    .col-sm-push-9 {
        left: 75%
    }

    .col-sm-push-8 {
        left: 66.66666667%
    }

    .col-sm-push-7 {
        left: 58.33333333%
    }

    .col-sm-push-6 {
        left: 50%
    }

    .col-sm-push-5 {
        left: 41.66666667%
    }

    .col-sm-push-4 {
        left: 33.33333333%
    }

    .col-sm-push-3 {
        left: 25%
    }

    .col-sm-push-2 {
        left: 16.66666667%
    }

    .col-sm-push-1 {
        left: 8.33333333%
    }

    .col-sm-push-0 {
        left: auto
    }

    .col-sm-offset-12 {
        margin-left: 100%
    }

    .col-sm-offset-11 {
        margin-left: 91.66666667%
    }

    .col-sm-offset-10 {
        margin-left: 83.33333333%
    }

    .col-sm-offset-9 {
        margin-left: 75%
    }

    .col-sm-offset-8 {
        margin-left: 66.66666667%
    }

    .col-sm-offset-7 {
        margin-left: 58.33333333%
    }

    .col-sm-offset-6 {
        margin-left: 50%
    }

    .col-sm-offset-5 {
        margin-left: 41.66666667%
    }

    .col-sm-offset-4 {
        margin-left: 33.33333333%
    }

    .col-sm-offset-3 {
        margin-left: 25%
    }

    .col-sm-offset-2 {
        margin-left: 16.66666667%
    }

    .col-sm-offset-1 {
        margin-left: 8.33333333%
    }

    .col-sm-offset-0 {
        margin-left: 0
    }
}

@media (min-width:992px) {

    .col-md-1,
    .col-md-2,
    .col-md-3,
    .col-md-4,
    .col-md-5,
    .col-md-6,
    .col-md-7,
    .col-md-8,
    .col-md-9,
    .col-md-10,
    .col-md-11,
    .col-md-12 {
        float: left
    }

    .col-md-12 {
        width: 100%
    }

    .col-md-11 {
        width: 91.66666667%
    }

    .col-md-10 {
        width: 83.33333333%
    }

    .col-md-9 {
        width: 75%
    }

    .col-md-8 {
        width: 66.66666667%
    }

    .col-md-7 {
        width: 58.33333333%
    }

    .col-md-6 {
        width: 50%
    }

    .col-md-5 {
        width: 41.66666667%
    }

    .col-md-4 {
        width: 33.33333333%
    }

    .col-md-3 {
        width: 25%
    }

    .col-md-2 {
        width: 16.66666667%
    }

    .col-md-1 {
        width: 8.33333333%
    }

    .col-md-pull-12 {
        right: 100%
    }

    .col-md-pull-11 {
        right: 91.66666667%
    }

    .col-md-pull-10 {
        right: 83.33333333%
    }

    .col-md-pull-9 {
        right: 75%
    }

    .col-md-pull-8 {
        right: 66.66666667%
    }

    .col-md-pull-7 {
        right: 58.33333333%
    }

    .col-md-pull-6 {
        right: 50%
    }

    .col-md-pull-5 {
        right: 41.66666667%
    }

    .col-md-pull-4 {
        right: 33.33333333%
    }

    .col-md-pull-3 {
        right: 25%
    }

    .col-md-pull-2 {
        right: 16.66666667%
    }

    .col-md-pull-1 {
        right: 8.33333333%
    }

    .col-md-pull-0 {
        right: auto
    }

    .col-md-push-12 {
        left: 100%
    }

    .col-md-push-11 {
        left: 91.66666667%
    }

    .col-md-push-10 {
        left: 83.33333333%
    }

    .col-md-push-9 {
        left: 75%
    }

    .col-md-push-8 {
        left: 66.66666667%
    }

    .col-md-push-7 {
        left: 58.33333333%
    }

    .col-md-push-6 {
        left: 50%
    }

    .col-md-push-5 {
        left: 41.66666667%
    }

    .col-md-push-4 {
        left: 33.33333333%
    }

    .col-md-push-3 {
        left: 25%
    }

    .col-md-push-2 {
        left: 16.66666667%
    }

    .col-md-push-1 {
        left: 8.33333333%
    }

    .col-md-push-0 {
        left: auto
    }

    .col-md-offset-12 {
        margin-left: 100%
    }

    .col-md-offset-11 {
        margin-left: 91.66666667%
    }

    .col-md-offset-10 {
        margin-left: 83.33333333%
    }

    .col-md-offset-9 {
        margin-left: 75%
    }

    .col-md-offset-8 {
        margin-left: 66.66666667%
    }

    .col-md-offset-7 {
        margin-left: 58.33333333%
    }

    .col-md-offset-6 {
        margin-left: 50%
    }

    .col-md-offset-5 {
        margin-left: 41.66666667%
    }

    .col-md-offset-4 {
        margin-left: 33.33333333%
    }

    .col-md-offset-3 {
        margin-left: 25%
    }

    .col-md-offset-2 {
        margin-left: 16.66666667%
    }

    .col-md-offset-1 {
        margin-left: 8.33333333%
    }

    .col-md-offset-0 {
        margin-left: 0
    }
}

@media (min-width:1200px) {

    .col-lg-1,
    .col-lg-2,
    .col-lg-3,
    .col-lg-4,
    .col-lg-5,
    .col-lg-6,
    .col-lg-7,
    .col-lg-8,
    .col-lg-9,
    .col-lg-10,
    .col-lg-11,
    .col-lg-12 {
        float: left
    }

    .col-lg-12 {
        width: 100%
    }

    .col-lg-11 {
        width: 91.66666667%
    }

    .col-lg-10 {
        width: 83.33333333%
    }

    .col-lg-9 {
        width: 75%
    }

    .col-lg-8 {
        width: 66.66666667%
    }

    .col-lg-7 {
        width: 58.33333333%
    }

    .col-lg-6 {
        width: 50%
    }

    .col-lg-5 {
        width: 41.66666667%
    }

    .col-lg-4 {
        width: 33.33333333%
    }

    .col-lg-3 {
        width: 25%
    }

    .col-lg-2 {
        width: 16.66666667%
    }

    .col-lg-1 {
        width: 8.33333333%
    }

    .col-lg-pull-12 {
        right: 100%
    }

    .col-lg-pull-11 {
        right: 91.66666667%
    }

    .col-lg-pull-10 {
        right: 83.33333333%
    }

    .col-lg-pull-9 {
        right: 75%
    }

    .col-lg-pull-8 {
        right: 66.66666667%
    }

    .col-lg-pull-7 {
        right: 58.33333333%
    }

    .col-lg-pull-6 {
        right: 50%
    }

    .col-lg-pull-5 {
        right: 41.66666667%
    }

    .col-lg-pull-4 {
        right: 33.33333333%
    }

    .col-lg-pull-3 {
        right: 25%
    }

    .col-lg-pull-2 {
        right: 16.66666667%
    }

    .col-lg-pull-1 {
        right: 8.33333333%
    }

    .col-lg-pull-0 {
        right: auto
    }

    .col-lg-push-12 {
        left: 100%
    }

    .col-lg-push-11 {
        left: 91.66666667%
    }

    .col-lg-push-10 {
        left: 83.33333333%
    }

    .col-lg-push-9 {
        left: 75%
    }

    .col-lg-push-8 {
        left: 66.66666667%
    }

    .col-lg-push-7 {
        left: 58.33333333%
    }

    .col-lg-push-6 {
        left: 50%
    }

    .col-lg-push-5 {
        left: 41.66666667%
    }

    .col-lg-push-4 {
        left: 33.33333333%
    }

    .col-lg-push-3 {
        left: 25%
    }

    .col-lg-push-2 {
        left: 16.66666667%
    }

    .col-lg-push-1 {
        left: 8.33333333%
    }

    .col-lg-push-0 {
        left: auto
    }

    .col-lg-offset-12 {
        margin-left: 100%
    }

    .col-lg-offset-11 {
        margin-left: 91.66666667%
    }

    .col-lg-offset-10 {
        margin-left: 83.33333333%
    }

    .col-lg-offset-9 {
        margin-left: 75%
    }

    .col-lg-offset-8 {
        margin-left: 66.66666667%
    }

    .col-lg-offset-7 {
        margin-left: 58.33333333%
    }

    .col-lg-offset-6 {
        margin-left: 50%
    }

    .col-lg-offset-5 {
        margin-left: 41.66666667%
    }

    .col-lg-offset-4 {
        margin-left: 33.33333333%
    }

    .col-lg-offset-3 {
        margin-left: 25%
    }

    .col-lg-offset-2 {
        margin-left: 16.66666667%
    }

    .col-lg-offset-1 {
        margin-left: 8.33333333%
    }

    .col-lg-offset-0 {
        margin-left: 0
    }
}

.clearfix:before,
.clearfix:after,
.dl-horizontal dd:before,
.dl-horizontal dd:after,
.container:before,
.container:after,
.container-fluid:before,
.container-fluid:after,
.row:before,
.row:after,
.form-horizontal .form-group:before,
.form-horizontal .form-group:after,
.btn-toolbar:before,
.btn-toolbar:after,
.btn-group-vertical > .btn-group:before,
.btn-group-vertical > .btn-group:after,
.nav:before,
.nav:after,
.navbar:before,
.navbar:after,
.navbar-header:before,
.navbar-header:after,
.navbar-collapse:before,
.navbar-collapse:after,
.pager:before,
.pager:after,
.panel-body:before,
.panel-body:after,
.modal-footer:before,
.modal-footer:after {
    display: table;
    content: " "
}

.clearfix:after,
.dl-horizontal dd:after,
.container:after,
.container-fluid:after,
.row:after,
.form-horizontal .form-group:after,
.btn-toolbar:after,
.btn-group-vertical > .btn-group:after,
.nav:after,
.navbar:after,
.navbar-header:after,
.navbar-collapse:after,
.pager:after,
.panel-body:after,
.modal-footer:after {
    clear: both
}

.center-block {
    display: block;
    margin-right: auto;
    margin-left: auto
}

.pull-right {
    float: right !important
}

/* forms */
.form-row {
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    margin-right: -5px;
    margin-left: -5px;
    margin-bottom: 5px;
}

.form-row > .col,
.form-row > [class*=col-] {
    padding-right: 5px;
    padding-left: 5px;
}

.col {
    -ms-flex-preferred-size: 0;
    flex-basis: 0;
    -ms-flex-positive: 1;
    flex-grow: 1;
    max-width: 100%;
}

.col {
    position: relative;
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
}

.margin-top-25px {
    margin-top: 25px;
}

.form-control {
    display: block;
    width: 100%;
    height: calc(1.5em + .75rem + 2px);
    padding: .375rem .75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: .25rem;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

button,
input {
    overflow: visible;
}

.form-check-label {
    margin-bottom: 0;
}

.form-check-inline {
    display: -ms-inline-flexbox;
    display: inline-flex;
    -ms-flex-align: center;
    align-items: center;
    padding-left: 0;
    margin-right: .75rem;
}
.form-check-inline {
    position: relative;
    top: 33px;
    width: 10%;
}
.form-check {
    position: relative;
    display: block;
    padding-left: 1.25rem;
}

.form-check-inline .form-check-input {
    position: static;
    margin-top: 0;
    margin-right: .3125rem;
    margin-left: 0;
}

input[type=checkbox],
input[type=radio] {
    box-sizing: border-box;
    padding: 0;
}

.form-check-input {
    position: absolute;
    margin-top: .3rem;
    margin-left: -1.25rem;
}
/* forms */
*{ box-sizing: border-box}
.my-metro-student-registration-form-container {
    padding: 10px;
    width: 100%;
}
/* inputs only */
.my-metro-form .my-metro-inputs{
    display: inline-block;
    min-height: 50px;
    width: 100%;
    font-size: 14px;
    line-height: 1.8;
    padding: 6px 12px;
    vertical-align: middle;
    background-color: transparent;
    color: #333;
    border: 1px solid #ddd;
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    -ms-border-radius: 3px;
    border-radius: 3px;
    -webkit-transition: all 0.3s ease;
    -moz-transition: all 0.3s ease;
    -ms-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    transition: all 0.3s ease;
}

.my-metro-form .my-metro-input-padding{
    padding: 18px 15px 18px 15px;
}

.my-metro-form .my-metro-input-border{
    border-color: #eeeeee;
}

.my-metro-form .my-metro-inputs:focus{
    border-color: #84c340;
    outline: 0;
    box-shadow: none;
}

.my-metro-form .my-metro-input-number{
    max-width: 100%;
}

    /* inputs warnings and border colors */
.my-input-success{
    border: 1px solid #12c512 !important;
}
.my-input-danger{
    border: 1px solid #f52828 !important;
}

/* inputs buttons */
.my-metro-form .my-metro-input-btn{
    display: inline-block;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    margin: 0;
    cursor: pointer;
    text-align: center;
    letter-spacing: 0.1em;
    line-height: 1;
    -webkit-transition: all 0.3s ease;
    -moz-transition: all 0.3s ease;
    -ms-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    transition: all 0.3s ease;
}

.my-metro-form .my-metro-btn-success{
    background: #84c340;
    color: white;
}

.my-metro-form .my-metro-btn-padding{
   padding: 18px 15px 18px 15px;
}

.my-metro-form .my-metro-btn-full-width{
    width: 100%;
    height: 45px;
}
.my-metro-form .my-metro-input-btn:hover{
    background-color: #6aa32d;
    color: white;
}

/* notice */
.my-metro-notice-container {
    width: 100%;
}

.my-metro-notice {
    width: 500px;
    border: 1px solid #ccc;
    padding: 6px 0px 6px 20px;
    box-sizing: border-box;
    margin: 5px auto;
    vertical-align: middle;
    font-family: "Muli";
    font-weight: bold;
    color: inherit;
}

.my-metro-notice-warning {
    border-left: 4px solid #fb1922;
    color: black;
    background: whitesmoke;
}

.my-metro-notice-align-left {
    text-align: left;
}

     Password*
     <input type="password" id="password" name="password" class="form-control my-metro-inputs my-metro-input-border my-metro-input-padding" placeholder="password" value="" required onfocusout="passwordChecker(this)">

 var inValid = /\s/;
 var value = " ur value with spaces like this " or " ";

  if((inValid.test(value))){
      console.log("white space");
  }else if((!inValid.test(value))){
      console.log("no space");
  }

/* in this code the invalid variable hold rg = regular expression like
    / \s /

    the \s = whitespace
    and more are discussed in link:
    http://www.javascripter.net/faq/regularexpressionsyntax.htm */


text:
Q: HTML pattern attribute not working when checked in database Hi everybody i have a form in index.html. Following are two code snippets, please have a look and help me sort out the issue mentioned at the end of this question . Thank you
<form method="post" action="subscribe.php" class="contactform center-block">

            <input
                   name="fullName"
                   type="text"
                   class="form-control"
                   pattern="[a-zA-Z][a-zA-Z ]{2,}"
                   id="userName"
                   placeholder="Enter your Full Name here"
                   required
            >

                <input
                     type="submit"
                     name="submit"
                     id="submit1"
                     value="Subscibe!"
                     class="submitBtn btn btn-primary ">

    </form>

and here is subscribe.php
<?php

 if(!empty($_POST)) {

$mysqli = new mysqli(
    'localhost',
    'username',
    'password',
    'dbname'
);

$admin = 'example@hello.com';
$useremail = $_POST['email'];
$subject = "My Subject";
$username = $_POST['fullName'];
$email = $_POST['email'];
$header = 'From ' . $email;

$message = <<<EMAIL

  message body.....

EMAIL;

// Check for connection
if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
}

//Insert our data

$sql = "INSERT INTO subscribe(fullName,email)VALUES(

'{$mysqli->real_escape_string($_POST['fullName'])}',
'{$mysqli->real_escape_string(($_POST['email']))}' )";

// Print Response from MySql

if (mysqli_query($mysqli, $sql)) {

    if(mail( $admin , $subject , $message, $header)){
    header('Location: http://www.example.com/');

    }

 } else {

    die("Error: {$mysqli->errno} : {$mysqli->error}");
 }

 // Close the connection

 $mysqli->close();

 }

 ?>

Issue
MySql Database is connected and working properly, data is inserted but the problem lies when i look at subscribe table in DB and fullName column still contains row having value like this 59c29dc55ff88 even i have mentioned the pattern in input tag in html form above . It works correctly in web page but when i look in DB the value is shown in the format i have mentioned. I am worried how someone can insert this type of data in name input when pattern attribute is mentioned already .
Please guide me . Thanks for your help


text:
Q: How to avoid "act" warnings in a integration tests with React Testing Library I am rendering the  component in an integration test of my single page app and attempting to follow a happy path from landing on a page to the first question of a quiz / memory game.
Warning: An update to GamePlay inside a test was not wrapped in act(...).

The second line is the one that triggers multiple warnings...
    const firstItem = getAllByRole("listitem")[0]
    userEvent.click(firstItem)

It clicks the first option in a list which causes the gameplay component to render. That component shows a word for 5000ms then hides it using a setTimeout which is set in the component's useEffect hook (below). An answer input field is also disabled and enabled in this routine.
    function hideQuestion() {
        setInputDisabled(false)
        setDisplayWord(false)
    }

    const [displayWord, setDisplayWord]= useState(true);

    useEffect(()=>{
        setTimeout(hideQuestion, 5000)
    },[displayWord])

    const [inputDisabled, setInputDisabled] = useState(true);

From reading around I think it might be this use of setTimeout that's responsible but none of the mitigations I have tried have done anything. I tried wrapping the click line in an "act" function and that did nothing. I tried making the test async and awaiting that line but again that did nothing - I still get this error (and several similar)...
  console.error
    Warning: An update to GamePlay inside a test was not wrapped in act(...).

    When testing, code that causes React state updates should be wrapped into act(...):

    act(() => {
      /* fire events that update state */
    });
    /* assert on the output */

    This ensures that you're testing the behavior the user would see in the browser. Learn more at https://reactjs.org/link/wrap-tests-with-act
        at GamePlay (/home/user/code/spellingapp/src/components/GamePlay.js:3:20)
        at MainPage (/home/user/code/spellingapp/src/components/MainPage.js:8:29)
        at Route (/home/user/code/spellingapp/node_modules/react-router/cjs/react-router.js:470:29)
        at Switch (/home/user/code/spellingapp/node_modules/react-router/cjs/react-router.js:676:29)
        at Router (/home/user/code/spellingapp/node_modules/react-router/cjs/react-router.js:99:30)
        at BrowserRouter (/home/user/code/spellingapp/node_modules/react-router-dom/cjs/react-router-dom.js:67:35)
        at App (/home/user/code/spellingapp/src/App.js:16:29)

       5 |   function hideQuestion() {
       6 |     // console.log("I have hidden the word and enabled the text box")
    >  7 |     setInputDisabled(false)

I tried reading this article: https://kentcdodds.com/blog/fix-the-not-wrapped-in-act-warning
But I'm struggling to understand it fully and relate it to my own code. I think the gist of it is that you will get these warning when there are "unexpected" state changes but I can't see how I'm supposed to make mine expected. My app is a real time game so the whole thing runs off timers - one timer finishes and another one starts. I don't want to have to run through a full 10 minutes of gameplay so it can finish neatly. I just want to test from landing page to the first interaction as a smoke test of the core integration logic.
Right now all I can think of is to make a test fixture with only one question so I can run the whole game end to end, but this seems like overkill when my current test runs fine (apart from the warnings) and does all I want it to do right now. I'd appreciate any pointers or suggestions, even if it's that I'm just barking up the wrong tree. Thanks!

A: Here are several things you can do:

*

*The warning tells you that your app continues after your test completed, and thus other things happen during the run that you didn't check in your test and didn't wait for. So if you're happy with what you are testing, be warned and keep it like that.

*You can make your app a bit more testable by giving it options. For example you can have an optional prop indicating the amount of time to wait in timers, so that you can put it to 0 or a small number in your tests.

*You can mock timers:

beforeEach(jest.useFakeTimers);
afterEach(jest.useRealTimers);

test("your game", async () => {
  const { getAllByRole } = render(<Game />);
  // [...]
  const firstItem = getAllByRole("listitem")[0]
  userEvent.click(firstItem)
  act(() => jest.advanceTimersByTime(5000));
  // [...]
  act(() => jest.advanceTimersByTime(5000));
  // [...]
});


text:
Q: combine numpy array "element-wise" Currently I have two arrays: the shape of a1 is (5,4,6,3), the second one a2 is (5,4,6) and finally I want to get a merged array (5,4,6,4)
Currently I "for-loop" each (6,3) array and np.stack it with corresponding (6,1) to (6,4).
for i in range(a1.shape[0]):
    for j in range(a1.shape[1]):
        a = np.hstack((a1[i,j], a2[i,j].reshape(6,1)))

However, it's not pretty efficient if it's much bigger than 5*4.
Do you have a better way?

A: Is this what you want?
import numpy as np

a1 = np.ones((5, 4, 6, 3))
a2 = np.ones((5, 4, 6))

result = np.concatenate((a1, a2[..., np.newaxis]), axis=-1)

print(result.shape)

(5, 4, 6, 4)


text:
Q: Will my Rails model and controller names collide with Rails' reserved words? I'm about to create a new Rails 6 application with the model / table names Requests and Routes and the controller names RequestsController and RoutesController.
Will these work in a Rails 6 application?
When I run rails generate model Request everything looks normal. Rails doesn't complain.
But according to this list Request is a reserved word in Rails.
So will this work or will this get me into trouble? I would like to know before because renaming models in Rails can be cumbersome.

A: You will run into problems. Eg if you create a table named length it will cause problems so it's almost certain words on the reserved list will also.
Not a lot to gain with a lot to lose. Sometimes they will only cause issues when trying to scale an application eg have more than once instance of an app running.

A: It turns out I did not run into any problems with my approach. I was able to name my models Request and Route and didn't get any errors so far. I also have a RequestsController and a RoutesController.


text:
Q: Is it natural to say "tuck in the flaps of the medicine box to close it"?
Medicine or pills are often stored in boxes like the above picture.
Is the above box called "a pill box" or "medicine box"?
And to close the box, we have to fold its flaps in a certain way.
Is it natural to say "tuck in the flaps of the medicine box to close it"?

A: This is what many older people will think of as a pillbox. Note the shape.


text:
Q: How to add custom email headers in Google App Engine Mail API I need help on how to add several custom email headers when sending email using GAE's Mail API (Python) i.e. Message-id, person-id and etc.
But somehow, I don't see it in the documentation: https://cloud.google.com/appengine/docs/standard/python/refdocs/google.appengine.api.mail
I can receive emails and read custom email headers using the method below:
mail_message.original.getitem('mail_header')
But I don't know how to send an email with custom email headers.
Here is the code i use to send email:
mail.send_mail(sender=sender_address,
               to="handsome_me@yahoo.com",
               subject="gwapo",
               body="Hi")

A: Looks like you missed this line in the docs:

PROPERTIES = set(['body', 'amp_html', 'sender', 'to', 'cc', 'bcc', 'attachments', 'headers', 'html', 'reply_to', 'subject'])

You can provide a headers parameter containing a list of custom headers.
Looking at the sources, the headers paramenter is subject to the following restrictions:

*

*must be a dict

*all values must be strings

*all keys must be ASCII

*key should be in the following white list: Auto-Submitted, In-Reply-To, List-Id, List-Unsubscribe, On-Behalf-Of, References, Resent-Date, Resent-From, Resent-To.

I'm afraid you won't be able to override message-id using AppEngine as it is not in the HEADERS_WHITELIST. I forgot how crippled AppEngine is, you may want to check third-party email services. I've used mailgun and they allow arbitrary headers as long as they are prefixed by X- (just include a h:X-My-Arbitrary-Header in the payload). From the AppEngine docs:

Sending Messages with Third-Party Services
Python 2.7/3.7 |Java 8/11 |PHP 5/7 |Ruby |Go 1.9/1.11/1.12 |Node.js
  Python 3.7 applications on App Engine can use third-party companies to send email, SMS messages, or make and receive phone calls. For example, you might send email to confirm business transactions, confirm the creation of user accounts, or send marketing communications.
This page lists some examples of companies that provide communication services and client libraries for Python 3.7 applications on App Engine.
Note: The services offered by these third-party companies are not covered by the App Engine Service Level Agreement.
Mailgun
Mailgun provides both RESTful APIs and client libraries for sending email. As a GCP project user, your first 30,000 messages are free every month. See the monthly pricing calculator on the sign up page for pricing on additional messages and volume discounts.
Learn more about Mailgun:

*

*Mailgun developer documentation

*Mailgun client libraries
...
SendGrid
You can use SendGrid to power your emails on App Engine. SendGrid can improve your deliverability and provide transparency into what actually happens to those emails your app sends. You can see statistics on opens, clicks, unsubscribes, spam reports and more with the SendGrid interface or its API.
App Engine customers can send 12,000 emails every month for free by signing up for the SendGrid Email API plan through the Google Cloud Platform Console. Note that Google is compensated for customers who sign up for a paid account.
Learn more about SendGrid:

*

*SendGrid developer documentation

*SendGrid client libraries

I'm not affiliated with any of those and the original page mentions other services, I'm quoting mailgun because I've used it and know it works, and sendgrid because it is mentioned by OP.

A: Im working on devselz.com a service which allows unlimited emails to be sent / month. It uses a P2P with private servers, where on users can use their own servers (by installing a compatct SMTP provided by devselz.)
Here are the docs: https://devselz.com/support/


text:
Q: How to access parameters in an ngrx effect in Angular 2? I have a http service call that requires two parameters when dispatched:
@Injectable()
export class InvoiceService {
  . . .

  getInvoice(invoiceNumber: string, zipCode: string): Observable<Invoice> {
    . . .
  }
}

How do I subsequently pass those two parameters to this.invoiceService.getInvoice() in my Effect?
@Injectable()
export class InvoiceEffects {
  @Effect()
  getInvoice = this.actions
    .ofType(InvoiceActions.GET_INVOICE)
    .switchMap(() => this.invoiceService.getInvoice())  // need params here
    .map(invoice => {
      return this.invoiceActions.getInvoiceResult(invoice);
    })
}

A: In @ngrx/effects v5.0 the utility function toPayload was removed, it has been deprecated since @ngrx/effects v4.0.
For Details see: https://github.com/ngrx/platform/commit/b390ef5
Now (since v5.0):

actions$.
  .ofType('SOME_ACTION')
  .map((action: SomeActionWithPayload) => action.payload)

Example:

@Effect({dispatch: false})
printPayloadEffect$ = this.action$
    .ofType(fromActions.DEMO_ACTION)
    .map((action: fromActions.DemoAction) => action.payload)
    .pipe(
        tap((payload) => console.log(payload))
    );

Before:

import { toPayload } from '@ngrx/effects';

actions$.
  ofType('SOME_ACTION').
  map(toPayload);

A: You can access the payload within the action:
@Injectable()
export class InvoiceEffects {
  @Effect()
  getInvoice = this.actions
    .ofType(InvoiceActions.GET_INVOICE)
    .switchMap((action) => this.invoiceService.getInvoice(
      action.payload.invoiceNumber,
      action.payload.zipCode
    ))
    .map(invoice => this.invoiceActions.getInvoiceResult(invoice))
}

Or you can use the toPayload function from ngrx/effects to map the action's payload:
import { Actions, Effect, toPayload } from "@ngrx/effects";

@Injectable()
export class InvoiceEffects {
  @Effect()
  getInvoice = this.actions
    .ofType(InvoiceActions.GET_INVOICE)
    .map(toPayload)
    .switchMap((payload) => this.invoiceService.getInvoice(
      payload.invoiceNumber,
      payload.zipCode
    ))
    .map(invoice => this.invoiceActions.getInvoiceResult(invoice))
}