why there’s a runtime error in my code?


Here is my code,it runs good for the example input , but when it comes to larger input, it keeps giving me runtime error (KeyError: -1 del queue[minKey] File “q2case2.py”, line 25, in getShortestPath )

import sys import math  def getShortestPath(numVertices,vertices,edges):     queue = {}     queue[0] = 0.0     distance = -1     while (bool(queue)):         min = 999.0         minKey = -1         for key in queue.keys():             if(queue[key] <  min):                 min = queue[key]                 minKey = key          if(minKey == numVertices-1):             distance = min             break;         del queue[minKey]           for v in edges[minKey].keys():             if (v not in queue):                 queue[v] = min + edges[minKey][v]             else:                 if(queue[v] > min + edges[minKey][v]):                     queue[v] = min + edges[minKey][v]     return(distance) inp = sys.stdin.readline().strip() while inp!= "":      inp = inp.split(',')      size = len(inp)     n = inp[0]     vertices = {}     numVertices = 0     for i in range(1,size):         if(i%2 == 1):             vertices[numVertices] = ( float(inp[i]) , float(inp[i+1]) )             numVertices += 1     edges = {}     for u in vertices.keys():         edges[u] = {}         for v in vertices.keys():             if( u != v):                 dist = (vertices[u][0]-vertices[v][0])*(vertices[u][0]-vertices[v][0]) + (vertices[u][1]-vertices[v][1])*(vertices[u][1]-vertices[v][1])                 if(dist <= 10000.0):                     dist = math.sqrt(dist)                     edges[u][v] = dist       distance = getShortestPath(numVertices,vertices,edges)     if(distance == -1):             print(-1)     else:         print('{0:.2f}'.format(distance))     inp = sys.stdin.readline().strip() 

How to tell an OpenLDAP server to index a new attribute when there’s no slapd.conf file present?

I’ve been given the task to enable OpenLDAP client users to use “sudo”.

In order to do that, I’ve expanded LDAP schema and added sudo functions such as sudoHost, sudoUser, etc… as shown in many guides over the internet.

Now I’d like to tell the openldap server to index the new attribute “sudoUser” but the configuration at hand is such that there’s no slapd.conf file and instead there’s a “cn=config” directory which holds the relevant db files including the one I intend to modify.

This file is generated when using ldapmodify command and cannot be manually modified.

The user which i’m using to log into the openldap phpmyadmin ui is called: cn=admin,dc=company,dc=com.

When I added the sudo schema to OpenLDAP, I’ve used the following command:

ldapadd -x -D "cn=admin,dc=company,dc=com" -W -H ldap:// -f sudo.ldif 

And supplied this user’s password.

Now, when I try to add that index to the OpenLDAP database, I need to bind to “cn=config” instead of that admin user but I don’t know this password and I get an error saying “Invalid credentials” when I run the following command:

ldapmodify -x -D "cn=config" -H ldap:///  -W 

I’ve also tried running:

ldapmodify -x -D "cn=admin,dc=company,dc=com" -H ldapi:/// -W 

and then pasting:

dn: olcDatabase={1}mdb changetype: modify add: olcDbIndex olcDbIndex: sudoUser eq 

also tried the above configuration with dn: cn=config,olcDatabase={1}mdb.

But then I get the following error:

modifying entry "olcDatabase={1}mdb" ldap_modify: Server is unwilling to perform (53)     additional info: no global superior knowledge 

What am I doing wrong and how can I add this index to the db file?

There’s no ntpd in centos 7, how to sync time automatically and manually with chrony?

Seems there’s no ntpd in centos7, how can I sync time in centos7?

I found out that chrony should be used in centos7, what is manual way to update time using chrony?

I assume chronyd is something equivalent to ntpd? and what’s the command equivalent to ntpdate -s time.nist.gov?

Fresh install of OS+Firefox and now there’s a persistent notification

I just reformatted and reinstalled things on my phone to fix some issues. I installed Firefox from apkmirror and now there’s a mostly persistent notification that shows up when I go to certain sites (The Guardian and AJC were two that it popped up on). There was a mention of a playback queue wen I was experimenting with closing the notification, so it seems video related.

I used Android 6’s notification manager to block all popups, which is the nuclear option. I can’t think of a reason why I’d want a notification from Firefox, but I could not find a way within Firefox to disable the notification.

What is this new anti-feature called, and how are you supposed to disable it within Firefox?

OctOS M (Android 6), Firefox firefox_67.0-2015628937_minAPI16(armeabi-v7a)(nodpi)

I accidentally deleted basic_cart_vat, there’s a way to a restore this field?

I accidentally deleted the field basic_cart_vat from Orders, now I’m receiving a error because I don’t have the field.

InvalidArgumentException: Field basic_cart_vat is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 586 of /home/sgpam/www/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php). 
  • How can I fix this?

Xiaomi Redmi Note 5 cannot connect to LG FH2 speaker since there’s a Bluetooth profile incompatibility

I have found that my LG FH2 speaker uses the A2DP profile protocol: http://gscs-b2c.lge.com/downloadFile?fileId=gQHBfK7s0ZXFVKL7CatPeA

…whereas my Android phone is unable to get connected to it, since it has a different profile AVRCP: https://source.android.com/devices/bluetooth/services

Please note I am not trying to make my phone an audio sink, only audio gateway is totally fine for me.

¿How can I install, push, hack, or sideload via ADB such an A2DP Bluetooth profile so I can connect my mobile to my speaker?

Edit: it’s a Redmi Note 5 global version (model M1803E7SH Latin America)

Change the img tag there’s some error

I need to change this tag <img> to <amp-img>, I’ve been researching about this and I have this function for change the img tag.

function amptheme_image($  variables) {   // Remove RDF properties incompatible with AMP specification.   if (isset($  variables['attributes']['typeof'])) {     unset($  variables['attributes']['typeof']);   }    $  attributes = $  variables['attributes'];   $  attributes['src'] = file_create_url($  variables['path']);    foreach (array('width', 'height', 'alt', 'title') as $  key) {      if (isset($  variables[$  key])) {       if (empty($  attributes[$  key])) {         $  attributes[$  key] = $  variables[$  key];       }     }   }    return '<amp-img' . drupal_attributes($  attributes) . '></amp-img>'; } 

This function should change <img> to <amp-img> but it’s not working.

The img tag is not working

I think it’s maybe for the name of the function. My theme’s name is bartik, but the function example it’s amptheme_image.

I just did tried like this bartiktheme_image, also bartik_theme_image, but it’s the same error.

I also tried like this, theme_image, but boom error cause there’s another function with the same name.

Thanks for the answers and suggestions.