Showing posts with label and. Show all posts
Showing posts with label and. Show all posts

Friday, May 8, 2015

How To Rotate An Object in Inkscape Free Rotate Specific Degrees and 90 Degree Increments

Free Rotate An Object

Select the Object that you wish to Rotate

8 Black Arrows will appear around the Object when it is selected. These are Resizing Handles.

Clicking on the Object again will change the Resizing Handles to Rotation and Skew Arrows

The Rotation Arrows are at the 4 Corners of the Object. Move the cursor over any one of them, hold the mouse button down, and turn the mouse in a Clockwise or Counter-clockwise direction to Free Rotate.

Rotate Object To A Specified Degree




Go to the Menu Bar and select Object > Transform




















This will open the Transform Window which has 5 Tabs, namely Move, Scale, Rotate, Skew, and Matrix.  


Select the Rotate Tab.

Where you see Angle, you will type in the Degrees you would like the Object to be Rotated.

Keep in mind that to Rotate the Object Clockwise, you will have to enter a Negative Number (e.g. -30). 

To Rotate the Object Counter-clockwise you will have to enter a Positive Number (e.g. 30). Click on the Apply Button when finished.

Rotate Object in 90 Degree Increments

Select the Object you wish to Rotate

Go to the Menu Bar and select Object > Rotate 90 Deg CW.


























This will move your Object forward in a Clockwise Direction at 90 Degree Increments each time you use it.

 


To Rotate in a Counter-clockwise Direction go to Object > Rotate 90 Deg CCW

























This will move your Object backward in a Counter-clockwise Direction at 90 Degree Increments each time you use it.

  

 
Read more »

Wednesday, February 18, 2015

The all new iPhone6 and iPhone6

The iPhone 6 features you probably missed

Beyond the borked keynote live cast, frustrating pre-order process and Android cult members saying iPhone 6 is like the Nexus 4, Apples thinner, lighter, faster and larger iPhone model is here, confirming almost every credible expectation listed here and here. Heres this weeks collection of little-known iPhone 6 facts.

    

Notice the power button

Did you notice Apple moved the power button in iPhone 6? This has always sat at the right on top the phone, but has now been moved to the top on the right side of the device.

Phase detection

These are the first phones in the world to be equipped with phase detection autofocusing, so youre going to get pro-quality automatic focusing while shooting videos or taking a picture. No other smartphone has this.

Focus Pixels

Focus Pixel improves exposure control in the 8-megapixel camera twice as fast as the iPhone 5S. Optical (previously digital) image stabilization, the capacity to shoot Full HD video at up to 60fps, 240fps slow motion (with 3x zoom) and a larger f2.2 aperture allows in up to 81% more light for better quality snaps.

Dual-domain

Apple has used dual-domain pixels inside the very bright (500cd/m2) displays on the new iPhones, so you can expect much better viewing angles even in uneven lighting conditions -- though black tones may seem slightly purple if the pixels are incorrectly arranged, so well see how that goes in manufacturing.

Much faster LTE/4G

Apple has radically improved the 4G/LTE support in this model. The iPhone 6 is capable of 4G download speds up to 150Mbps and will handle HD voice calling over 4G (which carriers want to turn us all onto). And it supports 20 LTE bands -- more than anyone else right now.

Wi-Fi wonder

Wi-Fi support is far, far better. You can look forward to Wi-Fi speeds up to three times faster than was possible on the previous generation iPhone thanks to its support for 802.11ac. This report explains why this matters. Support for VoLTE is a big deal.

Siri is aware

Apple has tweaked iPhones intelligent voice assistant, Siri; you no longer need to press the home button to call up the voice assistant, you only need to say "Hey Siri" and it activates for you.
Read more »

Tuesday, February 17, 2015

Pros and Cons of Interviewing Bloggers on your Blog



Pros and Cons of Interviewing Bloggers on your Blog

For some people bloggingis a way of life; they like producing content that stimulates conversation while also informing readers about a particular topic. In order to stay motivated, a blogger must get traffic by producing quality content and practicing tried and true techniques. One of these techniques is to interview another blogger or an individual who has authority in the same niche as you to provide a different perspective to your readers, which adds value. While this technique is effective, there are also some costs that go along with it. This article will go over the benefits and costs of interviewing bloggers for your blog.

Also Read: How to Choose the Right Theme for Your Blog?
Also Read: The 3 Basic Things You Should Know Before Creating a Blog to Become a Successful Blogger

Pros
As stated previously, one of the main benefits in interviewing bloggers for your blog is that your readers get to hear a different voice than the one theyre used to. While you’re the one asking the questions, the bulk of the content will be transcribed in the voice of the interviewee. This gives your audience real insight into what a person is thinking and allows them formulate opinions based on how another thinks, not just you. The immediate benefit to this is that your readers will feel like your blog is a place of discussion and exploration rather than a dictatorship ran by a person behind a computer.

