How to debug windows storage applications - windows-10

I was using Properties.Settings.Default to store persistent data between sessions. For example, I was using Properties.Settings.Default.mute to store a boolean of whether or not to mute sounds.
I went online and it recommends to use Windows.Storage.ApplicationData.Current.LocalSettings.Values. So I try setting Windows.Storage.ApplicationData.Current.LocalSettings.Values["mute"] and using that, but that actually crashes the debugger, so I can't even debug whatever the issue is.

You have to set some data in Windows.Storage.ApplicationData.Current.LocalSettings.Values["mute"] before use it,  for example:
Windows.Storage.ApplicationData.Current.LocalSettings.Values["mute"]  = true;
(or false or an other value  ) the you can get it like this 
var t = Windows.Storage.ApplicationData.Current.LocalSettings.Values["mute"];

Related

libtorrent disable dht and lsd in the session

We are creating libtorrent session like this:
ses_settings = lt.session_settings()
ses_settings.ignore_limits_on_local_network = False
ses_settings.announce_to_all_trackers = True
ses_settings.ssl_listen = 0
ses = lt.session()
ses.listen_on(LISTEN_ON_RANGE_START, LISTEN_ON_RANGE_END)
ses.set_settings(ses_settings)
ses.set_download_rate_limit(download_rate)
ses.set_upload_rate_limit(upload_rate)
Similar to ssl_listen, we want to disable DHT, LSD, UPnP, NAT-PMP in the libtorrent session. Is there any way to do it ?
Also in the libtorrent manual page its mentioned as:
Configuration options can be updated after the session is started by calling apply_settings(). Some settings are best set before starting the session though, like listen_interfaces, to avoid race conditions. If you start the session with the default settings and then immediately change them, there will still be a window where the default settings apply.
Changing the settings may trigger listen sockets to close and re-open and NAT-PMP, UPnP updates to be sent. For this reason, it's typically a good idea to batch settings updates into a single call.
How to do the batch setting updates in a single call ?
Basically we want to change these default setting fields: enable_lsd, enable_dht, enable_upnp, enable_natpmp and then create a session object with these settings.
the session_settings type and set_settings() function on session are deprecated (and have been for quite a while). The reference documentation online (https://libtorrent.org) is for the most recent stable release, so you won't find them documented there.
Instead, use settings_pack and apply_settings() on the session. Or even better, pass in your settings pack to the session constructor.
In the C++ interface, settings_pack is a class with a fairly simple interface, but in the python binding it's just a plain dictionary.
To set up a settings pack in python, you do this:
sett = {'enable_lsd': False,
'enable_dht': False,
'enable_upnp': False,
'enable_natpmp': False,
'listen_interfaces': '0.0.0.0:%s' % LISTEN_ON_RANGE_START,
'download_rate_limit': download_rate,
'upload_rate_limit': upload_rate,
'announce_to_all_tracker': True}
ses = lt.session(sett)
# ...
You'll find all the available settings in the reference documentation.

Struts Action without session (Liferay)

I would like to create a simple struts action within Liferay, which would be a publicly accessible path to get some data. This is all perfectly fine, and I am able to create as many of those as I need. However, the data comes with several extra http headers that are not needed, and more importantly, with a cookie and a session.
What I would like to do is to simply get the client to obtain its data and go, no sessions are required. Is that a way to achieve this? I know we can disable sessions for the entire system, but I would like to be punctual.
The code is pretty standard:
#Component( immediate = true, property = {
"path=" + AuthPublicPath.ASSET_BRIDGE_URL, "service.ranking:Integer=" + Integer.MAX_VALUE
}, service = StrutsAction.class )

Firefox Add-on SDK equivalent to Chrome's chrome.storage.sync? [duplicate]

I'm currently converting a Chrome extension into a Firefox add-on and would appreciate to replicate the chrome.storage.sync feature.
However, I cannot manage to find whether the data stored by a Firefox add-on using simple-storage will be automatically synced whenever a user of the add-on is signed into Firefox Sync.
Given that all the pieces of data stored via the latter method can be found in the user profile, I presume it will... as long as the add-on is available at https://addons.mozilla.org ?
Any information on the topic would be greatly appreciated.
simple-storage is not synced. But you can sync it with little effort.
The trick it to store the storage object, it is serializable by definition, as a string preference and tell to the sync service to synchronize it.
Lets name that preference syncstorage and mark it as synchronizable.
var self = require("sdk/self");
var prefs = require("sdk/preferences/service");
prefs.set("services.sync.prefs.sync.extensions." + self.id + ".syncstorage", true);
When storing something to simple-storage reflect the change to syncstorage.
var sp = require("sdk/simple-prefs");
var ss = require("sdk/simple-storage");
sp.prefs["syncstorage"] = JSON.stringify(ss.storage);
For the opposite effect watch syncstorage for changes
sp.on("syncstorage", function(prefname){
ss.storage = JSON.parse(sp.prefs["syncstorage"]);
})
Last but not least, It would nice and perhaps mandatory to sync only with the explicit consent of the user.

Set CheckForGLErrors State

I have a problem with multiple "Warning: detected OpenGL error 'invalid value' after RenderBin::draw(...)" error messages emitted by OSG. I found this thread showing a way to add additional debug information. Unfortunately I can't find a way to set the State.
I can create a State and set the flag using the code:
osg::ref_ptr<osg::State> debugState = new osg::State();
debugState->setCheckForGLErrors(osg::State::CheckForGLErrors::ONCE_PER_ATTRIBUTE);
But what do I do after? I can't find a way to add the State to a StateSet.
You can obviously use gDEBugger as some of the answers in the thread suggest. If you still want to really do it via osg::State then you can probably add a osg::Drawable::DrawCallback to all your drawables. Then within the drawImplementation of the DrawCallback you can do something like -
virtual void drawImplementation (osg::RenderInfo & renderinfo, const osg::Drawable * drawable) const
{
State& state = *renderInfo.getState();
state->setCheckForGLErrors(osg::State::CheckForGLErrors::ONCE_PER_ATTRIBUTE);
drawable->drawImplementation();
}
I am not very sure if changing the state this late would work perfectly, you need to check this. If it doesn't work you can also do something like state.checkGLErrors("start of Geometry::drawImplementation()"); and state.checkGLErrors("end of Geometry::drawImplementation()"); before and after calling drawable->drawImplementation() .

Appcelerator. Handle memory usage. Best practice

Titanium SDK version: 1.7.0
iPhone SDK version: 4.2
I am developing an iOS app and I monitor the memory usage for each window And it keeps decreasing for every screen.
What is consuming memory in general? I use views, tables and XHR data.
How can I release memory / decrease usage on each window?
Thankful for all input!
Considering you are dealing with JavaScript being translated to Objective-C and can't necessarily write a native solution without using modules you could start by setting window variables to null (myJsWindowVar = null;), or delete those variables using delete (delete myJsWindowVar;). Personally I think setting variables to null will better translate to the suggested Objective-C best practice which is to set a pointer reference to null and prevent orphaned objects from hanging around.
Make sure you close unused windows and clear our any references to native objects you no longer need in the app.
// create a window object
var aWindow = Ti.UI.createWindow();
var aLabel = Ti.UI.createLabel({ text : "Hey" });
aWindow.add(aLabel);
aWindow.open();
// done with window
aWindow.close();
aWindow = null;
aLabel.null;
Check out this presentation from the Appcelerator Codestrong conference for more details.

Resources