2013년 9월 21일 토요일

Amazon RDS 에서 utf-8 로 세팅하기

AWS Management Console에서 rds 접속

parameter 그룹 만들기

왼쪽 메뉴 - Parameter Groups ->

Create DB Parameter Group 클릭



자신의 mysql 버전에 맞게 만들자 (이름이랑 desc 는 상관없다)
왼쪽 돋보기를 클릭하여 디테일 화면으로 이동


































파라메터 수정

해당 내역을 스샷과 같게 수정한 후 오른쪽위의 "Save Changes" 클릭




















파라메터 적용

왼쪽 메뉴의 Instances 클릭 ->
"Instance Action" 에서 "Modify" 클릭

방금 추가한 그룹을 선택하자





















이제 instance 상태가 applying 에서 pending-reboot 로 변경된다.
"Instance Action" 에서 "Reboot" 클릭

적용확인

SHOW VARIABLES LIKE '%colla%';

SHOW VARIABLES LIKE '%char%';




2013년 4월 23일 화요일

php mysql의 datetime 이 어제 날짜인지 확인하는 함수

function is_yesterday($mysql_datetime){
$yesterday = date("Y-m-d", strtotime("-1 day"));
$check_day = date("Y-m-d", strtotime($mysql_datetime));
if($yesterday == $check_day){
return true;
}
return false;
}

어제말고 다른날짜로 변경하고 싶다면 아래 링크를 참조하면 된다
http://littletrue.egloos.com/3959171

2013년 4월 15일 월요일

codeigniter 에서 mysql NOW() 쓰는방법

각각 하나씩 set 을 하여 escape 시킨다

$data = array('name' => $name, 'count' => $count);
$this->db->set('updated_at', 'NOW()', false);
$this->db->insert('mytable');
view raw ci_sql_eval.php hosted with ❤ by GitHub
참고 : http://codeigniter-kr.org/user_guide_2.1.0/database/active_record.html
참고 : http://ellislab.com/forums/viewthread/73126/

2013년 4월 11일 목요일

codeigniter show_error 에서 <p> 태그 안나오게 하기

/system/core/Exceptions.php 의 show_error 함수를 수정


// before
$message = '<p>'.implode('</p><p>', ( ! is_array($message)) ? array($message) : $message).'</p>';
// after
$message = implode('', ( ! is_array($message)) ? array($message) : $message);

2013년 4월 4일 목요일

nginx 에서 code igniter index.php 없애는 법

url 에 index.php 가 안나오도록 하는방법

nginx/default.conf 수정
# root
location / {
try_files $uri $uri/ /index.php;
}
# v2 folder
location /v2/ {
try_files $uri $uri/ /v2/index.php;
}
view raw gistfile1.sh hosted with ❤ by GitHub
ci 의 루트 폴더가 / 이라면 첫번째
ci 의 루트 폴더가 하위 디렉토리라면 v2 대신에 수정하고 쓰면된다.

출처 : http://wiki.nginx.org/Codeigniter

phpstorm 에서 code igniter 자동완성 기능 쓰기 - phpStorm-CC-Helpers

phpstorm 에서 ci 자동완성 기능을 쓰는 방법

https://github.com/topdown/phpStorm-CC-Helpers

이곳에서 zip 파일을 받아 압축 푼 후

CI_code_completion 폴더를 내 프로젝트에 넣는다

그 후

/system/core/Controller.php
/system/core/Model.php
/system/database/DB_active_rec.php

세 파일을 Mark as Plain Text 로 변경 (파일에서 우클릭) 하면 끝

내 모델 등록하는 법


CI_code_completion 폴더에 있는 my_models.php 파일을 수정
주석에 예제로 나와 있는 모델명을 내 모델에 맞게 수정하면 된다. (주석을 해둔상태로)

예)
* @property Member_model $Member_model

<?php die();
/**
* Add you custom models here that you are loading in your controllers
*
* <code>
* $this->site_model->get_records()
* </code>
* Where site_model is the model Class
*
* ---------------------- Models to Load ----------------------
* @property Member_model $Member_model
* @property Number_model $Number_model
* @property Util_model $Util_model
* @property Content_model $Content_model
* @property Comment_model $Comment_model
*/
class my_models
{
}
// End my_models.php
view raw gistfile1.php hosted with ❤ by GitHub

2013년 3월 13일 수요일

php 큰따옴표 "" 에서 클래스변수도 먹힐까?


<?php
class test{
var $foo = "ok works";
function test_function(){
echo "aaa ".$this->foo." aaa";
echo "</br></br>";
echo "aaa $this->foo aaa";
echo "</br></br>";
}
}
?>
view raw gistfile1.php hosted with ❤ by GitHub

결과는

aaa ok works aaa
aaa ok works aaa
ㅇㅇ 먹힌다.



노가다를 줄여주는 안드로이드 템플릿

https://github.com/jgilfelt/android-adt-templates

이곳엔 기본 템플릿 외에 유용한 템플릿이 추가되어있다.


사용법

  1. 압축푼 파일을 sdk-folder/extras/templates/ 에 있는 activities 와 others 폴더에 각각 넣는다.
    (난 sdk-folder/tools/templates/ 에 있었음)
  2. New->Other ->Android->Android Object