Another benefit of interviewing bloggers on your blog is that you get real-life contact with the person if it’s a face-to-face interview. If start corresponding with other bloggers in your niche and become friendly, these good feelings go to a different level once you meet and chat about the issues. What this does overtime is allow your name and blog pop up in that person’s mind whenever they encounter something dealing with your topic, giving you a great lead source.

Cons
As with most things that produces a benefit, there is a cost to it. One of the costs of interviewing bloggers to your blog is that you may simply be a poor interviewer. Having good interviewing skills is different than knowing about a topic. So if you have poor interviewing skills and your readers discover this it will bring down some of your authority. If a person can’t ask the right questions to a person, will they be able to ask the right questions about a topic? This line of thought can lose your readers. 

Also Read: How to Find the Websites or Blogs that are Copying your Content? 
Also Read: The Top 10 Websites to create free Logo for your Blog

Another cost to interviewing bloggers on your blog is that you can ruffle some feathers with your peers. In order to get traffic, one must network with others so that they can exchange links, guest posts, and other things. If you interview a person and it turns out that you have an agenda or that your lines of questions go into unpleasant territory, knowingly or unknowingly, then you can lose the trust--or worse respect--of that individual. Being able to gracefully navigate a variety of topics and issues is a requirement for interviewing.

Conclusion
While there are benefits and costs to interviewing bloggers on your blog, the former outweigh the latter. You can’t be scared of what might happen and forego the benefits that could happen.

Author Bio:
This is a guest post written by Tarun Jaitely, He is a blogger and writes about Make Money Online, Blogging, SEO, Reviews. He recommends you to check out his latest review about sensational wordpresstheme from MyThemeShopon his blog. 
Read more »

Monday, February 16, 2015

Turbo C for Windows XP How to Download and Install

Hello friends, after enjoying the festival of diwali I am back again to write something for you. Many visitors asked me that from where they can download turbo c++ for windows xp. So i thought that i should do something to help them. In this post i am giving you the link to download the compiler and step by step guide to install it.

Turbo C++ for Windows XP - How to Download and Install

- Click Here to Download Turbo C++ for Windows XP -


Also Read: Download Turbo C++ for Windows 8 for Free
Also Read: Download Borland C++ Compiler For Free

How to Install Turbo C++ for Windows Xp

1. First of all download the compiler from the link given above.
2. Now extract the zip file and than open TC3SETUP.
3. After that click on Unzip. You can also change the path where you want to install it.
4. By default it is installed in C:TC.
5. You have done!! Please share and like it.
Read more »

Sunday, February 15, 2015

Embedding BI Call username password and dashboard parameters from CDE dashobard URL using iframe tags

A small workout on Embedding BI using Pentaho CDE dashboards..

Version Specific :
BA server : 5.1.0 stable CE
C-Tools : CDE,CDA,CDF of latest TRUNK version (after 14.x)

Steps :
1) Open your dashboard in new window to generate the URL
2) For instance the URL is some thing similar as shown below

URL when you open in new window
http://localhost:8085/pentaho/api/repos/:public:Explore:CDEExploring:Test:passParametersFromURL.wcdf/generatedContent

URL after adding BA Server Username and Password as parameters
http://localhost:8085/pentaho/api/repos/:public:Explore:CDEExploring:Test:passParametersFromURL.wcdf/generatedContent?userid=admin&password=password

URL after adding Dashboard parameters along with BA server credentials as parameters

http://localhost:8085/pentaho/api/repos/:public:Explore:CDEExploring:Test:passParametersFromURL.wcdf/generatedContent?userid=admin&password=password&param1_deptId=100&param2_Date=01/04/2014

Here you need to take custom parameters instead of Simple parameters.
i.e.,
For example :
param1_deptId is the custom parameter and in the java script area you need to write below code
function sendParam(){
   
       return  Dashboards.getQueryParameter("param1_deptId");
   
}


In another case of passing parameter like date type

param2_Date is the custom parameter and in the java script area you need to write below code
function sendParam(){
   
       return  Dashboards.getQueryParameter("param2_Date");
   
}


You need to add these parameters to your chart and query
For chart : 
Parameters : param1_deptId,param2_Date
Listners : param1_deptId,param2_Date
For query :
Parameters: param1_deptId (String Type) 
                     param2_Date(String Type)   

Sample Query in Oracle SQL where clause for the above scenario :
where 
to_char(column1_deptId)=${param1_deptId}
AND
to_char(column2_date(+),mm/dd/yyyy) =${param2_Date}

note that in the above clause (+) indicates in right outer join Oracle 10g

NOTE: You can pass multiple general parameters by adding &paramName=value in the URL


3) Copy paste the URL in the web browser and test.. You will find the dashboard output directly.

Imp Note : 
URL passing mechanism in BA server 5 is slightly differ from previous versions.
As suggested in jira for pentaho 5 server, you need to modify applicationContext-spring-security.xml under pentaho-solutions/system

Change 1 : at line 22 


