TwitterFacebook

Android Studio – tools and features – part 007

If you try to update your old Android Studio to Android Studio 1.2 RC 2 you may got this error:
The following SDK components were not installed: …
Most commons errors are for this components:
extra-android-m2repository,tools,addon-google_apis-google-21,android-21,sys-img-x86-addon-google_apis-google-21,source-21,extra-google-m2repository…
After this error the process of installation it’s stopped running.
To fix this you need to take a look to this path : …\AppData\Local\Android\sdk1
Start the : SDK Manager.exe application to update all your SDK components…
…or try to run android.bat command from tools folder : tools\android.bat update sdk –no-ui
After that the installation / update of Android Studio will be like in the next images.
android
android2
Then make all settings
android3

Android Studio – tools and features – part 006

You can quickly filter through commands by using the Find Actions shortcut.
That can be show you with : Ctrl+Shift+A keys and you will see the next dialog like into the next picture.
android-adb-key

Using facepy to deal with facebook – part 001.

This python module allow you to get some data from facebook using Facebook’s Graph API.
The development team told us:
Facepy can do more than reading your latest posts and posting photographs of parrots, but you’ll have to read the documentation to find out how.
You can use pip to install this module ( pip2.7 or pip3.4):

pip install facepy
The python script is simple :
...\Python34>cd Scripts
Scripts>pip3.4.exe install facepy

Now you can test this with this simple script:

