Monday, December 29, 2014

Facebook Android Sdk : Serialize GraphUser object


If you check at the Facebook sdk GraphUser object documentation , it does not implements the java.io.Serializable as a result of which you can pass the GraphUser object through activities.


Though if you like to pass GraphUser to other activities, you can do it by saving GraphUser json string in a String instance and then pass it,


// Save GraphUser json information in String instance and pass to another activity using intent
List<GraphUser> selectedUsers = friendPickerFragment.getSelection();
List<GraphUser> selectedUsersJson = new ArrayList<String>();
for (GraphUser graphUser : selectedUsers) {
selectedUsersJson.add(graphUser.getInnerJSONObject().toString());
}


// Re-initialize the GraphUser from the saved graph user json from the intent
List<GraphUser> selectedUsers = new ArrayList<GraphUser>();
for (String graphUserJson : selectedUsersJson) {
selectedUsers .add(GraphObject.Factory.create(new JSONObject(graphUserJson),GraphUser.class));
}


Happy Serializing :)

Saturday, December 6, 2014

Download Android SDK offline

Many of you interested in Android development or automation, must have downloaded Android SDK installer and have noticed once you install the SDK on your machine, you still need to download some more file using the Android SDK Manager like :

Android SDK Tools
Android Platform Tools
Android API's

In some case you may not have the fast internet connection/bandwidth to download this much stuff.( Same with me :D ). So, here is the solution i am sharing with you guys how you can download with stuff from an high internet connection machine and then cut and paste to your development machine :)
  1. Navigate to the link https://dl-ssl.google.com/android/repository/repository-10.xml in browser. [ Note this is the last updated link at the time of writing this post.In future you will need to check the latest page by +1 increment to digit shown in url. Example next updated version should have 'respository-10.xml' in end ]
  2.  Search for the sdk-tools/platform-tools/other stuff in the page like:
    1.   For example to download the android sdk api 21,search for "android-21". You will see entry in xml like "android-21_r01.zip"
    2. Copy the entry and append to url 'http://dl-ssl.google.com/android/repository/'
    3. Your download url will be like http://dl-ssl.google.com/android/repository/android-21_r01.zip
[ Similarly you can download the other stuff zip files as mentioned in above steps ]

Once you have downloaded, you just copy the zip file to your development machine.Extract the files and place under <android-sdk-path>/<respective-folder-for-tools/other-stuff>. 

You can check the placed files are correct,by opening the ANDROID SDK MANAGER and check the Status of downloaded tools is shown as 'INSTALLED'
:) :)



sdk tools/platform tools/API's download links for your reference  [ latest as of post writing ]

Leave your question in case of any issues :) 

Wednesday, August 20, 2014

Adding Windows PowerShell Cmdlets

 You may all have seen some error like below when running a command on Windows PowerShell. This usually occurs when the command PowerShell snap-in is not added.

The term 'Get-SPWebApplication' is not recognized as the name of a cmdlet, function, script file, or operable program.

Solution:  How to add the required snap-in if not already added from the PowerShell script itself.


# Example to add SharePoint Cmdlets [ SharePoint should be installed on machine ]
if ( (Get-PSSnapin -Name Microsoft.Sharepoint.Powershell -ErrorAction SilentlyContinue) -eq $null )
{
    Add-PsSnapin Microsoft.Sharepoint.Powershell
    Write-Output "`n Snap-in Microsoft.SharePoint.PowerShell added."
}
else
{
    Write-Output "`n Snap-in Microsoft.SharePoint.PowerShell already added."
# Example to add SQL Cmdlets [ SQL management tools should be installed on machine ]
if ( (Get-PSSnapin -Name SqlServerCmdletSnapin100 -ErrorAction SilentlyContinue) -eq $null )
{
    Add-PsSnapin SqlServerCmdletSnapin100
    Write-Output "`n Snap-in SqlServerCmdletSnapin100 added."
}
else
{
    Write-Output "`n Snap-in SqlServerCmdletSnapin100 already added."
}
if ( (Get-PSSnapin -Name SqlServerProviderSnapin100 -ErrorAction SilentlyContinue) -eq $null )
{
    Add-PsSnapin SqlServerProviderSnapin100
    Write-Output "`n Snap-in SqlServerProviderSnapin100."
}
else
{
    Write-Output "`n Snap-in SqlServerProviderSnapin100 already added."
}

Wednesday, July 23, 2014

Address is invalid on local machine, or port is not valid on remote machine


This issue is caused generally when your Java attempts to use an IPV6 address, where either OS does not support it or its not set up properly. You may get this issue while running your java program from CMD, Java IDE or when downloading jar dependency using maven etc.

So, to resolve this you just need to tell your java code to use IPV4 instead of IPV6 :)