Original Code :
/api/**=securityContextHolderAwareRequestFilterForWS,httpSessionPentahoSessionContextIntegrationFilter,httpSessionContextIntegrationFilter,basicProcessingFilter,anonymousProcessingFilter,exceptionTranslationFilterForWS,filterInvocationInterceptorForWS
Replace the Original Code with :

/api/**=securityContextHolderAwareRequestFilterForWS,httpSessionPentahoSessionContextIntegrationFilter,httpSessionContextIntegrationFilter,requestParameterProcessingFilter,basicProcessingFilter,anonymousProcessingFilter,exceptionTranslationFilterForWS,filterInvocationInterceptorForWS

Change 2 : at line 23  
Original Code :

/plugin/**=securityContextHolderAwareRequestFilterForWS,httpSessionPentahoSessionContextIntegrationFilter,httpSessionContextIntegrationFilter,basicProcessingFilter,anonymousProcessingFilter,exceptionTranslationFilterForWS,filterInvocationInterceptorForWS
Replace the Original Code with :

 plugin/**=securityContextHolderAwareRequestFilterForWS,httpSessionPentahoSessionContextIntegrationFilter,httpSessionContextIntegrationFilter,requestParameterProcessingFilter,basicProcessingFilter,anonymousProcessingFilter,exceptionTranslationFilterForWS,filterInvocationInterceptorForWS

Once you done the changes , you need to restart the BA server.

Using iframetags :

<iframe src="DashboardURLwithParameters"></iframe>

References : 
1) http://pedroalves-bi.blogspot.in/2013/08/embedded-analytics-in-pentaho-with.html

2) http://forums.pentaho.com/showthread.php?157329-Authentication-for-CDE-Dashboard

3)http://jira.pentaho.com/browse/BISERVER-10708

4)http://forums.pentaho.com/showthread.php?146325-How-to-link-a-CDE-dashboard-to-another-CDE-dashboard-by-passing-parameters&p=358865#post358865


Thank you for reading this article and if you have any queries and/or suggestions drop your comments....

Read more »

Saturday, February 14, 2015

Remove Watermark from WowSlider 4 x and latest version




Hello Users my name is HarryBest and today im telling you the way to remove watermark from wowslider very easily. You can also remove the watermark from wowslider by just follow these steps:

Step 1: Install your WowSlider 4.x software from here: Download

Step 2: After installing WowSlider create you project and publish it

Step 3: After publishing your project open your project folder and find "wowslider.js" locate at "engine1 folder" (or "your publish project folder/engine1/ ) and open it with Notepad and press "Ctrl+F" and search this code
"{return false}).show().appendTo" and change show to hide like this "{return false}).hide().appendTo" and save it by pressing "Ctrl+S" and open your project.

For example:
change show to hide
Just convert show to hide and save it by pressing Ctrl+S

Step 4: The Last one Step is Copy your real images and paste them into your
"your publish project folder/data1/images"

For example
This is real image

This is your image in your publish project folder
Step 5: Open your publish project and Congratulation you have did it
Any complain, just comment i will give you reply in 3 to 4 hour Thnx Users.....!

Still Problem occur: Watch Video Tutorial
Read more »

Friday, February 13, 2015

Reading ERS ASAR Data and Creating Quicklooks

In this previous post it was described how gdal reads Radarsat SAR data. I want to read ERS /ASAR data and create quicklooks for each file.

ERS /ASAR data has different formats, files ending with *.001 , *.E1, *.E2 or *. N1  Gdal can read all these formats, also the *.001 files which not all software reads. For the latter, the "DAT_01.001" is the file to be passed to gdal.

As first step, I create a list containing all files with these endings. I use os.walk to recursively search through all folders:

filelist_CEOS = []
for root, dirnames, filenames in os.walk(Z:\ERS_Envisat_SAR\Arctic\2005):
for filename in fnmatch.filter(filenames, DAT_01.001):
filelist_CEOS.append(os.path.join(root, filename))

filelist_E1E2 = []
for root, dirnames, filenames in os.walk(Z:\ERS_Envisat_SAR\Arctic\2005):
for filename in fnmatch.filter(filenames, *.E1):
filelist_E1E2.append(os.path.join(root, filename))
for root, dirnames, filenames in os.walk(Z:\ERS_Envisat_SAR\Arctic\2005):
for filename in fnmatch.filter(filenames, *.E2):
filelist_E1E2.append(os.path.join(root, filename))
for root, dirnames, filenames in os.walk(Z:\ERS_Envisat_SAR\Arctic\2005):
for filename in fnmatch.filter(filenames, *.N1):
filelist_E1E2.append(os.path.join(root, filename))

gdalwarp is able to read all of this formats and I can proceed to process all the files from this filelist, calling gdalwarp from within a Python script. This map-projects the raw SAR file and creates a GeoTIFF:


os.system(gdalwarp -tps  -t_srs EPSG:32633  + file_from_filelist +   + outputfilename )  


For a small quicklook a convert it to jpeg and make it smaller:
os.system(gdal_translate -of JPEG -ot byte -outsize 20% 20% -scale 0 1000 0 255  + outputfilename +   + browseimage )

The whole script reading in all ERS /ASAR images and creating a quicklook can be found here and is hopefully documented well enough.


Read more »

Tuesday, February 10, 2015

Reading Raster Data with Python and gdal

I am trying to learn Python for Geoprocessing. Here are some very basic notes on "playing" with Python/gdal/ogr. The online documentation is, I must say, rather confusing, so I try it step by step at the command line as below.

I follow the very useful lecture notes at http://www.gis.usu.edu/~chrisg/python/2009/ and the tutorial at http://www.gdal.org/gdal_tutorial.html

Importing both gdal and gdalconst; just "import gdalconst" does not work (and I dont understand why right now...):

    >>> import gdal
    >>> from gdalconst import *


Defining the filename (assuming its located in the current working directory of python -- use os.getced and os.chdir):

    >>> filename = ERS1PRI_19920430o04133tr481fr1989_AppOrb_Calib_Spk_SarsimTC_LinDB.tif

Now the file can be opened, the driver only needs to be imported for write-access if I understand correctly:

    >>> dataset = gdal.Open(filename, GA_ReadOnly)

Typing "dataset" shows the pointer to the opened file:

    >>> dataset
    <osgeo.gdal.Dataset; proxy of <Swig Object of type GDALDatasetShadow * at 0x0000000003550EA0> >
>>>


Various information can be retrieved from the opened file:

    >>> cols = dataset.RasterXSize
    >>> rows = dataset.RasterYSize
    >>> bands = dataset.RasterCount
    >>> driver = dataset.GetDriver().LongName

    >>> cols
    7257
    >>> rows
    7226
    >>> bands
    1
    >>>driver

    GeoTIFF
    >>>

Geoinformation can be retrieved with GetGeoTransform().

>>> geotransform = dataset.GetGeoTransform()

The variable "geotransform" now contains a list with Geoinformation:

    >>> geotransform
    (368745.92379062285, 20.0, 0.0, 8828671.611738198, 0.0, -20.0) 


The answer to what these values mean are found in the documentation:

    adfGeoTransform[0] /* top left x */
    adfGeoTransform[1] /* w-e pixel resolution */
    adfGeoTransform[2] /* rotation, 0 if image is "north up" */
    adfGeoTransform[3] /* top left y */
    adfGeoTransform[4] /* rotation, 0 if image is "north up" */
    adfGeoTransform[5] /* n-s pixel resolution */


