Incorrect domain name in objective-c for mac machine - objective-c

I am trying to get the domain name of my macbook pro using following method.
NSString *name = [[NSHost currentHost] name];
It returns me the name like 'The-Special-MBP.local' but this is not consistent, It returns me some other string sometimes.
I am not getting why is this happening, the same function call returns two different values at different times.
Basically I need to indicate the different machines in network with some unique id or string hence I am reading the name from NSHost class but it gives different values for same machine.
Any help is appreciated.

If you want a unique id for your MAC, you may refer the following:
https://stackoverflow.com/a/5868967/1987246

It depends on your ethernet connection. Please you are connected in same network

Related

Getting the values of an /AIF/ERR variant

I did try using the RS_VARIANT_CONTENTS and RS_VARIANT_VALUES_TECH_DATA, it did show the values of the variant except the values of the name space, interface and interface version in which I also need to retrieve. I also searched the VARI* and TVARC tables but I didn't found it there.
I think it has something to do with the program name and screen number. Do you have any ideas or other way that I can retrieve all those values, whether using FM or select?
Thank you.
Some of the parameters in the transaction /AIF/ERR, the ones you are talking about, vary dynamically based on the value chosen in the Application screen field. They are handled by another AIF program, and they are not saved in the program variant, but in the table /AIF/T_ERR_VARS.
You may call the function module /AIF/ERR_VAR_LOAD to load the missing parameters.
Its usage is shown in the subroutine GET_VAR of the program /AIF/ERROR_HANDLING_TRANS (which is the program behind the transaction /AIF/ERR).

VB.NET Get RAM Serial Number like AIDA64

I want to get the serial numbers abour my RAM modules.
I used this commands/solutions to get the serials:
wmic memorychip get serialnumber
ObjectQuery("SELECT * FROM Win32_PhysicalMemory")
These are showing absolutely nothing to me (null). After that, I tried AIDA64 and I can see the serials inside the program.
The question is: How can I get these serial numbers like AIDA64 in VB.NET?
I tried to find them in regedit, still nothing.
Thanks for your help!

How to identify Drive ID?

The new Google Drive Android API has 2 types of string IDs available, the 'resource' ID and the 'encoded' ID.
'encoded' id from DriveId.encodeToString()
"DriveId:CAESHDBCMW1RVVcyYUZKZmRhakIzMDBVbXMYjAUgssy8yYFRTTNKRU55"
'resource' id from DriveId.getResourceId()
"UW2aFJfdajB3M3JENy00Ums0B1mQ"
In the process I end-up with a string that can contain any one of them (result of some timing issues). My question is:
If I need to 'parse' the string in order to identify the type, is there a characteristic I can rely on? For instance:
'encoded' id will always start with 'DriveId:' substring
'resource' id will have some length limit
can I abuse error return from 'decodeFromString()'?
or should I form (pre-pend) the string container with my own tag? What could be the minimal 'safe' tag (i.e. what will never appear in the beginning of these ids) ?
Please point me in the right direction so I don't have to re-do it with the next release.
I have run into yet another issue that should be mentioned here so others don't waste time falling into the same pit. The 'resourceID' can be ported and will remain unique for the object it identifies, where 'encodedID' has only 'device' scope. Means that you CAN'T transfer 'encodedID' to another device (with the same account) and try to retrieve file/folder with it. So I assume it is unique to a Google Play Services instance.
Please do not rely on any formatting of either ID type. This are subject to change without notice.
If you need to use both, and track the differences between them you should have your own method of doing so within your app.
Really, you should probably always just store the encoded ID since this one is always guaranteed to present, and if it contains a resourceId, its easy to get back out.

calling script_execute with a variable

