Solve Windows 10 / 8 Installation: Setup was unable to create a new system partition or locate an existing system partition

Hi again people,

this past weekend I had some problems when installing Windows 10 from an USB Drive instead of a traditional DVD in an old Laptop (> 8 years).

So I created the media installation device from another Win installation and when I boot it everything worked fine until I tried to create the partition to install the system, at that point the installation software showed me an error: “Setup was unable to create a new system partition or locate an existing system partition“.

After some hours I was able to do it with some patience and BIOS tries, this was the thing I did by searching on the Internet:

  • Changing the USB port in the partition selection screen, then press ‘refresh’ button and try. (It didn’t work for me).
  • Accesing CMD pressing Shift+F10 (It didn’t work for me):
    • Once in shell type ‘DISKPART’
    • Type ‘list disk’
    • Check the number of the disk where you want to install Windows and type ‘select disk *’ (where * is the number of your selected disk).
    • Type ‘clean’ (this will erase you disk).
    • Type ‘create partition primary’
    • Try to install, if it doesn’t make the same steps and continue with the new ones.
    • Type ‘active’
    • after clean, type ‘format fs=ntfs quick’
    • Type ‘assign’
    • Exit the screen and try to install Windows.
  • Change SATA options from AHCI to IDE. (It didn’t work for me).
  • Change boot order of devices in BIOS, making your future Windows HDD the first option, save and restart, open BIOS again and launch USB from there. (It didn’t work for me).

While these settings may not work for me directly, maybe they affect the process of the final solution so please at least make sure you did the ACHI to IDE and Boot order options mentioned above.

Then, make sure you have enabled Legacy boot from BIOS and UEFI boot, and boot the USB device in  UEFI mode, in my BIOS settings that option was showed in the save settings screen after enabling UEFI bootin Boot options. This trick was the final solution for me which allowed me to enjoy the new version of Windows in my old laptop.

I hope this help some lost people as I was yesterday haha.

Enjoy your new Windows!

 

 

 

Unity rotation

How to rotate an object around its center in Unity

Unity and me

Hi to all. Today I add a new technology which one I have been working the last year. It’s Unity, a game engine that can make it quite easier to develop a common game, but at the same time Unity offers you a lot of powerful tools to enable you make more complex projects. Yooka-Laylee by Platonic Games is the most recent exaple of a big, famous and mainstream game done using this engine.

Actually I’m using the engine to create augmented reality applications for the company where I’m working at, ANSWARETECH. And while using it I’ve been getting stressed with many problems that I’ll be commenting in different posts.

Rotating the object

Ok, I’ll not extend more your wait. I was trying a way to rotate a 3D Obj that I’ve loaded dinamically from the Web using Simple .OBJ asset to a Vuforia Trackable Object in order to be able to display it in augmented reality over a marker.

After getting it I decided that it would be good if we could add some functionality to the GameObject so I started to add transformation buttons: scale+, scale-, rotateX, rotateY (sorry, not rotateZ).

But I found some problems in the results of the rotate functions. So  after trying some alternatives and playing with Transform.Rotate, Transform.RotateAround, Transform.rotation (Quaternions), I had the idea of using an empty GameObject as parent of my OBJ and position it on its center, this way I could rotate parent easily and avoid anchor problems of my not 0,0,0 located 3d model.

So I finally did it with the following code:

using UnityEngine;
using System.Collections;

// ...

public static class Load3D {

// ...

    public void loadModel() {
    // ... In my 3D loading function

        model.transform.parent = marker.transform; //model is my OBJ model. Marker is the Vuforia thing

        model.transform.rotation = new Quaternion(0,0,0,0); //Resets rotation after adding it to parent

        Vector3 objCenter = model.GetComponent<Renderer>().bounds.center;

        GameObject container = new GameObject(); //new blank parent for my model.

        container.transform.parent = marker.transform;

        container.transform.rotation = new Quaternion(0,0,0,0);

        container.transform.Position = objCenter;

        model.transform.parent = container.transform;
}

    public void RotateMyModel() {
        // ... In my rotation functionality
        model.transform.parent.Rotate(Vector.up * 90);
        //or
        model.transform.parent.Rotate(Vector.right * 90);
        //or
        model.transform.parent.Rotate(Vector.forward * 90);
    }
}

 

Well, and that’s all 🙂

I hope it helps someone and avoid some headaches.

Have a nice coding day!

 

Filter A HTML string for title and meta tags

This week I’ve worked in a little project where I need to get a website title and meta description to autofill the site details on a user’s favourite sites.

To achieve this, my site makes an HTTP request to a URL like “http://google.com” and return to the browser that site’s full HTML code which I filter to get the title and description.

I think it’s an useful script so I decided to share how I filtered the code, so here it is.

//////
// 'response' is the HTTP request result and 'content' 
// is the attribute containing the HTML code
//////

//If you wanna find the title:

results.content.match(/<title[^>]*>([^<]+)<\/title>/)[1]


//If you wanna find the meta tag which contains site description: (jQuery)

$(results.content).filter('meta[name="description"]').attr("content")
$(results.content).filter('meta[name="Description"]').attr("content")


Hope it helps someone! =)

The basic and fast guide for using Git

Happy new year you all! Have you thought about your new aims of 2016? One of mine is trying to write a post each 2 weeks, so let’s start with it!

In this post I will show the basic workflow and commands that anyone should know when using Git in their projects.

Beggining

Git is a version control software which help us adding “checkpoints” to our code for letting us recover the code if we save a code with mistakes. This functionality will help us in other tasks of a coder’s life like teamworking or testing new software features. Let’s see.