and one can retrieve a single value from this list for example with

    >>> originX = geotransform[0]
    >>> originY = geotransform[3]
    >>> pixelWidth = geotransform[1]
    >>> pixelHeight = geotransform[5]
    >>> originX
    368745.92379062285
    >>> originY
    8828671.611738198
    >>> pixelWidth
    20.0
    >>> pixelHeight
    -20.0 


But how to get the individual data values in the file?

Get the band and read the first line:

    >>> band = dataset.GetRasterBand(1)

    >>> bandtype = gdal.GetDataTypeName(band.DataType)
    >>> bandtype
    Float32
    >>> scanline = band.ReadRaster( 0, 0, band.XSize, 1,band.XSize, 1, band.DataType)




Since I was not sure what the "ReadRaster" parameters meant, google led me to this useful page:

The ReadRaster() call has the arguments: def ReadRaster(self, xoff, yoff, xsize, ysize, buf_xsize = None, buf_ysize = None, buf_type = None, band_list = None ): The xoff, yoff, xsize, ysize parameter define the rectangle on the raster file to read. The buf_xsize, buf_ysize values are the size of the resulting buffer. So you might say "0,0,512,512,100,100" to read a 512x512 block at the top left of the image into a 100x100 buffer (downsampling the image).
which I found here

Typing "scanline" gives me long lines of this:

    >>> scanline
    `Bxa2x8d`Bxa2x8d`Bxa2x8d`Bxa2x8d`Bxa2x8d`Bxa2x8d`Bxa2x8d`Bxa2x8d`Bxa2x8d`.........


