What do you think about the Joel Test?

Question: The Joel Test is a well known test for determining how good your team is. What do you think about the points? Do you disagree with any of them? Is there anything that you would add?
Answer: Jeff Atwood has The Programmer's Bill of Rights.
From the post:

Every programmer shall have two monitors
Every programmer shall have a fast PC
Every programmer shall have their choice of mouse and keyboard
Every programmer shall have a comfortable chair
Every programmer shall have a fast internet connection
Every programmer shall have quiet working conditions

This seems to have some items that I'd like to see on Joel's list.  Specifically in the area of hardware (dual monitor, fast PC, mouse/keyboard, comfortable chair, fast connection).
The only thing not mentioned is having a comfortable and adjustable desk.
This could all be added by changing:
Current #9: Do you use the best tools money can buy?
to
Improved #9: Do you use the best tools and equipment money can buy?
Comment: Isn't your #6 identical to #8 on the Joel test:
Comment: It's Jeff Atwood's #6, and yes, it is.
Comment: It looks like the Joel Test is more specific to helping programmers develop clean, bug free software as opposed to working conditions, except #8
Answer: It's interesting that point 8 now reads:
8. Do programmers have quiet working conditions?

when it used to read (something like)
8. Do programmers have their own office?

and the last paragraph still starts:

Now let's move them into separate offices with walls and doors.

I was always suspicious of this test as in all the places I've worked - both as employee and visitor - the only people with their own offices are the directors and senior managers.
Writing software in the real world is usually a team activity, you need to talk to your team-mates to bounce ideas around etc. and that is harder to do with people in separate offices even with instant messaging systems. Being able to draw things out and show people code and diagrams helps a great deal. This isn't to say that distributed teams can't work - they obviously can and do, that's just a different set of problems.
What I would say is that each team needs to be in it's own office of 6-8 people (assuming that's the size of the team). That way they can interact without disturbing the other teams (if there are any) and get on with their work without being disturbed by the sales team or visitors (at one place I worked you came through the front door straight into the development area).
If you are working with other developers, but each is working on separate projects, then a shared office can be useful - but only if you are strict about taking meetings to the meeting room and respecting other people's deadlines etc.
Most of the others are self evident truths.
Comment: The problem with bouncing ideas off teammates is that ASKING them verbally is a huge distraction. If you need to do some serious collaboration, then work in a collaboration space. But for "hey how would you do this" questions you're much better off with IM.
Comment: You can't ever mean eight people in the same room, can you? I'm already annoyed by sharing a room with three other programmers (each of which works on his own stuff, with one working on a completely not related project and another one being the backend/database guy). I know for sure that if I shared the room with *seven* other guys I'd just go postal.
Comment: @ChrisF: perhaps that's the problem. The four of us sitting in the same room barely have anything to do with each other, programming wise. It's more like 4 people working on 2 1/2 projects sitting in the same room. And now add a boss who absolutely doesn't mind holding half-hour long discussions with another programmer right next to your desk despite the meeting room being *just across the hallway*. >.<
Comment: @ChrisF - *"Writing software in the real world is a team activity, you need to talk to your team-mates to bounce ideas around etc. and that is so much harder with people in separate offices."* - So, how do development teams spread across different locations work? I've worked **closely** with people across the US or Brazil or India - IM and Adobe Connect - as well as co-located, from small to very large distributed teams. Yours is a very disruptive environment. Working in teams can be done efficiently, but what you are prescribing is anything but (your idea is right from waterfalling the 70's)
Comment: @ChrisF - could be. I mean, every person has different (and legitimate) work experiences. I rather have people IM me than walking over to my desk and disrupt my line of though when coding. It forces communication to be very concise, spartan and to the point. Anything that requires more complex communication, e-mail. Anything truly urgent, a face-to-face meetup (or a call or teleconference for those in remote locations.) From waterfall to very agile, I've found that companies that do this help programmers retain their focus during development, reducing the signal-to-noise ratio.
Comment: @Matt - For the little things you're right, but office space is always scarce - no company wants to spend money on empty offices - which is why having teams in their own space helps. You can turn the office into a "collaboration space".
Comment: I've found three is the ideal number in an office. Eight people in an office, talking to someone disturbs six people. (I don't work with anyone in the same country as me, yet I'm in an open plan office. :()
Comment: @Baelnorn - I don't know where you work, but the only time there were less than 6 people in the same room was when I worked for company that consisted of 6! However, I've always worked as part of a team.
Comment: @luis - maybe it's just me then.
Comment: +1 for colocation.  Close communication between team members is vital, and becomes much more difficult when people are in different rooms, buildings, countries, timezones etc.
Answer: I like it but if I were using it to evaluate a company I wouldn't equally weigh all the items. Not having source control is a much bigger problem then not buying the best tools money can buy.
Answer: The only deal-breaker for me is:
 8. Do programmers have quiet working conditions?

Interesting it's the question most likely to be failed by Stack Overflow job postings.
Some of the questions are difficult to fail, particularly if there is more than one programmer in the company:
 1. Do you use source control?
 2. Can you make a build in one step?
 4. Do you have a bug database?

Most of the others I don't really care about. I mean, honestly:
12. Do you do hallway usability testing?

There is one to detect liars:
 5. Do you fix bugs before writing new code?

Comment: I think you'd be surprised how many companies can't make a build in one step and don't have a bug database.  You're probably right about source control, but I'd argue that a lot of companies use it simply to backup their code and don't even scratch the surface of the benefits of source control.
Comment: When I started at my current job we had a source control system, but builds were done on one guy's machine and only he knew all the steps, and bugs were tracked on paper. These are all "fixed" now, but I'd never take these things for granted.
Comment: Just look at the job postings on SO. The number of them that fail the first three is surprising.
Comment: @DjangoReinhardt I'd forgotten about these questions. They used to appear as a tick list on SO job postings. Not seen any of those for years. It's not like job ads have much in the way of information for those that might be interested.
Answer: I have to say that it is a good "baseline", but with any measuring tool there are other factors.  For example not a single company that I have worked for has done Daily Builds (I know, I know), but some of them have been very good.
I personally have a few other items that I would add to a list.

Do you support developer education by attending conferences, purchasing books, or something of that nature?
Do you have a simple, documented process to adopt new tools if necessary to complete job functions
Do you provide developers equipment and an environment that will allow them to be productive.

More than anything these are items have have "pissed me off" from previous employers, and well they are now fast track questions that I ask about each and every opportunity.
Comment: Isn't 3 already in the list?
Comment: Yes, in one form or another it is.  But I list mine a bit differently so I left it there.
Answer: I agree with most of Joel's points.  I'm not so sure about "hallway usability testing".  Usability testing, sure, but actually grabbing someone from the hallway and making them test your program, even though it's not their job?  That seems like a great way to tick people off.
Comment: the whole point of hallway usability testing is that it needs to be someone who doesn't use the program regularly. Once you've built it and/or spent hours using it (like a dedicated tester) your perspective on the app is going to be skewed
Comment: Surely its a cultural thing - if its not excessively disruptive and if its a part of the way the business functions then it shouldn't "tick people off" - *especially* not if the purpose of the business is development of applications.
Comment: Maybe the point is it should be a part of other people's job?
Answer: The Joel Test does not test how good a team is. It tests how well your team adheres to the Joel Test.
Here's a better test of how good your team is. I call it the GrandmasterB test. It has one question.
1) Is the software you write any good?
It's irrelevant to me whether you 'hallway test' or not, or what source control you have, or what your build process is (if there is one - not every lanugage has them). The true measure of a team is the quality of the software they create.
Basically, you could follow every single step of the Joel Test, and still end up with crap code and products that never ship. For example, source control does not magically make one a better coder; it makes code easier to manage.  And having the latest version of Visual Studio doesn't mean your application will work better than if it was written with Visual Studio 2005.
Comment: You're missing the point. The Joel Test isn't about how good the software is, it's about how *effective* the production process is. A team that fails the Joel test may still make good products, but chances are it'll take much longer and the workers will be miserable.

Also, tools doesn't refer just to software. It also means hardware, from your computer down to your desk and keyboard.
Comment: You never mentioned shipping on time. Also, I'd be extremely surprised to see an effective team that failed (completely) the Joel Test. Things like version control, testing and usability are all critical. The other items can be pretty big impediments as well.
Comment: I think you're missing the point.  If a team finishes projects on time and produces good quality software, they are, by definition, effective.  And they have, by definition, an effective process.
Comment: This is a good point, but the main weakness is the subjectivity of it. Everyone might have a different opinion of the software quality, depending on their experience, skill level, and usage perspective. But I do like the point.
Comment: If their effective process is only effective for the members that are on the team, particularly if the team is small, how well will it stand up to growth or in the event of an untimely disaster or retirement? Being able to produce code that works well and ships on time via a process that just exists in the heads of the people developing it is a recipe for disaster, a team that sooner or later (probably sooner) will face an issue from which most people can't, or simply won't want to, recover.
Answer: Although I think it makes good sense in the general sense, I found the list quite centered on the specific kind of software that Fog Creek Software does (shrinkwrap). That's not really surprising, as he also talks about that on another post, Five Worlds. And there are lots of developments outside that world.
There are some conditions that really don't make a lot of sense if you develop for example embedded software for a satellite or a vending machine, like daily builds (3) or usability testings (12).
Comment: Why wouldn't you create unit tests for embedded software (and have them automatically run by a build system)?
Comment: Agreed. Once you move away from the "top of the stack" apps, a lot of contemporary ideas seem to become a bit... irrelevant.
Comment: I agree. There are a lot of developer jobs in corporate IT shops...certainly not as glamorous as doing shrink wrap. As most of these companies are not in the software business, most of them typically score about 4 on the Joel Test.

