Unlock i4s SoftBank carrier IOS 8.1.2 & fix ussd services

January 5, 2015 Leave a comment

Here the step by step to unlock my iPhone 4S 32G SoftBank carrier IOS 8.1.2 and fix ussd services (ex: to check current balance with command *111# or Internet quota *123#)

  1. Purchase R-sim 9 Pro
  2. Check whether it worked on current iOS version (in my case it worked with ios 5.1.1)
  3. Download & Install the latest iTunes version
  4. Backup iphone data with iTunes
  5. Update current ios version to ios 8.1.2 with iTunes  (need to RESTORE & update if device has been jailbreak before)
  6. Just cancel if there is “carrier settings update” popup
  7. Download & jailbreak with TaiG v1.2.0 (check cydia & uncheck 3K Assistant options)
  8. Reboot
  9. Run cydia and add following repo
  10. Search and Install “CommCenter patch for iOS 7” & “iFile”
  11. Run iFile and go to folder /System/Library/Carrier Bundles/iPhone/Default.bundle/
  12. Select on carrier.plst and select “Property List Viewer”
  13. Scroll down and find the item “SupportsSupplementaryServicesOver3GPP” And turn it “On”
  14. Reboot
  15. Test
Categories: Iphone

Create Simple Loading Screen

December 16, 2014 Leave a comment

Just try to create simple Loading screen during the idle time …

  1. Create Folders Scripts, Scenes, and Textures in Assets Folder
    • Scenes
      • Loading.unity (Set Background in Main Camera to Black)
      • Scene01.unity
      • Scene02.unity
    • Scripts
      • Base
        • PersistentObject.cs
      • Game
        • Scene01Controller.cs
        • Scene02Controller.cs
      • Loading
        • LoadingManager.cs
        • LoadingScript.cs
        • Fading.cs
    • Textures
      • fadeout_texture.png (black image 2×2 pixels) imported as texture
  2. Write Script
    • PersistentObject.cs
      using UnityEngine;
      using System.Collections;
      
      public abstract class PersistentObject<T> : 
      MonoBehaviour where T : Component {
          private static T instance;
          
          void Awake() {
              if (instance == null) {
                  instance = GetComponent<T>();
                  DontDestroyOnLoad(gameObject);
                  OnAwake();
              } else {
                  Destroy(gameObject);
              }
          }
          
          protected virtual void OnAwake() {
              
          }
      }
    • Fading.cs
      using UnityEngine;
      using System.Collections;
      
      public class Fading : MonoBehaviour 
      {
          public Texture2D fadeOutTexture;
          public float fadeSpeed = 0.8f;
      
          private int drawDepth = -1000;
          private float alpha = 1.0f;
          private int fadeDir = -1;
      
          void OnGUI()
          {
            alpha += fadeDir * fadeSpeed * Time.deltaTime;
            alpha = Mathf.Clamp01(alpha);
      
            GUI.color = new Color(GUI.color.r,GUI.color.g,GUI.color.b,alpha);
            GUI.depth = drawDepth;
            GUI.DrawTexture(new Rect(0,0, Screen.width, Screen.height), 
                            fadeOutTexture);
      
          }
      
          public float BeginFade(int direction)
          {
              fadeDir = direction;
              return fadeSpeed;
          }
      
          void OnLevelWasLoaded()
          {
              BeginFade(-1);
          }
      }
    • LoadingManager.cs
      using UnityEngine;
      using System.Collections;
      
      public class LoadingManager : PersistentObject<LoadingManager
      {
          private string _nextScene = "Scene01";
          public string NextScene { get { return _nextScene;} }
          public void Load (string name) {
              _nextScene = name;
              Application.LoadLevel("Loading");
          }
          IEnumerator WaitAndLoad() { 
              float fadeTime = Component.FindObjectOfType<Fading>().BeginFade(1);
              yield return new WaitForSeconds(fadeTime);
              Application.LoadLevel("Loading");
          }
       }
    • LoadingScript.cs
      using UnityEngine;
      using System.Collections;
      
      public class LoadingScript : MonoBehaviour 
      {
          [SerializeFieldprivate GUIText textLbl;
          private float progress;
          AsyncOperation op;
          
          IEnumerator Start() {
              yield return new WaitForSeconds(0.2f);
              LoadingManager loadingManager = 
              Component.FindObjectOfType<LoadingManager>();
              op = Application.LoadLevelAsync(loadingManager.NextScene);
              yield return op;
          }
          
         void Update() {
              if( (op!=null) && (!op.isDone) ) {
                  progress = op.progress * 100f;
                  textLbl.text = "Loading.. " + progress" %";
              }
          }
      }
      
    • Scene01Controller.cs
      using UnityEngine;
      using System.Collections;
      
      public class Scene01Controller : MonoBehaviour 
      {
          void OnGUI() {
              GUILayout.BeginArea (new Rect (10,10,100,100));
              if(GUILayout.Button("Scene02")) {
                  var loadingManager = 
                  Component.FindObjectOfType<LoadingManager>();
                  loadingManager.Load("Scene02");
              }
              GUILayout.EndArea ();
          }
      }
    • Scene02Controller.cs
      using UnityEngine;
      using System.Collections;
      
      public class Scene02Controller : MonoBehaviour 
      {
          void OnGUI() {
              GUILayout.BeginArea (new Rect (10,10,100,100));
              if(GUILayout.Button("Scene01")) {
                  var loadingManager = 
                  Component.FindObjectOfType<LoadingManager>();
                  loadingManager.Load("Scene01");
              }
              GUILayout.EndArea ();
          }
      }
  3. Attach Script
    • LoadingScript.cs & LoadingManager.cs
      Create 2 empty game objects (LoadingScript and LoadingManager) in Loading.unity and attach these script
    • Fading.cs
      Attach this script to LoadingManager game object in scene Loading.unity and assign fadeout_texture texture
    • Scene01Controller.cs
      Create 1  empty game object in Scene01.unity and attach this script
    • Scene02Controller.cs
      Create 1 empty game object in Scene02.unity and attach this script
  4. Attach GUIText Component
    • Attach GUIText Component to LoadingScript.cs empty game object (step3)
    • Set text to “Loading ..”
    • Set position to (0.5,0.5,0.0)
    • Set Anchor value to “middle center” and Alignment to “center”
    • Drag this GUIText Component to variable textLbl in LoadingScript.cs inspector
  5. Include Scenes in Build Settings
    • Loading.unity
    • Scene01.unity
    • Scene02.unity
  6. Test
Categories: Game and CG, Programming, Unity

Plastic SCM Mysql Database Config

October 30, 2014 Leave a comment

This is step-by-step to Change Mysql Server Configuration before migrating plastic scm database from MS SQL Server (CE)

  1. Edit the my.cnf file, normally located in /etc or /etc/mysql in Linux, or the c:\Program Files\MySQL\my.ini file in Windows. Add or edit the lines below.
  2. The innodb_buffer_pool_size should be around half of the memory of your server machine. This is the most important value. Note that due to a limitation in MySQL, this value should be maximum 4GB (more details here):
    innodb_buffer_pool_size = 2G
  3. innodb_additional_mem_pool_size should be a 5% of the innodb_buffer_pool_size:
    innodb_additional_mem_pool_size = 100M
  4. Set innodb_log_file_size to 25% of buffer pool size.
    innodb_log_file_size = 500M
  5. innodb_log_buffer_size can be around 2% of the buffer pool size or, at a minimum, 8MB.
    innodb_log_buffer_size = 40M
  6. Also, don’t forget to set the max_allowed_packet to 10MB. This is mandatory for correct Plastic SCM operation:
    max_allowed_packet = 10M
  7. Once these settings are in place, restart the MySQL service.

original source : http://www.plasticscm.com/infocenter/technical-articles/kb-how-to-fine-tune-mysql-performance-for-plastic-scm.aspx

Categories: Database, Version Control

Installing EPEL Repository (CentOS 6.x)

October 20, 2014 Leave a comment

You install the EPEL repository by downloading the appropriate RPM package for your system and installing it.

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -Uvh epel-release-6*.rpm

The Remi repository provides newer versions of the software in the core CentOS and Red Hat repositories. The Remi repository depends on the EPEL repository.

wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm 
sudo rpm -Uvh remi-release-6*.rpm

References:

Categories: Linux

Adapter

June 22, 2014 Leave a comment

Frequency of Use Medium – High Intent Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces. Structure Adapter Applicability Use the Adapter pattern when:

  • you want to use an existing class, and its interface does not match the one you need.
  • you want to create a reusable class that cooperates with unrelated or unforeseen classes, that is, classes that don’t necessarily have compatible interfaces.
  • (object adapter only) you need to use several existing subclasses, but it’s impractical to adapt their interface by subclassing every one. An object adapter can adapt the interface of its parent class

Implementation Code (C#)

using System;
public class MainClass {
 public static void Main() {
  Target target = new Adapter();
  target.Request();
 }
}

 class Target {
  public virtual void Request() {
   Console.WriteLine("Called Target Request");
  }
 }
 
 class Adapter : Target {
 private Adaptee _adaptee = new Adaptee();
 
 public override void Request() {
  _adaptee.SpecificRequest();
  }
 }
 
 class Adaptee {
  public void SpecificRequest() {
   Console.WriteLine("Called Adaptee specific Request");
  }
 }

Code Output

 Called Adaptee specific Request
Categories: C#, Design Pattern, Programming

Observer

June 8, 2014 Leave a comment

Frequency of Use
High

Intent
Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.

Structure

20140608-185029-67829449.jpg

Applicability
Use the Observer pattern in any of the following situations:

  • When an abstraction has two aspects, one dependent on the other. Encapsulating these aspects in separate objects lets you vary and reuse them independently.
  • When a change to one object requires changing others, and you don’t know how many objects need to be changed.
  • When an object should be able to notify other objects without making assumptions about who these objects are. In other words, you don’t want these objects tightly coupled.

 

Code Implementation (C#)

using System;
using System.Collections.Generic;

namespace Observer
{
 public class MainClass
 {
  public static void Main()
  {
    ConcreteSubject s = new ConcreteSubject();
    s.Attach(new ConcreteObserver(s, "X"));
    s.Attach(new ConcreteObserver(s, "Y"));
    s.Attach(new ConcreteObserver(s, "Z"));

    s.SubjectState = "ABCD";
    s.Notify();

    Console.ReadKey();
  }
 }

 abstract class Subject
 {
  private List<Observer> _observers = new List<Observer>();

  public void Attach(Observer observer)
  {
    _observers.Add(observer);
  }

  public void Detach(Observer observer)
  {
    _observers.Remove(observer);
  }

  public void Notify()
  {
   foreach (var observer in _observers)
   {
    observer.Update();
   }
  }
 }

 class ConcreteSubject : Subject
 {
  private string _subjectState;

  public string SubjectState
  {
    get { return _subjectState; }
    set { _subjectState = value; }
  }
 }

 abstract class Observer
 {
   public abstract void Update();
 }

 class ConcreteObserver : Observer
 {
   private string _name;
   private ConcreteSubject _subject;
   private string _observerState;

   public ConcreteObserver(ConcreteSubject subject, string name)
   {
     this._subject = subject;
     this._name = name;
   }

   public override void Update()
   {
    _observerState = _subject.SubjectState;
    Console.WriteLine("State of Observer {0} is {1}",
                      _name, _observerState);

   }

   public ConcreteSubject Subject
   {
    get { return _subject; }
    set { _subject = value; }
   }

  }
 }

Code Output

State of Observer X is ABCD 
State of Observer Y is ABCD 
State of Observer Z is ABCD
Categories: C#, Design Pattern, Programming

Flyweight

May 31, 2014 Leave a comment

Frequency of Use
Low

Intent
Use sharing to support large numbers of fine-grained objects efficiently.

Structure

20140531-125430-46470258.jpg

Applicability
The Flyweight pattern’s effectiveness depends heavily on how and where it’s used. Apply the Flyweight pattern when all of the following are true:

  • An application uses a large number of objects.
  • Storage costs are high because of the sheer quantity of objects.
  • Most object state can be made extrinsic.
  • Many groups of objects may be replaced by relatively few shared objects once extrinsic state is removed.
  • The application doesn’t depend on object identity. Since flyweight objects may be shared, identity tests will return true for conceptually distinct objects.

Code Implementatio  (C#)

using System;
using System.Collections;

namespace Flyweight
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            FlyweightFactory ff = new FlyweightFactory();

            int state = 20;
            Flyweight fx = ff.GetFlyweight("X");
            fx.Operation(state);

            Flyweight fy = ff.GetFlyweight("Y");
            fy.Operation(state);

            Flyweight fz = ff.GetFlyweight("Z");
            fz.Operation(state);

            UnsharedConcreteFlyweight fu = new UnsharedConcreteFlyweight();
            fu.Operation(state);

        }
    }

    class FlyweightFactory
    {
        private Hashtable _flyweights = new Hashtable();

        public FlyweightFactory()
        {
            _flyweights.Add("X", new ConcreteFlyweight());
            _flyweights.Add("Y", new ConcreteFlyweight());
            _flyweights.Add("Z", new ConcreteFlyweight());

        }

        public Flyweight GetFlyweight(string key)
        {
            return ((Flyweight)_flyweights[key]);
        }
    }

    abstract class Flyweight
    {
        public abstract void Operation(int extrinsicstate);
    }

    class ConcreteFlyweight : Flyweight
    {
        public override void Operation(int extrinsicstate)
        {
            Console.WriteLine("ConcreteFlyweight:" + extrinsicstate);
        }
    }

    class UnsharedConcreteFlyweight : Flyweight
    {
        public override void Operation(int extrinsicstate)
        {
            Console.WriteLine("UnsharedConcreteFlyweight:" + extrinsicstate);
        }
    }

}

Code Output

ConcreteFlyweight:20
ConcreteFlyweight:20
ConcreteFlyweight:20
 
UnsharedConcreteFlyweight:20
Categories: C#, Design Pattern, Programming