C:\Python34>python.exe
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import facepy
>>> from facepy import *
>>> from facepy import GraphAPI
>>> graph = GraphAPI('.....my...token.....'
)
>>> graph.get('me')
{'gender': .....................................
......................'}

Make low poly fir tree with Blender 3D.

This will be the final result of this tutorial, I hope you will find this helpful.
fir-tree-output
First, open and save the scene with the name fir-tree or named it with your file name project.
The next step is to remove the default cube with Delete key or X key and press Enter key to remove it.
Press Shift + A keys and select from Mesh – Cylinder.
The see if you have the this Panel in the left of the screen. If is not just press T key to make it visible ( working like on / off swich). Change the number of the vertices to 8, see the next image:
treelow-001
Now will need to have a Front Orto view, so press key 1 and 5 from Numpad ( you need to have Num Lk on).
Press G+Z keys and move the cylinder up to red line ( this means the cylinder it’s under x-y 0,0 horizontal plane).
Press Tab key – this will allow you to edit this object. Press A to deselect the vertices and Z – this allow you to select the back size with vertices.
Select with B key the bottom of this cylinder and press G + Z . Move this selection to make the height of leaf litter.
treelow-002
Press S and scale this selection to make the top of the tree.
Press Ctr+R and after press 5 to make 5 sections – press Enter key or left mouse button. Then press A key to deselect this.
For each section of the tree will make same changes.
First , move the mouse on the first area of the top selection and press Ctr+R – will see another color line , move this to the bottom and press Enter key – the limit will be the top of the next section. Press S key and scale this selection.
See the next screenshot:
treelow-003
After we make this changes for all sections will go to the next step.
This is a bit difficult. You need to select with Alt key and right mouse button and then with Shift key – this will make the old selection – all this rings , see the next image:
treelow-004
With this selections press G and Z key and move to the bottom like in the next image:
treelow-005
Press Z key and Tab key to go to the Object Mode. Click on the material and press New button.
treelow-006
Press on Diffuse material , and select green color and darkness like this:
treelow-007
The last step is to make the the tree’s trunk.
Add one new cylinder , scale it , move it under the first cylinder. Make one brown material for tree’s trunk.
Select Camera position to see the tree when press the 0 key from NumPad and press F12 key to render it.
You can also try to change the subject. You will gain the skill and accuracy with time.

LINQ and LinkPad – part 001.

LINQ stands for Language Integrated Query and enadbles us to query any type of data store, like SQL Server , XML documents, Objects in memory etc.
You don’t need to know the syntax specific to data source because LINQ enables us to work with different data source.
The great goal is that it provides intellisense and compile time error checking.
If we development one application and this working with databases , xml documents and / or in memory objects then we can use LINQ.
LINQ query can be using any .NET supported programmiing language, because LINQ component between the LINQ query and the data source.
LinqPad tool can be downloaded for free from here.Now I help you to learn , write and test LINQ.
Today I will try to use C# with LinqPad.
LinqPad help you to under C# to make it converted to Intermediate Language (IL) which is also known as Microsoft Intermediate Language or Common Intermediate Language.
LinqPad
If you try to use LinqPad without source code then the oonly error under C# will come into C#Statement : ; expected
Press F4 button then press Add button (Query Properties ) and type WindowsBase.dll (Add Custom Assembly References – window) then press Ok button.
LinqPad
Let’s test all. Wrote this example and under Results tab click under IL.

Example 1
C# Expression

DateTime.Now.ToString("dd-MMM-yyyy")

Result IL

IL_0000:  call        System.DateTime.get_Now
IL_0005:  stloc.0     // CS$0$0000
IL_0006:  ldloca.s    00 // CS$0$0000
IL_0008:  ldstr       "dd-MMM-yyyy"
IL_000D:  call        System.DateTime.ToString
IL_0012:  call        LINQPad.Extensions.Dump
IL_0017:  pop         
IL_0018:  ret   

Example 2
C# Statement

int[] numbers =  {1,2,3,4,5};
var result = from n in numbers
	where n >  0
	select n;
result.Dump();

Result IL:

IL_0018:  brtrue.s    IL_002B
IL_001A:  ldnull      
IL_001B:  ldftn       b__0
IL_0021:  newobj      System.Func
...

this can a little dizzy for you but will come with future details.

Example 3
C# Program

static void IterationExample()
	  {
	      int i = 0;
	      while (i < 5)
	      {
	          i++;
	      }
	  }

Results IL :

IterationExample:
IL_0000:  ldc.i4.0    
IL_0001:  stloc.0     // i
IL_0002:  br.s        IL_0008
IL_0004:  ldloc.0     // i
IL_0005:  ldc.i4.1    
IL_0006:  add         
IL_0007:  stloc.0     // i
IL_0008:  ldloc.0     // i
IL_0009:  ldc.i4.5    
IL_000A:  blt.s       IL_0004
IL_000C:  ret

This examples will show us the results over IL.
Using LinqPad with assemblies .NET .
Under C# the most simple DLL example can be:

using System;

public class Test
{
	public static void Test()
	{
		Console.WriteLine("tutorial LinqPad -001");
	}

}

If we wrote into LinqPad under C# Statement and then run it.

Console.WriteLine(“tutorial LinqPad -001″);
… the result will be :

IL_0000:  ldstr       "tutorial LinqPad -001"
IL_0005:  call        System.Console.WriteLine
IL_000A:  ret

The next step is to create one new file into our C# project named Test.dll with this source code:

.assembly Test {}
.assembly extern mscorlib {}
.class public Test extends [mscorlib]System.Object {
	.method public static void TestMethod() cil managed {
	ldstr       "tutorial LinqPad -001"
	call        void [mscorlib]System.Console::WriteLine(string)
	ret         

	}
}

If you parse this code you will see under call I need to add this :

.assembly Test {}
.assembly extern mscorlib {}
.class public Test extends [mscorlib]System.Object {
	.method public static void TestMethod() cil managed {
void [mscorlib]   ::   (string)
	}
}

This is just one simple example about LinqPad.This software it’s very good when working with SQL , ASP , data , arrays.
To make the DLL file you need this : ilasm.exe
Run the command under cmd.exe:

C:\C#>C:\Windows\Microsoft.NET\Framework64\v2.0.50727\ilasm.exe /DLL /OUT:Test.dll Test.il

The result will be: Test.dll .
Let test it:
Make another file with notepad , named DllTest.cs and put this source code:

using System;
class MainClass
{
	static void Main()
	{
	Test.TestMethod();
	}
}

Use cmd.exe to complile this into exe file format :

C:\C#>C:\Windows\Microsoft.NET\Framework64\v2.0.50727\csc.exe /r:Test.dll DllTest.cs

If you run this using cmd.exe the the output will be:

C:\C#>DllTest.exe
tutorial LinkPad -001