Note that the returned scanline is of type string, and contains xsize*4 bytes of raw binary floating point data. To convert this into readable values use struct.unpack and instead you get long lines of float numbers:

    >>> import struct
    >>> value = struct.unpack(f * band.XSize, scanline)
    >>> value
    (-1.0000000031710769e-30, -1.0000000031710769e-30, -1.0000000031710769e-30, -1.0000000031710769e-30, -1.0000000031710769e-30, -1.0000000031710769e-30, -1.0000000031710769e-30, -1.0000000031710769e-30, -1.0000000031710769e-30, ....


Now I can get individual values, but all are in "one line" and not in an array:

     >>> value[8]
    -1.0000000031710769e-30


I rather read the whole file into an array:

    >>>data = band.ReadAsArray(0, 0, cols, rows)
    >>> value = data[3500,4000]
    >>> value
    -8.30476 


Using the numpy library I can define the datatype in the array:
   >>> import numpy
   >>> data = band.ReadAsArray(0, 0, dataset.RasterXSize, dataset.RasterYSize).astype(numpy.float)
   >>> value = data[3500,4000]
   >>> value
   -8.3047599792480469
   >>>


One has  to be careful not confusing column and rows! Matrix is value = data[row, column], and it starts with 0, so the value -8.30476 is located at y=row=3501 and x=column=4001.

To be continued....
Read more »

Fedora 18 and mount cifs not mounting windows share

If you are having problem mounting a window share in Fedora 18, saying "Permission Denied" just like the one below:


[root@localhost ~]# mount.cifs //192.168.0.50/customer /ian -o user=administrator
Password for administrator@//192.168.0.50/customer:  ***
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)


Try this solution: (add sec=ntlm on the option)

mount.cifs //192.168.0.50/customer /ian -o user=administrator,sec=ntlm
Read more »

Thursday, February 5, 2015

Android beginner tutorial Part 58 Send and receive data between Activities

In this tutorial well learn how to transfer data between two Activities.

We are going to have two activities - MainActivity and SecondActivity. Ive already covered how to create secondary Activities in the tutorial about Intents. I explained how to do that in detail in that tutorial, so if you followed my tutorials you should be able to do that. A reminder: add an Activity in the Manifest XML file and add a SecondActivity.java class and an activity_second.xml layout.

The main activity is going to have a button that opens a new Activity. However, it launches it with an intention to receive a result. This is done using a startActivityForResult() method. By doing it that way we tell our main activity to expect a result from the Activity were launching. In the second activity well have an EditText input and a button. When the button is pressed, the data in the text field is sent back to the main activity and the second activity is closed.

When the main activity receives the message, it displays it in a toast.

Lets see how we are going to do this. Firstly, go to activity_main.xml layout and add a button:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >

<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="32sp"
android:text="First Activity"
/>

<Button android:id="@+id/goButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Launch Second Activity"
/>

</LinearLayout>

In MainActivity.java declare an ID for the request:

private static final int IDM_TEST = 101;

Use it when you call startActivityForResult() in the click event handler of the button:

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

final Button btn = (Button)findViewById(R.id.goButton);
btn.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(getApplicationContext(), SecondActivity.class);
startActivityForResult(intent, IDM_TEST);
}
});
}

The request is sent, but what about receiving the results?

Create a function onActivityResult(). Call its superclass and then check if resultCode parameter equals RESULT_OK. That means weve received a result as expected.

Inside the if...statement declare an "extras" variable, which is a Bundle type object and gets its values from data.getExtras().

Then we check if requestCode parameters value equals IDM_TEST (the id we passed when requesting the result), and if so, toast the results using the extras object:

protected void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == RESULT_OK){
Bundle extras = data.getExtras();
// handle results
if(requestCode == IDM_TEST){
Toast toast = Toast.makeText(MainActivity.this, extras.getString("UserText"), Toast.LENGTH_SHORT);
toast.show();
}
}
}

Full MainActivity.java code:

package com.kircode.codeforfood_test;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends Activity{

private static final int IDM_TEST = 101;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

final Button btn = (Button)findViewById(R.id.goButton);
btn.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(getApplicationContext(), SecondActivity.class);
startActivityForResult(intent, IDM_TEST);
}
});
}

protected void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == RESULT_OK){
Bundle extras = data.getExtras();
// handle results
if(requestCode == IDM_TEST){
Toast toast = Toast.makeText(MainActivity.this, extras.getString("UserText"), Toast.LENGTH_SHORT);
toast.show();
}
}
}

}

The activity_second.xml layout has an EditText object and a Button:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >

<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="32sp"
android:text="Second Activity"
/>

<EditText android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Write something here..."
android:id="@+id/editText"
/>

<Button android:id="@+id/backButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="OK"
/>

</LinearLayout>

In SecondActivity.java class, we only need to handle the button. When it is clicked, we create an intent and use a method called setResult(). To pass the values to the parent activity we can use the putExtra() method of the intent. It has 2 parameters - name and value.

package com.kircode.codeforfood_test;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class SecondActivity extends Activity{


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);

final Button btn = (Button)findViewById(R.id.backButton);
btn.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
EditText text = (EditText)findViewById(R.id.editText);

Intent intent = new Intent();
intent.putExtra("UserText", text.getText().toString());
setResult(RESULT_OK, intent);
finish();
}
});
}

}

Thats all! Now you can go to the second activity from your main one, enter some text, return to the main activity using the button and see the main activity display the data received from the second one.

Thanks for reading!
Read more »

How to Create an Account on Facebook Instructions Guides Tips and Training Video Tutorials

