갑자기 스크립트 언어가 하고 싶어져서 시작해보는 루아

윈도우에서 설치할꺼다

http://code.google.com/p/luaforwindows/ 요기서 Lua for windows 받아서 설치~

http://www.lua.org/ 리눅스 버전은 요기서 다운로드~

 

루아를 받아서 설치하고 나면 한줄씩 실행 해볼 수 있는 요런 커맨드라인과

(hello world를 띄워 보았다.)

SCiTE 라는 편집기가 설치가 된다.

 

 

하지만!! 나는 이클립스를 사랑하는 게으른 개발자.
플러그인이 있으면 따뜻하겠지....

2012년 9월 24일 현재
Lua - http://luaeclipse.luaforge.net/update-site/site.xml 사이트로 제공이 되고 있다.

이클립스에서 Window -> Install new software 로 가서 사이트를 추가하자!
그러면 아래 화면이 나온다

덮어놓고 LuaEclipse 1.2구나 해서 전체 선택한다음 설치하면 오류나니까 주의!
안에 보면 Lua Development Tool 이 두개가 있는것이 보인다.

위에 있는게 32비트용, 아래가 64비트용이다. 둘 중 맞는걸로 설치해주자.

라고 하고 설치하려고 했는데 설치가 안된다 -_-......뭐지 집에서 32비트용으로 설치할 땐 됐는데....
뭔가 문제가 있나보다 - -)

여튼 설치하고 나서 new project 해보면 루아가 있는 걸 확인할 수 있을게다

에잉 = =) 64비트 지원은 아직 안되나보네...


이클립스를 실행시 failed to create the java virtual machine과 같은 메세지가 나온다면 

이클립스 폴더의 eclipse.ini 파일을 열어서 수정해준다.

-vm
C:\Program Files\Java\jdk1.5\bin\javaw.exe(자바 설치 위치)

알맞게 각자의 위치로 설정해준다.

이래도 고쳐지지 않으면

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.200.v20120522-1813
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Xms40m
-Xmx512m


빨간색으로 표시된 부분을 알맞은 메모리 크기로 바꾸어준다.

이 오류는 아마도 이클립스가 실행될 때 자바 가상머신에 할당될 메모리가 부족해서 생기는 오류인 듯.

사실 글 쓰기 전에 카테고리를 어디에 넣어야 할지 정말 많은 고민을 했다 ㅋㅋㅋ

Valgrind는 여러 CPU family에서 사용 가능하고 또한 지원하는 언어도 다양하기 때문에 거의 어디서든 사용할 수 있기 때문이다.

그래서 그냥 programing에 넣어버렸다.


각설하고, Valgrind는 memory trace tool로 대부분 memory leak이나 잘못된 포인터의 접근 등을 알아보는데 쓰이지만 나는 현재 진행하고 있는 in-memory 프로젝트에서 Cassandra가 현재 어떻게, 얼마나 메모리를 사용하고 있는지 알아보기 위해 사용하도록 하겠다.

1. 다운 & 설치

# wget http://www.valgrind.org/downloads/valgrind-3.7.0.tar.bz2

# tar -xvjf valgrind-3.7.0.tar.bz2

리눅스의 기본 3대 설치법

./configure

make

make install

끗!


단, 주의할 점이 있는데 README를 읽어보자.

Important!  Do not move the valgrind installation into a place
different from that specified by --prefix at build time.  This will
cause things to break in subtle ways, mostly when Valgrind handles
fork/exec calls.

라고 합니다. 난 걍 설치 ㄱㄱ


구동하기 위해선 다음과 같은 패키지가 필요한듯.

On Debian, Ubuntu:                 libc6-dbg
On SuSE, openSuSE, Fedora, RHEL:   glibc-debuginfo


테스트 해보자 ! ls -l 을 가지고 테스트해 보겠다

# valgrind ls -l

leak check을 위해서는 --leak-check=yes 옵션을 붙여준다.

==8275== HEAP SUMMARY:
==8275==     in use at exit: 15,212 bytes in 109 blocks
==8275==   total heap usage: 604 allocs, 495 frees, 102,693 bytes allocated
==8275==
==8275== LEAK SUMMARY:
==8275==    definitely lost: 80 bytes in 2 blocks
==8275==    indirectly lost: 240 bytes in 20 blocks
==8275==      possibly lost: 0 bytes in 0 blocks
==8275==    still reachable: 14,892 bytes in 87 blocks
==8275==         suppressed: 0 bytes in 0 blocks
==8275== Rerun with --leak-check=full to see details of leaked memory
==8275==
==8275== For counts of detected and suppressed errors, rerun with: -v
==8275== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 31 from 8)


