Saturday, April 11, 2015

[OSX - Yosemite] How to install Yosemite

Today, You can install Yosemite! Please prepare yosemite usb media or download from app store.

Step 01. Get into Setup screen. It's flat design


Step 02. Select your language. I choose English.



Step 03. It's startup screen. Click "Continue" button.



Step 04. Here is software license agreement. Click "Continue" button.



Step 05. Then you will get agree dialog. Click "Agree" button.




Step 06. Select your disk. And click "Continue" button.



Step 07. Waiting for some minutes. And your computer will reboot.



Step 08. Select your location and click "Continue".




Step 09. Select your Keyboard and click "Continue"



Step 10. This is transfer your information setting screen. I selected "Don't transfer". And click "Continue".




Step 11. Sign in apple. If you select "Don't sign in". You will get skip dialog.





Step 12. Please agree "Terms and Conditions". Click "Agree" button.


Step 13. Click "Agree" button again.



Step 14. Create your account. Enter all information. Click "Continue".




Step 15. Diagnostics setting screen. I uncheck all things. Click "Continue".




Step 16.  Waiting for a second. Mac will be set up automately.



Step 17. Finally you got yosemite desktop screen.


Step 18. Check your OS X Version.


After that. Enjoy your Yosemite life!!

Thursday, April 9, 2015

[Data Structures] Queue with list in C

Here is Queue data structure with Linked List in C programming language.



#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>

typedef struct Node {
    struct Node* Next;
    int data;
} Node;

Node *front,*rear;

void initQue(void);
void enque(int);
bool deque(int *);
void printQue();

int main(int argc, const char * argv[]) {
    int input=0;
    initQue();
    while(true) {
        printf("Queue with List Program\n");
        printf("1. Enque\n");
        printf("2. Deque\n");
        printf("3. Print Que\n");
        printf("4. Exit\n");
        printf("Enter your command : ");
        scanf("%d",&input);
        getchar();
        
        switch (input) {
            case 1:
                printf("Enter a data : ");
                scanf("%d",&input);
                getchar();
                enque(input);
                break;
            case 2:
                if(deque(&input)) {
                    printf("Data is %d.\n",input);
                } else {
                    printf("Que is empty.\n");
                }
                break;
            case 3:
                printQue();
                break;
            case 4:
                exit(0);
            default:
                break;
        }
    }

    return 0;
}

void initQue(void) {
    front = (Node *)malloc(sizeof(Node));
    rear = (Node *)malloc(sizeof(Node));
    front->Next = rear;
    rear->Next = rear;
}

void enque(int data) {
    Node *tempNode = (Node *)malloc(sizeof(Node));
    tempNode->data = data;
    if(front->Next==rear) {
        front->Next = tempNode;
        tempNode->Next = rear;
        rear->Next = tempNode;
    } else {
        rear->Next->Next = tempNode;
        tempNode->Next = rear;
        rear->Next = tempNode;
    }
}

bool deque(int *data) {
    if(front->Next==rear) {
        return false;
    }
    Node *tempNode = front->Next;
    *data = tempNode->data;
    front->Next = tempNode->Next;
    free(tempNode);
    return true;
}

void printQue() {
    Node *currentNode = front->Next;
    if(front->Next==rear) {
        printf("Que is empty.\n");
        return;
    }
    printf("Front -> ");
    while(currentNode!=rear) {
        printf("%d -> ",currentNode->data);
        currentNode = currentNode->Next;
    }
    printf("Rear\n");
}






Wednesday, April 8, 2015

[OSX - Yosemite 10.10.x] How to fix brew after Yosemite upgrade????

  After Yosemite upgrade did you see this message when you run brew??

  /usr/loca/bin/brew: /usr/local/library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or Directory
  /usr/local/bin/brew: line 26: /usr/local/Library/brew.rb: Undefined error: 0

  If you saw that al least once. Here is solution.


Step 01. Go do Versions Directory

cd /System/Library/Frameworks/Ruby.framework/Versions
sudo ln -s Current 1.8
brew update

After do this, There is new Current directory.


Step 02.  Delete 1.8 directory

sudo rm 1.8

And you can see 2.0 and Current directory only.


Now you can use brew clearly :)