"To fix when running from Command prompt. Just add the properly as: "
java -Djava.net.preferIPv4Stack=true <Your Java Class to Run>

" TO fix when running from Java IDE. Suppose Intellij IDEA: "
Set the property under Run -> Edit Configuration

Thursday, July 10, 2014

Hide photos videos on your Android mobile without any software


So, everybody may have got the issue with hiding personal videos or images on their mobile phones. And also there are lot of software to serve the purpose but the problem with them is that either good ones are paid or not that good.

Here i will show you the way to hide any files mainly images/videos from your android gallery.

1. On your Android mobile phone, first download and install a File manager if you does not have already.  Here, i have used the 'ES File Explorer' which you can download freely from the Google play.


2. Open the File Explorer -> Go to its Settings ->  Set 'Show Hidden Files' to 'ON'

3. Create a new folder in File Manager with name ".hide". You can see that created folder is faded as compared to other folders with does not start with a "."

                                 [ Here you can pick any name but is should start with a "." ]

3.Move you all the files images/videos to ".hide" folder, Go and check in gallery now they are not visible there : ) 

4.  Now, if you want to view the hidden stuff yourself then you can:
  1. View directly by going to hidden folder from the File Explorer.
  2. Or can rename the hidden folder by removing the "." from the front it will be again visible in Gallery.    Again then you can add "." in folder name to hide it again :)


Monday, June 30, 2014

How to Disable Selenium HtmlUnitDriver logging

Recently, while working on a project using Selenium HtmlUnitDriver, i found that it generates too much log messages by default to output console which really fills the screen with non wanted messages.


So, like me some of you may also get this and wanted to resolve the same. What i did is added the below code statements to suppress the logging messages.


LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log","org.apache.commons.logging.impl.NoOpLog");
java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Level.OFF);
java.util.logging.Logger.getLogger("org.apache.commons.httpclient").setLevel(Level.OFF); 

and it Worked :) :)

Sunday, June 29, 2014

Setup your code respository on Github

1. Sign up first on the http://github.com for your free account.

2. After login, click on the 'New Repository' as shown in the image below:


3. Then, on next page provide your new repository -
- Repository Name [ anything you like]
- Description [ This is optional. You can provide some basic overview of your repository so people can     understand your work from there.]
Repository Visibility Type [ Here if you want to make your repository PRIVATE then you need to upgrade your github account, otherwise you can go with PUBLIC repository.]
 - Check the option "Initialize this repository with a README"
-  Add .gitignore file [ For this select your project language, for example here i selected java]
Add a License [ You may add a license if u like and as per your requirement, here i am adding MIT ]
- Then just click on 'Create Repository' button

4. So, here is your repository created:

5. From the above screenshot, you can see a unique HTTPS Clone URL is generated for you repository. You can use this to pull your repository, start working on it, and then push back your changes.

6.  To clone your repository to your local system, just download the git client for your system and install.
  

7. Now to clone your repository, open the installed Git bash:
    -  Type the clone command as  [   git clone https://github.com/lalit-k/test-project.git  ]


8.  Go to the folder on your local machine, where you cloned the repository to access the file. :)


Tuesday, June 24, 2014

ISTQB - CTFL Cleared!!! :)



