Sunday, 1 September 2013

SRSetRestorePoint API creates a restore point bu not when system protection is disabled

SRSetRestorePoint API creates a restore point bu not when system
protection is disabled

I am working on a POC where in I need to develop an application on Win7
and Win8, pure C++ win32 application, that modifies (like installs or
un-installs) the system. Before that the application has to create a
system restore point. I cannot use .net or C++/CLI.
I googled and found the below link
http://msdn.microsoft.com/en-us/library/windows/desktop/aa378987(v=vs.85).aspx
With this (SRSetRestorePoint API) I am able to create the system restore
point (application gets the required admin privilege). But I am facing the
following issues
1) If system restore or protection is disabled or turned off, then the API
fails and will not create restore point. Is there any such APIs (no .net
method, only C++) using which I can enable system protection if turned off
or disabled?
2) Though the restore point is getting created, it is not appearing in the
"Recommended restore:" dialog in Computer->Properties->System Protection->
System Restore. This is where a newly and recently created restore point
appears. But with this API it is not. However, if we select, "Choose a
different restore point" option, then the created restore point appears in
that list.
Is there a way or what needs to be done to make the created restore point
(created using SRSetRestorePoint API) appear in "Recommended restore:"?
Code snippet:
RESTOREPOINTINFO RstPt;
STATEMGRSTATUS MgrStat;
DWORD dwErr = ERROR_SUCCESS;
RstPt.dwRestorePtType = APPLICATION_UNINSTALL;
RstPt.dwEventType = BEGIN_SYSTEM_CHANGE;
_tcscpy(RstPt.szDescription, _T("Demo Restore Point"));
if (!SRSetRestorePoint(&RstPt, &MgrStat))
{
dwErr = MgrStat.nStatus;
if(dwErr == ERROR_SERVICE_DISABLED)
{
//What to do in this case?
}
return FALSE;
}
RstPt.dwEventType = END_SYSTEM_CHANGE;
RstPt.llSequenceNumber = MgrStat.llSequenceNumber;
if (!SRSetRestorePoint(&RstPt, &MgrStat))
{
return FALSE;
}
Any help or pointers will be appreciated.
Thanks in advance. .

View network activity for browser child window

View network activity for browser child window

I need to reverse-engineer some javascript application which does
authorization using facebook auth.
Facebook auth window pops up, asks for my permissions, and gets closed
instantly, so I am unable to grasp anything from the performed action, as
it's too fast.
The problem is that neither Chrome DevTools, nor Firefox Firebug does
display network activity for child windows like OAuth permission.
Is there a way to enable FULL network log? An extension, whatever? (It
better be free and easy to use)

Can't normalize array. Sum is NaN. Weka

Can't normalize array. Sum is NaN. Weka

I got an error "Can't normalize array. Sum is NaN." when I use the trained
model to classify text. I am using stringToWordVector filter.
This is my arff file after I filter using the stringToWordVector
@relation
'emotion_class-weka.filters.unsupervised.attribute.StringToWordVector-R1-W1000-prune-rate-1.0-N0-stemmerweka.core.stemmers.NullStemmer-M1-tokenizerweka.core.tokenizers.WordTokenizer
-delimiters \" \\r\\n\\t.,;:\\\'\\\"()?!\"'\n\n
@attribute class_list {Happy,Fear,Anger,Sad,Neutral}
@attribute #Bopha numeric
@attribute #PlanPhilippines numeric
@attribute Mindanao numeric
@attribute interviewing numeric
@attribute survivors numeric
@attribute team numeric
@data
{0 ?,1 1,2 1,3 1,4 1,5 1,6 1}
this my code:
//Reads arff file
StringBuilder buffer = new StringBuilder(sample);
BufferedReader reader = new BufferedReader(new
java.io.StringReader(buffer.ToString()));
weka.core.converters.ArffLoader.ArffReader arff = new
weka.core.converters.ArffLoader.ArffReader(reader);
Instances dataRaw = arff.getData();
//Use string to word vector
StringToWordVector filter = new StringToWordVector();
filter.setInputFormat(dataRaw);
Instances dataFiltered = Filter.useFilter(dataRaw, filter);
dataRaw.setClassIndex(dataRaw.numAttributes() - 1);
Instances labeled = new Instances(dataFiltered);
Classifier cls = null;
cls =
(Classifier)weka.core.SerializationHelper.read("SampleModel.model");
for (int i = 0; i < dataFiltered.numInstances(); i++)
{
double clsLabel = cls.classifyInstance(dataFiltered.instance(i));
labeled.instance(i).setClassValue(clsLabel);
MessageBox.Show(clsLabel.ToString());
}
The error is in double clsLabel =
cls.classifyInstance(dataFiltered.instance(i));
Do you have other solution? Thanks in advance

Saturday, 31 August 2013

QtCreator GUI open text file

QtCreator GUI open text file

