구글 애드센스는 광고를 자동으로 등록해주고 있지만 자신의 블로그에 적합하지 않거나 개인적으로 노출하기 싫은 광고도 노출이 되기 때문에 직접 선택적으로 차단해야 합니다.


google adsense logo

 

1. 일반 카테고리를 이용 차단

 

애드센스에 로그인을 합니다.


좌측 메뉴에서

차단관리 > 모든 사이트를 선택 합니다.



그러면 우측에 탭 메뉴가 나오고 여기서

일반 카테고리를 선택 합니다.


설명을 위해 하나를 선택해 보겠습니다.

금융과 관련 카테고리를 선택합니다.

허용됨으로 체크 되어있는 금융(52)를 클릭 합니다.



하부 카테고리 리스트에 추가적인 카테고리가 있는 경우 ▶ 표시가 있습니다.

이번엔 융자 대출을 클릭해 봅니다.



한번 차단을 해볼까요?

차단 하려는 광고 좌측 체크박스를 클릭하면 바로 적용이 됩니다.


하나씩 클기하며 차단을 적용 합니다.

상위 카테고리로 이동 하려면 위에 있는

네비게이션을 사용하면 됩니다.




2. 민감한 카테고리 이용 차단

 

일반 카테고리를 이용한 차단은 종류가 많아서 관리가 어렵다면

손쉽게 전체를 관리 할 수 있는 기능이 민감한 카테고리입니다.



~욱 한번 아래로 훌터보면 감이 잡히죠?

 

위에서부터 하나씩 보면서 맘에 들지 않는 광고 단어들을

좌측 체크박스를 클릭하면 바로 차단이 됩니다.



 

지금까지 5개월동안 1달러도 못번 블로그의 팁이었습니다. ㅋㅋ


2019년 황금 돼지해에는 꼭 원달라” “원달라


- copy coding -


android에서 사용하는 여러 저장 방법 중 간단하게 사용할 수 있는 기능 입니다.

개발에 필요한 크지 않은 변수와 값들을 내부에 저장하기에 적당합니다.

key-value 형식으로 저장이 됩니다.

 


1. SharedPreferences

 

SharedPreferences에서 사용하는 상수와  Method들 입니다.

그냥 이런게 있구나 하고 보시고 필요시 사용하면 됩니다.

 

1.1 Constants


SharedPreference Constants


Type

Constant

Description

int

MODE_APPEND

기존 preferences 신규 preferences 추가

int

MODE_MULTI_PROCESS

이미 호출되어 사용 중인지 체크

int

MODE_PRIVATE

생성한 application에서만 사용 가능

int

MODE_WORLD_READABLE

다른 application에서 읽을 있음

int

MODE_WORLD_WRITEABLE

다른 application에서 기록할 있음

 


1.2 Methods


SharedPreference Methods

 

Type

Method

abstract boolean

contains(String key)

- 키 값이 들어있는지 체크

abstract SharedPreferences.Editor

edit()

- 신규 Editor를 생성

abstract Map

getAll()

- 저장된 모든 값을 검색

abstract boolean

getBoolean(String key, boolean defValue)

- 키에 해당하는 boolean 값 검색

abstract float

getFloat(String key, float defValue)

- 키에 해당하는 float 값 검색

abstract int

getInt(String key, int defValue)

- 키에 해당하는 int 값 검색

abstract long

getLong(String key, long defValue)

- 키에 해당하는 long 값 검색

abstract String

getString(String key, String defValue)

- 키에 해당하는 set 형태의 string 값 검색

abstract Set

getStringSet(String key, Set defValues)

- 키에 해당하는 boolean 값 검색


1.3 Editor Methods


SharedPreference.Editor Methods

 

Type

Method

abstract void

apply()

- 비동기 적으로 값을 저장 한다

abstract SharedPreferences.Editor

clear()

- 모든 값을 삭제 한다.

abstract boolean

commit()

- 동기 적으로 값을 저장 하고 결과를 리턴 한다

abstract SharedPreferences.Editor

putBoolean(String key, boolean value)

- bool 값을 설정 한다

abstract SharedPreferences.Editor

putFloat(String key, float value)

- float 값을 설정 한다

abstract SharedPreferences.Editor

putInt(String key, int value)

- int 값을 설정 한다

abstract SharedPreferences.Editor

putLong(String key, long value)

- long 값을 설정 한다

abstract SharedPreferences.Editor

putString(String key, String value)

- string 값을 설정 한다

abstract SharedPreferences.Editor

putStringSet(String key, Set values)

- set  값을 설정 한다

abstract SharedPreferences.Editor

remove(String key)

- key 해당하는 값을 삭제 한다

 

* putxxx() 작업은 반영을 위해 commit() 또는 apply()를 호출해야 합니다.

* remove()는 반영을 위해 commit()을 호출 해야 합니다.



2. 프로그램 설명

 