What do you think about the Joel Test?


What does the Catholic church teach about fate of non-Catholic christians?

Question: From what I've heard, The Roman Catholic Church claims to be the only representative authority of God on Earth. Does it indeed claim that, and if so what does it say happens to members of non-Catholic churches when they die?
Answer: The Catholic Church is very explicit in its teachings that "all salvation comes from Christ the Head through the Church" (CCC 846).  The only way to enter the Church and become part of the Body of Christ is through baptism.  Thus, baptism is necessary for salvation (CCC 1257).
This is not meant to be interpreted as only Catholics can attain salvation.  Rather, the Church teaches that "anyone, even a non-baptized person, with the required intention, can baptize, by using the Trinitarian baptismal formula (CCC 1256)."  Thus, anyone baptized with water and "in the name of the Father, and of the Son, and of the Holy Spirit" is part of the Mystical Body of Christ and can attain salvation. To the best of my knowledge, this includes most non-Catholic Christians. (Note there are other forms of baptism recognized, baptism by blood and baptism by desire, but those seem out of scope for this question.)
Now Baptism isn't the only requirement for salvation.  One must also die free from mortal sin (CCC 1033). For a sin to be mortal, that is to be grave enough to cut us off from the life of God, three conditions must be met: "Mortal sin is sin whose object is grave matter and which is also committed with full knowledge and deliberate consent." (CCC 1857). This full knowledge includes both knowledge that it is a sin, and that it is a grave matter (CCC 1859).  Thus a sinner who through no fault of his own, believes he is not sinning does not commit a mortal sin.
If one does fall into a state of mortal sin, then normally the sacrament of reconciliation is necessary (CCC 1856) to restore or "reconcile" one with God.  However, it is recognized that a perfect contrition can also attain this forgiveness (CCC 1452).
In conclusion, the Catholic Church teaches that the sacraments of the Church are the surest and easiest way to reach salvation, but it is still possible for other members of the Body of Christ to enter Heaven.
Comment: @alvoutila Like many things theological, there isn't an easy yes or no answer. The Catholic Church does not teach a concept of "saved," but that doesn't mean born again Christians are barred from heaven. Those who are part of the Mystical Body of Christ (MBoC) will enter heaven; those who are not will not. So, are born again Christians part of the MBoC? That depends on whether they've been baptized and are free from mortal sin. Baptism joins you with the MBoC, mortal sin cuts you off, and reconciliation restores you to unity with the MBoC.
Comment: If you're interested, [there's an encylical](http://w2.vatican.va/content/pius-xii/en/encyclicals/documents/hf_p-xii_enc_29061943_mystici-corporis-christi.html) on the doctrine of the Mystical Body of Christ.
Comment: @cledoux:: I didn't find from your sources about what catholic church teaches about non-catholic born again christians; I mean are they saved and thus will enter to heaven according to doctrine of catholic church? I would like to get a source for whether non catholic born again christians can attain salvation or not?


BoxDetection Algorithm

Question: I am looking for guidance making a program in C# that take in a bunch of bmp images and detects a box on the image and returns the cropped box as a bmp image in a separate folder.
I am using Visual Basic 2010.
I have looked into all the different built in algorithms the .NET server has, and I have also downloaded and tried the Emgucv examples and what not. I found a program that uses a preset image and crops it to a certain rectangle specified by where the user clicks
http://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=30725
and am trying to incorporate parts of this with the Example.ShapeDetection.exe that is built in to the Emgucv reference.
<code>using System;
using System.Drawing.Drawing2D;
using System.Collections;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Text;
using Emgu.CV;
using Emgu.Util;
using Emgu.CV.Structure;
using Emgu.CV.CvEnum;

namespace Project1{
    public static class Project1 {
 public static void main()
    {
        //load in desired images to be processed
        //Load the image from file
     //for loop that runs all the code below for all the files in a certain folder
     //for example
     //for(int i = 0; i<"number of images in image folder"; i++){
     //code that loads the bmp images

    Image<Bgr, Byte> img = new Image<Bgr, byte>(fileNameTextBox.Text).Resize(400, 400, true);
    Image<Gray, Byte> gray = img.Convert<Gray, Byte>().PyrDown().PyrUp();
    Gray cannyThreshold = new Gray(180);
    Gray cannyThresholdLinking = new Gray(120);
    Gray circleAccumulatorThreshold = new Gray(120);
    Image<Gray, Byte> cannyEdges = gray.Canny(cannyThreshold, cannyThresholdLinking);
    LineSegment2D[] lines = cannyEdges.HoughLinesBinary(
        1, //Distance resolution in pixel-related units
        Math.PI / 45.0, //Angle resolution measured in radians.
        20, //threshold
        10, //min Line width
        10 //gap between lines
        )[0]; //Get the lines from the first channel

    #region Find rectangles

    List<MCvBox2D> boxList = new List<MCvBox2D>();

    using (MemStorage storage = new MemStorage()) //allocate storage for contour approximation
        for (Contour<Point> contours = cannyEdges.FindContours(); contours != null; contours = contours.HNext)
        {
            Contour<Point> currentContour = contours.ApproxPoly(contours.Perimeter * 0.05, storage);

            if (contours.Area > 100) //only consider contours with area greater than 250
            {
                if (currentContour.Total == 4) //The contour has 4 vertices.
                {
                    #region determine if all the angles in the contour are 90 degree's
                    bool isRectangle = true;
                    Point[] pts = currentContour.ToArray();
                    LineSegment2D[] edges = PointCollection.PolyLine(pts, true);

                    for (int i = 0; i < edges.Length; i++)
                    {
                        double angle = Math.Abs(
                           edges[(i + 1) % edges.Length].GetExteriorAngleDegree(edges[i]));
                        if (angle < 89 || angle > 91)
                        {
                            isRectangle = false;
                            break;
                        }
                    }

                    #endregion

                    if (isRectangle) boxList.Add(currentContour.GetMinAreaRect());
                }
            }
        }
    #endregion

    originalImageBox.Image = img;

    #region draw rectangles
    Image<Bgr, Byte> RectangleImage = img.Copy();
    foreach (MCvBox2D box in boxList)
        RectangleImage.Draw(box, new Bgr(Color.Green), 2);
    RectangleImageBox.Image = RectangleImage;
    #endregion
}
}
}
</code>
This is the code I have at the moment and there are several problems with it that I know about but I can not seem to find a way to solve them.

filenameImageBox, originalImageBox, and RectangleImageBox do not exist in the current context. My guess is that this is because they referred to an image that no longer exists.
As it says in my comments, I am trying to write a loop that goes through all *.bmp images in Resources and loads them to the program. I'm not sure where to go on this though.
Most importantly though is that this code HOPEFULLY detects the rectangle I am looking for and simply re draws a rectangle in the same location with same dimensions on a blank image. What I would like it to do is to simply crop the rectangle to be the size of the full screen. There are parts in the Cropping Images program linked above that can do this but I was struggling isolating the cropping from that program with the rectangle detection of the ShapeDetection algorithm.

Suggestions would be greatly appreciated. I have only been working in C# for a couple weeks, previous experience in c++ and Java though.
Answer: here i guess this will help you
<code>     else if (currentContour.Total == 4) //The contour has 4 vertices.
                    {double angle = Math.Abs(edges[(i + 1) % edges.Length].GetExteriorAngleDegree(edges[i]));
                             if (angle > 75 || angle < 95)
                            {...
</code>

BoxDetection Algorithm


Possible to get custom rims made?

Question: I have an older car with an unusual lug configuration so it is very difficult to get rims for it. Is it possible to get custom aluminum rims cast and machined to a specific lug configuration? If so, what search term should I use? I can't use "custom rim" because that just brings up regular production wheels.
Comment: Try asking at a wheel specialist.
Comment: I'm curious what kind of vehicle this is...   and there are also places that provide stamped steel wheels for race vehicles (dirt track/outlaw/nascar support races) that make offset/setback and bolt pattern to order.
Answer: Most aftermarket wheels are available in a custom PCD (lug configuration as you call it) as they are drilled to order to save having loads of stock.
Just ring and speak to some of the popular wheel brands and ask them if they will machine and supply a set in your desired PCD.
Another possibility is getting a used set re-dilled/machined to your PCD, depending on how different they are it could be very cost effective to do. It is actually better if the two PCDs are vastly different as it means there is more material in between the existing holes and the new ones, if they are too close it will require tig welding the old holes up. A good wheel specialist or machine shop should be able to do this.
Comment: I talked to a dealer for BBS and he said they had only production wheels, no blanks. Is that just because the dealer doesn't have the equipment to drill blanks, or will every BBS dealer say the same thing? Also, on BBS's web site, there is no mention of blanks.
Answer: Yes. The term you need to search on is "made-to-order".

Possible to get custom rims made?


Plasmid: Empty Backbone?

Question: When searching for a plasmid on Addgene what does it mean if it is said to be an "empty backbone"? Why would one want an empty backbone?
Answer: If you look on a very basic plasmid map, you usually see three different features: An origin of replication (often abbreviated ori or origin) which is necessary for the replication of the plasmid, a resistance gene (not necessary but useful to select for) and and multi cloning site (abbreviated MCS) which contains a number of unique restriction enzyme recognition sites, see the figure (from here):

In molecular biology plasmids are used to overexpress proteins in bacteria (or other cells) which are of any interest. To do this, you bring in the coding information for this gene into the plasmid using the MCS. Here you can cut the plasmid controlled (only open the ring on one site) and insert DNA of interest. An empty plasmid in this context means that it can readily used for cloning purposes as it does not contain any foreign DNA.
Answer: cause you want to put your own stuff in without worrying about other people's junk interfering with your stuff.
Something like why would you want an empty hard drive and not one which is almost full with stuff from somebody you don't know.

Plasmid: Empty Backbone?


Why is "такое" always neuter in the phrase "Что такое...?"

Question: Why is "такое" always neuter in the phrase "Что такое...?" (no matter what noun follows.) Also, what does the phrase mean? "How is... like?" Thank you!
Answer:
Also, what does the phrase mean?

If simply "Что такое?" then it means "What happened?" If "Что такое X?" then it stands for "What is (the meaning, usage, appliance etc. of) X?"
So you may think the word "такое" isn't really an attribute of "X" but rather a vague counterpart of "is" (or more precisely it's like "What thing is X?"). Remember that the Russians (almost) never say "что есть X?", and saying just "что Х?" is very ambiguous (does it mean "What do you mean by X?", or "X doesn't matter", or "What happened about X?", and so on). So the logic insists on having some additional word here, and this word must be as neutral (gender) as possible.
Considering this from grammatical point of view, "такое" is a pronoun (not an adjective!) which must be put in the neuter gender, as we're talking about some inanimate object. The logic is quite clear: the question "What is X?" assumes the answer of a kind "X is Y", and here "такое" is a pronoun used in place of that (yet) unknown "Y". But which gender is "Y"? You may expect the animate nouns to keep gender the same in any "X is Y" sentence. But it's not the case with inanimate ones where the gender is a pure grammatical abstraction. So the neuter gender comes to help as usual.
UPD. Okay, animate/inanimate dichotomy is perhaps somewhat misleading here. Although in Russian we do not normally use constructs such as "What is he?", still there are cases when it's possible to put "what" along with animate nouns/notions/names etc. This could be something like "What is a human being?" type of "abstract" question, or even intentional derogatory form, and so on. Anyway, when you ask in Russian "what"-type of question, you expect the answer to be effectively genderless, and so the pronoun "такой" should be put into the neuter gender.
Comment: Let me disagree with you. First of all, _"Что такое X?"_ not necessarily implies "talking about some inanimate object", we can ask that question about _anything_ in the Universe, e.g. _Что такое человек?_ or _Что такое шурин?_ Also, note, that there's another question, _Кто такой/такая Х?_ — the choice of the gender depends not on the object asked about, but on the question word used. Besides, using the trerm "inanimate" is somehow misleading, since in Russian many things which are non-living are treated as animate nouns: _робот, матрёшка, мертвец_. Would you consider rewriting your answer?
Comment: @YellowSky Okay, added.
Answer: Because что effectively is neuter in gender. Что произошло, что упало etc.
Similarly, кто effectively is masculine in gender, e. g. кто родил и жалеет, что не сделал аборт[1]
[1]: Which form of past tense should be used when the gender of the speaker is unknown? .
Comment: @YellowSky - ровно так же: кто такие эмпирики, но что такое эмпиреи.
Comment: What about "Кто такая Элис?" Here the gender is feminine.
Comment: @YellowSky - там Элис - подлежащее.  "Что такое" - устойчивый оборот, который не склоняется.


Android GUI gets hanged during registration on berkeke server

Question: I have written a code which involves media transmission between android device and a sip based phone.It works well for audio transmission.Further,I want to register the device on berkeke server but after 8seconds of launching,application gets hanged(device successfully got registered). I am unable to find whether the problem is with GUI or registration process.Earlier,before registration,it works for 90 seconds and then gets hanged.Please help me on this.
Answer: Are you using any kind of threading to handle the transactions separate from the UI thread? Always keep two things in mind:
Do not block the UI thread, and
Make sure that you access the Android UI toolkit only on the UI thread.
Painless Threading
Answer: Use async calls, I think your registration is making a blocking call.
http://developer.android.com/reference/android/os/AsyncTask.html
Answer: For CPU intense tasks and network related tasks make use of the Async Tasks else your UI gets hanged you will get an ANR (Application Not Responding) error.


Android as MIDI sequencer with digital piano

Question: Is it possible to use an Android tablet as a MIDI sequencer with a Yamaha Clavinova CLP-170 digital piano? My Yamaha piano has a USB port.
Answer: I can't speak from experience since I don't own any Android devices, but in theory, yes it is possible.
Assuming your Android tablet can handle class-compliant MIDI devices (i.e. if it can act as a USB host), and presuming that your piano acts as such a device when plugged in via USB (I can't say for sure with either of your devices, but this is not uncommon), then all you need is some sequencer app that can write to a generic MIDI interface. A quick Google search suggests that several sequencer apps exist, although I don't know if any support communicating to a USB device.
If your piano isn't class compliant, it should still have MIDI DIN in and out ports, so a generic USB MIDI interface with DIN cables such as this one ought to communicate with it in a similar way.
Comment: Thanks for the answer. USB Connection with a PC ( Notebooks ) works perfect. I could not directly connect the ubs cable to my android device, so I coudn't test it. Thats why I asked to be sure it will be working, before I buy the expensiv special USB Cable for my Android Device. So I hope someone can answer this with experience.
Answer: If CLP-170 is class compliant then it is possible starting with Android 3.1 if the device supports USB Host mode. I can tell you most of the phones do not support USB Host mode but tablets usually do. I own a Nexus 4 and a Nexus 7.
I developed an app which is a lot more complex then a midi sequencer, my app acts like an Arranger (Auto accompaniment software, midiArranger) and it works great with Nexus 7, Nexus 10 and other. It is free and currently in beta testing. I asked the community what other devices they use and I will get back to you. I plan to develop a MIDI sequencer too, the ones I saw out there are not too good.
If your device has a micro usb port you will need an USB OTG Cable like this.
Answer: You can definitely connect your Clavinova to an android device. Since your digital piano has USB type B port, all you need is a USB A to B cable, and then depending on which port your Android has, you'll need a USB type A (female) to C (male) if your android device has a USB type C port OR USB type A (female) to microUSB adapter if your device has a microUSB port. Once you've connected you can do tons of music-related things starting from learning how to play the piano and ending with recording your own songs. You can read all about it in this article.


Bypass CP login

Question: I've got a very special case in a big offline installation .
For strange technical and administrative reasons, I must have 5 different Craft instances each one in it's own server (on the local network) , but all Crafts should look and act as one.
That is: for the client there is only 1 CMS.
I need the access to be centralized through a single index.php displaying a menu with all the applications.
When the client click one app, he should be redirected to the Craft CP instance ( on its own server) where that App is located. So:
App1 links to http://192.168.1.20/app1/admin/entries/app1
App2 links to http://192.168.1.32/app2/admin/entries/app2
So the number of Crafts and servers should be invisible to client.
He only cliks an app and he go to edit that App.
He don't mind if it is on a server or on another....
One of the problems I'm facing is CP login.
The 1st time the client wants to edit App1 (located on server A) has to login (on Craft's A Control Panel ) .
But if he wants to edit App2 (located on server B) has to login (on Craft's B Control Panel ) .
But I don't want he to login twice. This should be transparent...
So I'm trying to create a login form at index for he to login once.
Then I'd like to send login creadentials via AJAX to every Craft instance to be pre-logged.
Then, if client access that server, Craft will not request to login again.
Is this possible?
How can I send user & pass credentials to Craft to be pre-logged in a hidden way ?
Another "solution" could be remove CP login.
As this case is an offline installation (with no connection outside), and there's only 1 user profile, looks to me that there's no need for login.
How could I remove it?
Thanks in advanced
Answer: For your second "solution", try the Auto Login plugin, which lets you whitelist an IP address or username(s)
https://github.com/sjelfull/craft3-autologin

Bypass CP login


Maintaining privacy on the web?

Question: I just read an article about the Importance of anonymity on the web.. Is it possible to maintain anonymity using services like Ubuntu One, and are there any native system tools within Ubuntu that will help me to maintain privacy and/or anonymity? I'm using Ubuntu 11.10 64bit.
Answer: The measures you take to protect your privacy depend on the concessions you are willing to make in order to make use of different services.  For example, if you decide to use Facebook, you will have filled out some info which is then visible to your contacts.  Any FB applications that you use will have had access to some of your info and could just as well have recorded and stored it in a database elsewhere. If you use a service like Google Docs or Dropbox, you are giving your files to a third party and trusting that they will not breach that trust.
A lot of your privacy measures will be up to you and the information you supply, I don't think tools can help you very much.  Sure, you could browse through a proxy but if you give information to a website, then that kind of defeats the point.
A few things you can attempt to do:

When signing up to a website that you won't be visiting regularly, lie about your details.  But remember the lies in case you ever need them again.
Browse with cookies turned off, although you may experience a somewhat crippled web experience with this
Browse with JavaScript turned off: You can accomplish this with a browser extension called 'scriptblock' and whitelist the websites that you need/trust.  Again, it'll be a very different experience with scripts turned off.  Some websites simply won't work.
Browse using a proxy service (you can even pay for proxy servers) so that your IP address isn't available to the party recording it
Answer: "Internet Privacy" is a very broad issue and some of the tools that can be used to track you are quite sophisticated, and some of the tracking tools do not have anything to do with your OS.
Here are some very broad suggestions
TOR
https://www.torproject.org/
Your ip address is only one piece of data that can be used to track you. I say this because a lot of people suggest TOR. Not that TOR does not have uses mind you, you should at least be aware of it's limitations as well.
If you are going to use tor with any reliability, you really need to read the documentation. Not just the installation guide, but all of the information, including the information of proxies and DNS leaks.
The tor project has very pertinent information on using tor, including this
https://www.torproject.org/download/download-easy.html.en#warning
In fact, the tor project advises you download the "tor bundle"
https://www.torproject.org/download/download-easy.html.en
Which includes tor, Vidalia , and patched applications.
Browser
Your choice of browser is also important. Some browsers (chrome) "phone home".
http://lifehacker.com/5763452/what-data-does-chrome-send-to-google-about-me
You should take the time to search the information your browser sends.
Browser settings
Your browser settings are important. Most browsers have a privacy mode, you should use it.
The issues here are cookies, flash cookies, html5 cookies.
It is possible for web sites to view your history and bookmarks ;)
Search engines
What search engine do you use ?
Take a look at this page:
https://www.ixquick.com/eng/protect-privacy.html
Passive OS Fingerprinting
Beware your IP address is not the only way you can be tracked.
See
https://panopticlick.eff.org/
technical details
http://www.ouah.org/incosfingerp.htm
If the above link is a little too technical, see
http://net.tutsplus.com/tutorials/other/http-headers-for-dummies/
The thing that "hurts" with these tools, the more you try to hide, the more you stand out. Try it, use a proxy server to filter the information your browser sends and you will be more and more unique.
Conclusions
It is extremely difficult to remain anonymous and requires education and diligence.
You can not be anonymous simply by installing an application, you have to change your behaviors as well (see the tor pages I linked).
Answer: Anonymity
For anonymity you can use Tor, which will make your real IP virtually impossible to detect. When you setup Tor you will use internet through a proxy, so all the information you send or receive (including Ubuntu One file transfers) will go through Tor and be made anonymous.
Security
For security, I believe there are some commercial antiviruses for Linux (though I don't really see a need for one, been using Ubuntu for years without antivirus and computer runs perfect).
You can also use a firewall, I believe Ubuntu runs UFW naturally. This will prevent people from breaking into your computer through ports.

Maintaining privacy on the web?


How do I review my own code?

Question: I'm working on a project solo and have to maintain my own code. Usually code review is done not by the code author, so the reviewer can look at the code with the fresh eyes — however, I don't have such luxury. What practices can I employ to more effectively review my own code?
Comment: Reviewing your own code is easy. Write a piece code. Step away for 2 weeks/months/years as you continue to learn and develop other software. Come back to that piece and try to understand what the code is doing. You know you learned something when you think: "what kind of idiot wrote this?!".
Comment: I'm not sure you can, at least not effectively - you can crowd source a review team at http://codereview.stackexchange.com/ if your code is not proprietary though
Comment: You can review your code in an altered mind state. Or you can code in an altered mind state and delegate a code review to your normal boring self.
Comment: You cannot review your own code.  If you cannot get other humans, I would consider the best you can do to use as many static analyzers you can get your hands on, and enable ALL warnings.
Comment: @YuriyZubarev But what if you don't want to wait for weeks/month/years?
Comment: try writing some unit tests for your code. that should give you some feedback.
Comment: @anatoliiG http://en.wikipedia.org/wiki/Forget-Me-Now
Comment: In my first ever comp sci lecture, decades ago, the lecturer recommended we each get a cat. When there is a bug, you sit with the cat and go through the listing, line by line, explaining to the cat "the bug can't possibly be in this line. The bug ... D'oh!".  I swear that it doesn't work without the cat. Perhaps the same method could be extended to code review?
Comment: @Mawg what you are doing sounds like rubber duck debugging. http://en.wikipedia.org/wiki/Rubber_duck_debugging with a cat. I might have to try that with my cat, but I'd feel silly. More so than when I talk to an actual rubber duck
Answer: First of all, make use of tools to check as much as you can. Tests (backed up with some reasonable code coverage) will give you some confidence of the correctness of the code. Static analysis tools can catch a lot of best practice things. There will always be issues that you need human eyes on to determine though and you will never do as good a job reviewing your own stuff as someone else, there are some things you can do to help however

check tests exist and pass (possibly have a target test coverage, though you may need to break this in certain cases, but you should be able to justify why)
check Static analysis passes (there will also be false negatives here but that is fine as long as you can justify why then its fine to suppress them)
maintain a check list of further things to check in review (ideally add this as new static analysis rules if possible) make sure you check anything the SA can't check, e.g., are comments still valid, are things named appropriately (naming things is of course, one of the 2 hard problems known to computer science)
if a fault is identified check if the cause is systemic and look at why it wasn't found in earlier tests or reviews

This of course is useful when you are reviewing others code as well
Comment: Concerning the check-list, having a [spec](http://www.joelonsoftware.com/articles/AardvarkSpec.html) is super useful.
Comment: I don't like checklists. They make reviewer concentrate on checklist instead of thinking the problem, the solution, and many other things.  So I suggest make them minimal.
Answer: Take a look into the Code Review Stack Exchange site. It is for sharing code from projects you are working on for peer review:

Code Review Stack Exchange is a question and answer site for seeking peer review of your code. We're working together to improve the skills of programmers worldwide by taking working code and making it better.
If you are looking for feedback on a specific working piece of code from your project in the following areas…

Best practices and design pattern usage
Security issues
Performance
Correctness in unanticipated cases

You can also use code static analysis tools to detect certain kind of problems, but they are going to produce false alarms in some cases, and can not suggest how to improve the design.
Comment: At best this is only a limited solution.  Continually putting your entire daily output on CR.SE isn't feasible since large chinks of it's going to be fairly mundane boilerplate code.  CR.SE is also not going to be much help with spotting problems that require a non-trivial understanding of the entire application architecture or domain the app is written for.  From informal, look at coworkers code when it's checked in style, reviews where I work these sort of errors are probably more common than the ones that would be suitable for catching via CR.SE.
Comment: I normally don't like a 5 word answer, but this one is *just so right*.
Comment: **The real value in reviewing** is getting pieces of code you never though would ever present any problem spotted and highlighted as *non-obvious* nor *self explaining* or even *non logically correct*. You can't post the snippet to `code review` if you are not already aware it's a problematic one.
Comment: @ZJR Well, is the code in your projects 100% reviewed? If yes, your engineers have too much free time. As for your 2nd comment, I don't see problems in asking for a code review in a code that you think is perfect.
Comment: That's an excellent answer to the question "How to get my code reviewed", and a good advice in general (I will definitely do that) — but still a little offtopic.
Comment: @ZJR Any code review can fail. Has it ever happened to you that you do a code review with a possible solution, and then few days later you get a big idea that makes the code review's solution looks like a wtf?
Comment: @ZJR I whole heartedly disagree with your arguments against this answer. Plenty of people get quality reviews from strangers on CR everyday. Now, the arguments about licensing hold true, but CR is a completely viable option for a solo dev working on an open source project.
Comment: Say, @ZJR, where's your CR.SE account? ;)
Comment: @golergka Off topic in what way? The question is : "How do I review my own code?" with nobody around.
Comment: @VJovic maybe off topic because a direct answer to "how do I review my own code without people" is not "use these people". I think OP is looking for tips on assessing own code if there are no others available whatsoever. (ex. what if codereview is down, or coder has no Internet access when needing to review code, etc)
Comment: @VJovic kind of offtopic because it clearly isn't feasible to do *real* code review on a stack website, just some non-working/odd bits and bops. You can't paste your whole source code in there.
Comment: @YannisRizos Does the current answer fit the guidelines?
Comment: @VJovic no, it does not, but I know it would benefit from it: it's chock full of WTFs I can't even see anymore. Ah, just because you made me thought about it, a note on the side: random reviewers, in certain circumstances, can prove a waste of time: sometimes you need someone that is at ease with the domain and/or the techniques (in my case, I'm thinking regexps) involved, or they'll just **wtf** everything.
Comment: @VJovic it depends on what depth of review you're asking about and the size of the team.  None of the projects I've worked on did any sort of formal code; so I normally do quick sanity check lookovers on all code added to source control.  At ~5 minutes/developer/day this won't scale to large teams, but does generally flag major problems other devs missed early on.
Comment: There are IPR issues. Posting the code on StackExchange means releasing it under Creative Commons. The OP may not be allowed to do that, especially if its a closed-source project.
Answer: I've developed several totally different persons in my head.
One of them is not even a programmer!
We're chatting, discussing latest news and reviewing each other's code.
I strongly recommend my approach.
ps
He is not kidding.
Comment: My names are Bill, Jeff, Bob, and Alice, and we approve this message.
Answer: I agree whit jk-s opinion that single-person review is not as efficient as 2 person review. however you can try to make the best of it:
short term review (shortly after the code was produced)
I am using git as a local repository. Whenever I have finished a feature or fixed a bug I transfer the changes to the repository.
Before i check in I compare what I have changed in my code and rethink:

do variable/method/classnames still reflect what they are used for?

long term review (6 months after the code was produced)
I ask myself:

can I describe in one sentense what a class/method/variable does?
how easy is it to use a class in isolation (whitout the other classes) or write a unittest for?
Comment: +1 for short term review suggestion. Using git to view all changes between different points in time can really help cleaning up the code.
Comment: I quiet like the long term review idea, I think I'd probably combine it into a general project wash-up review though and maybe not review all code (then again I don't tend to do solo development much)
Comment: I try to do something in between: review my code in about a month. I also like the 6 month review.
Answer: First, set your code aside for as long as practical. Work on something else, some other piece of code. Even after a day, you will be amazed at what you will find.
Second, document your code. Many programmers hate to document their code, but make yourself sit down and write out documentation, how to use the code and how it works. By looking at your code in a different way, you will find mistakes.
It has been said that true mastery of a subject is the ability to teach it to someone else. With documentation you are trying to teach someone else your code.
Answer: Transform this debugging technique to a code review technique: http://en.wikipedia.org/wiki/Rubber_duck_debugging
The concept works wonders for putting you into a proper mindset for working through code as if it were new.
Comment: These days, my rubber duck is the Stack Exchange ask-a-question form. The desire to write a *good question* does the trick.
Comment: @KevinReid, I would *love* to see some stats on abandoned SE posts - especially ones that people have been typing for longer than 60s on. I know I've done that same thing myself at least 5 times.
Comment: I believe the duck technique has been independently invented at multiple sites; here's a great story about it: http://hwrnmnbsol.livejournal.com/148664.html
Comment: Excellent advice. It's even better as I already have a rubber duck on my desk (it's been here as a model for one of my game characters, but I guess it won't mind additional job of an IT consultant).
Comment: Wah! I didn't know this was " a thing". I just commented above that my comp sci professor recommended this during our first ever lecture, decades ago. He recommended a cat, but I suppose ea rubber duck would do. One thing is sure, it doesn't work without the anthropomorphic sidekick :-)
Answer: In addition to the useful tools mentioned in other answers, I think modifying your mindset it useful when doing a code review.  It's silly, but I say to myself:  "I'm putting on my code review hat".  I do the same with QA.
Then it's important to limit yourself to that mindset.  You're either the reviewer or the reviewee, you can't be both at once.  So as a reviewer, I take objective notes to share with the reviewee.  I don't change the code while I'm reviewing it, that's not something a reviewer should do.
The formality feels a little absurd at times, but I find when working solo that I'm often pulled in a lot of directions.  So I may not necessarily close the review loop before something else comes up - that formality (and really, I'm talking rough notes in a wiki tool), is useful for making sure the review gets done.  Likewise with my QA hat on, I add tickets for bugs before I fix them.
Comment: @VJovic - I don't think I perform the best possible code review on my code, but I usually find things that could be improved.  I read a lot of other people's code too.  My viewpoint on what "good" code looks like is constantly evolving.  I'm embarrassed by code I wrote years ago.  It's no different than proofing your own article - it takes practice and a lot more effort, but it's doable.  The key thing I can't review myself is if an abstraction makes sense to someone else.  But I can ask myself how to make something simpler, is this necessary, etc.
Comment: Getting into the right mindset is really important. I find that it helps if I actually print out the code and go through it on paper with a marker pen. Then I cannot change anything when reviewing (which prevents me from going into coding mode) and can easily scribble comments and movement arrows on the paper.
Comment: I don't think it's possible to review your own code
Comment: @VJovic - As ThomasOwens mentioned, you can also create a checklist from past mistakes and run through that pretty objectively.  That's the other nice thing about being sort of formal about it, you can see what you missed during the review and adjust your process accordingly.  I find I learn a lot of lessons by tracking myself and making an effort to change my approach when indicated.
Comment: That means reviewing old code, and not new code. For that you need to gain experience, which can take long.
Answer: It seems the common sentiment is that self-review is not effective. I disagree, and I think self-review can catch a lot of issues if done thoroughly.
Here are tips from my few years of experience:

Have a rough checklist handy. These are things you want to flag while you read your code.
Take your code review offline. It might sound wasteful, but take printouts that you can annotate and flip back-and-forth, or the digital equivalent of nicely highlighted pdfs synced to an iPad which is then taken offline. Go away from your desk, so that all you do is review your code distraction-free.
Do it early in the morning, rather than the end of a working day. Fresh pair of eyes is better. In fact, it might help to have been away from the code a day before reviewing it afresh.

Just an FYI - these guidelines were part of recommendations in Oracle a few years ago when I was working there, where the aim was to catch bugs "upstream" before the code went into testing. It helped a lot, although it was considered boring job by a lot of developers.
Comment: I'd also add "wait 24 hours" so you aren't looking at code you just wrote. Make sure it's at least 1 day old so you are seeing it after sleeping overnight and not touching it for 24 full hours.
Comment: I often use printouts when I need to review or especially refactor some code. It works wonders for me.
Comment: Like in some film we learned from GB that a fake orgasm is better than no orgasm -- self-review is better than nothing. Yes, you can train to do rubberducking a lot. But it's still quite ineffective compared to actual peer review. especially without being exposed to actually good reviewers for some time to pick up methods.
Answer: The Personal Software Process technique for reviews might be useful, although it relies on having historical data about your work and quality of products.
You start with historical data about your work products, specifically the number and types of defects. There are various methods of classifying defects, such as this one from a PSP course. You can develop your own, but the idea is that you need to be able to tell what mistakes you are making along the way.
Once you know what mistakes you are making, you can develop a checklist that you can use during a review. This checklist would cover the top mistakes that you are making that you think can best be caught in a review (as opposed to using some other tool). Every time you review a work product, use the checklist and look for those mistakes or errors, document them, and fix them. Periodically revise this checklist from time to time to make sure you are focusing on real, relevant problems in your code.
I would also recommend using tool support when it makes sense. Static analysis tools can help find some defects, and some even support style checking to enforce consistency and good code style. Using an IDE with code completion and syntax highlighting can also help you prevent or detect some problems before you click "build". Unit tests can cover logic problems. And if your project is sufficiently large or complex, continuous integration can combine all of these into a regularly-run process and produce nice reports for you.
Answer: Working solo means that unless you trust complete strangers to review code on your behalf, that you will need to look at the way you write your software in order to maintain code quality.
First and foremost, you should have a means to ensure that your code is matching requirements, and second that your code will be relatively easy to change if you decide later that you got something wrong. My suggestion would be to apply a Behaviour Driven Development approach for the following reasons:

BDD means writing code test first.  This ensures all of your code is covered by tests.
BDD is essentially TDD, but with a slightly different focus and "language". What this implies is that you continuously refactor your code as you are working on it, and use your tests to ensure your refactoring efforts continue to ensure that your code satisfies your product spec.
BDD language encourages tests to be written in the form of statements that essentially encode requirements as unit tests.

So the idea here, is that your continuous refactoring of code even after you get your tests to pass, means that you are effectively reviewing your own code and using your unit tests as the "extra pair of eyes" which make sure your code doesn't stray from the requirements that are encoded in the tests. Also, high test coverage based around requirements ensures you will be able to change your code in the future without failing the requirements.
The real issue for you will be whether or not you're able to spot potential issues in your code that will indicate a need to refactor.  There are several profiling tools on the market that can help you with this, as well as several other tools which are concerned with code quality metrics. These can often tell you many things that code reviews can miss, and are a must when developing projects on your own. In reality however, experience is the key, and once you are in the habit of being merciless in your refactoring, you will likely become much more critical of your own code.  If you haven't already, I'd suggest reading Martin Fowler's Refactoring book as a starting point, and looking for a good BDD API that you feel will work for you in whichever language you have chosen to work with.
Answer: Whenever I've been in the same situation as yourself, I've tried to solve the problem of "being too close to the code to objectively examine it" by using code review / metric tools.  It goes without saying that a tool cannot give the same value as an experienced reviewer, but you can still use them to pinpoint areas of bad design.
One tool that I've found fairly useful in this regard was SourceMonitor.  It's a bit simplistic, but it gives a good mid-level opinion of your code, such as the number of methods in a class, and the complexity of each method.  I've always felt that this type of information was as important (if not more important than) the enforcement of coding styles via tools like StyleCop, etc (which are important, but are often not the source of the largest problems).  Use these tools with the usual disclaimers:  know when to break a rule of thumb, and something that is all green in a code metric tool isn't automatically of good quality.
Answer: I can't tell you the number of times I have been explaining something to a code reviewer and the lightbulb in my head turns on and says, "Hey wait a minute." So I often find my own mistakes in the code review that the other person didn't see.  So you could try that, just start explaining the code as if there was a person sitting next to you who was trying to understand what you did and why.
Another thing that I find frequently in code reviews is that the developer did not actually follow the requirement. So comparing your code and what it does the the actual requirement is a good check.
We frequently do things like SSIS packages that have similar structural needs - for code reviews I developed a checklist of things to check (is the configuration correct, is logging set up, does it use the metadata database, are the files in the standard location, etc.). You might have some things that would be handy to check every time in a code review as well. Sit down and think about what you would put on a checklist of things you want to make sure to check in your code review (First item, make sure the requirement is met, next item might have something to do with trapping and logging errors). As you make mistakes and correct them, you may add other items to the list (say something like, do I move to the next record in a loop or am I going to endlessly repeat the same first item - it only take one endless loop to teach you to look for that!). This is mostly to keep you from forgetting to do some things that should be done.
Comment: As Patrick Hughes suggests in his answer, using a proxy like a rubber duckie to stand in for the reviewer helps the mindset.
Answer: Give it 3 months, then go back and look at your code. I promise you, if you can't find something wrong with it (or question who wrote this junk!) you are a better man than I!
Comment: That's my technique also. 3 months is long enough that anything I can't immediately understand needs to be simplified or documented better, but short enough that I still remember what's going on enough to easily rectify it.
Answer: I usually print out all my code and sit down in a quiet environment and read through it, I find a lot of typos, issues, things to refactor, cleanup by doing that. It's a good self-check that I think everyone should do.
Comment: A good addition to the advice above, thanks — although I think that a tablet or something like that (with editor, but without a development environment) would work too. I wonder who downvoted that and why.
Answer: Back in college I was a writing tutor. It has certainly given me some perspectives on coding that I think many developers would never have thought of. One of the most important is to read your code aloud. It doesn't sound like much, but I will give a perfect example that I think everyone can relate to.
Have you ever written an email or a paper, reread multiple times to make sure its correct, then sent it, only to find that you have a glaring spelling error, typo or grammatical error? I just did this yesterday when I asked a client to press the shit key instead of the shift key. When you read in your head - you see what you want to see.
This is a shortcut for the 'just wait a day or a week or a month' suggestions others have made. If you read it aloud you catch the same things. I don't know why it is so effective, but after sitting with hundreds of students and having them read aloud, all I can say is that it works.
Comment: +1 This would go along with the "explain it to your cat" approach. Using different parts of your brain can be helpful when you can't use a co-worker.
Comment: plus one for shit key
Answer: Most of the people tend to consider their code as their own babies and feed them with ego to rather than reality. Just like any other code reviews, review it as you're seeing someone else's code. Completely forget that you've wrote something. Review each line of the code. A check list would helpful for being aesthetics about reviewing own code. Automated tools for code review can help to some extend. I have used some tools like klocwork (commercial software), This is quite useful while you're working in large projects and several developers are working for it. Always focus on defect detection rather than correction.
But a best practice would be, review yourself and later involve at least two other people for review with distinguished roles.
Answer: Consider doing a Fagan inspection by yourself - you'll have to adapt the process because you're by yourself, but you should be able to get quite a bit of value out of it.  The trick is going to be to find the right "ruleset" to evaluate your code against as a solo dev, and then having the discipline to ask those questions in a critical, analytical, merciless frame of mind each time.  I suspect you may want to brainstorm your own 4-5 crucial questions to start with, and then evolving it over time.  Some people are against formal inspections because they seem to be so time-intensive... before you decide that they're too expensive, bear in mind all the statistical evidence that doing inspections properly actually reduce project time.  Here's a Wikipedia link that you can start further research with:
http://en.wikipedia.org/wiki/Software_inspection
There have been a few books too, e.g. Google for "Software Inspection Process" by Strauss and Ebenau.
Another option is to pay someone to inspect an important project - or perhaps pay them occasionally to do inspections of all your code.  This guy's pretty good, we've flown him out a number of times to train our newer devs:
http://www.javaspecialists.eu/
Answer: Apart from all the recommendations for code review, you can use the tools like PMD and findBug to do first level of sanity for your code.
Answer: This has not actually been placed in an answer yet (but has been added as a comment to an existing answer)
Review your code after a good nights sleep, e.g. start the day by reviewing the code that you wrote the previous day.
This will of course not give you the collective experience of a team, but it will give let you review the code from a new perspective.
For instance, if you left a piece of code with a nasty hack, you might not be too inclined to fix it up, if you review your code immediately after. After all, when you start reviewing your code, you already know, and have accepted, the presence of this hack. But if you have had a good nights sleep you are probably more motivated to find a better solution.
When we sleep, the brain doesn't actually stop working on the problems that we have, so you might actually come up with a solution there, though those solutions may sometimes present themselves in odd ways.

How do I review my own code?


Blocking One Attacker with Multiple Creatures

Question: In what situation would I want to have multiple creatures block one attacker? If one creature can absorb all of the damage, why subject more creatures to the excess damage? Other than trample, is there any advantage?
Answer: The simplest case is using multiple weaker creatures (say, two 1/1s) to block and kill a single 2/2. Using only one creature would (under normal conditions) be rather bad.
Even better, use two 1/3s to block and kill a single 2/2, while your creatures survive combat unharmed (barring any instants being cast).
Comment: @Christopher Combat damage is assigned simultaneously. Simplifying it, we (1) declare attackers, (2) declare blockers, and (3) have the attackers and blockers simultaneously exchange damage. (There is no "attack back" since they're blockers, they're just assigning damage.)
Comment: Unless of course the attacker has first strike and the defenders don't.  (Magic is one of those games where almost every statement about it has an exception).  And of course, the defenders could have first strike and kill the attackers before they are damaged.
Comment: And if you have 10 1/1 lifelinkers, throwing them all against a 2/2 can be desirable, especially if the opponent is tapped out
Comment: Wouldn't the two 1/1s take damage AND die before they attack back?
Comment: The OP already mentioned the trample case.
Comment: @Christopher only if the 2/2 had first strike. Without first or double strike (or in unstable last strike and triple strike) involved, all damage is done at the same time, attacking creatures do not do their damage before blocking creatures.
Answer: In addition to Glorfindel's answer of gang-blocking with weaker creature to kill a stronger attacker, there are some edge-cases where it is beneficial to you to have your creatures deal damage.
An example for a case for this happens semi-regularly in the current standard Tokens deck where one player has a lot of 1/1 Lifelink tokens. Say player A has 10 1/1 Lifelink soldiers and they are attacked by a 1/1 goblin token (say from Goblin Warboss).

If Player A blocks the 1/1 goblin with a single lifelinker he will lose 1 solider and gain 1 life.
If Player A blocks the 1/1 goblin with all his lifelinkers he will lose 1 solider and gain 10 life.
Answer: Another reason to block with more creatures than you expect to need is for insurance against combat tricks (instants played after declaring blockers but before combat damage is dealt). If I'm at very low life, I will often over-block to prevent trample-granting buff instants from killing me. Over-blocking can also help to ensure that you kill an attacker - if someone attacks with a 1/1 when I have two 3/3s on the battlefield, I might block with both, as it's likely they have some instant like a +3/+3 which would hurt if I block with just one of my creatures, but might be a fair tradeoff if I block with both. Sure, it looks like the one blocker will be enough when declaring blockers, but it's very useful to consider what might happen before damage is dealt.
Answer: A good question, and the answer is, yes. Not always but there are several cases where blocking with multiple creatures benefits you over blocking with just one. Malco and Glorfindel have given reasons which I will mention here too for completeness.
As you said trample is a big reason to block with multiple creatures, you need to put enough toughness in front of the creature to prevent the rest getting through.
As Glorfindel said, killing the attacker is another reason, weenie decks have alot of small creatures, often tokens, that are expendable, throwing a few in the way of a big threat may lose you more creatures, but the creature they lost may matter much more.
As Malco said, lifelink effects work when you overkill, unlike some other combat card games, you deal the full power of your creatures to whatever you block, not just enough to kill that creature. The overkill when you have lifelink gains you more life.
Playing instants in MTG during combat is known as combat tricks, if a person casts Giant Growth or something similar on their attacker during combat, your blocker that was bigger than the attacker may now be the smaller creature. If you block with a second creature or third, you might still lose some creatures in the exchange, but the extra damage may be enough to still kill their creature, or they may not spend the spell on a losing combat.
You may have effects that care about when you deal damage to creatures. One example of this I can think of is Greatbow Doyen, which makes your archers deal damage to the creature's controller equal to the damage they do to creatures, you can block with a lot of archers to really punish the player for attacking, if you don't win outright from all that non-combat damage.
There are creatures that have effects that happen specifically when you block with that creature, such as Megalonoth, Engulfing Slagwurm, and Goldenglow Moth. Including these creatures in a block, even when it isn't needed to kill the creature will give you the benefit of their effect.
Menace is an ability on creatures that force you to block with 2 or more creatures. Even with a creature as weak as Goblin Glory Chaser though you only need one damage to kill their creature, this forces you to block with at least two or not at all.
You may simply have to block with everything you have. A creature like Prized Unicorn or something enchanted with Lure forces you to block a single of your opponent's creatures with everything. This is usually done to let the rest of their army through to hit directly.


How long can I keep pureed root ginger

Question: As the title says, how long can I keep pureed root ginger in the fridge?
Answer: If you have a lot or don't anticipate using it in the next 5 days, then freeze it.
If it's already minced or pureed then simply measure it into quantities that will be the easiest for you to use and then freeze them on a tray lined with plastic wrap.  Once frozen, remove and put into a self-sealing bag and keep in the freezer for future use.
Whole ginger can be frozen simply as it is.  Just put it a bag in the freezer. Galangal for example, is commonly sold frozen in asian markets  You can pull it out and grate what you need on a rasp style zester while frozen.  I never even peel ginger as most uses for it require it to either be minced finely or strained out all together.  A little gingerroot skin is just more fiber for the diet.
Answer: You can also freeze ginger pretty well for at least a few months - if you spoon out tablespoon-sized chunks onto a cookie sheet til frozen, then you can use as needed. Not quite as good as freshly grated, but easy in a pinch.
Answer: I don't think preservation is the issue you want to worry about, it is taste.
As with most fresh vegetable matter, you should have no trouble telling if that ginger has become unwholesome. It's not like canned goods, where you have to worry about botulism. If it's bad, it will look and smell bad.
Long before it's bad, however, it will be off.
Personally, I only grate what I need. You can always grate a bit more if you're low.
If for some reason you are sitting on 250g of grated ginger due to an overenthusiastic assistant or something, I'd personally try to turn it into gingerbread within about 2 days.

How long can I keep pureed root ginger


My LEGO character's helmet keeps falling off... Is there any way to fix?

Question: My figure won't keep its helmet on and if I get it on it is very loose and will spin around.
Comment: Have you tried the helmet on another head and another helmet on that head?
Comment: Are you sure that it's a genuine LEGO figure? It would well be a lower quality bootleg.
Comment: That won't help if head and helmet belong to this particular minifig.
Answer: The best and most effective technique I've come across is to use a bit of nail varnish on the inner anti-stud of the helmet piece, as Tonk explained on his blog TonksToysBlog. Just be sure to apply a very tiny amount and give it plenty of time to dry.
Also, if it matters to you, the helmet you have pictured does not go to the figure pictured. The figure is Jay Legacy from 2019. The helmet, on the other hand, is 98133pb02 from 2012-2016.
Comment: Most likely, yes. I don't see that as being the problem but you never know.
Comment: Shouldn't the pieces be interchangeable and still fit well?
Answer:
Hmm... Looks like his character is fairly new, with it being introduced this year, Jay (Legacy).    With the relative newness of the pieces, I'm surprised the clutch strength is at issue.

Well, anyway, head over to LEGO's customer service page and fill out the request to replace your broken piece(S).  I'm emphasizing because we don't know which piece, Helmet or Head, is "jayed" up.

Part #40925pb02: Minifigure, Headgear Ninjago Wrap Type 4 with Dark Blue Headband Pattern.

Part #3626cpb1892: Minifigure, Head Dual Sided Reddish Brown Eyebrows and Freckles, Lopsided Grin / Frown Pattern (Jay) - Hollow Stud.

Request to replace broken pieces HERE.

Parting words of advise: "Sunlight is the LEGO killer": Be cautious of any of your precious pieces being exposed to direct sunlight.  The darker the piece the more warping sun heat it will absorb.  I've ruined sculptures this way, where they just fall apart after spending a month in the sun on a shelf.
Answer:
I've had the same problem with two of my new LEGO sets. However, I've managed to fix my Stormtrooper helmet by taking a small piece of a rubber band about 2 centimeters long and put it between the helmet and the head. The rubber slows the spinning and it doesn't fall off as easily.
Comment: I noticed that all of the red Sith Storm Troopers in the recent battle pack (the blue speeder one) were the same, and I opened about 8 packs.
Comment: I don't think this will solve the problem since the stormtrooper helmet has space for the rubber band but the blue Ninjago accessory doesn't look like it will have space for it.
Answer: Assuming that they came together as a set, some Lego helmets don't fit tight in order to make it "easier" to put the helmet on, and if not, might not fit correctly at all.  However, there could be an issue with the pieces itself.  Get a cotton swab and some water, DO NOT USE ALCOHOL, as it will eat at the paint, and clean out the contacts.
Comment: Hi and welcome to Bricks.SE. Cleaning the head and helmet would result in even less clutch power, wouldn't it?


Why were there 8 kings of Edom?

Question: Is there any symbolism or other explanation as to why there were specifically eight kings of Edom who ruled before any king in Yisrael did, like it says in Bereshis 36 (31-39)?
Comment: Hello rikitikitembo, and welcome to Mi Yodeya! ....I hope you don't mind that I edited your question; if I did anything you didn't like, you can always [fix it here](http://judaism.stackexchange.com/posts/45425/edit). [ _Note: I edited the tags of the question, and linked to the specific verses you referred to._ ]
Comment: The last king, Hadar, is not the same as the others: it is not mentioned that he died. Therefore, typically, this episode is referred to as the 7 primordial kings who died.
Comment: Interesting question; here's hoping you find a good answer! +1
Comment: @paquda referred where? In Chronicles it is recorded that he died.
Comment: @rikitikitembo referred to in kabbalistic literature. If you google the phrase ז' מלכין קדמאין דמיתו you'll get some sources if you want them.
Answer: Rashi on that verse brings a medrash Gen.Rabbah 83:2 that says the eight kings correspond to the first eight jewish kings. Edom came to autonomous power only during the rule of the ninth king.
Comment: Max, welcome to Mi Yodeya, and thanks very much for contributing this answer! I hope you'll look around and find other material of interest, perhaps including our 500+ other [tag:parshanut-torah-comment] questions.
Comment: Are these only kings of Judah that you count? If Saul is the 1st the 8th is Yehoram of Judah who actually reigned the same time as Yehoram of Israel. The 9th king was Ahaziah or only reigned for a short time and was wicked. And after him the even more wicked Queen Ataliah. This lets us understand the "when you feel aggrieved" clause. A wicked king in Judah and Eisav can break the chains.
Answer: At the simplest level, it's saying that when Esav chose to sell off the birthright, he had the opportunity to fast-forward history -- boom! Monarchy, nationhood, no muss no fuss. Jacob, on the other hand, had to go on an arduous journey and process of becoming a nation. Thus, "Esav had eight kings while Israel still hadn't gotten to that stage." (If you want quick and easy, Judaism's not for you.)
But this doesn't say anything about the number 8 per se.
Comment: +1, but this is the simplest level?
Answer: The first 8 kings proper of Israel and then Judah were:

Saul
David
Solomon
Rehoboam
Aviyah
Asa
Yehoshafat
Yehoram (of Judah)

The 9th king was Ahazya, the one killed by Yehu. And after that was Queen Ataliah.
The first 8 kings were all righteous, and then Ahazya and Queen Ataliah were wicked.
Remember the prophecy / blessing from Yitzchak "when you feel aggrieved, you will break the yoke.." Once the kings of Judah turned wicked, Edom could break the yoke and rebel.
This is based on Rashi's intepretation.
Answer: There is an interesting commentary that Edom had 8 kings before Israel had even one because Jacob humbled himself before Esau at the time of their reunion and called him "my Lord" (adoni) 8 times.
Comment: Welcome to Mi Yodeya Meir! Thanks for sharing the answer. Consider familiarizing yourself with the nature of the site, with this short [Beginners' Guide](http://meta.judaism.stackexchange.com/a/3887/8775). Hopefully well see you around the site. || Where did you see this commentary?

Why were there 8 kings of Edom?


Can I buy train tickets in Georgia, Tbilisi (the country) 5 hours before the departure?

Question: I am going to Tbilisi from Yerevan and I will arrive around 14:00 and want to leave to Zugdidi on the same night. The train departs on 21:45.
So I like to purchase the tickets as soon as I arrive in Tbilisi
Comment: Taking a minibus from Yerevan to Tibilisi will be faster than the train.
Comment: I heard that they'll do the charting 4-6 hours before the train departure and I can't get tickets after it but I'm not sure about that. I guess I'll have enough time to get them, thanks!
Comment: This is a great question and please report back after you've done the trip. I could not find useful information on [Caravanistan](http://caravanistan.com/georgia/), [Caravanistan forum](http://caravanistan.com/forum/viewforum.php?f=15&sid=afbdb446f24625d607fab6aca34457d0), [Seat 61](http://www.seat61.com/Caucasus.htm), [Wikivoyage](https://en.wikivoyage.org/wiki/Georgia_(country)#Get_around) nor [Wikitravel](http://wikitravel.org/en/Georgia_(country)#By_train_2).
Comment: [German Wikivoyage](https://de.wikivoyage.org/wiki/Georgien#Mobilit.C3.A4t) is fairly well-sorted and does not mention such a requirement to buy tickets far in advance but perhaps you could try to [get an online-ticket](http://tickets.railway.ge/login.aspx?lang=en-US)?
Comment: I initially answered here, but I realized it was out of scope for the question. If you'd like to know [how to get to Yerevan by minibus](http://travel.stackexchange.com/q/77116/10280), I've created a question-answer for that. The marshrutka is likely cheaper, faster, and has great scenery.
Answer: I see little sense in your worries about time limits when acquiring tickets in Georgian Railways offices. There are no essential grounds for it, moreover, tourists reported they bought tickets half an hour before the departure.
As it was kindly suggested by mts, online booking is optimal if you are not completely sure in ticket availability just-in-time. The only limitation, which exists is related exclusively to online booking:

E-Tickets are to be sold 40 days prior to date of train departure.
  E-tickets booked less than 2 hours before the departure time will not
  be processed.
Terms Of Use

Selling period starts 40 days prior to departure and ends 2 hours before. Nothing similar is known about offline selling.
The only assumption we can make is that offline selling period starts similarly as online (40 days before), but there are evidences that on-site offices start to sell tickets later than online ones (20 days before). However, this is informal info and shouldn't be treated as a rule of thumb.
The only limitation you should take into account is would you be able to board the train or not.


Nintendo's recent emulation patent: why?

Question: This particular application is all over the news today: HAND-HELD VIDEO GAME PLATFORM EMULATION
I'm approaching this out of sheer curiosity. It is my understanding that emulating other hardware is a concept that predates the internet, and Nintendo, and more to the point of this patent, emulation of Nintendo's video game consoles has been done for quite literally every console the company has ever released, by various individuals and groups.
This patent makes one claim:

A method of adapting an emulator, the method comprising: executing, on a processor, an emulator capable of running a plurality different binary applications; recognizing, by the processor, an identity of a binary application based on an inspection of the binary application; automatically adapting, by the processor, a behavior of the emulator to the binary application based on the recognized identity of the binary application; and generating, by the processor, an audio visual presentation using the adapted behavior of the emulator.

This sounds like the exact behavior of any of the programs from the second link above.
A description of any modern emulator:
It loads specially-formatted binary files, in the form of ROM images. These images contain information as to the format of the rest of the data in their headers, as well as a name that's used to trigger special behavior from the emulator, these can take the form of compatibility or speed workarounds to deal with certain code in the program being emulated. The result of this executed code is then output to a monitor and speakers.
Comment: There's an extensive discussion about this application at https://news.ycombinator.com/item?id=8672919
Comment: Just to reiterate, this is just a publication of patent application. It has yet to be examined, yet alone granted.
Answer: From that claim, it looks like they have a universal emulator that decides which console it emulates by looking at the game's binaries.
Comment: Yes, the phrases like "plurality different binary applications" "adapting...a behavior of the emulator to the binary application"


hide Office 365 - SharePoint Online files for others than creator

Question: I'm creating a Sharepoint intranet solution in my site and I want to be able to give each user a personal library/list of they're files that only they can view/edit. How is this possible in Office 365 - SharePoint Online?
Answer: Office 365 is not different from On-Premise SharePoint Sandbox Environment from a Development point of view.
So while building the solution if you build with keeping the Sandbox restrictions in mind, you will be good to go.
For your particular problem, I would look into User Permissions. Allowing only the authorized users to view/edit the list.
Here is a link to get you started with the SharePoint Client Object Model and User Permissions:
http://blogs.technet.com/b/speschka/archive/2009/11/01/using-the-sharepoint-2010-client-object-model-part-5.aspx
Comment: Thanks, I looked into User Permissions and that solved the issue. Had to break the inheritance on each folder.


How can I prevent simple syrup from crystallizing?

Question: When I store it in the refrigerator, my simple syrup always seems to crystallize.  How can I prevent this?  How long should I expect simple syrup to keep?
Comment: I think a more important question is, why is it crystallizing at all? I've had [simple syrup in my fridge for months and it didn't crystallize](http://cooking.stackexchange.com/q/5602/1601). Perhaps my fridge is colder or warmer than Katie's? Is this a 1-to-1 water-sugar recipe?
Comment: So we might be looking for data on the saturation concentration of sugar at various temperatures... something I was going to post a question about, since the syrup for my lemon sherbet crystallized slightly in the refrigerator today!
Comment: @Neil - Yes, it's a one part water to one part sugar recipe.
Comment: Agave syrup doesn't crystallize.
Comment: @Chloe Agave syrup doesn't crystallize because it's mostly fructose and glucose, roughly the same as high fructose corn syrup.
Comment: I had 2+ sugar : 1 water syrup crystallize (took a while, though - months) in the fridge, so I went whole hog on inverting (citric acid and SLOW cooking) when I refilled and dissolved what was in there - it's quite a bit different tasting, though.
Answer: There are a couple of things you can do to prevent sugar crystallising. You can add some glucose syrup, or you can 'invert' the sugar by adding some acid, namely cream of tartar. Both should be readily available, online if not at your supermarket. Cream of tartar is also useful when making meringue.
Comment: Doh! Shouldn't have followed Lebovitz's recipe so carefully - he had me add the lemon juice after chilling the syrup.
Answer: I always throw in some corn syrup when make a simple syrup.  The extra glucose adds some "chaos" to the mix and keeps the crystals from forming their structure.
I also like to add some cream of tartar to help break up the sucrose in the table sugar into its component parts of fructose and glucose.
Answer: Simply adding a few drops of lemon juice in boiling sugar solution will prevent it from crystallizing.
Comment: If you can, I'd love a bit of explanation of how this works.
Answer: When my honey crystallizes, I put it in an electric oven set to 50 degrees C for a couple of hours. Perhaps this trick would work with syrup as well since their composition is similar. Also, make sure that there are no crystals when you put it in the refrigerator, they act as seeds on which more crystals grow.
Comment: You can cook simple syrup again to remove the crystals, but it's not really effective for preventing crystallization in the first place.
Answer: I make a lot of syrup because I love pancakes and waffles.  There are a couple of things I do which I have found keep my syrup from crystallizing (this is based on personal experience and not any kind of scientific proof).
1) I only use about 3/4 the amount of sugar. My recipe calls for 2 cups but I only use 1 1/2 cups.
2) I don't boil the sugar. I boil the water, remove it from the heat, and immediately stir in the sugar. just make sure the sugar dissolves completely.
This does make the syrup thinner, but we prefer it that way.
Comment: This will surely prevent it from crystalization, because your solution is no longer supersaturated. But it will also be unusable for most recipes. It will only work as the end product (such as pouring over pancakes), but never as an ingredient in candymaking.
Answer: A scrupulously clean saucepan is important. It's possible that banging or scraping the spoon along the insides of the saucepan "seeds" the crystallization process. Also, "A seed crystal is a surface that sucrose molecules (that's the sugar) can begin to attach themselves to—it could be a few sucrose molecules stuck together, a piece of dust, or even a little air bubble." So, stirring well but not crazily is advised.
Answer: Add lemon juice, or citric acid.
You also need to clean the sides of the pot while you are boiling your syrup. The sides of the pot contained undiluted sugars, so when they touch the syrup your syrup will crystalize.
Answer: If you're adding sugar and water together, don't bring it up to a boil. Gently simmer it for a longer period of time until the sugar is completely dissolved. Also, the higher the sugar ratio, the higher the likelihood of crystals forming. From my experience, bringing it to a boil is what causes the crystallization, for whatever reason.


Travel documents needed for UK visitor Visa for wife

Question: I'm on a tier 2 general visa in the UK. I'm currently engaged and soon after my wedding, I'm planning to bring my wife along with me to the UK to stay with me for 3 weeks. She will then return to India and complete her internship and education. As we are not married yet, we do not have a marriage certificate and we will not be able to obtain one before she files for her tourist visa.
Can you please suggest the list of documents which will be required to successfully obtain her tourist visa ? Since she is a student, she is dependent on her parents for her finances.
Is it okay to write a cover letter/invitation letter from me stating that we are not applying for Tier 2 dependent visa as she has to go back to India to complete her education and will be away from the UK for around 180 days to ensure that her visitor Visa is approved ?
Comment: Hello and welcome to TSE. Looks like you have two different questions here. It would be best to ask them separately.
Answer: The UK publishes a guide to supporting documents for a visitor visa here https://www.gov.uk/government/publications/visitor-visa-guide-to-supporting-documents/guide-to-supporting-documents-visiting-the-uk
There is nothing you personally can do to 'ensure' that her visitor visa application is approved. It may help you to read How to prove that you have significant ties with family in your home country? and What details should a good cover letter contain to back up a UK Visit Visa application?
Comment: This is not a 'one-line answer'. It directs the OP to the official guidance on required documents (without repeating its contents, which makes no sense) and provides links to two questions that are relevant to the OP's question.


Power steering pulley wheel

Question: The diameter of the original power steering pump pulley wheel on my 2004 Mercedes ML 350 is approximately 110 mm. The diameter of many replacements is 130 mm. Will the original serpentine belt still fit?
Comment: I can confirm that the original belt fits and it was not too difficult to put onto the tension pulley. As long as the tension pulley provides a constant force throughout it's range of movement, it should probably be fine.
Answer: If my calculations are correct and my SWAG (silly wild @$$ guess) of how much your ML350's belt contacts the power steering pump pulley, you will need a belt which is ~15.75mm longer (or 1.5cm) than what you have now. Here is my reasoning:
This picture should represent your serpentine belt configuration:

Pulley #4 is the power steering pump. You can see the belt covers about 1/4 of the circumference. The original pulley, being 110mm in diameter has a circumference of ~345.5mm, while the newer one with a diameter of 130mm would have a circumference of ~408.4mm. The difference is ~62.9mm. 1/4 of that (distance the belt actually rides on the pulley) is ~15.725mm.
The reason why you'll need to get a longer belt in the first place is that the belt tensioner is designed to operate in a given arc. If your belt is too short (as would be your original), the tensioner will be too tight and will wear out sooner. This also puts more stress on all other pulley components which the belt rides on. If the belt is too long, the tensioner will not provide enough tension and will allow the belt to slip across the accessory pulleys. Does this absolutely mean your current belt will not work? By all means no: it probably would work. In your case, you will probably be wearing out expensive components much faster than would be normal.
I'm not sure on your MB, but most tensioner pulleys have an indicator on them which shows belt health. It might have a pointer which, when the belt is appropriately installed, show you if it is in it's proper range. If it does not have one of these (which I'm not seeing in the pictures I've just looked at), you can scribe your own line across the two portions of the tensioner pulley (base where it attaches to the engine and arm which has the pulley on it). When you install the new belt, the two lines should be very close to lining up, if not completely, when everything is put back together. If you are doing this work yourself, it appears you'll need a retaining pin to hold the tensioner pulley in place, as seen in this picture from RockAuto.com:

Power steering pulley wheel


Calculating the total energy of a signal

Question: I have a vector of signals and need to calculate the total energy. I have read somewhere that you can do this by summing up the entire vector and then finding the absolute value of the result. Is this correct? Could anyone suggest any tutorials, or, equations if this is the wrong method, thanks.
Answer: The energy of a discrete-time signal is the sum of the squares:
$$
E_x = \sum_n |x[n]|^2
$$
If you need the average power of your signal, divide the energy by the number of samples in your vector. Power is the average energy per sample of your signal.
If your signal vector is a sample of a stationary process (i.e. a recording clip of someone talking), then average power probably has more meaning than energy (which will grow with the sample length).
Comment: But my data samples aren't in blocks.. Say I have.. v1 = {128, 128, 127, 126} I sum up all the elements and then square them?
Comment: In matlab style: energy = sum( x.^2 ); square each element and then add.
Comment: @Jusancho I get it now, so rather than squaring the sum of elements, you square each of the elements and then add? So e,g, x = {128, 128, 127, 126} x^2 = {16384, .., ..,} and then sum(x^2)? Thanks
Comment: Where does this formula come from? (what is the source?)