Windows Defender update error code 80070002 windows 8.1

A solution to the problem when Windows Update fails at updating Windows Defender in Windows 8.1 and especially when the problem is related to corrupted definitions is to remove all definitions using the following steps:

1. Run “Command prompt” as administrator
2. cd “C:\Program Files\Windows Defender”
3. MpCmdRun.exe -RemoveDefinitions -All
4. Update to the latest definitions through “Windows Defender” in “Control Panel”

The next Windows Update should work as normal.

CALayer: Implicit animation of a custom property

For Apple’s iOS, below is the code to implicitly animate a custom property, using float as an example, in a subclass of CALayer:

/* MyLayer.m */
@interface MyLayer() {
    BOOL _isPresenting; /* TRUE for presentation layer */
}
@property (nonatomic) float property; /* normally defined in MyLayer.h */
@end
@implementation MyLayer
@synthesize property = _property;
- (void)setProperty:(float)property {
    if (_isPresenting) {
        NSLog(@"Presenting layer");
        _property = property;
        return;
    }
    NSLog(@"Setting value");
    if ([self animationForKey:@"animateProperty"]) {
        _property = [[self presentationLayer] property];
        [self removeAnimationForKey:@"animateProperty"];
    }
    CABasicAnimation *a = [CABasicAnimation animationWithKeyPath:@"property"];
    [a setFromValue:[NSNumber numberWithFloat:_property]];
    [a setToValue:[NSNumber numberWithFloat:property]];
    /* Set other animation properties */
    [self addAnimation:a forKey:@"animateProperty"];
    _property = property;
}
+ (BOOL)needsDisplayForKey:(NSString *)key {
    if ([key isEqualToString:@"property"]) {
        return YES;
    }
    return [super needsDisplayForKey:key];
}
- (id)init {
    if (self = [super init]) {
        _property = 10; /* initial value */
    }
    return  self;
}
- (id)initWithLayer:(id)layer {
    if (self = [super initWithLayer:layer]) {
        MyLayer *l = (MyLayer *)layer;
        _isPresenting = TRUE;
        _property = l.property;
    }
    return self;
}
- (void)drawInContext:(CGContextRef)ctx {
    NSLog(@"%f", _property);
    /* Add drawing code */
}
@end
Then, setting the custom property with:
myLayer.property = 50;
gives the following in the log:
Setting value
Presenting layer
18.953653
Presenting layer
25.723625
Presenting layer
..
..
..
Presenting layer
49.999870
50.000000
50.000000
The animation is working, but it cannot be overridden. It is time to change that by adding:
+ (id<CAAction>)defaultActionForKey:(NSString *)key {
    if ([key isEqualToString:@"property"]) {
        CABasicAnimation *a = [CABasicAnimation animationWithKeyPath:@"property"];
        [a setValue:@"defaultAction" forKey:@"animationType"];
        return a;
    }
    return [super defaultActionForKey:key];
}
and modifying the setter to:
- (void)setProperty:(float)property {
    if (_isPresenting) {
        NSLog(@"Presenting layer");
        _property = property;
        return;
    }
    NSLog(@"Setting value");
    if ([self animationForKey:@"animateProperty"]) {
        _property = [[self presentationLayer] property];
        [self removeAnimationForKey:@"animateProperty"];
    }
    CABasicAnimation *a = (CABasicAnimation *)[self actionForKey:@"property"];
    if (a) {
        if ([[a valueForKey:@"animationType"] isEqualToString:@"defaultAction"]) {
            [a setFromValue:[NSNumber numberWithFloat:_property]];
            [a setToValue:[NSNumber numberWithFloat:property]];
            /* Set other animation properties */
        }
        [self addAnimation:a forKey:@"animateProperty"];
    }
    _property = property;
}
Now, all is good.

Apple’s GLKit framework for IOS 5

Apple’s GLKit framework for IOS 5 is a few objective-c classes that make it easier to program for OpenGL ES 2.0, especially when porting from OpenGL ES 1.1 applications to 2.0. OpenGL ES 2.0 of course is the new graphics API for creating pretty 3D scenes in mobile apps. What makes it particularly hard for developers to program in 2.0 is shader programming. The methods of graphics rendering or fixed-function pipeline in 1.1 has been completely removed and made programable in 2.0, requiring developers to write their own rendering codes in OpenGL shading language or GLSL; that is shader programming. Apple’s GLKit classes manage all the shader programming needed to render scenes in 2.0, so that the developers can eat-the-pie-without-baking-it. It is not such a bad idea except that shader programming is for customizing the rendering process and the main reason for switching to 2.0. If we are going to switch to OpenGL ES 2.0, we should learn shader programming, at least that is what I thought.