So, finally i got a mail from ISQI with my ISTQB Foundation Level exam results. I passed with 85% i.e 34 out of 40 question :)

I decided to write this blog, for those who like to take this examination without formal or no formal training. Well, i didn't took any.

How To Register:1. Either give exam from your country Testing board. For India you can go to http://istqb.in/, register and schedule your exam.
2. Second option is to give through other exam providers like Prometric or PearsonVue.

Well, i gave through PearsonVue. You can go to http://pearsonvue.com/isqi/ and schedule your exam.

Results Declaration [ PearsonVue ISQI ]:Well after completion, the attended at the examination center gave me the result with PASS status but it didn't had any score. Then after 1 week i got a mail from the ISQI with my results and now i am waiting for the my certificate :) As they said it will may take around 6 week to max :|

Study Material to Follow/I Followed [ Collected from istqb.in and internet ]: 

https://drive.google.com/folderview?id=0B8oqIHl1Y-9uVTVNUm5WakhkOVU&usp=sharing

SharePoint 2013 - Enable Sign in as a Different User




1. Find and open the following file from the Sharepoint 15 hive
 'C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\CONTROLTEMPLATES\Welcome.ascx'

2. Add the following control code before the control having ID 'id="ID_RequestAccess"' and save the file.
<SharePoint:MenuItemTemplate runat="server" ID="ID_LoginAsDifferentUser"
 Text="<%$Resources:wss,personalactions_loginasdifferentuser%>"
 Description="<%$Resources:wss,personalactions_loginasdifferentuserdescription%>"
 MenuGroupId="100"
 Sequence="100"
 UseShortId="true"
 />




3. Reload the SharePoint web application and check again. 'Sign in as a Different User' should be visible now :)

Saturday, May 3, 2014

Handle Sharepoint HTTP basic window authentication - using selenium webdriver java


import org.openqa.selenium.Alert;
import java.awt.*; import java.awt.datatransfer.StringSelection; import java.awt.event.KeyEvent;
// Switch to alert window. Alert authenticationWindow = driver.switchTo().alert();
// Type the username/email. authenticationWindow.sendKeys("<username/email address>");
// Shift cursor focus to password input text field. Robot robot = new Robot(); robot.keyPress(KeyEvent.VK_TAB);
// Type the password in password field. [ Selenium does not know at this point that the cursor focus is shifted, so calling Alert class instance sendKeys() will cause password to be typed in username field. So, we are copying the password first to windows clipboard and then pasting it directly into the password field using  Robot class instance ] StringSelection stringSelection = new StringSelection("<user password>"); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection,null); robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_V); robot.keyRelease(KeyEvent.VK_CONTROL);
// Accept the authentication window. robot.keyPress(KeyEvent.VK_ENTER);

Sunday, April 13, 2014

How i tricked IntelliJ IDEA ultimate edition to keep running even after the trial period.

Jetbrains IntelliJ IDEA Ultimate edition allow to use its IDE for 30 days for free but after that it ask you to register else it get closed after every 30 minutes run, which is bad bad bad :(

So what i noticed and did to overcome this, i wanted to share with you all.Actually, i noticed that its IDE saves the current system time and on basis of that it gets closed after 30 minutes.

So i created a batch script which reset the time every 20 minutes so the IDE run time does not over and you get it running till you want :) :) :) :)

Copy and save the below commands with name 'tReset.bat' and start after starting your Intellij ultimate edition. <!-Code Start--->
 
@echo off


:start
REM : Save the current time in a variable
FOR /F %%G IN ('time /t') DO Set cTime=%%G

REM Displaye current time
echo %cTime%

REM Sleep for 20 minutes
Sleep 20

REM Reset the time
time %cTime%

goto start
<!-Code End--->
Thanks :) :) :)

NOTE:  You can use it the above solution at your own for personal use and make sure your system is not a part of Active Directory because in that case your system may get out of sync with AD :\

AWS Certified Solutions Architect Associate - AWS Introduction - Questions

All the Best !!! Show Result !! Try Again !! ×