Accessing local packages within a go module (go 1.11)

Let me define this first modules are collections of packages. In Go 11, I use go modules like the following: If both packages are in the same project, you could just do the following: In go.mod: module github.com/userName/moduleName and inside your main.go import “github.com/userName/moduleName/platform” However, if they are separate modules, i.e different physical paths and … Read more

Angular – ui-router get previous state

I use resolve to save the current state data before moving to the new state: angular.module(‘MyModule’) .config([‘$stateProvider’, function ($stateProvider) { $stateProvider .state(‘mystate’, { templateUrl: ‘mytemplate.html’, controller: [“PreviousState”, function (PreviousState) { if (PreviousState.Name == “mystate”) { // … } }], resolve: { PreviousState: [“$state”, function ($state) { var currentStateData = { Name: $state.current.name, Params: angular.copy($state.params), URL: … Read more

Can an angular directive pass arguments to functions in expressions specified in the directive’s attributes?

If you declare your callback as mentioned by @lex82 like callback = “callback(item.id, arg2)” You can call the callback method in the directive scope with object map and it would do the binding correctly. Like scope.callback({arg2:”some value”}); without requiring for $parse. See my fiddle(console log) http://jsfiddle.net/k7czc/2/ Update: There is a small example of this in … Read more

Mocking a class: Mock() or patch()?

mock.patch is a very very different critter than mock.Mock. patch replaces the class with a mock object and lets you work with the mock instance. Take a look at this snippet: >>> class MyClass(object): … def __init__(self): … print ‘Created [email protected]{0}’.format(id(self)) … >>> def create_instance(): … return MyClass() … >>> x = create_instance() Created [email protected]Read more

Update React component every second

You need to use setInterval to trigger the change, but you also need to clear the timer when the component unmounts to prevent it leaving errors and leaking memory: componentDidMount() { this.interval = setInterval(() => this.setState({ time: Date.now() }), 1000); } componentWillUnmount() { clearInterval(this.interval); }

How to print to console when using Qt

If it is good enough to print to stderr, you can use the following streams originally intended for debugging: #include<QDebug> //qInfo is qt5.5+ only. qInfo() << “C++ Style Info Message”; qInfo( “C Style Info Message” ); qDebug() << “C++ Style Debug Message”; qDebug( “C Style Debug Message” ); qWarning() << “C++ Style Warning Message”; qWarning( … Read more

Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE] even if app appears to not be installed

I’ve seen this several times. Usually, it’s due to having a signed release version on my phone, then trying to deploy the debug version on top. It gets stuck in an invalid state where it’s not fully uninstalled. The solution that works for me is to open a command prompt and type: adb uninstall my.package.id … Read more