Module in Google Colab not updating after change - module

I changed the method in a module, say util.py saved in google drive from
def return_no(num1,num2):
return num1*num2
to
def return_no(num1,num2):
return num1+num2
But calling the method from google colab is returning the multiplication of the two number, even though I have changed it to summation.
Any suggestion on how to solve this problem?

It takes some time to reflect on changes made to your module.
Restart your runtime and try, it should reflect.
runtime -> restart runtimes or Ctrl+M

Related

Google Cloud "could not create Compute Engine instance without a base image" for TPU Instance

I tries to create a TPU instance with:
ctpu up --tf-version=1.15 --name=test --tpu-size=v2-8 --preemptible
But it says "could not create Compute Engine instance without a base image".
It was working 1 month ago, but it is not now.
Could anybody tell me what happened?
For future reference posting zcain#'s response here:
Hello, sorry for the inconvenience.
As of this week, all versions <= TF-1.15.2 are deprecated.
Could you try --tf-version=1.15.4 or --tf-version=1.15.5
1.15.3 is technically possible too but I wouldn't recommend it as that is also going to be deprecated soon.
this page lists some versions if you ever run into this again

Prestashop : Declaration of AdminLoginControllerCore::viewAccess() must be compatible with AdminControllerCore:

I was using prestashop on hosting with no problem.
Now I started my home web server and I'm trying to get it working.
I tried many different prestashop versions and reinstalled them x times..
All the time problem is that, I can Access front panel, but not the backend panel..
All the time it shows Http 500 ERROR : Server can't Handle this request.
Now I enabled debugging and it shows me error:
Fatal error: Declaration of AdminLoginControllerCore::viewAccess() must be compatible with AdminControllerCore::viewAccess($disable = false) in C:\xampp\htdocs\Shop\controllers\admin\AdminLoginController.php on line 27
And Line
class AdminLoginControllerCore extends AdminController{
I can't understand why this is happening, becouse I haven't edited and changed any file or folder.
It happens because you have to implement a method in a child class with all parameters of a parent class method. So in your parent class viewAccess has a parameter $disable=false and you need to have it in your child viewAccess() declaration. Just put that parameter in the declaration public function viewAccess($disable=false) and you even need not use it inside. And why it was not showing on the hosting but show in a local machine it is sooner in due to different PHP versions on the servers. Because in different versions it has different error levels.
The way to fix this is simple:
go to ROOT/controllers\admin\AdminLoginController.php
al line 153 you’ll have to change
public function viewAccess() to public function viewAccess($disable = false).
I had that issue with a fresh installation of PS 1.7 yesterday but did'nt come out of it. Today, apparently the same one with PS 1.6.18, thought I was expecting it would'nt, but it seems that PS can't stand PHP 7.2.4, no matter which PS version it is (of course I should have guessed that a previous version would'nt make it better than a recent one ...). Some PHP warnings might have turned into fatal errors now. The fact is, when I went into controllers/admin/adminLoginController on line 153 and typed public function viewAccess($disable = false) instead of public function viewAccess() the blank screen went away and my back-office was there (with some remaining warnings ...). Those files would'nt have to be overwritten to allow upgrade, but anyway 1.6.18 is the last upgrade of 1.6 series... Hope it can help.

Run code when user deletes module from a page