간단히 사용하는 저장 공간이기 때문에 설치하는 것도 없고

핸들만 얻어서 사용하면 됩니다.

 

2.1 Handle 얻기


getSharedPreferences() : 여러개의 Shared Preference 파일들을 사용 하는 경우

getPreferences() : 한개의 Shared Preference 파일을 사용하는 경우.

 

여기서는 첫번째 getSharedPreferences()를 사용 합니다.

정의는

public abstract SharedPreferences getSharedPreferences (String name, int mode)

이렇게 되어 있고


사용은

SharedPreferences sharePref = getSharedPreferences("SHARE_PREF", MODE_PRIVATE);

이렇게 합니다.


SHARE_PREF라는 이름의 저장소를 생성한 application에서만

사용가능 모드로 사용하기 위해 생성합니다.

만일 SHARE_PREF 라는파일이 없으면 신규로 생성 합니다.


 버튼을 클릭하면 작업을 하고 바로 리스트를 가져오도록 되어있습니다.

 

2.2 Data 저장


Editor를 이용하여 저장 합니다.

SharedPreferences.Editor editor = sharePref.edit();

각각의 데이터 타입별로 저장해 보았습니다.

public void saveData() {
    editor.putBoolean("isShare", true);
    editor.putFloat("fRate", 1.33f);
    editor.putInt("nValue", 100);
    editor.putString("name", "copycoding");
    editor.apply();

}

2.3 Data 수정


저장과 같은 방식으로 값만 변경하면 됩니다.

public void updateData() {
    editor.putBoolean("isShare", false);
    editor.putFloat("fRate", 3.33f);
    editor.putInt("nValue", 5000);
    editor.putString("name", "copycoding.tistory");
    editor.apply();
}

2.4 Data 삭제


remove()key값을 적어주면 됩니다.

public void deleteData() {
    editor.remove("nValue");
    editor.commit();
}

2.5 불러오기


최초 생성한 핸들(여기서는 sharePref)을 이용해서 불러옵니다.

public void listData() {
    String dataList = "";
    Map totalValue = sharePref.getAll();
    for(Map.Entry entry : totalValue.entrySet()) {
        dataList += entry.getKey().toString()+ ": " + entry.getValue().toString() + "\r\n";
        Log.d("share : ", entry.getKey() + ": " + entry.getValue());
    }
    tvList.setText(dataList);
}


저는 자동으로 출력하려고 만든거고 하나씩 가져오려면

sharePref.getString(“name”, “”);

이렇게 하면 됩니다.

뒤에 “”이건 default 값을 적어주는 것입니다.

 

 

3. Source Code

 

3.1 activity_main.xml

 

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/btn_onclick1"
        android:text="Save"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="50dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:onClick="btnClick"/`
    <Button
        android:id="@+id/btn_onclick2"
        android:text="Update"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="100dp"
        android:layout_marginTop="50dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:onClick="btnClick"/>
    <Button
        android:id="@+id/btn_onclick3"
        android:text="Delete"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="190dp"
        android:layout_marginTop="50dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:onClick="btnClick"/>
    <Button
        android:id="@+id/btn_onclick4"
        android:text="Clear"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="280dp"
        android:layout_marginTop="50dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:onClick="btnClick"/>

    <TextView
        android:id="@+id/tvList"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="SharedPreferences Test"
        android:layout_marginTop="100dp"
        android:textSize="25dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>


3.2 MainActivity.java


package copycoding.android.app.sharedprefer;

import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import java.util.Map;

public class MainActivity extends AppCompatActivity {

    static private String SHARE_NAME = "SHARE_PREF";
    static SharedPreferences sharePref = null;
    static SharedPreferences.Editor editor = null;
    TextView tvList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        tvList = (TextView)findViewById(R.id.tvList);

        sharePref = getSharedPreferences(SHARE_NAME, MODE_PRIVATE);
        editor = sharePref.edit();
    }

    public void btnClick(View view) {
        if(view.getId() == R.id.btn_onclick1) {  // Buttoon의 ID를 찾아서 실행이 된다.
            saveData();
        } else if(view.getId() == R.id.btn_onclick2) {
            updateData();
        } else if(view.getId() == R.id.btn_onclick3) {
            deleteData();
        } else if(view.getId() == R.id.btn_onclick4) {
            editor.clear();
            editor.commit();
        }
        listData();
    }

    public void saveData() {
        editor.putBoolean("isShare", true);
        editor.putFloat("fRate", 1.33f);
        editor.putInt("nValue", 100);
        editor.putString("name", "copycoding");
        editor.apply();

    }

    public void updateData() {
        editor.putBoolean("isShare", false);
        editor.putFloat("fRate", 3.33f);
        editor.putInt("nValue", 5000);
        editor.putString("name", "copycoding.tistory");
        editor.apply();
    }

    public void deleteData() {
        editor.remove("nValue");
        editor.commit();
    }

    public void listData() {
        String dataList = "";
        Map<String, ?> totalValue = sharePref.getAll();
        for(Map.Entry<String, ?> entry : totalValue.entrySet()) {
            dataList += entry.getKey().toString()+ ": " + entry.getValue().toString() + "\r\n";
            Log.d("share : ", entry.getKey() + ": " + entry.getValue());
        }
        tvList.setText(dataList);
    }
}


