Skip to content

Instantly share code, notes, and snippets.

View okmttdhr's full-sized avatar
🥕
Is this organic?

okmttdhr, tada okmttdhr

🥕
Is this organic?
View GitHub Profile
@okmttdhr
okmttdhr / .zshrc
Created February 11, 2014 08:32 — forked from masayan0911/.zshrc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
# Set to this to use case-sensitive completion
@okmttdhr
okmttdhr / Notification.php
Last active August 29, 2015 14:06
通知
function ntf_add($user_id,$body,$model,$action,$data_id) {
$this->create();
$record['Notification']['user_id'] = $user_id; //通知させたいユーザー
$record['Notification']['body'] = $body; // 通知メッセージ
// http://host/model/action/data_id を訪れたときに既読処理を行う
$record['Notification']['model'] = $model;
$record['Notification']['action'] = $action;
$record['Notification']['data_id'] = $data_id;
@okmttdhr
okmttdhr / MessagesController.php
Last active August 29, 2015 14:06
通知:コントローラーで追加
$this->Notification->ntf_add(
$user_id, // 通知させたいユーザー
$user.'さんからメッセージが届いています', // 通知メッセージ
'offers', // モデル
'view', // アクション
$offer_id // 数値など
);
@okmttdhr
okmttdhr / MyActivity.java
Last active August 29, 2015 14:06
ListView: listクリックで下に何か表示&ボタンクリックでlist追加
// 参考:http://www.adakoda.com/android/000077.html http://techbooster.org/android/ui/9039/
package edu.self.myapp01;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
@okmttdhr
okmttdhr / list_view.xml
Created September 25, 2014 22:36
ListView: listクリックで下に何か表示&ボタンクリックでlist追加
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ListView
android:layout_width="match_parent"
@okmttdhr
okmttdhr / MyActivity.java
Last active August 29, 2015 14:06
[Android]割り勘計算機
// 参考:http://androidguide.nomaki.jp/html/app_r21/appMain.html
package edu.self.myapp01;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
@okmttdhr
okmttdhr / calc_app.xml
Last active August 29, 2015 14:06
[Android]割り勘計算機
<!-- 参考:http://androidguide.nomaki.jp/html/app_r21/appMain.html -->
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp">
<LinearLayout
@okmttdhr
okmttdhr / gist:b7c9a7ce31d424098ac3
Created September 30, 2014 10:08
AndroidでGDriveのコンテントをゲットして返します
DriveFile file = file.openContents(mGoogleApiClient, DriveFile.MODE_READ_ONLY, null).addResultCallback(contentsOpenedCallback);
ResultCallback<DriveApi.ContentsResult> contentsOpenedCallback =
new ResultCallback<DriveApi.ContentsResult>() {
@Override
public void onResult(DriveApi.ContentsResult result) {
if (!result.getStatus().isSuccess()) {
// display an error saying file can't be opened
return;
}
@okmttdhr
okmttdhr / gist:c51858004a5284819265
Created October 16, 2014 06:16
Androidからカレンダー一覧の取得処理です。
//カラム
String[] projection = new String[] { "_id", "name" };
//Uriの作成
Uri calendars = Uri.parse("content://com.android.calendar/calendars");
//クエリ実行
Cursor c = getContentResolver().query(calendars, projection, null, null, null);
//値を取得
if (c.moveToFirst()) {
String name;
String id;
@okmttdhr
okmttdhr / gist:57f3ee6938e7fc97e477
Created October 16, 2014 06:17
[Android]取得したカレンダーの一覧をデータベースに保存する例
private FileHackerDatabaseHelper dbHelper;
dbHelper = new FileHackerDatabaseHelper(getContext());
final SQLiteDatabase db = dbHelper.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(TITLE, mTitle);
values.put(START, mStart);
values.put(END, mEnd);
values.put(EVENT_ORIGINAL_ID, mOriginalId);
values.put(ALL_DAY, mAllDay);
values.put(CALENDAR_ID, mCalendarId);