Wednesday, 27 November 2019

plot explanation - Why did they start killing people? - Movies & TV

In the movie The Wild Hunt, after a series of incidents occur with Evelyn, the shaman's followers end up kidnapping her and make her wear the skull mask. After she puts on the skull mask she starts freaking out and runs off. They start following her, starting the Wild Hunt, but instead of playing in-game they actually start killing people.



Why did Murtagh and his followers start killing people? Being upset over what happened in a game seems like a rather odd issue to kill people over.

javascript - What is the purpose of the var keyword and when should I use it (or omit it)?




NOTE: This question was asked from the viewpoint of ECMAScript version 3 or 5. The answers might become outdated with the introduction of new features in the release of ECMAScript 6.





What exactly is the function of the var keyword in JavaScript, and what is the difference between



var someNumber = 2;
var someFunction = function() { doSomething; }
var someObject = { }
var someObject.someProperty = 5;



and



someNumber = 2;
someFunction = function() { doSomething; }
someObject = { }
someObject.someProperty = 5;


?




When would you use either one, and why/what does it do?


Answer



If you're in the global scope then there's not much difference. Read Kangax's answer for explanation



If you're in a function then var will create a local variable, "no var" will look up the scope chain until it finds the variable or hits the global scope (at which point it will create it):



// These are both globals
var foo = 1;
bar = 2;


function()
{
var foo = 1; // Local
bar = 2; // Global

// Execute an anonymous function
(function()
{
var wibble = 1; // Local
foo = 2; // Inherits from scope above (creating a closure)

moo = 3; // Global
}())
}


If you're not doing an assignment then you need to use var:



var x; // Declare x

How do i declare two dimensional arrays in javascript?

could you not just do something like this?


var x = new Array(4);             #1st array, array of arrays
y = new Array(1, 4, 2, 0); #2nd dimension of arrays, an array of values
z = new Array(4, 8, 3, 9); #^^^
a = new Array(7, 0, 2, 4); #^^^
t = new Array(9, 0, 3, 1); #^^^

then to access 7 (the 1st value) in array a (3) you could type:


var example = x.3.1

if this wont work please tell me cos this is what i was told and what im now using to program my game

javascript - Implementing Mozilla's toSource() method in Internet Explorer

Has anyone implemented Mozilla's Object.toSource() method for Internet Explorer and other non-Gecko browsers? I'm looking for a lightweight way to serialize simple objects into strings.

How are variables assigned in PHP classes?




I did an exercise in codeacademy related to objects in PHP. It asked me to define a public variable $name in class Cat:



    
class Cat {

public $isAlive = true;
public $numLegs = 4;
public $name;

public function __construct( $name ) {
$this->name = $name;
}


public function meow() {
return "Meow meow. " . $this->name . "
";
}
}

$cat1 = new Cat( "CodeCat" );
echo $cat1->meow();

?>



Is this public $name; line actually needed? As I understand this, I call special function __construct with an argument value CodeCat. Then this CodeCat is assigned to variable $this->name and that's what I use later in function meow. If I comment out the public $name; line, then this does not affect the result.


Answer




Is this public $name; line actually needed? ... If I comment out the
public $name; line, then this does not affect the result.




PHP will create properties on your objects on request, even if you never formally declared them.




Class Thing{}
$a = new Thing();
$a->name = 'John';
echo $a->name; // John
echo $a->age; // doesn't break script but PHP gives 'Notice: undefined property'


Run it here



So your code runs either way because PHP adds the name property when you set it to something inside __construct(). Since properties are public by default, you get the same result.




This code design (using properties without declaring them) is a poor habit for several reasons including:




  • It's a nightmare for others who want to use or interact with your code

  • It's a nightmare for you if you're dealing with anything more than a very simple script. In a large application it will be impossible to know does this instance of Cat have a name?, what about this instance?, what other properties does it have anyway? None of these will be easy to answer if you add properties dynamically across different functions, or worse, different files.

  • Calling code has no guarantee that a property exists, so your program will likely have many more bugs

  • IDEs and code editors have no way to know the shape of your objects, so you're deprived of powerful tooling. Your scripts will take longer to write


ios - iPhone - LocationManager doesn't converge even though a user's Location Services are on?

