cc.LayerColor strange error (cocos2d-js) - cocos2d-js

I'm creating a LayerColor in cocos2d-js, from the documentation at http://www.cocos2d-x.org/reference/html5-js/V3.0rc0/index.html
I'm using the exact same code from the documentation
var yellowBackground = cc.LayerColor.create(cc.color(255,255,0,255));
And I get this strange error:
Uncaught TypeError: Cannot read property 'createBuffer' of null
_p.ctor CCLayerWebGL.js:59
Class CCClass.js:127
cc.LayerColor.create CCLayer.js:633
(anonymous function) app.js:1
Line 1 in app.js is the line I quoted.
Any ideas?

I am using this code and it works. u need to pass new to the cc.color().
var whiteBackground = cc.LayerColor.create(new cc.Color(255,255,255,255));
this.addChild(whiteBackground);

Related

NSUrl throws exception

In my Xamarin.iOS app, I have this code:
using (var url = new NSUrl(uri))
{
// some code
}
It was working before, but when I create the new NSUrl(uri) it throws an exception with the message:
Could not initialize an instance of the type 'Foundation.NSUrl': the
native 'initWithString:' method returned nil. It is possible to ignore
this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to
false.
My uri is something like this:
https://myappdev.blob.core.windows.net/myimages/apples/auth0|5db82ec6a5ee570c97cd5465.jpg?1666895662894
When I paste uri into my browser I get an image. (the url above is an example so you won't get an image if you try to download it)
I can reproduce your issue in Xamarin.ios and get the same error.
I noticed that a special character "|" in your url. Seems the error was due to this special character.
And after I changed "|" to "%" then the error disappeared.

Zapier Scripting - Error: Cannot find module 'moment'

I'm trying to use Moment.js library in Zapier. The documentation says that it's available. However, when I add this line:
var moment = require('moment');
I keep getting this error:
Bargle. We hit an error creating a run javascript. :-( Error:
Error: Cannot find module 'moment'
If I remove the declaration, I get ReferenceError: moment is not defined
moment is not available in https://zapier.com/help/code/ - maybe you are thinking of https://zapier.com/developer/documentation/v2/scripting/?
I can understand how one could confuse the two - but one is a simple code step in a Zap, the other is how partners developer applications on Zapier.
Moment library is available in Zapier, no need to call(require) it. Here's a snippet of code where I have used it.
var date;
if (outbound.Date === undefined) {
var d = moment();
var n = d.format();
date = n.split('.');
outbound.Date = date[0];
}

Laravel 5.1 - Retrieving single Models using string instead of the name of the model

Sorry for title. I don't know what to write.
This is my problem:
If i write this is all ok:
$obj_license = License::where('licenses.company_id',$company->id)->first();
But this throw an error:
$license='License';
$obj_license = $license::where('licenses.company_id',$company->id)->first();
ERROR: Class 'Butchery_license' not found
This is just an example. I really need to have the second way working. There is a solution?
Try to use full path to a class:
$license='App\License';
$obj_license = $license::where('licenses.company_id',$company->id)->first();

GDK ESourceRegistry Used to Work but Not Anymore

I'm developing Thunderbird addon that uses libedataserver.so.
Addon uses js-ctypes to call e_source_registry_new_sync from the above library. See below code:
var lib = ctypes.open("libedataserver-1.2.so.18");
var GCancellable = {};
GCancellable.cls = new ctypes.StructType("GCancellable");
var GError = {};
GError.cls = new ctypes.StructType("GError");
var ESourceRegistry = {};
ESourceRegistry.cls = new ctypes.StructType("ESourceRegistry");
ESourceRegistry.e_source_registry_new_sync =
lib.declare(
"e_source_registry_new_sync",
ctypes.default_abi,
ESourceRegistry.cls.ptr,
GCancellable.cls.ptr,
GError.cls.ptr.ptr);
//below line causes an error
var sourceRegistry = ESourceRegistry.e_source_registry_new_sync(null, null);
It works perfectly fine on Ubuntu however on Fedora 21 it prints below output and hangs:
(thunderbird:2735): GLib-GObject-WARNING **: cannot register existing type 'EDBusSource'
(thunderbird:2735): GLib-GObject-CRITICAL **: g_type_interface_add_prerequisite: assertion 'G_TYPE_IS_INTERFACE (interface_type)' failed
(thunderbird:2735): GLib-CRITICAL **: g_once_init_leave: assertion 'result != 0' failed
(thunderbird:2735): GLib-GObject-WARNING **: invalid cast from 'EDBusSourceProxy' to '<invalid>'
I'm using Fedora 21 with evolution-data-server 3.12.11-1.fc21.
Ubuntu uses evolution-data-server 3.12.10.
I developed simple C application that calls e_source_registry_new_sync and it works perfectly fine.
Can someone suggest what might be the reason of this issue?
#UPDATE:
I raised a Fedora bug. According to Fedora maintainers issue is caused by loading libedataserver twice (my code and evolution-ews):
The problem seems to be that thunderbird loads libedataserver-1.2.so.18 on its own, while the libcamelews.so has a runtime dependency on libedataserver-1.2.so, but this is not (in runtime) satisfied by the thunderbird-loaded libedataserver-1.2.so.18, thus it is loaded again, which breaks the GLib type system.
Please comment if there is something I can do from addon side.
You are asking about the error happening with this function: https://developer.gnome.org/libedataserver/stable/ESourceRegistry.html#e-source-registry-new-sync
The docs state that on error, NULL is returned and GError is set appropriately. I 'll test the code later and see what's up but I'll tell you here how to test it yourself.
GError is not an opque structure. Define it like this:
var GQuark = ctypes.uint32_t;
GError.cls = new ctypes.StructType('GError', [
{'domain': GQuark},
{'code': ctypes.int},
{'message': ctypes.char.ptr}
]);
Taken from here: https://gist.github.com/Noitidart/dbe54fcd7794c8ddff6f#file-_ff-addon-snippet-gdk_giolaunch-js-L22
Then set up your code to return error like this:
var error = GError.cls.ptr(); // can use `null` if we dont care to see error but we want to know what is happening so we can fix it
var sourceRegistry = ESourceRegistry.e_source_registry_new_sync(null, error.address());
if (sourceRegistry.isNull()) {
console.error('An error occured when calling e_source_registry_new_sync!');
console.info('ERROR DETAILS', 'Domain:', error.contents.domain.toString(), 'Code:', error.contents.code, 'Message:', error.contents.message.readString());
}
Then based on the error details look up that code and message and it will tell you what's up, then search StackOverflow or wherever for a solution to it if it's not obvious.

Lua error -Bad argument #1 to remove

When i try to remove the object from table using the following coding it returns a Bad argument error,
Code
table.remove(tablesArr[currentTableObj[currentTableCode].tableId]["STATUS"], currentTableObj[currentTableCode].tableId)
table.insert(tablesArr[currentTableObj[currentTableCode].tableId]["STATUS"], currentTableObj[currentTableCode].tableId,tostring(currentTableObj[currentTableCode].status+1))
Error
Bad argument #1 to 'remove' (table expected, got string)
I knew the syntax of removing is
table.remove(tablesArr,currentTableObj[currentTableCode].tableId);
But i want to remove the exact value in
tablesArr[currentTableObj[currentTableCode].tableId]["STATUS"]
How to remove the index value in 2d array in lua,Please help to solve.
If you want to remove value just set it to nil:
tablesArr[currentTableObj[currentTableCode].tableId]["STATUS"] = nil

Resources