computer architecture – Cache Blocks Direct Mapping

If the main memory address has 18 bits (7 for tag,7 for line and 4 for word)
and each word is 8 bits.
I found that the main memory capacity is 256-KBytes, total cache lines is 128 line,
total cache words is 128*16(16 word per block/line) = 2048 words.
Then what will be the size of cache words?
I am very confusing on it. I can’t get the definition of cache words.
Can anyone tell me what is the cache words?
Thank you!

blocks – Placing a programatically created menu

I’m creating a menu programatically using this code

$this->menu = $this->entityTypeManager->getStorage('menu')->create(
    (
      'id' => $properties('id'),
      'label' => $properties('label'),
      'langcode' => $properties('language'),
      'status' => TRUE,
    )
  );
  // Save the menu.
  $this->menu->save();

When visiting the block ui I see the block is already created. It appears that I do not have responsibility for creating this block, although I don’t seem to be able to load the block straight after creation of the menu. I need to place this block in a specific region programatically. What would be the preferred method of doing this be?

bitcoin core – How Do I Fix This Error Without Loosing Stored Blocks On Pc?

Hello Bitcoin Enthusiasts

I opened my Bitcoin Core program today on my windows 7 pc via external hard disk (1 TB) and i found the following error:

MinGW Runtime Assertion
Assertion Failed!

Program: E:Blockchainbitcoin-qt.ex
File: chain.cpp, line 103

Expression: pindexWalk-> pprev

DEBUG LOG: pastebin.com/YNEuRAcv

Please how do i fix this error without loosing the blocks on my external hard disk which i have synchronized for months?

Looking forward to your answer. Thank you in advance

static blocks are not displaying in frontend

I moved the main server to localhost with subdomain , all the pages are working but static blocks are not displaying in frontend, where i have to change to display the static blocks in frontend

What router setting blocks Google Play Store?

I have 1 year old router Zyxel NBG6604. My Android Phone (Xiao Mi A2) can use WLAN for surfing etc but it cannot download any new apps from Google Play Store nor any update either. I connected my laptop to the router via Ethernet cable and created WLAN hotspot with the same result.

Then I got another router Zyxel VMG3625-T20A. With it my phone can use WLAN also for Google Play Store downloads and updates, both directly and when using laptop hotspot.

It clearly looks as though some router setting blocks Google Play Store with Zyxel NBG6604 but what that is? Both routers were factory-clean, the only thing I have done is to set up SSID and Key for WLAN.

physics – How to search through large numbers of discrete objects that interact with each other, like Minecraft blocks?

Imagine you had a world like Minecraft, but wanted to bake in some sort of physics (okay, I was playing minetest actually).

For example, blocks under too much pressure might break, limiting how many blocks can be stacked on top of one another. I see one approach to this:

  1. Systematically check each block. See if there is a block on top of that, a block on top of that, ect. Then, determine the pressure on the block that you just started with. Do this for each and every block.

I also imagine you could somehow check each block, then have it modify the properties of the blocks around it. If all force was from top to bottom, you could just start at the top. But if you want to have a “net force” (so unsupported blocks accelerate) I have no idea how this could be implemented. For instance, three blocks are floating in mid air.

How can I solve this class of problem?

advanced custom fields – Can blocks be used as a conditional statement on a theme?

I’m new at using the block editor and need help. I have ACF Pro and need help. I create a block that has radio buttons called article_type that has four options: post, gallery, image, audio and video.

Can blocks be used as conditional statement on a theme?

So, for example, can I use that block to show or hide additional items based on what’s selected? I tried to do <?php if( get_field('article_type') == 'post' ) { } <?php endif;?> on my index.php and it doesn’t work.

This is what I have in my functions.php file:

function register_acf_block_types() {
// register a testimonial block.
acf_register_block_type(array(
    'name'              => 'settings',
    'title'             => __('OPBY settings'),
    'description'       => __('Settings for a post'),
    'category'          => 'formatting',
    'mode'              => 'edit',
    'icon'              => 'admin-comments',
    'keywords'          => array( 'opby', 'openbayou', 'settings' ),
));
}
// Check if function exists and hook into setup.
if( function_exists('acf_register_block_type') ) {
    add_action('acf/init', 'register_acf_block_types');
};
function be_post_block_template() {
   $post_type_object = get_post_type_object( 'post' );
   $post_type_object->template = array(
      array( 'core/paragraph' ),
      array( 'acf/settings' ),
   );
}
add_action( 'init', 'be_post_block_template' );

python – Nested try/catch blocks