I'm using GameMaker:Studio Pro and trying to execute a script stored in a variable as below:
script = close_dialog;
script_execute(script);
It doesn't work. It's obviously looking for a script named "script". Anyone know how I can accomplish this?
This question's quite old now, but in case anyone else ends up here via google (as I did), here's something I found that worked quite well and avoids the need for any extra data structures as reference:
scriptToCall = asset_get_index(scr_scriptName);
script_execute(scriptToCall);
The first line here creates the variable scriptToCall and then assigns to it Game Maker's internal ID number for the script you want to call. This allows script_execute to correctly find the script from the ID, which doesn't work if you try to pass it a string containing the script name.
I'm using this to define which scripts should be called in a particular situation from an included txt file, hence the need to convert a string into an addressable script ID!
You seem to have some confusion over how Game Maker works, so I will try to address this before I get around to the actual question.
GML is a rather simple-minded beast, it only knows two data types: strings and numbers. Everything else (objects, sprites, scripts, data structures, instances and so on) is represented with a number in your GML code.
For example, you might have an object called "Player" which has all kinds of fancy events, but to the code Player is just a constant number which you can (e.g.) print out with show_message(string(Player));
Now, the function script_execute(script) takes as argument the ID of the script that should be executed. That ID is just a normal number. script_execute will find the script with that ID in some internal table and then run the script.
In other words, instead of calling script_execute(close_dialog) you could just as well call script_execute(14) if you happened to know that the ID of close_dialog is 14 (although that is bad practice, since it make the code difficult to understand and brittle against ID changes).
Now it should be obvious that assigning the numeric value of close_dialog to a variable first and then calling script_execute on that variable is perfectly OK. In the end, script_execute only cares about the number that is passed, not about the name of the variable that this number comes from.
If you are thinking ahead a bit, you might wonder whether you need script_execute at all then, or if you could instead just do this:
script = close_dialog;
script();
In my opinion, it would be perfectly fine to allow this in the language, but it does not work - the function call operator actually does care about the name of the thing you try to call.
Now with that background out of the way, on to your actual question. If close_dialog is actually a script, your suggested code will work fine. If it is an extension function (or a built-in function -- I don't own Studio so what do I know) then it does not actually have an ID, and you can't call it with script_execute. In fact, you can't even assign close_dialog to a variable then because it does not have any value in GML -- all you can do with it then is call it. To work around this though, you could create a script (say, close_dialog_script which only calls close_dialog, which you can then use just as above.
Edit: Since it does not seem to work anyway, check whether you have a different resource by the name of close_dialog (perhaps a button sprite). This kind of conflict could mean that close_dialog gives you the ID of the sprite, not of the script, while calling the script directly would still work.
After much discussion on the forums, I ended up going with this method.
I wrote a script called script_id()
var sid;
sid = 6; //6 = scriptnotfound script :)
switch (argument0) {
case "load_room":
sid = 0;
break;
case "show_dialog":
sid = 1;
break;
case "close_dialog":
sid = 3;
break;
case "scrExample":
sid = 4;
break;
}
return sid;
So now I can call script_execute(script_id("close_dialog"));
I hate it, but it's better than keeping a spreadsheet... in my opinion.
There's also another way, with execute_string();
Should look like this:
execute_string(string(scriptName) + "();");

Predicate to sum child's value

I'm trying to get total salary for the whole company by:
NSNumber *totalSalary = [company valueForKeyPath:#"departments.employees.#sum.salary"];
But I keep getting this error, "-[__NSSet0 decimalValue]: unrecognized selector sent to instance 0x10031eb00".
I think I'm doing something wrong but I'm not sure where.
Don't fear. Although the set and array operators in KVC are very powerful, I still find myself having to refer to the documentation almost every time I use them in complex key paths like this. Because valueForKeyPath: is a method, you can call it from the debugger console. I often find that getting the key path right requires setting a breakpoint just before the KVC call and trying some stuff in the debugger console. Python with PyObjC (included in OSX since 10.5) is also a great interactive environment to test/debug KVC keypaths. In this particular example...
#sum sends the -[NSNumber decimalValue] message to each item returned by [company valueForKeyPath:#"departments.employees"] (the "receiving array" in key-value coding language). It thus expects that each item in the receiving array is an NSNumber. I suspect that company.departments is a set, thus [company valueForKeyPath:#"departments.employees"] is a set of sets, not a collection of NSNumbers. I believe you want to create a "flattened" collection of all the employees, from which you can then calculate the sum:
id allEmployees = [company valueForKeyPath:#"departments.#distinctUnionOfSets.employees"];
NSNumber *totalSalary = [allEmployees valueForKeyPath:#"#sum.salary"];
Assuming each employee is in only one department, the following also appears to work
NSNumber *totalSalary = [company valueForKeyPath:#"departments.#sum.employees.#sum.salary"];
You appear to be traversing several collections (the collection of all departments and the collection of the employees of those departments). You'll need to union them into one container (all employees) before summing them.
Check out the #unionOf... set and array operators here:
http://tinyurl.com/yk5njks
I haven't tried this, but I think departments.#unionOfSets.employees.#sum.salary is the correct way to do it. Let me know if it's otherwise!
Update: Barry Wark beat me to it. :-) He's right, it's distinct union of sets, otherwise, you'd get repeat employees wherever an employee belongs to more than one department. Though I don't believe it's necessary to do it in two steps:
#"departments.#distinctUnionOfSets.employees.#sum.salary" should do it.