템플릿들

  • EfficientListAdapter
    매번 리스트를 만드려면 view holder 패턴을 작성해야되는데 이를 편리하게 하여준다

    public class ItemAdapter extends BaseAdapter
    {
    // TODO replace with a collection of real data
    private static final List<DummyItem> DATA = DummyItemContent.ITEMS;
    private LayoutInflater mInflater;
    public ItemAdapter(Context context)
    {
    // Cache the LayoutInflate to avoid asking for a new one each time.
    mInflater = LayoutInflater.from(context);
    }
    /**
    * @see android.widget.ListAdapter#getCount()
    */
    public int getCount()
    {
    return DATA.size();
    }
    /**
    * @see android.widget.ListAdapter#getItem(int)
    */
    public Object getItem(int position)
    {
    return DATA.get(position);
    }
    /**
    * Use the array index as a unique id.
    *
    * @see android.widget.ListAdapter#getItemId(int)
    */
    public long getItemId(int position)
    {
    return position;
    }
    /**
    * Make a view to hold each row.
    *
    * @see android.widget.ListAdapter#getView(int, android.view.View,
    * android.view.ViewGroup)
    */
    public View getView(int position, View convertView, ViewGroup parent)
    {
    // A ViewHolder keeps references to children views to avoid unneccessary
    // calls
    // to findViewById() on each row.
    ViewHolder holder;
    // When convertView is not null, we can reuse it directly, there is no
    // need
    // to reinflate it. We only inflate a new View when the convertView
    // supplied
    // by ListView is null.
    if (convertView == null)
    {
    convertView = mInflater.inflate(R.layout.list_item_item, parent,
    false);
    // Creates a ViewHolder and store references to the two children
    // views
    // we want to bind data to.
    holder = new ViewHolder();
    // TODO store references to your views
    holder.title = (TextView) convertView.findViewById(R.id.title);
    holder.subtitle = (TextView) convertView
    .findViewById(R.id.subtitle);
    holder.thumbnail = (ImageView) convertView
    .findViewById(R.id.thumbnail);
    convertView.setTag(holder);
    }
    else
    {
    // Get the ViewHolder back to get fast access to the TextView
    // and the ImageView.
    holder = (ViewHolder) convertView.getTag();
    }
    // TODO Bind your data efficiently with the holder.
    holder.title.setText(DATA.get(position).content);
    holder.subtitle.setText(DATA.get(position).content);
    holder.thumbnail.setImageResource(DATA.get(position).thumbnail);
    return convertView;
    }
    static class ViewHolder
    {
    // TODO define members for each view in the item layout
    TextView title;
    TextView subtitle;
    ImageView thumbnail;
    }
    }
    view raw gistfile1.java hosted with ❤ by GitHub
  • ParcelableType
    Parcelable 클래스 템플릿
    public class NameCard implements Parcelable
    {
    // TODO declare your real class members
    // Members must be either primitives, primitive arrays or parcelables
    private int mFoo;
    private String mBar;
    // TODO implement your constructors, getters & setters, methods
    private NameCard(Parcel in)
    {
    // TODO read your class members from the parcel
    // Note: order is important - you must read in the same order
    // you write in writeToParcel!
    mFoo = in.readInt();
    mBar = in.readString();
    }
    @Override
    public void writeToParcel(Parcel out, int flags)
    {
    // TODO write your class members to the parcel
    // Note: order is important - you must write in the same order
    // you read in your private parcelable constructor!
    out.writeInt(mFoo);
    out.writeString(mBar);
    }
    @Override
    public int describeContents()
    {
    // TODO return Parcelable.CONTENTS_FILE_DESCRIPTOR if your class members
    // include a FileDescriptor, otherwise you can simply return 0
    return 0;
    }
    public static final Parcelable.Creator<NameCard> CREATOR = new Parcelable.Creator<NameCard>() {
    public NameCard createFromParcel(Parcel in)
    {
    return new NameCard(in);
    }
    public NameCard[] newArray(int size)
    {
    return new NameCard[size];
    }
    };
    }
    view raw gistfile1.java hosted with ❤ by GitHub
  • Sherlock 템플릿들
    기본 activity 와 같은 템플릿으로 Sherlock 라이브러리를 사용하여 생성
  • TVLeftNavBarActivity
    google TV 를 위한 것이라고 한다. 원문참고

    This template creates a new blank activity with a left navigation/action bar implementation optimized for Google TV. You can select different visual behaviors (expanded, collapsed, or expand on focus) and navigation modes (standard, tabs or list). This template has a dependency on the Google TV LeftNavBarLibrary project which is available here.

2013년 3월 12일 화요일

restful 테스트 쉽게 하는곳

post, get data 를 테스트 하기에 좋은 사이트

Postman



크롬을 쓴다면 매우 유용한 도구
13년 5월 20일 현재 926명 평가에 무료 별점 5개를 기록하고 있다.

https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm/related

http://hackst.com/





깔끔한 디자인에 원하던 기능이 모두 있다. history 기능도 있음
가끔씩 접속 안됨


http://www.hurl.it/


심플한 사이트. Ruby 환경이라면 직접 소스를 다운받아 사용할 수 있다.
역시 가끔씩 에러가 뜸

https://apigee.com/console/

twitter, facebook 등등 수십가지의 api 들을 테스트 해볼수 있게 미리 지정되어 있다.
가장 위의 Other 를 선택하면 직접 url 입력이 가능하다.
기업에서 운영하기 때문에 접속이 안되는 일은 없음

java 정규식 빈칸만 있는 문자인지를 체크하고 싶을때

if (string.trim().length() > 0){
// true
}
if (string.matches(".*\\w.*")) {
// true
}
view raw gistfile1.java hosted with ❤ by GitHub


첫번째 : trim 으로 공백을 모두 없앴을때 length 가 0 일때 true

두번째 : /w 로 문자열에 문자가 포함되었는지를 체크, 이 방법은 특수문자만으로 이루어진 글일때 역시 false 를 반환한다

ex) #$@! = false

출처 : http://stackoverflow.com/questions/3247067/how-to-check-that-java-string-is-not-all-whitespaces