Does anyone know what could cause locationManager to not converge to a value even though Location Services are on?



Edit 1 - The locationManager works fine for some users, but for other users their location never gets updated. And the user's device, whose location never gets updated, has GPS since the devices are iPhone 5, iPad3, iPhone 4, etc. I'm wondering if they are too far out in the country and always indoors. so GPS, WiFi, cell towers don't reach them? But somehow they get online....




Edit 2 - More clarification: The user has internet access as they are able to make a new account on my web server. And when locationManager has converged on a value, using #2 below, then the gps location on my web server is updated but that never happens. The user is on the device in the app long enough to answer 10 questions and upload their photo. Is that not enough time for locationManager to converge if the user has internet access?



Edit 3 - Another weird thing happens: On the website when the user's account is created, the users's gps_lat is set to 0. When the user does update his gps_lat on the website using locationManager from the iPhone, the updated value for gps_lat is (null). What could cause locationManager to produce output = (null)?




  1. I check that Location Services are on with the following code:



     BOOL locationServicesDenied    = ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied);


  2. Then I update the user's location on the website when the locationManager has converged with this code:




    -(void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
    fromLocation:(CLLocation *)oldLocation
    {



    if((newLocation.horizontalAccuracy >  0.0f) && (newLocation.horizontalAccuracy < 7000.0f){
    [self update_website:self];

    }




But update_website never gets called. Which makes me think that the newLocation.horizontalAccuracy never gets below 7000.



Does anyone have any idea why locationManager fails to converge even though Location Services are on?

.net - StyleCop SA1600 rule and interfaces realisation

Answer


Answer




StyleCop rule SA1600 demands that every type member has it's own documentation header. I think it's quite reasonable and I like this rule. But suppose we have the following hierarchy:




/// 
/// Documentation for interface ISomeModule.
///

interface ISomeModule
{
///
/// Documentation for DoA.
///

void DoA();


///
/// Documentation for DoB.
///

void DoB();
}

///
/// Documentation for StandardModule.
///

class StandardModule : ISomeModule

{
private readonly SomeCoolType _value;

///
/// Documentation for constructor.
///

public StandardModule(SomeCoolType value)
{
_value = value;
}


// SA1600 violation here!
public void DoA()
{
// realisation of DoA().
}

// SA1600 violation here!
public void DoB()
{

// realisation of DoB().
}

///
/// Documentation for MyOwnDoC.
///

public void MyOwnDoC()
{
// realisation of MyOwnDoC().
}

}


Here, I fully documented interface members DoA() and DoB(), we know what these methods exactly do from the interface documentation. VS Intellisence knows it too and we can see description of methods by hovering mouse over these methods even in class StandardModule. So it is not necessary to copy documentation from interface to derived class. But StyleCop demands to do it. Why? Does anybody know?



If we try to solve this issue, we can go 4 different ways:



1. Copy documentation from interface.
The problem here is if we copy documentation we will meet the issue of updating documentation in all derived classes if interface behaviour changes.




2. Suppress message with SuppressMessageAttribute.
Well, suppose we say "Ok, I can use SuppressMessageAttribute" to suppress this violation I don't agree with. And I prepend class StandardModule with SuppressMessageAttribute for rule SA1600. But now StyleCop stops checking for documentation headers in class StandardModule at all. I don't want it, because we have constructor and some other methods.



3. Divide class into regions,
We can divide class StandardModule into 2 regions and use message suppression only on the part that implements interface ISomeModule. And I think that all parts should be placed into one file. I like this approach most of all (after the way #4), but now we have to deal with multiple parts of one class.



4. Modify rule SA1600. Is it possible to make my own implementation of rule SA1600 so that it takes into account whether class members were documented in a base class or in interface? (here I don't ask if we can write our own rule for StyleCop, I know we can, but I mean whether StyleCop engine can check if some members came from interface or base class).



What is the most preferable way to solve SA1600 problem on interface realisation?


Answer




The upcoming StyleCop 4.4.1 release is supposed to support the inheritdoc tag. If you're willing to use a documentation-generation tool that supports this tag (e.g.: Sandcastle or FiXml), you might have a working solution that would address both your concerns.


php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...