Friday, December 27, 2013

[Android] How to ROOT Sony Xperia Z TMobile C6606 4.2.2 Jelly Bean, Build# 10.3.1.E.0.191

Sony Xperia Z TMobile
Model number: C6606
Android version: 4.2.2
Build number: 10.3.1.E.0.191

Here what I did.

Prepare

1. Download and install Android SDK (http://developer.android.com/sdk/index.html or follow directions here: http://theunlockr.com/2009/10/06/how-to-set-up-adb-usb-drivers-for-android-devices/)
2. Turn on USB debugging mode (Settings => About phone => Tab on the  Build number 6 or 7 times => Developer options appear => Select Developer options => Check USB debugging)
3. Install Xperia Z driver (download here: http://dl-developer.sonymobile.com/drivers/Xperia_Z_driver.zip) => install driver (to verify, use cmd line navigate to platform-tools and run "adb devices" => you should see your device ID)

Root

1. I downloaded and tried this version "rootkitZ_20131112.zip", but it failed (http://cubeundcube.blogspot.jp/2013/11/xperiarootz-so-02e-so-04e.html)
2. Then I downloaded and tried this version "rootkitXperia_20131207.zip" (https://mobile.twitter.com/cubeundcube/status/409191968795680770), but I got error (unknown adb...)
3. I copied "adb.exe" "AdbWinApi.dll" "AdbWinUsbApi.dll" from version #1 above to version #2 => then double click on adb.exe (try to copy these 3 files to different folder of the #2 method, if it doesn't work)
4. Re-run #2 install.bat (I confirmed this method works, rootkitXperia_20131207, but must run or copy the adb file over from method 1)
5. See attached for proof http://imageshack.us/a/img833/7803/ptut.png

Hope this helps someone. :)

Tuesday, October 8, 2013

[OUTLOOK] How to Setup Gmail Account on Microsoft Outlook

Tools => E-mail Account...
Add a new e-mail account => Next button => POP3 =>

[Screenshot 1]

User Information

  1. Enter your name
  2. Enter your email address
Logon Information
  1. Enter full gmail address as User Name
  2. enter your gmail account password
Server Information
  1. Incoming mail server (POP3): pop.gmail.com
  2. Outgoing mail server (SMTP): smtp.gmail.com
Then click on More Settings... button


[Screenshot 2]

Internet E-Mail Settings window => Click on Advanced tab
  1. Incoming server (POP3): 995
    Check the check box This server requires an encrypted connection (SSL)
  2. Outgoing server (SMTP): 465
    Check the check box This server requires an encrypted connection (SSL)

Tuesday, September 24, 2013

[JavaScript] Code Snippets

Redirect to the page with code below to close the window right away.
<script type="text/javascript">
window.open('','_self','');
window.close();
</script>


Thursday, May 2, 2013

[C#] How To Add JavaScript or CSS Dynamically To Page Header


Add JavaScript Dynamically To Page Header
string strJS = "<s" + "cript type=\"text/javascript\">";
strJS += "ADD YOUR SCRIPTS HERE";
strJS += "</" + "script>";
LiteralControl myJS = new LiteralControl();
myJS.Text = strJS;
Page.Header.Controls.Add(myJS);

Add CSS Dynamically To Page Header
string strCS = "<style type=\"text/css\">";
strCS += "ADD YOUR CSS CLASSES HERE";
strCS += "</style>";
LiteralControl myCS = new LiteralControl();
myCS.Text = strCS;
Page.Header.Controls.Add(myCS);
Short version: Page.Header.Controls.Add(new LiteralControl("<style type=\"text/css\"> CSS CLASS HERE }</style>"));

Tips: add /r and/or /n for new line

Wednesday, May 1, 2013

[C#] Convert String Array (string[]) to comma delimited string


string[] arrStrings = new string[] { "string1", "string2", "string3" };
string strDelimited = String.Join(",", arrStrings);

Result: string1,string2,string3

Thursday, April 18, 2013

[SharePoint] Upload File To Document Library Using SharePoint Object Model - Authenticate or Anonymous Access



using Microsoft.SharePoint;    //SharePoint
using System.IO;                //Stream

//if  Anonymous Access, document library must set to allow anonymous to add items
string strSharePointURL = "http://www.sharepoint.com";

if (txtUpload.HasFile)
{
    if (txtUpload.PostedFile.ContentLength > 0)
    {
        //string strFileName = txtUpload.PostedFile.FileName;
        string strFileName = txtUpload.FileName;

        Stream fStream = txtUpload.PostedFile.InputStream;
        byte[] bStream = new byte[fStream.Length];
        fStream.Read(bStream, 0, bStream.Length);
        fStream.Close();

        SPSecurity.RunWithElevatedPrivileges(delegate()
        {
            using (SPSite objSite = new SPSite(strSharePointURL))
            {
                using (SPWeb objWeb = objSite.OpenWeb())
                {
                    SPFolder libraryFolder = objWeb.Folders["Document_Library_Name"];
                    objWeb.AllowUnsafeUpdates = true;

                    libraryFolder.Files.Add(strFileName, bStream, true);
                }
            }
        });
    }
}
//In html code
<asp:FileUpload runat="server" id="txtUpload"/>

Monday, April 15, 2013

[SQL] Get Date Only - Date Only No Time

DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0)

Sunday, April 14, 2013

[MAC]: How To Burn ISO Disc Images

  1. Insert a blank disc.
  2. Start Disk Utility.
    • BY: Finder -> Applications -> Utilities -> Disk Utility
    • OR: LauchPad -> Other -> Disk Utility
  3. From the File menu, choose Open Disk Image and select the ISO to be burned.
  4. In the list of volumes, you will now see an item representing the ISO file. Select it.
  5. Click the Burn button and follow the instructions.

Saturday, March 16, 2013

[C#] How to Add Web Reference Dynamically

Issue: Using SharePoint Web Services Lists and Copy in our custom ASP.NET code using C#

Lists: http://www.AnySharePointSite.com/_vti_bin/Lists.asmx
Copy: http://www.AnySharePointSite.com/_vti_bin/Copy.asmx

In Visual Studio (we use 2005 for SharePoint 2007), to use Web service, you can right click on a project and select Add Web Reference. However, we use SharePoint Designer (2007) to add custom ASP.NET code using C# and there is no open to add Web Reference to use in the code.

Solution: Add Web Reference on the fly (dynamically). We created a class WebServices with CallWebService function to add Web reference to invoke any Web service method.

Usage: see upcoming blog...


using System;
using System.Net;                       //NetworkCredential,WebClient
using System.IO;                        //Stream
using System.Security.Permissions;      //SecurityPermissionAttribute
using System.Web.Services.Description;  //ServiceDescription,ServiceDescriptionImporter,ServiceDescriptionImportStyle,ServiceDescriptionImportWarnings -> Reference/.NET/System.Web.Services
using System.CodeDom;                   //CodeNamespace,CodeCompileUnit,importer,provider1
using System.CodeDom.Compiler;          //CodeDomProvider,CompilerParameters,CompilerResults
using System.Reflection;                //MethodInfo

public class WebServices
{
    [SecurityPermissionAttribute(SecurityAction.Demand, Unrestricted = false)]
    //[SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)]
    public object CallWebService(string webServiceAsmxUrl, string serviceName, string methodName, object[] args)
    {
        WebClient client = new System.Net.WebClient();

        //Comment out next 2 lines if use custom credential to access authenticated/secured Web service, replace with username/password/domain
        //NetworkCredential customCredential = new NetworkCredential("USER_NAME", "PASSWORD", "DOMAIN_NAME");
        //client.Credentials = customCredential;

        // Connect To the web service
        Stream stream = client.OpenRead(webServiceAsmxUrl + "?wsdl");

        // Now read the WSDL file describing a service.
        ServiceDescription description = ServiceDescription.Read(stream);

        ///// LOAD THE DOM /////////

        // Initialize a service description importer.
        ServiceDescriptionImporter importer = new ServiceDescriptionImporter();
        importer.ProtocolName = "Soap12"; // Use SOAP 1.2.
        //importer.ProtocolName = "Soap"; // Use this for SharePoint 2003
        importer.AddServiceDescription(description, null, null);

        // Generate a proxy client.
        importer.Style = ServiceDescriptionImportStyle.Client;

        // Generate properties to represent primitive values.
        importer.CodeGenerationOptions = System.Xml.Serialization.CodeGenerationOptions.GenerateProperties;

        // Initialize a Code-DOM tree into which we will import the service.
        CodeNamespace nmspace = new CodeNamespace();
        CodeCompileUnit unit1 = new CodeCompileUnit();
        unit1.Namespaces.Add(nmspace);

        // Import the service into the Code-DOM tree. This creates proxy code that uses the service.
        ServiceDescriptionImportWarnings warning = importer.Import(nmspace, unit1);

        if (warning == 0) // If zero then we are good to go
        {
            // Generate the proxy code
            CodeDomProvider provider1 = CodeDomProvider.CreateProvider("CSharp");

            // Compile the assembly proxy with the appropriate references
            string[] assemblyReferences = new string[5] { "System.dll", "System.Web.Services.dll", "System.Web.dll", "System.Xml.dll", "System.Data.dll" };
            CompilerParameters parms = new CompilerParameters(assemblyReferences);
            CompilerResults results = provider1.CompileAssemblyFromDom(parms, unit1);

            // Check For Errors
            if (results.Errors.Count > 0)
            {
                foreach (CompilerError oops in results.Errors)
                {
                    System.Diagnostics.Debug.WriteLine("========Compiler error============");
                    System.Diagnostics.Debug.WriteLine(oops.ErrorText);
                }
                throw new System.Exception("Compile Error Occured calling webservice. Check Debug ouput window.");
            }

            // Finally, Invoke the web service method
            object wsvcClass = results.CompiledAssembly.CreateInstance(serviceName);
            MethodInfo mi = wsvcClass.GetType().GetMethod(methodName);
            //((System.Web.Services.Protocols.WebClientProtocol)(wsvcClass)).Credentials = customCredential;        //custom credential
            //((System.Web.Services.Protocols.SoapHttpClientProtocol)(wsvcClass)).Credentials = customCredential;   // OR custom credential

            return mi.Invoke(wsvcClass, args);
        }

        else
        {
            return null;
        }
    }
}