I'm currently developing a DNN module. It would be nice if we were able to run custom code whenever a module is deleted from a page by the user, and also when a module gets restored from recycle bin.
I haven't found any examples on how this could be done, so I'm not sure if this is possible? Any ideas?
I am unaware of any event mechanism inside DNN where you could set your hooks. You could probably debug the DNN code and trace the call stack until you find a usable spot where you can inject some code (which would likely be destroyed after the next DNN update), or maybe detect a way that was intended to be used by the core team.
However, if a module is deleted from a page, the IsDeleted field in the Modules table is set to true. If it gets restored from the bin, it is again set to false.
You can use a TRIGGER in your Sql Server that fires when the Modules table is updated, checks if the update refers to an IsDeleted field, write stuff into a Notification table, and use Sql Query Notification based on SqlDependency to run some code (see http://www.codeproject.com/Articles/144344/Query-Notification-using-SqlDependency-and-SqlCach for an introduction).
Some steps to go, but it should work (and be less exhausting than climbing the Matterhorn :-) ).
There is absolutely hooks in DNN Platform (DotNetNuke) that a developer can attached C# code to.
While there isn't a turn key example that I can provide at the moment, check out the following:
https://github.com/dnnsoftware/Dnn.Platform/blob/c35fdc7fb75db0438f3b872ce4e279e3ea73e7c2/DNN%20Platform/Library/Entities/EventManager.cs
You are looking to hook onto the ModuleRemoved event by the sounds of it.
Here is an example for the user logging in that you could adapt to your event:
Does DNN fire an event when a user logs in?
I hope this helps in the future.

vb.net 2010 - reading from registry doesn't work - win 7

I thought this would be dead simple however....
Right, so all I'm simply trying to do is read a value from my registry. I have been through several examples but can't get any of them to work. I've also tried running my application in Admin mode and still nothing. Can someone please help?
From all my examples that I've tried, I'll use the simplest one.
This works:
Dim val As String
val = Registry.LocalMachine.OpenSubKey("Hardware\Description\System\CentralProcessor\0").GetValue("Identifier").ToString()
MsgBox(val)
This (the one I want) doesn't:
Dim val As String
val = Registry.LocalMachine.OpenSubKey("SOFTWARE\PTSClient").GetValue("ConfigDB").ToString()
MsgBox(val)
THe latter path and value is one that I've manually created in the registry. I've checked the permissions between the two and they are the exact same. I've also tried running the app as administrator. I get a runtime error on the val= line, it says: Use the "new" keyword to create an object instance.
Any ideas? All the various online examples have failed and for the life of me, I can't figure out why...
Cheers,
J
Well, I have tried your code with a sample application compiled for x86 and, as expected, it fails with a null value exception.
I assume you are building an application for x86 mode and running in a 64bit environment.
Of course, if this is not the case, let me know and I will delete this answer.
In the situation outlined above, the calls to read/write in the LocalMachine.Software registry path will be automatically changed by the Operating System to read/write in the Software\Wow6432Node subkey and thus, your code is unable to find your manually inserted key ("SOFTWARE\PTSClient").
This code will give a null value as return from Registry.LocalMachine.OpenSubKey("SOFTWARE\PTSClient") leading to the failure to get the ConfigDB value.
You need to add your keys/values to the Software\Wow6432Node path or compile your application for AnyCPU mode or let your code write the value to the register (it will be redirected to the Wow6432Node).

IAT/EAT hooking "gethostbyname"

I wrote this code to hook API functions by changing the address in the IAT and EAT: http://pastebin.com/7d9N1J2c
This works just fine when I want to hook "recv" or "connect". However for some unknown reason when trying to hook "gethostbyname", my hook function is never called.
I tried to find "gethostbyname" in a debugger by taking the base address of the wsock32.dll module + 0x375e, which is what the ordinal 52 of my wsock32.dll is showing as offset. But that just makes me end up in some random asm code, not at the beginning of a function.
The same method however works fine for trying to find the "recv" entry point.
Does anyone see what I might be doing wrong?
I recommend this tool:
http://www.moduleanalyzer.com/
They do exactly the same and show the url that was connected with that API.
The problem is that there are more than one API to translate an url to an address. The application you are hooking may be using another version of the API that you're not intercepting.
Run some disassembler like IDA and attach to your process after you hook this functions, ida get apply changes on attaching and play process and check what is wrong.
In other way you have many libraries to do hooks with trampolines like Microsoft Detours, NCodeHook etc.