If you want to learn how to create an account on Facebook and youre looking for resources about Facebook - instructions, guides, tips, and training - check out these free Facebook video tutorials below. These are from the Facebook Essential Training Course by lynda.com. It will teach you the basics of creating an account on Facebook and managing it. It has topics on: finding and adding friends, liking pages, reading the News Feed, writing on a friend’s wall, updating your status, posting videos and links, creating a page for a business, protecting privacy and staying secure, deactivating an account, and more. Check out the free videos below to see start learning. To view the entire course, become a lynda.com member or sign up for a FREE 7-day trial.

Facebook
Facebook Essential Training by

START LEARNING TODAY!
or

WATCH THESE 5 FREE VIDEOS FROM THE COURSE

Facebook Essential Training - Welcome


Facebook Instructions - Changing your profile photo


Facebook Instructions - Understanding your News Feed


Facebook Instructions - Uploading videos


Facebook Instructions - Adding, removing, and blocking friends from your Chat list

START LEARNING TODAY!
or
Course Information

Training Provider: Lynda.com
Title: Facebook Essential Training
Author: Garrick Chow
Duration: 3hrs 10mins
Date of release: 10 May 2011

Chapter 1: What Is Facebook?
Understanding Facebook and social networking

Chapter 2: Signing Up and Creating a Profile
Signing up with Facebook
Editing your profile
Changing your profile photo
Configuring your notifications

Chapter 3: Finding and Adding Friends
Understanding Facebook friends
Finding friends, family, and coworkers
Managing friend requests
Organizing friends into lists
Removing and blocking friends
Liking pages
Whats "poking"?

Chapter 4: Your Home Page and Your Wall
Understanding the home page
Understanding your News Feed
Understanding your Wall
Writing on a friends Wall

Chapter 5. Updating Your Status and Sharing
Content
Updating your status
Posting photos, videos, and links
Writing Notes
Tagging friends

Chapter 6: Managing Photos and Videos
Uploading photos and creating albums
Uploading videos
Tagging, editing, and deleting photos

Chapter 7: Sending and Receiving Private Messages
Sending private messages
Reading, replying to, and deleting private messages
Setting privacy for private messages

Chapter 8: Chatting
Displaying the Chat list and chatting with friends
Adding, removing, and blocking friends from your Chat list
Disabling Chat

Chapter 9: Searching Facebook
Searching for people
Searching for content
Editing your public search listing

Chapter 10: Facebook Groups
Searching for and joining groups
Creating and administering a group
Posting content to a group

Chapter 11: Facebook Applications
Understanding applications
Accepting, ignoring, and removing application requests
Installing and using applications
Viewing application settings and uninstalling applications

Chapter 12: Creating a Page for Your Business
Creating a page for your business, band, or organization
Assigning other people as administrators for your page
Using your page identity to post and comment on other peoples pages
Setting up a user name for your page

Chapter 13: Protecting Your Privacy and
Staying Secure
Choosing what to share publicly
Configuring sharing
Using https to log in
Using one-time passwords
Signing out remotely
Recognizing new devices accessing your account

Chapter 14: Taking a Break from Facebook
Downloading your information
Deactivating your account
Deleting your account
About Lynda.com

Lynda.com is an online video training provider with over 1000 courses covering a wide array of topics - 3D, video, business, the web, graphic design, programming, animation, photography, and more. They produce top quality video tutorials with the best industry experts as your instructors. With a subscription, you can log-in at any time, and learn at your own pace. New courses are added each week, and you will receive a certificate of completion for each course that you finish.

Start learning today!
If you enjoyed the sample videos above and want to access the entire Facebook Essential Training course, you can sign up for a lynda.com membership. Your membership will allow you to access not only this course, but also the entire lynda.com library for as low as $25 for 1-month. Their training library has over 1000 courses with 50,000+ video tutorials. No long-term commitment required. You can cancel your membership at any time.


Not yet convinced? Try a FREE 7-day trial.
As a special promotion, visitors of this site can get a FREE 7-day trial to lynda.com. This free trial gives you access to their entire training library of over 1000 courses.

Sign-up for a lynda.com membership today to learn how to how to create an account on Facebook and to view all the Facebook instructions, guides, and Tips from this excellent video training course.

START LEARNING TODAY!
or
Read more »

Wednesday, February 4, 2015

Android beginner tutorial Part 69 Queries and Cursors

In this tutorial we will add our Content Provider to the Manifest xml and learn a bit about queries and cursors.

To make a Content Provider visible and usable by the system and your own application, we need to add it to the AndroidManifest.xml file of our project.

Add a new node provider to the application node, set values for two of its attributes - android:name and android:authorities. The name attribute points to the custom ContentProvider class, and the authorities value is the URI address of the provider:

        <provider 
android:name="com.kircode.codeforfood_test.myContentProvider"
android:authorities="com.kircode.codeforfood_test.contactprovider">
</provider>

To send SQL queries to the content provider from your application, use the ContentResolver object that is obtainable using getContentResolver() method.