Obviously, GLKit is for IOS 5 and does not work in IOS 4. The framework methods are also very standard, mainly to ease the porting of 1.1 applications. GLKit has very few capabilities beyond what was defined in 1.1 that I suspect that Apple’s main reason for creating GLKit is to remove the support for OpenGL ES 1.1 in the future. These are all speculations. It is probable that Apple will improve GLKit defining more classes for volumetric shadows, bump mapping, refraction, and so on. If so, GLKit may be the future, extending its classes into future OpenGL ES API with new capabilities like tessellation. Developers of course have the option to choose third parties’ development kit, making GLKit framework an inefficient and redundant layer.

Site update

It is almost 2012 and perhaps the end of the world? Probably not as the odd of any super extra- or terrestrial event is still quite small; well, at least NASA and most scientists still have not predicted anything serious to happen in the next few years. And any tendency of the humanity to self-destruct would probably take more than a decade to reach critical conditions, considering that the Europe still survives its debts and the U.S. is hanging tough with China and her own debts.. China is still selling cheap exports, and the rest of the world doing whatever they should be doing; oil reserve: check for about half a century; food capacity: check for most of the seven billions of us; climate destruction: check for still seeing massive ice land at the poles…

And so, it is still considered worthwhile to update an almost no-content blog site, just for the fun of doing it.. wow, now it looks cool!

Sin of a Solar Empire Mod – TEC Supremacy

TEC Supremacy (Link, 15MB) is my first mod of Sin of a Solar Empire (PC game) – Entrenchment 1.051. Below are the changes:

1. New Ships:

  • TEC Sova Strike Carrier – an experimental carrier with more fire power, but costs more (G3200, M450, C250). It carries advance strike crafts: interceptors and torpedo bombers. These strike crafts have longer build times.
  • TEC Interceptor – an advance multi-role fighter with two weapons: light lasers (hidden in the game) and auto-cannons (rear firing). It is fast and good against fighters, bombers and light frigates.
  • TEC Torpedo bomber – a slower but better armored bomber with more powerful missiles, rear-firing auto cannons and front lasers. Missiles are slow and cannot hit fighters.

2. New planets:

  • Plague Gas Giants – an uncolonizable gas giant contaminated with an unknown green plague. The plague can spread from ship-to-ship, and even infects people on structures and planets, regardless of races, friends or enemies. Plague damages ships, structures and star bases for 5 min. It stalls the population growth on infected planet, but causes no damage (a limit of the game).
  • Moss infested Terran – a Terran planet overwhelmed by red moss. Moss invades all ships in the planet’s gravity well but cannot spread from ship-to-ship. The invasion lasts forever and can only be removed by solar radiation, near the sun. Moss damages hull and drains anti-matter from the ships. Successful colonization of the planet by any fraction stops the invasion (another limit by design of the game), but existing ones stay. The planet is low on health (200 pt), but can be upgraded (to 3000 pt) to prevent new moss.

3. Other changes:

  • Fixed the regular fighter’s texture and mesh. For some reasons, it looked bad.

Edit: Update to version 1.051

Human’s excess

Scarce resources are consumed in excess for the power that supposedly protects against scarcity. By using more prevents shortfall. The extra becomes credits, free to burn and free to deny. And when the credits run wild, everything does not seem so inevitable. For there were excess, where did the shortfall come from?

Recession

The collective or perhaps a sizable group of bankers, manufacturers and investors around the world is feeling the blues and has become pessimistic about the current state of the economy, and thus recession is in fashion. Something as important as the jobs and well beings of billions people, something also known as the economy, is somehow subjected to the emotional feelings of our mental illness. Doctors of economics will say that it is a chronic disease, something like the flu, that we will never overcome, despite the technology innovations, the experts’ oversights, and multiple flu shots, also known as stimulation packages.

Perhaps it is a balance of greed and share prosperity, where there is a pie that is best served when everyone shares, but some people thought that they deserve a little bit more of the pie for their sacrifices and hard work. This same thinking/transaction/trading that happens over and over again will sooner or later reveal weaknesses in the exchange system. The weakest link is thus subjected to exploitation, and the system eventually falters. It is also time to ask which clothes is the flu virus wearing this season.