2013. 7. 29. 17:58

아래와 같은 오류가 발생하면 

MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.

아래와 같은 명령어로 해결한다.

redis 127.0.0.1:6379> config set stop-writes-on-bgsave-error no



출처 : https://github.com/antirez/redis/issues/584

Posted by CoolDragon
2013. 7. 17. 19:37

EXEC sp_addlinkedserver   

    @server='db link 명', 

    @srvproduct='',

    @provider='SQLNCLI', 

    @datasrc='tcp:0.0.0.0'


EXEC sp_addlinkedsrvlogin

    @useself='FALSE',

    @rmtsrvname='db link 명',

    @rmtuser='계정',

    @rmtpassword='비밀번호'


더 잘 정리된 포스트 http://blog.naver.com/PostView.nhn?blogId=0131v&logNo=110110231583

Posted by CoolDragon
2013. 7. 15. 13:35

####################

# 방화벽 포트 등록 #

####################

$ vi /etc/sysconfig/iptables

-A INPUT -p tcp -m state --state NEW -m tcp --dport 6379 -j ACCEPT (6379 포트 항목 추가)

$ /etc/init.d/iptables restart (방화벽 포트 설정 재시작)


####################

# GCC 설치         #

####################

# yum groupinstall 'Development Tools'


####################

# Redis 설치       #

####################

$ wget http://redis.googlecode.com/files/redis-2.6.14.tar.gz

$ tar xzf redis-2.6.14.tar.gz

$ cd redis-2.6.14

$ make && make install


$ src/redis-server


$ src/redis-cli

redis> set foo bar

OK

redis> get foo

"bar":q


####################

# Redis 서비스 실행#

####################

$ mkdir /etc/redis /var/lib/redis

$ sed -e "s/^daemonize no$/daemonize yes/" -e "s/^dir \.\//dir \/var\/lib\/redis\//" -e "s/^loglevel debug$/loglevel notice/" -e "s/^logfile stdout$/logfile \/var\/log\/redis.log/" redis.conf > /etc/redis/redis.conf


$ wget https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server

$ sed -i "s/usr\/local\/sbin\/redis/usr\/local\/bin\/redis/" redis-server

$ chmod u+x redis-server

$ mv redis-server /etc/init.d

$ /sbin/chkconfig --add redis-server

$ /sbin/chkconfig --level 345 redis-server on

$ /sbin/service redis-server start

$ ps -ef // 프로세스 체크


####################

# Redis TEST       #

####################

telnet 아이피 포트

set attitude:today "happy"

get attitude:today



[출처]

http://redis.io/download

http://www.ebrueggeman.com/blog/install-redis-centos-56

Posted by CoolDragon
2013. 3. 18. 10:01

아래와 같이 하면 Enum으로 데이터를 선언하고 실제 소스에서는 enum 형식으로 비교하고 UI에서는 Description 내용으로 보여줄 수 있다.


    public enum eGameInfo

    {

        [Description("사과")]

        Apple = 1,

        [Description("오렌지")]

        Orange = 2,

        [Description("망고")]

        Mango = 3,

    }


    public class HtmlHelper

    {

        public static string GetComboBoxHtml<TEnum>(string id, string style, TEnum eValue, bool isAll, string allText, string allValue, string[] exceptValues)

        {

            string html = "";


            string[] names = Enum.GetNames(typeof(TEnum));

            Array values = Enum.GetValues(typeof(TEnum));


            html += string.Format("<select id=\"{0}\">", id);

            for (int i = 0; i <= names.Length - 1; i++)

            {

                string value = Convert.ToInt32(values.GetValue(i)).ToString();

                string text = names[i];

                string name = HtmlHelper.GetDescriptName<TEnum>(text);

                if (!string.IsNullOrEmpty(name)) text = name;


                if (exceptValues.Where(code => code.Equals(value)).Count() == 0)

                {                    

                    html += string.Format("    <option value=\"{0}\" {2}>{1}</option>", value, text, eValue.ToString().Equals(values.GetValue(i).ToString()) ? "selected=\"selected\"" : "");

                }

            }

            html += string.Format("</select>");


            return html;

        }


        public static string GetDescriptName<T>(string memberName)

        {

            string name = string.Empty;

            var type = typeof(T);


            foreach (System.Reflection.MemberInfo member in type.GetMember(memberName))

            {

                object[] attributes = member.GetCustomAttributes(false);


                if (attributes.Length != 0)

                {

                    foreach (object attr in attributes)

                    {

                        DescriptionAttribute descAttr = attr as DescriptionAttribute;


                        if (descAttr != null)

                        {

                            name = descAttr.Description;

                            break;

                        }

                    }

                }

            }

            return name;

        }

    }

Posted by CoolDragon
2013. 1. 29. 23:00

1. 윈도우즈 버전 다운로드


2. 서비스로 구동하기 위하여 NSSM(the Non-Sucking Service Manager) 사이트에서 프로그램을 다운로드 받음

    2.1 다운로드 받은 파일을 압축을 풀고 아래와 같이 실행을 한다.

   ※ 주의 : 서비스를 생성할 때 되도록이면 c:\Program Files 경로에서 생성하지 말길 바란다.  서비스는 생성되지만 공백이 있어 

               그런지 정상적으로 실행되지 않는다. 따라서 경로를 바꿔서 하는게 정신 건강에 좋을 것 같다.

3. 실행코드

var http = require('http');

http.createServer(function (req, res) {

  res.writeHead(200, {'Content-Type': 'text/plain'});

  res.end('Hello World\n');

}).listen(1337, '127.0.0.1');

console.log('Server running at http://127.0.0.1:1337/');

4. 실행결과




Posted by CoolDragon
2012. 12. 11. 19:23