For example, this way we can send a query that selects all names and phones of the people in our database.

String[] columns = new String[] {myDbHelper.NAME, myDbHelper.PHONE};
ContentResolver resolver = getContentResolver();
Cursor cursor = resolver.query(CONTENT_URI, columns, null, null, null);

The query() method, for instance, has 5 parameters. Those are the URI address of the provider, the projection (list of columns to return, if null - everything is returned), selection (what would normally be written after "WHERE" in an SQL command), selectionArgs (extra functionality for selection parameter) and sortOrder (what would normally be written after "ORDER BY").

The Cursor object thats returned to us is a helpful tool for navigating through the results of the query. It has a set of useful methods like moveToFirst(), moveToLast(), moveToNext(), moveToPrevious(), moveToPosition(), getToPosition() and more.

Since the Cursor lines up all the results in some sort of a row and moves back and forth displaying one at a time, there are a few methods that let us know where exactly the cursor is currently located. These methods are isFirst(), isLast(), isBeforeFirst() and isAfterLast().

The insert(), update() and delete() methods are also all called from the ContentResolver object, but they dont result any Cusors. They are even simpler commands that basically insert, update and delete rows in a table.

Thats all for today.

Thanks for reading!
Read more »

Play Scala and Iteratees vs Node js JavaScript and Socket io

The Play Framework takes a functional programming approach to stream processing (e.g. Comet, chunked responses, WebSockets) by using abstractions called Iteratees, Enumerators, and Enumeratees. When I originally tried to wrap my head around Iteratees, I found that the existing documentation and sample apps were fairly confusing and ineffective for getting started. Since teaching is often the best way to learn, I decided to write a blog post as a way to become more comfortable with functional I/O.

On the JavaScript side of the world, node.js and socket.io take an imperative programming approach for stream processing by using the EventEmitter API. Ive found this imperative approach easy to learn, so for this blog post, Ill show a side by side comparison of the imperative and functional techniques for each example. The focus of the post will be on WebSockets, including a basic "hello world" example, an echo server, and a simple chat application.

Note: Ill only implement server-side code in this post. You can test your server without writing any client-side code by using the WebSocket echo client on websocket.org and giving it a URL like ws://localhost:9000/some-path.

Producer, consumer, adapter

Terms like Iteratee, Enumerator, and Enumeratee can be confusing, so lets start by trying to define them using normal human terms:
  1. Enumerator: every time you hear Enumerator, think "producer". This is the thing that pumps out chunks of data. 
  2. Iteratee: every time you hear Iteratee, think "consumer". They are the inverse of the Java Iterator: in an Iterator, you call "next" to request a chunk of data; in an Iteratee, you define a "fold" method that reacts to each chunk of data (inversion of control).
  3. Enumeratee: every time you hear Enumeratee, think "adapter". Enumeratees can be attached in front of Iteratees to modify the data streaming through them.

A "hello world" example

Lets start with a simple "hello world" WebSocket example. The first step is accepting a WebSocket connection.

In socket.io, you do this by listening for a connection event with io.sockets.on:


In Play, you create a WebSocket Action and return an Enumerator that is used to send messages to the client and Iteratee that is used to react to messages from the client. For this first version, well just use an Enumerator and Iteratee that do nothing.

Youll need to expose this WebSocket endpoint in your routes file:

You can now use the URL ws://localhost:9000/connect in the  WebSocket echo client on websocket.org. You should be able to connect, though you wont see anything interesting quite yet.

Next, lets see how we could send a message to the client. In socket.io, the socket object has an emit method:

To send a message to a client in Play, well replace the empty Enumerator from the first example with an Enumerator that contains our message. Remember, the Enumerator is the "producer", so its responsible for pumping down any data we want to send to the client.

The Enumerator companion object has handy methods to create an Enumerator from a File, InputStream, OutputStream, a Future, and, as well use in this case, an apply method to create an Enumerator from a fixed set of data:

Finally, lets log any messages we get from the client. In socket.io, we can do this by listening for messages with the socket.on method:


In Play, the Iteratee we return in the WebSocket Action is the "consumer", so its responsible for reacting to any messages from the client. You can implement an Iteratee from scratch, but the Iteratee companion object has many methods that simplify the common cases, including "consume" (which consumes and concatenates all the data), "head" (consume just the first chunk of data), and "foreach", which fires a provided callback for each chunk of data. In this case, well use "foreach" and pass it a function that logs each message:


If you reconnect to your WebSocket using the websocket.org test tool, you should now see the message "Hello!". If you send some messages from the webpage, they should show up in your Play console.

Not bad, right? The main take aways are:
  1. Use the WebSocket.using method to define an Action that can accept WebSocket connections
  2. Return an Iteratee that knows how to consume messages from the client
  3. Return an Enumerator that knows how to produce messages for the client
An echo server with some filtering

Lets go a tiny bit further and create an echo server: that is, a server that echoes back any messages it gets from the client.