I have recently encountered the classical problem of nested try/catch blocks in Python:

def enum_value(enum_cls: enum.Enum, member_or_name_or_value):
  """
  :param enum_cls: enum class for which to obtain value of a member
  :param member_or_name_or_value:
    if this argument is either:
    - member of enum `enum_cls`, or
    - the name of a member of `enum_cls`, or
    - the numeric index of a member of `enum_cls`
    then return that member;
    otherwise raise KeyError
  """
  if isinstance(member_or_name_or_value, enum_cls):
    return member_or_name_or_value

  try:
    return enum_cls(member_or_name_or_value)

  except KeyError:
    try:
      return next(
        member
        for member in enum_cls.__members__.values()
        if member.value == member_or_name_or_value
      )

    except StopIteration:
      msg = f'invalid member {member_or_name_or_value!r} for {enum_cls!r}'
      raise KeyError(msg) from None

And while not being particularly hard to follow, the code didn’t seem right. I could imagine this in a more complex case, a few levels of try/catch blocks deeper, and it would quickly become ugly.

So I tried to rewrite it into something more linear:

def enum_value(enum_cls: enum.Enum, member_or_name_or_value):
  if isinstance(member_or_name_or_value, enum_cls):
    return member_or_name_or_value

  try:
    return enum_cls(member_or_name_or_value)
  except KeyError:
    pass

  try:
    return next(
      member
      for member in enum_cls.__members__.values()
      if member.value == member_or_name_or_value
    )

  except StopIteration:
    pass

  msg = f'invalid member {member_or_name_or_value!r} for {enum_cls!r}'
  raise KeyError(msg) from None

Now I have several groups consisting of 4 lines of code; two of which are the same for all groups: try: and pass.

Since I’m not handling the exceptions in any way, I can just suppress them with contextlib.suppress:

def enum_value(enum_cls: enum.Enum, member_or_name_or_value):

  if isinstance(member_or_name_or_value, enum_cls):
    return member_or_name_or_value

  with contextlib.suppress(KeyError):
    return enum_cls(member_or_name_or_value)

  with contextlib.suppress(StopIteration):
    return next(
      member
      for member in enum_cls.__members__.values()
      if member.value == member_or_name_or_value
    )

  msg = f'invalid member {member_or_name_or_value!r} for {enum_cls!r}'
  raise KeyError(msg) from None

And this is fine by me. But note that it works only as long as I return directly from each with block, or otherwise keep the other with blocks from executing.


Now, what if I didn’t immediately return a value / break from a loop, etc? What if I wanted to simply do one of the with blocks, only the first one which succeeds, and then continue with the rest of the function?

def f(x, y):
  try:
    var = next(b for a, b in g1(x, y) if a)

  except StopIteration:
    try:
      for e in g2(x):
        cause_side_effects(e)
      var = e  # will cause NameError if g2(x) is empty

    except (NameError, Exception):
      raise ItsNotWorkingException() from None

  var2 = do_things(var, y)
  var3 = (x, y, *do_more_things(var, var2))
  return var3

I could introduce a variable to keep track of whether the previously executed block was successful, and only execute the next block if it wasn’t:

def f(x, y):

  success = False

  if not success:
    with contextlib.suppress(StopIteration):
      var = next(b for a, b in g1(x, y) if a)
      success = True

  if not success:
    with contextlib.suppress(NameError, Exception):
      for e in g2(x):
        cause_side_effects(e)
      var = e
      success True

  if not success:
    raise ItsNotWorkingException()

  var2 = do_things(var, y)
  var3 = (x, y, *do_more_things(var, var2))
  return var3

I see a lot of duplicity here. Moreover, what if I accidentally forget to assign success = True, or accidentally indent the assignment to the outer if instead of the with block? That little mistake could cause some big problems.

Another approach is to extract the nested blocks into helper functions, one function per try block, and have them tail-call the next helper upon exception:

def _f_helper(x, y):
  try:
    return next(b for a, b in g1(x, y) if a)
  except StopIteration:
    return _f_helper_2(x, y)

def _f_helper_2(x, y):
  try:
    for e in g2(x):
      cause_side_effects(e)
    return e  # will cause NameError if g2(x) is empty

  except (NameError, Exception):
    raise ItsNotWorkingException() from None

def f(x, y):
  var = _f_helper(x, y)

  var2 = do_things(var, y)
  var3 = (x, y, *do_more_things(var, var2))
  return var3

I like this approach even less than the previous. It bloats the namespace with helper functions specific to f, which probably couldn’t be reused elsewhere, and which were only created to cure a syntactic shortcoming of the language. Not the way I want to go…

