router – New gateway results in Google and Amazon security lockout, “device not recognized”

The cable company recently replaced my old gateway/wireless router. After the new gateway was installed (a “Touchstone TG1682G Telephony Gateway”, if it matters), both Google and Amazon required additional verification before I could log in to my accounts on their websites. Google gave me a message that my device was unknown or could not be verified and required that I either provide a backup email or phone to receive a confirmation code before proceeding. Amazon required me to enter an emailed code. AOL didn’t seem to notice or care.

But my actual device that I was using to connect to these websites has not changed. It is the same computer I have always used. My IP address probably changed with the new gateway, but the cable company has always assigned new IP addresses several times per year and it has never triggered a security lockout by Google or Amazon. Previously I would get the occasional e-mail notification that a sign-in was made on a new device (either “Linux” or “Windows” depending on which OS I was using), but nothing was ever triggered by getting a new IP.

Based on my understanding of a similar question asked on Quora it would be highly irregular if my router hardware were known to websites.

What about the installation of a new gateway could trigger account lockout protocols for Google and Amazon? Does anyone know what might be going on here?

functions – Prevent A Specific Custom Post Type Showing In WP Search Results Page

I’ve excluded certain pages from the WP Search with the code below in my functions.php file.

I also need to exclude a custom post type called ‘sites’.

I can’t seem to find the custom post type equivalent of the post__not_in argument ?

I don’t want to remove it in the custom post type code itself under public => false because I still want it to have its own url etc.

Does anyone know how to remove a specific custom post type from showing up in WP Search?

Any help would be wonderful !

// EXCLUDE CERTAIN PAGES FROM SEARCH RESULTS (PAGE IDs IN ARRAY)

function tp_remove_pages( $query ) {
  if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) {
    $query->set( 'post__not_in', array( 11,84,118,115,123,132 ) );
  }
}
add_action( 'pre_get_posts', 'tp_remove_pages' );

How to add position to products in product listing comes from search results in magento 1?

Hope you are doing good.

You can do it by following the below steps:

  1. Click on a category in the category tree to display the category related information.
  2. Then, click on “Category Products” tab that will display the category products grid.
  3. In the last column of product grid set/update the product position.
  4. If you see no product listed in the “Category Products” tab, it means that the category has no products assigned to it. So click the “Reset Filter” button to list all products, now select the products first and then in the last column of the product grid set the product position.
  5. Last, save the category.

Besides, The product position is a global attribute and there is a table with the relation between category id and product ids and also the position for that product in that category. The table is: catalog_category_product.

I hope that works for you.

Last you can also check for Magento DevDoc but its for version 2.

How can I hide a document library from search results without disabling search within the document library?

I have some document libraries that I wish to use for file archival purposes for older files that don’t need to be accessed on a daily basis, but still need to be kept for posterity. Because these files don’t need to be regularly accessed, I’d like to hide them from showing up in searches across the whole site collection, so that they don’t clog up the search.

I found a setting to disable the items in the document library from showing up in search results in the advanced settings for the document library: enter image description here

However, setting this option to “no” also disables search from working within the document library after a couple of moments. This makes it impossible to find files within search disabled document libraries when the need arises.

Is there any means of hiding the contents of a document library from a site collection wide search while still having search available within the document library?

programming languages – Suitable way to round results returned by any function of a class

Assume there is a abstract class Shape. The class has two functions area() and perimeter().

Let’s say Circle and Square inherit from Shape and override these methods. Obviously the results are going to be fractional.

What is the best way to set a precision value for the results. Say the user says PRECISION=2 or PRECISION=3 and the results returned by the functions of Circle and Square class are returned accordingly. Where should I define this functionality? I was wondering how do libraries like numpy handle this situation.

One approach can be to add an optional parameter to these functions and round the results accordingly.