JSON 메시지 생성 (출처 : http://code.google.com/p/aspjson/)

JSON_2.0.4.asp

JSON_UTIL_0.1.1.asp

<!-- #include virtual="JSON_2.0.4.asp" -->

<!-- #include virtual="JSON_UTIL_0.1.1.asp" -->

<%

Dim json

Dim person, people(4)


For i = 0 To 4

Set person = jsObject()

person("name") = "park"

person("age") = 20

person("sex") = "male"

Set people(i) = person

Next


Set json = jsObject()

json("count") = Ubound(people)

json("people") = people


Response.Write toJSON(json)

' 결과

{"count":4,"people":[{"name":"park","age":20,"sex":"male"},{"name":"park","age":20,"sex":"male"},{"name":"park","age":20,"sex":"male"},{"name":"park","age":20,"sex":"male"},{"name":"park","age":20,"sex":"male"}]}

%>


JSON 메시지 파싱 (https://github.com/nagaozen/asp-xtreme-evolution/blob/master/lib/axe/classes/Parsers/json2.asp)

json2.asp

<!-- #include virtual="json2.asp" -->


dim Info : set Info = JSON.parse(join(array( _
    "{", _
    " ""firstname"": ""Fabio"",", _
    " ""lastname"": ""長尾"",", _
    " ""alive"": true,", _
    " ""age"": 27,", _
    " ""nickname"": ""nagaozen"",", _
    " ""fruits"": [", _
    " ""banana"",", _
    " ""orange"",", _
    " ""apple"",", _
    " ""papaya"",", _
    " ""pineapple""", _
    " ],", _
    " ""complex"": {", _
    " ""real"": 1,", _
    " ""imaginary"": 2", _
    " }", _
    "}" _
)))

Response.write(Info.firstname & vbNewline) ' prints Fabio
Response.write(Info.alive & vbNewline) ' prints True
Response.write(Info.age & vbNewline) ' prints 27
Response.write(Info.fruits.get(0) & vbNewline) ' prints banana
Response.write(Info.fruits.get(1) & vbNewline) ' prints orange
Response.write(Info.complex.real & vbNewline) ' prints 1
Response.write(Info.complex.imaginary & vbNewline) ' prints 2

Posted by CoolDragon
2012. 12. 11. 17:40



ASP 방식

Function BytesToStr(bytes)
    Dim Stream
    Set Stream = Server.CreateObject("Adodb.Stream")
        Stream.Type = 1 'adTypeBinary
        Stream.Open
        Stream.Write bytes
        Stream.Position = 0
        Stream.Type = 2 'adTypeText
        Stream.Charset = "iso-8859-1"
        BytesToStr = Stream.ReadText
        Stream.Close
    Set Stream = Nothing
End Function
If Request.TotalBytes > 0 Then
    Dim lngBytesCount
        lngBytesCount = Request.TotalBytes
    Response.Write BytesToStr(Request.BinaryRead(lngBytesCount))
End If


ASP.NET 방식

string jsonMessage = string.Empty;
System.IO.Stream inputStream = HttpContext.Current.Request.InputStream;
byte[] inputBuffer = new byte[inputStream.Length];
inputStream.Read(inputBuffer, 0, inputBuffer.Length);

try
{
	jsonMessage = System.Text.Encoding.UTF8.GetString(inputBuffer);
}
catch (Exception ex)
{
	throw ex;
}

return jsonMessage;

Posted by CoolDragon
2012. 10. 22. 17:39

첨부파일 참조..



MyBitis.zip


Posted by CoolDragon
2012. 10. 22. 17:31

<?xml version="1.0" encoding="utf-8" ?>

<sqlMap namespace="UserInfo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ibatis.apache.org/mapping">

  <alias>

    <typeAlias alias="MyUser"  type="MainApp.MyUser" />

  </alias>


  <statements>

    <!-- 동적 테이블 생성 -->

    <statement id='Create_Login_Log'>

      IF NOT EXISTS (SELECT 'X' FROM sysobjects where xtype = 'U' and name = 'Login_Log$yyyymm$')

      BEGIN

      create table Login_Log$yyyymm$

      (

      id int identity(1,1),

      name nvarchar(100)

      );

      END;


      IF NOT EXISTS (SELECT 'X' FROM sysobjects where xtype = 'U' and name = 'Login_Log2_$yyyymm$')

      BEGIN

      create table Login_Log2_$yyyymm$

      (

      id int,

      name nvarchar(100)

      );

      END;

    </statement>


    <!-- 동적 생성 테이블 데이터 Insert  -->

    <insert id="Insert_Login_Log" resultClass="int" >

      INSERT INTO Login_Log$yyyymm$ (name)

      VALUES (#name#);

      <selectKey resultClass="int" property="id" type="post" >

        SELECT @@IDENTITY AS VALUE;

      </selectKey>

    </insert>


    <!-- 동적 생성 테이블 데이터 Insert  -->

    <insert id="Insert_Login_Log2" resultClass="int" >

      INSERT INTO Login_Log2_$yyyymm$ (id, name)

      VALUES (#id#, #name#);

    </insert>


    <!-- 동적 테이블 데이터 조회 -->

    <select id="Select_Login_Log">

      SELECT *

      FROM Login_Log$yyyymm$ a inner join Login_Log2_$yyyymm$ b on a.id = b.id

      WHERE b.id = #id#;

    </select>

  </statements>

</sqlMap>

Posted by CoolDragon
2012. 10. 22. 17:25

1) iBatis.Net 프레임워크 다운로드

    http://blog.mybatis.org/


2) .NET 프로젝트 생성


3) iBatis.Net DLL 참조


4) config 파일 설정

 - provider 파일

 - sqlmap 파일

 - query 파일

Posted by CoolDragon