다음과 같은 결과가 잘 나오는 것을 볼 수 있다.

private static void Process_time()
{     
      int intInterval = 1000; // 1 second
      string procName = "ProcessName";
      
      while (true)
      {
             Process[] runningNow = Process.GetProcesses();             
             foreach (Process process in runningNow)
             {
                   using (PerformanceCounter pcProcess = new PerformanceCounter("Process", "% Processor Time", process.ProcessName))
                   {   
                        if (process.ProcessName == procName)>
                        {
                              pcProcess.NextValue();
                              System.Threading.Thread.Sleep(1000);
                              Console.WriteLine("Process:{0} CPU% {1}", process.ProcessName, pcProcess.NextValue());
       
                            //if (pcProcess.NextValue() > float.Parse("10");
                            // process의 점유율을 체크하여 10 이상이면 kill
                            //{
                            //    Console.WriteLine(string.Format("Killing {0} at {1}", procName, DateTime.Now.ToString()));
                            //    process.Kill();
                            //}
                        }
                   }
              }
                // Sleep till the next loop
                Thread.Sleep(intInterval);      
      }
}
string sql = "Provider=OraOLEDB.Oracle.1;Data Source=orcl;Persist Security Info=True;User ID=아이다;Password=비밀번호;";     //oracle 서버 연결 문자열

            OleDbConnection conn = new OleDbConnection(sql);
            conn.ConnectionString = sql;
            try
            {
                conn.Open();            //데이터베이스 연결
                OleDbCommand cmd = new OleDbCommand();
                cmd.CommandText = "select * from 테이블";   //테이블
                cmd.CommandType = CommandType.Text;         //검색쿼리
                cmd.Connection = conn;

                OleDbDataReader read = cmd.ExecuteReader(); //select 쿼리 결과
                Console.WriteLine("***** 테이블 분석 결과 *****");
                for (int i = 0; i < read.FieldCount; i++)
                {
                    Console.WriteLine("필드이름 : {0} \n", read.GetName(i));
                }
                Console.WriteLine("총필드 개수는" + read.FieldCount);
                read.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("에러발생{0}", ex.Message);
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();       //데이터베이스 연결 해제
                    Console.WriteLine("데이터베이스 연결 해제..");
                }
            }

mksdcard [-l 레이블] SD카드의 사이즈(K를 붙이면 킬로바이트, M을 붙이면 메가바이트) 파일 이름


C 드라이브에 sdcard01.img파일 생성


AVD로 새로운 test emulator 생성
SD카드 부분에 생성한 sdcard 이미지 삽입


에뮬레이터에서 확인~


 


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="패키지"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
     <activity android:name="액티비티">                             <!-- MapActivity -->
   
<intent-filter>
          <category android:name="android.intent.action.MAP"></category>
   </intent-filter>
  </activity>
  <activity android:name=".main" android:label="@string/app_name">
      <intent-filter>
             <action android:name="android.intent.action.MAIN" />
             <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
  </activity>
 <uses-library android:name="com.google.android.maps"></uses-library>   
<!-- you must add this library -->

</application>

<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>

public class Dday : Form
{
        public Dday()
        {
                addform = new Add(this);
        }
}

public partial class Add : Form
{
        Dday aa;

        public Add(Dday dd)
        {
            InitializeComponent();
            aa = dd;
        }
}

무한 삽질은 계속된다 쭈~~~~~~욱


아 드디어 찾았다 =ㅁ=;;;

C# 에서는 이쁘게 이벤트 관리를 해준다.

이거였다 -_-;
함수를 제작하고나서
모든 이벤트들을 내가 알아서 등록 할 수 있다...

어쩐지 함수 안으로 한 발자국도 안들어가더라니 -_-.....

이런 알흠다운 녀석 -_-
Key event
  1. Key down
  2. Key press
  3. Key up

private void Snake_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Up)
                MessageBox.Show("up");
        }


Graphic event
protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            Rectangle rect;

Brush brush = new SolidBrush(Color.Blue);
            rect = new Rectangle(5, 5, 5, 5);
            g.FillRectangle(brush, rect);
       }

시뮬레이터에서 돌려보니 키 이벤트가 도대체 먹지를 않는다 -ㅁ-;
뭐냐능??.....

+ Recent posts