This is easy to do in socket.io by combining socket.on and socket.emit:

Creating an Enumerator and Iteratee that are "joined" is strangely complicated to do from scratch in Play. Fortunately, Play has an object called Concurrent that contains several methods to create Enumerators and Iteratees that are connected in various ways. For example, the Concurrent.joined function gives us an echo WebSocket in one line:


Try it out in the browser by reconnecting from websocket.org. Any message you send should be echoed back and show up in the log on the webpage.

Lets make this example a little more interesting and filter the data we echo back. First, lets just modify each message by adding some text to it before echoing it back.

The imperative approach used in socket.io means you have to modify the actual listener function (the callback for socket.on) to accomplish this:

In Play, we can accomplish the same thing without having to modify the internals of the Concurrent.joined code. Since we have an actual value (the Iteratee) instead of just some side-effect function (the callback passed to socket.on), we can use functional composition to modify the Iteratee before returning it. To do that, well create an Enumeratee, which, as you may remember from above, is an adapter: well attach it in front of our Iteratee to modify the data before the Iteratee consumes it.

The Enumeratee companion object has several convenience methods for creating Enumeratees: well first use Enumeratee.map, which lets you transform each chunk of data:


The advantage of composition becomes even more apparent if we want to do some fancier filtering. For example, lets only echo back messages that arent empty and contain non-whitespace characters.

With socket.io, we have to make an even larger modification to the contents of the socket.on callback function. This is easy to do in single, simple example, but this would get more complicated across many examples in a large application.

In Play, we can simply add another Enumeratee to validate the content and compose it with the previous one. Well create this Enumeratee using the "collect" method, which only allows data to pass through it if it matches one of the cases for the PartialFunction you pass in:

Youll often run across Enumeratee code that uses operators instead of the function names. The ><> operator (fish?) composes two Enumeratees and the &> applies an Enumeratee to an Iteratee:

The operators do allow you to drop lots of parens in your code, but personally, I find the operators hard to remember and impossible to google. Therefore, I believe that in this case, they lead to code that is optimized for writing instead of reading, which is a bad trade off. I recommend sticking with the full function names.

Main take aways from this section:
  1. Use the methods in the Concurrent object to create Iteratees and Enumerators that are connected. Well see another example of this in the next section.
  2. Create and compose Enumeratees when you need to modify the stream of data going into your Iteratees. 

A chat server

As a final example, lets put together a simple WebSocket chat server that just handles a few basic tasks:
  1. Send a message to all clients when a user connects or disconnects
  2. Each time a message is received from a client, send it out to all other clients
Here is the socket.io version:

And here is the Play version:


There are two new things to learn from this code:
  1. We are using Concurrent.broadcast to create an Enumerator and Channel that can be shared across all WebSocket connections. Channel is a new class specifically built to push messages to multiple Iteratees (ie, multiple clients). Interestingly, it is an imperative abstraction, where you just call a "push" method for its side-effect. 
  2. The "map" method on the Iteratee will fire when the Iteratee is done; for WebSockets, this happens when the client disconnects, an event we capture and broadcast to all clients. 

If you open the websocket.org echo page in two separate tabs and start sending messages, you should see the messages showing up in the log in both tabs, prefixed with "[user1]: " or "[user2]: ". You should also see messages when a client connects or disconnects.

Final thoughts

Im still learning my way around Iteratees, so I welcome any corrections, suggestions, or other feedback. If youve come across other good tutorials and examples, please share them!

I must admit that I have some lingering doubts about Iteratees as the primary means of working with streams of data in Play. They seem to be a powerful abstraction - interleaving and modifying streams on the fly is especially cool - but the degree of complexity is very high; the sparse documentation and large vocabulary of strange method names (unfoldM, fromCallback1, joinConcatI, ><>) only make it worse.

Just about anyone can get rolling with socket.io in a matter of minutes, whereas most people take several tries across several days to grok Iteratees. Functional programming often offers a high cost to high reward trade-off, but the ratio with Iteratees is extreme. Moreover, it seems like you end up with an imperative approach for many use cases anyway, such as the Channel object returned by Concurrent.broadcast.

Id also argue that the vocabulary of Iteratees does not clearly convey the intent of the code. Look at the two chat server examples above: which one reads more clearly? In my opinion, socket.on and socket.emit make it crystal clear what the code is trying to do. On the other hand, Iteratee.foreach and Iteratee.map do not. The latter feels more like Im trying to make the tools do what I want, whereas in the former, Im clearly dealing with the actual problem space.

Iteratees are a fairly general tool, so perhaps they should be reserved for low-level, advanced functionality, while some simpler, use-case specific abstractions are available for most common use cases? For example, maybe we just need a good socket.io equivalent for Play built on top of Iteratees? Ive seen socket.io.play and atmosphere-play, but Im not sure if they are stable, maintained, tested, documented, or high quality. If anyone has experience with these libraries, let me know!

Read more »