We can also invert the control and put the rest of f into a separate function, called from the with blocks and immediately returned:

def f(x, y):
  with contextlib.suppress(StopIteration):
    var = next(b for a, b in g1(x, y) if a)
    return _f_rest(x, y, var)

  with contextlib.suppress(NameError, Exception):
    for e in g2(x):
      cause_side_effects(e)
    var = e

    return _f_rest(x, y, var)

  raise ItsNotWorkingException()

def _f_rest(x, y, var):
  var2 = do_things(var, y)
  var3 = (x, y, *do_more_things(var, var2))
  return var3

This looks good, but it won’t be that nice once there are many local variables that need to be passed around. But in that case, we can make _f_rest a nested function of f. That might be a bit of a hack, but I like this approach the most.

And finally, there’s the trick which I dubbed “emulated goto”. It looks like this:

def f(x, y):
  while True:
    with contextlib.suppress(StopIteration):
      var = next(b for a, b in g1(x, y) if a)
      break  # goto success

    with contextlib.suppress(NameError, Exception):
      for e in g2(x):
        cause_side_effects(e)
      var = e
      break  # goto success

    raise ItsNotWorkingException()

  # success:
  var2 = do_things(var, y)
  var3 = (x, y, *do_more_things(var, var2))
  return var3

  • Which way of dealing with nested exceptions do you find most readable or maintainable; which one would you use?
  • Is there another way around this problem, in Python or another similar language (eg. one which has exceptions)?
  • Which other languages deal with it better, and how? (This includes languages which don’t have exceptions.)
  • What are the respective shortcomings of the approaches (mine or other)?

python – Nested try/catch blocks

I have recently encountered the classical problem of nested try/catch blocks in Python:

def enum_value(enum_cls: enum.Enum, member_or_name_or_value):
  """
  :param enum_cls: enum class for which to obtain value of a member
  :param member_or_name_or_value:
    if this argument is either:
    - member of enum `enum_cls`, or
    - the name of a member of `enum_cls`, or
    - the numeric index of a member of `enum_cls`
    then return that member;
    otherwise raise KeyError
  """
  if isinstance(member_or_name_or_value, enum_cls):
    return member_or_name_or_value

  try:
    return enum_cls(member_or_name_or_value)

  except KeyError:
    try:
      return next(
        member
        for member in enum_cls.__members__.values()
        if member.value == member_or_name_or_value
      )

    except StopIteration:
      msg = f'invalid member {member_or_name_or_value!r} for {enum_cls!r}'
      raise KeyError(msg) from None

And while not being particularly hard to follow, the code didn’t seem right. I could imagine this in a more complex case, a few levels of try/catch blocks deeper, and it would quickly become ugly.

So I tried to rewrite it into something more linear:

def enum_value(enum_cls: enum.Enum, member_or_name_or_value):
  if isinstance(member_or_name_or_value, enum_cls):
    return member_or_name_or_value

  try:
    return enum_cls(member_or_name_or_value)
  except KeyError:
    pass

  try:
    return next(
      member
      for member in enum_cls.__members__.values()
      if member.value == member_or_name_or_value
    )

  except StopIteration:
    pass

  msg = f'invalid member {member_or_name_or_value!r} for {enum_cls!r}'
  raise KeyError(msg) from None

Now I have several groups consisting of 4 lines of code; two of which are the same for all groups: try: and pass.

Since I’m not handling the exceptions in any way, I can just suppress them with contextlib.suppress:

def enum_value(enum_cls: enum.Enum, member_or_name_or_value):

  if isinstance(member_or_name_or_value, enum_cls):
    return member_or_name_or_value

  with contextlib.suppress(KeyError):
    return enum_cls(member_or_name_or_value)

  with contextlib.suppress(StopIteration):
    return next(
      member
      for member in enum_cls.__members__.values()
      if member.value == member_or_name_or_value
    )

  msg = f'invalid member {member_or_name_or_value!r} for {enum_cls!r}'
  raise KeyError(msg) from None

And this is fine by me. But note that it works only as long as I return directly from each with block, or otherwise keep the other with blocks from executing.


Now, what if I didn’t immediately return a value / break from a loop, etc? What if I wanted to simply do one of the with blocks, only the first one which succeeds, and then continue with the rest of the function?