getArea(radius, prec=2) {

}
```

c# – Best practice when handling conditions and results within classes?

The method below needs to perform a set of operations in order to achieve a result. Neither the operations nor the result are relevant to the question. As you can see some smaller simpler operations have been split out into smaller private methods. I have left out the params and details for simplicity.

In my opinion the method is too big and would seem prone to bugs, however on the other hand I think its fairly clean and neat considering these operations must happen and the user needs to know if something hasn’t worked out. Its also my opinion that its fairly readable but i feel like i might be missing something.

Is there a better, more SOLID approach to handling this, or is this about as clean as it gets?

This class itself does nothing except coordinate a few services as shown below and return some feedback.
For a moment I considered the class may be ‘doing’ too much, but I am unable to see how splitting this further will result in cleaner code. in the end there is still going to be a class that needs to coordinate everything.

public Result AddSomething()
{
     var data = await _repo.Get<Data>();

     if (data.PropertyA) 
         return new Result().Fail("Fail message");  //1

     if (ConditionA(data ) && data.PropertyB) 
         return new Result().Fail("Another fail message");    //2

     SomeClass someClass = CreateSomeClass();

     SetPropsOnSomeClass(someClass);

     var resultOne= _serviceA.Execute(someClass);

     if (resultOne.IsOk == false)
         return new Result().Fail(resultOne.Message);   //3

     var resultTwo = _serviceB.Execute(someClass);

     if (resultTwo .IsOk == false)
         return new Result().Fail(resultTwo .Message);    //4

     SetMoreProps(someClass);

     SetMorePropsTwo(someClass, data);

     await CompressAndSave(someClass, data);

     data.PropertyC.Add(someClass);

     await _repo.CreateOrUpdate(data);

     await _repo.SaveChangesAsync();

     await _eventService.LogEvent(o => //some info taken from data);   

    return new Result().Ok("It all worked out");   //5
}

private SomeClass CreateSomeClass()()
{
    //
}

private void SetPropsOnSomeClass(//)
{
    //
}

private void SetMoreProps(//)
{
    //
}

private void SetMorePropsTwo(//)
{
    //
}

private async Task CompressAndSave(//)
{
    await _serviceC.Add(//);
    await _serviceC.Compress(//);
    await _serviceC.Save(//);
}

And an over simplified version of the Result class:

public class Result
{
    public bool IsOk {get; private set;}
    public string Message {get; private set;}

    public Result Ok()
    {
        IsOk = true;
    }

    public Result Fail(string message)
    {
        IsOk = false;
        Message = message;
    }

}

Question

Is there a cleaner, more SOLID approach to handling these situations?

I cannot seem to find a solution that sits well with me. Perhaps I am over thinking the problem or I simply lack the knowledge to implement a more ‘correct’ and clean approach.

PS. I understand ‘correct’ is subjective but I am looking to improve my code in as many possible ways provided it offers enough value to the next developer.

git "uncheckout" by 'reset –hard' does not produce expected results

I mistakenly created a remote branch, then did a checkout on it. So, if I do git branch --list I see:

* Team_Branch_01
MY-12345-own-branch 
master

I would like to delete ("uncheckout") MY-12345-own-branch, so that I remain with:

* Team_Branch_01
master

However, when I perform:

git reset --hard origin/MY-12345-own-branch
git branch --list

I am still getting:

* Team_Branch_01
MY-12345-own-branch 
master

Why?

What am I doing wrong?

javascript – react-select multi-select to show results outside the drop down

i’m building a simple multi-select option using react-select (windowed version), I have customised styling (DropDownIndicator component), maximised selection-option (Menu component) and used custom-filter. my current implementation includes:

  <WindowedSelect
    key={nilOrEmpty(drugsList)}
    styles={colourStyles}
    placeholder="Choose prescribed drugs"
    defaultValue={defaultValues}
    options={selected.length >= MAX_PRESCRIBED ? selected : drugsList}
    onChange={onChange}
    components={{ Menu, DropdownIndicator }}
    isValidNewOption={limitMaxSize}
    filterOption={customFilter}
    isMulti
  /> 

with state: const (selected, setSelected) and data drugsList, customerDrugs

with defaultValues which checks for values on selected,

with styling:

  multiValue: provided => ({
    ...provided,
    backgroundColor: null,
  }),
  multiValueLabel: provided => ({
    ...provided,
    color: colors.blue,
  }),
  placeholder: provided => ({
    ...provided,
    color: colors.blue,
    fontSize: fontSize(),
  }),

which yields simple react-select multi-value

enter image description here

simple

i’d like to have the multi-value chosen options outside the drop-down, something like that:

desired

I have tried to set hideSelectedOptions={true}, but this didn’t work. this could happen due to “defaultValues” which checks for current “Selected” state, but removing this will harm any refresh of user and having it-previous-chosen drugs.