I made a push button that will browse and get a textfile. But I need to
open it in a new window to check if the content of the textfile is
correct. How do I do this?
Also, I would like to have a line edit right next to the button that shows
which file I'm looking at. In other words, the directory of the file that
is opened through the button.
Currently, this is what I have:
void MainWindow::on_fileButton_clicked()
{
QString fileName1 = QFileDialog::getOpenFileName(this,tr("Open Text
File"), "", tr("Text Files (*.txt)"));
QFile file1(fileName1);
if(!file1.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QTextStream in(&file1);
while(!in.atEnd()){
QString line = in.readLine();
}
}

NSOutlineView drag promises with directories

NSOutlineView drag promises with directories

How does one implement an NSOutlineViewDataSource to allow dragging
directories that do not exist in the file system at the time of dragging
to the Finder? I have searched and searched and read a ton of the
documentation, but have had great difficulty finding anything of value
that works. I use a custom data source that manages a file system-like
tree, and all the items are instances of a class that keeps track of its
path. I would like to be able to drag files and directories out of the
outline view into the Finder.
I have:
- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray
*)items toPasteboard:(NSPasteboard *)pasteboard {
NSMutableArray *types = [NSMutableArray array];
for (JOItemInfo *itemInfo in items) {
NSString *extension = itemInfo.name.pathExtension;
if (extension.length > 0) [types addObject:extension];
}
[pasteboard declareTypes:@[(__bridge_transfer NSString
*)kPasteboardTypeFileURLPromise] owner:self];
[pasteboard setPropertyList:types forType:(__bridge_transfer
NSString *)kPasteboardTypeFileURLPromise];
DDLogInfo(@"Wrote types %@ to pasteboard %@ for key %@", types,
pasteboard, (__bridge_transfer NSString
*)kPasteboardTypeFileURLPromise);
return YES;
}
and an implementation of
-outlineView:namesOfPromisedFilesDroppedAtDestination:forDraggedItems:
that writes the items inside of the given path. This works in that I can
drag items out to the Finder, but when I let go nothing else happens, and
the -...namesOfPromisedFilesDropped... method isn't even called. Also,
[self.outlineView
setDraggingDestinationFeedbackStyle:NSTableViewDraggingDestinationFeedbackStyleRegular];
[self.outlineView setDraggingSourceOperationMask:NSDragOperationNone
forLocal:YES];
[self.outlineView setDraggingSourceOperationMask:NSDragOperationCopy
forLocal:NO];
is in my -awakeFromNib. The if (extension.length > 0) ... was based on an
example I found somewhere, but it was dated, and the documentation says to
return an extension, so I think that is appropriate. Personally, I find
the documentation for this whole area very lacking, especially in regard
to an NSOutlineView. Thanks!
Update: I changed (__bridge_transfer NSString
*)kPasteboardTypeFileURLPromise to NSFilesPromisePboardType, and I can now
drag files (with an extension at least) and they can be dropped
successfully in the Finder. (I had used the former b/c the documentation
for the latter recommended that, but they do not have the same effect.)
Directories and files without an extension still can't be dragged.

How To Upgrade A Deprecated Ember Method

How To Upgrade A Deprecated Ember Method

Just upgraded from the ember rc6 to rc8. I am getting a
Ember.ControllerMixin.Ember.Mixin.create.deprecatedSend in the console.
It is telling me
DEPRECATION: Action handlers implemented directly on controllers are
deprecated in favor of action handlers on an actions object
Just wondering what the correct way to handle this in Ember. I am calling
controller.send from inside of the setupController function on one of my
routes.

DetailViewController programmatically iOS

DetailViewController programmatically iOS

Im using a custom ModalViewController called MZFormSheetController to
display a Detail View for UICollectionView. Currently I have created
properties in the modal view controller such as these :
@property (strong,nonatomic) NSString *user;
@property (strong,nonatomic) NSString *caption;
@property (weak, nonatomic) IBOutlet UILabel *username;
@property (weak, nonatomic) IBOutlet UILabel *captiontext;
And I attempt to set the display of the detail view controller when the
user taps on the UICollectionViewCell like this: -
(void)collectionView:(UICollectionView *)collectionView
didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary *entry = [self entries][indexPath.row];
NSDictionary *text = [self entries][indexPath.row];
ModalViewController *m = [self.storyboard
instantiateViewControllerWithIdentifier:@"modalView"];
m.entry = [self entries][indexPath.row];
m.text = [self entries][indexPath.row];
m.user = entry[@"user"][@"full_name"];
m.caption = text[@"caption"][@"text"];
MZFormSheetController *formSheet = [[MZFormSheetController alloc]
initWithViewController:m];
formSheet.transitionStyle = MZFormSheetTransitionStyleDropDown;
formSheet.shouldDismissOnBackgroundViewTap = YES;
[formSheet presentAnimated:YES completionHandler:^(UIViewController
*presentedFSViewController) {
}];
formSheet.didTapOnBackgroundViewCompletionHandler = ^(CGPoint location)
{
};
}
I have created two labels in storyboard for the modalviewcontroller and I
attempt to make them equal the caption and user values from the
MainViewController like this
[self.username.text isEqualToString:self.user];
[self.captiontext.text isEqualToString:self.caption];
However after all this the labels of the modal view controller still say
label like this..