def f(x, y):
  try:
    var = next(b for a, b in g1(x, y) if a)

  except StopIteration:
    try:
      for e in g2(x):
        cause_side_effects(e)
      var = e  # will cause NameError if g2(x) is empty

    except (NameError, Exception):
      raise ItsNotWorkingException() from None

  var2 = do_things(var, y)
  var3 = (x, y, *do_more_things(var, var2))
  return var3

I could introduce a variable to keep track of whether the previously executed block was successful, and only execute the next block if it wasn’t:

def f(x, y):

  success = False

  if not success:
    with contextlib.suppress(StopIteration):
      var = next(b for a, b in g1(x, y) if a)
      success = True

  if not success:
    with contextlib.suppress(NameError, Exception):
      for e in g2(x):
        cause_side_effects(e)
      var = e
      success True

  if not success:
    raise ItsNotWorkingException()

  var2 = do_things(var, y)
  var3 = (x, y, *do_more_things(var, var2))
  return var3

I see a lot of duplicity here. Moreover, what if I accidentally forget to assign success = True, or accidentally indent the assignment to the outer if instead of the with block? That little mistake could cause some big problems.

Another approach is to extract the nested blocks into helper functions, one function per try block, and have them tail-call the next helper upon exception:

def _f_helper(x, y):
  try:
    return next(b for a, b in g1(x, y) if a)
  except StopIteration:
    return _f_helper_2(x, y)

def _f_helper_2(x, y):
  try:
    for e in g2(x):
      cause_side_effects(e)
    return e  # will cause NameError if g2(x) is empty

  except (NameError, Exception):
    raise ItsNotWorkingException() from None

def f(x, y):
  var = _f_helper(x, y)

  var2 = do_things(var, y)
  var3 = (x, y, *do_more_things(var, var2))
  return var3

I like this approach even less than the previous. It bloats the namespace with helper functions specific to f, which probably couldn’t be reused elsewhere, and which were only created to cure a syntactic shortcoming of the language. Not the way I want to go…

We can also invert the control and put the rest of f into a separate function, called from the with blocks and immediately returned:

def f(x, y):
  with contextlib.suppress(StopIteration):
    var = next(b for a, b in g1(x, y) if a)
    return _f_rest(x, y, var)

  with contextlib.suppress(NameError, Exception):
    for e in g2(x):
      cause_side_effects(e)
    var = e

    return _f_rest(x, y, var)

  raise ItsNotWorkingException()

def _f_rest(x, y, var):
  var2 = do_things(var, y)
  var3 = (x, y, *do_more_things(var, var2))
  return var3

This looks good, but it won’t be that nice once there are many local variables that need to be passed around. But in that case, we can make _f_rest a nested function of f. That might be a bit of a hack, but I like this approach the most.

And finally, there’s the trick which I dubbed “emulated goto”. It looks like this:

def f(x, y):
  while True:
    with contextlib.suppress(StopIteration):
      var = next(b for a, b in g1(x, y) if a)
      break  # goto success

    with contextlib.suppress(NameError, Exception):
      for e in g2(x):
        cause_side_effects(e)
      var = e
      break  # goto success

    raise ItsNotWorkingException()

  # success:
  var2 = do_things(var, y)
  var3 = (x, y, *do_more_things(var, var2))
  return var3

  • Which way of dealing with nested exceptions do you find most readable or maintainable; which one would you use?
  • Is there another way around this problem, in Python or another similar language (eg. one which has exceptions)?
  • Which other languages deal with it better, and how? (This includes languages which don’t have exceptions.)
  • What are the respective shortcomings of the approaches (mine or other)?

Leasing Residential IP blocks | Web Hosting Talk


There is only way you will achieve this, and that is to get the ips announced on their network plain and simple. You cannot just update some LOA block that you have acquired with some random foolishness in the iplocation or WHOIS. While there is many things that go into the secret sauce of residential ips, long story short, you need have a broadband service like DSL, or data circuit. You will then need ips from the carrier or know how to make yours look residential. If you are leasing ips and trying to make sure work, there are things you have to do for the GEO as well as keeping them looking like residential to pull all of this off and not get flagged. It is not a simple process.

Assuming you have done all of the steps required, will the achieve the desired results? Sure. But unless you are getting carrier ips on a data circuit, there are a number of steps involved to achieve this. Most people are not going to be investing in unclean ips on and data circuit term commitment contracts, hardware, and all that is needed in infrastructure on this gamble. After all, you need to make sure ips are CLEAN for your intended purpose if you are leasing beforehand. Otherwise, this whole process is a waste of time.

If you are a small fry (such as single /24), you are better off seeking out one of the handful of providers who offer this service.

https://www.webhostingtalk.com/