Git is commonly used as a command line tool but there is a lot of softwares with a GUI which can make the use of the version control much easier. We will use the command line tool.

When you are working with git you must initialize a git repository of your software, for doing this you should navigate to the root directory of your project and run:

$ git init

Once the repository is ready you could create a file containing the information about which directories should not be included, this file must be named as .gitignore and you can create it following the official guide.

Now is the time to add files to your repository, git offers a simple command for this: add. Using it you can add single files manually or add all files recursively using add . or add -A. So we are going to add any file in our project ( we’re not including files ignored in .gitignore) using:

$ git add .

(There are some commands for adding multiple files at once you could know the main differences in this stackoverflow question)

You will see in the terminal output which files have been added.

When we have all our files added we can save the state of this files in a checkpoint commiting them. For this we must use the commit command and we will add a message to this commit which will allow us difference it from others and know what files where modified and why.

$ git commit

We will be asked for adding the commit message and when you are ready just finish the commit. When commiting we can use the “-m” flag for adding fast message like:

$ git commit -m "Fix infinite loop error on loop.js"

It is highly recommended for any develop to follow good practices when writing commit messages. Use a standard will allow others using the same repository (when participating in a team you will use a common remote repository) identify why the code was commited. Here you have a funny guide explaining why commit messages are so important and some good practices.

Branches

A branch is a way to “freeze” your actual code in a point you want and start working in another feature or problem at the time that you are able to change to your frozen code. The frozen code here act as the base of the new code and you can create as many branches as you want from a same base. Using this you can work in different tasks in your code separately and organize your code easily. Branches can be created easily and can be easily removed too so it’s just a basic and great tool to use and, as any basic tool, you must understand how to work with it.

To manage and naveigate between branches there are two commands to know: branch and checkout.

Git branch

With this command you can create, rename and delete branches. Let’s see how to do it.

To add a new branch you can use:

$ git branch <name>

$ git branch bugfix

To rename a branch you must be in that branch and type

$ git branch <new_name>

To delete a branch just run:

$ git branch -d <branch_name>

This will show an alert if there are changes in your code which are not registered so if you want remove it fully without saving changes you can force it using:

$ git branch -D <branch_name>

Git checkout

With checkout you can navigate between branches and even create them.

For navigating you should run checkout with the name of the branch you want to navigate to:

$ git checkout <branch_name>

$ git checkout bugfix

You can create and navigate and create a new branch at the same time using:

$ git checkout -b <branch_name>

If that branch  already exists you will stay in the same branch you were and an alert message will be shwon in the terminal. You can force resetting a branch to your actual branch and moving to it using

$ git checkout -B <branch_name>

Git merge

When you have finish your task in a branch and want to update master (main branch) with it content you must use merge. Merge will mix the code of both branches automatically and if a conflict appears you will be warned in the terminal log and you will need to modify that files solve the conflicts and commit the fixed code.

To merge a branch you must move to the branch you want to merge to (if you want to update master to reflect bugfix you should checkout to master) and run merge:

$ git checkout master

$ git merge bugfix

With this you are ready to use Git locally with its basic use, in a next post I will explain how to use it remotely and some commands useful in team work.

Have a nice year and good luck!

Map and Reduce functions in JavaScript

Hi everyone, today I’m going to explain how to use two of the greatest functions to work with arrays in JavaScript: reduce and map. So let’s go to the example.

Array.prototype.map (callback [, thisArg])

Map is a function that allow us creating a new array result of operate with other array elements. The resulting array will have the same length as the original array.

The callback function has 3 args:

  • The current element in the array.
  • The index of the current element.
  • The full original array.

You can use thisArg to indicate which object will be used when you call this keyword in callback function.

Know this will allow us write a short example to show you how to use it:

 


var arr = [{a:5, b:2}, {a:7, b:1}, {a:2, b:7}, {a:12, b:6}];

var subtraction = arr.map(function( element, index, array) {
     return element.a - element.b;
});

console.log(subtraction); // Will show an array with [3, 6, -5, 6]

As you can see this array will have the same length as the original array used for map and the elements contained are the results from the return of callback function. Really simple and useful!

 

Array.prototype.reduce(callback [, initValue])

Reduce is a function which return a value after operating with all elements in an inputted array.

The callback function has 4 args:

  • Previous value
  • Actual value
  • The index of actual value
  • The full original array

You can use initValue arg to indicate which will be the first value of Previous value if no value is used then, in the first loop, Previous value will take the value of the first element of the original array, and Actual value will take the value of the second element. If initValue is used then the first loop will use it as Previous value and the first element of the array will be used as Actual value. The return value of this function can be any variable you want: a string, a number, an array, an object… You decide!

Let’s see an example,  this time we will generate an object counting the times that each character appears in a string:


var str = "Hello, this is just a reduce test!";
var strArr = str.split("");

var charCount = strArr.reduce(function( previousValue, actualValue, index, array) {
    if(previousValue[actualValue]){ 
      previousValue[actualValue]++; //if actual value has appeared in previous iterations just increase its value in our object
    } else { previousValue[actualValue] = 1; // else if it hasn't appeared yet just start count with "1" 
}
    return previousValue; //return previousValue for using it as previousValue in the next iteration 
}, {});  //We use an empty object as initialValue

console.log(charCount); // Will show in console something like "Object { H: 1, e: 4, l: 2, o: 1, ,: 1,  : 6, t: 4, h: 1, i: 2, s: 4, 7 more… }"

What a magic experience!

With this short post I hope you have understood correctly how this great functions work and now it only depends on what you do and how you use it in your awesome applications.

See you in future posts!