4. 결과


각각의 버튼에 대한 화면 입니다.

버튼을 클릭하면 기능을 수행하고 바로 결과에 대한 리스트를 출력합니다.



android data sharedpreferences



5. APK


다운받아 테스트를 해봅니다.


SharePref.apk


- copy coding -


GitHub에 프로젝트를 upload 하고 필요 없거나 잘못 올린 경우

프로젝트를 삭제해야 하는 상황이 발생 합니다.

삭제는 버튼만 몇번 클릭하면 완료 됩니다.


git repository delete


GitHub에서 삭제할 repository를 선택 합니다.

그러면 파일이 있는 페이지로 이동 됩니다.



상단에 [Settings]를 선택 합니다.

 

이동된 페이지에 여러 가지 기능이 나오는데 아래로 쭈~욱 스크롤 합니다.

그럼 맨 마지막에 Danger Zone이 나옵니다.



[Delete this repository] 버튼을 클릭 합니다.

 

여러가지 경고 문구가 있는 팝업 창이 나옵니다.



삭제 하려는 repository명칭을 확인 하고

하단에 있는 긴 [I understand the conse….] 버튼을 클릭 합니다.

 

그러면 한번 더 취소할 수 있는 기회로 비번을 입력하라고 합니다.

여기서 비번을 입력 하고



[Confirm password] 버튼을 클릭하면 Repository 삭제가 완료 됩니다.

 

다시 GitHub 메인 페이지로 돌아오면



완전히 삭제되었음을 확인 할 수 있습니다.


- copy coding -


TensorBoard를 어떻게 작동시키는지 알아보려고 합니다.

아나콘다를 설치하고 tensorflow도 설치 했으니 이건 식은죽 먹기 입니다.

 

1. TensorBoard 실행


먼저 Anaconda Prompt를 실행 합니다.



Tensorflow를 설치한 가상환경으로 이동 합니다.

>activate tensorflow

 

tensorboard 실행 명령어를 입력 합니다.



명령어를 살펴 보겠습니다.

(tensorflow) C:\Users\will>tensorboard --logdir=./path/logs/

 

log의 위치가

C:\Users\will\path\logs\

여기이고 이곳의 파일을 사용하라는 뜻입니다.


각자 알아서 path를 생성해 줍니다.

엔터키를 눌러 명령을 실행 합니다.



tensorboard가 실행이 되었다는군요.

종료는 키보드 Ctrl + C 를 누르면 되고 기본 Port6006 이라네요.

 


2. TensorBoard 브라우저

 

텐서보드는 콘솔로 띄우고 화면을 보는것은 웹브라우저에서 봐야 합니다.

브라우저를 하나 열고 http://localhost:6006을 입력 합니다.



아직 아무 작업도 하지 않아서 그냥 텍스트 안내만 나오고 있습니다.

 


3. TensorBoard port 변경 하기


만약 기존에 다른 프로그램에서 port 6006을 사용하고 있다면

텐서보드 기동시 변경을 해주면 됩니다.

(tensorflow) C:\Users\will>tensorboard --logdir=./path/logs/ --port=9999




변경된 port로 잘 실행 됩니다.

 


4. Tensorboard 메뉴


어떤 메뉴들이 있는지 확인해 볼까요?



다양한 메뉴들이 존재 합니다.

조만간 하나씩 사용해 봐야 겠네요.

 

 

5. Tensorboard 테스트

 

간단한 프로그램으로 텐서보드를 사용해 보겠습니다.

먼저 프로그램 작성 전에 아무 곳이나 log 저장할 위치를 설정해야 합니다.


저는 F:\tensordata\log로 결정 했습니다.

jupyter notebook에 프로그램을 작성합니다.



그냥 더하기 입니다.

그래프 저장은 절대값으로 입력해 보았습니다.

tensorflow가 덧셈을 잘 하는군요.

그래프가 로그 디렉토리에 생성이 되었는지 한번 가봅니다.



생성이 되어있네요.

그럼 이미지로 보도록 하겠습니다.

 

텐서보드를 띄우고



브라우저를 열어서 확인해 봅니다.

 

http://localhost:9999

url이 자동으로 변경이 되었습니다.

http://localhost:9999/#graphs&run=.


tensorboard


단순한 이미지지만 처음 만들었으니 용서가 됩니다.

 

tensorflow 코딩만 할 수 있으면 tensorboard도 잘 사용할 수 있겠습니다.


- copy coding -


1···949596979899100···118

+ Recent posts