「VOID」を含む日記 RSS

はてなキーワード: VOIDとは

2017-01-14

増田トラバブックマークレットを作った

はじめに

何番煎じだよって感じだけど、既存ブックマークレットクエリパラメータとかも含めてURLを取得したり、

選択範囲を本文に反映したりとか、俺にとってはいらない機能が色々あったので、

俺用に最適化したブックマークレットを作った。あと、はてな記法使ったことなかったのでそのテストも兼ねて。

ブックマークレットの導入方法はググれ。

前提

コード

javascript:usrID='KokoniIDwoIreru';function enc(s){ return encodeURIComponent?encodeURIComponent(s):encodeURI(s); }void(window.open('http://anond.hatelabo.jp/'+usrID+'/edit?title='+enc(location.href.replace(/\#.*$/, '').replace(/\?.*$/, '')),'_blank',''));

使い方

仕様

おまけ

俺が作ったものではないが、便利なブックマークレットを見つけたので一緒に載せる。

増田トラバリーは、デフォルトではすべて格納されており、

▼を押すことで内容が展開されるが、それを全て展開してくれる。

javascript:(function(){d=document;t=d.getElementsByTagName('ul')[1];a=t.getElementsByTagName('a');for(i=0;i<a.length;i++){if('#'==a[i].getAttributeNode('href').value)a[i].onclick();}})();

2016-10-17

vimをtinyでmakeするとエラーが大量に出るんだが

インストール出来てるし起動もできてるから無視していいのかな

clang: warning: argument unused during compilation: '-I .'

clang: warning: argument unused during compilation: '-I proto'

clang: warning: argument unused during compilation: '-U _FORTIFY_SOURCE'

screen.c:1513:17: warning: self-comparison always evaluates to true [-Wtautological-compare]

if (curwin == curwin)

^

screen.c:5676:19: warning: self-comparison always evaluates to true [-Wtautological-compare]

&& Columns == Columns)

regexp.c:3790:24: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:3790:24: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:3790:24: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:4052:24: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:4052:24: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:4052:24: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:5276:25: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:5276:25: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:5276:25: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:5337:24: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

{ if ((rex.reg_match == ((void*)0))) *(&rex.reg_startpos[rp->rs_no]) = (&rp->rs_un.sesave)->se_u.pos; else *(&rex.reg_startp[rp->rs_no]) = (&rp->rs_un.sesave)->se_u.ptr; };

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:5337:24: note: remove extraneous parentheses around the comparison to silence this warning

{ if ((rex.reg_match == ((void*)0))) *(&rex.reg_startpos[rp->rs_no]) = (&rp->rs_un.sesave)->se_u.pos; else *(&rex.reg_startp[rp->rs_no]) = (&rp->rs_un.sesave)->se_u.ptr; };

~ ^ ~

regexp.c:5337:24: note: use '=' to turn this equality comparison into an assignment

{ if ((rex.reg_match == ((void*)0))) *(&rex.reg_startpos[rp->rs_no]) = (&rp->rs_un.sesave)->se_u.pos; else *(&rex.reg_startp[rp->rs_no]) = (&rp->rs_un.sesave)->se_u.ptr; };

^~

=

regexp.c:5355:24: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

{ if ((rex.reg_match == ((void*)0))) *(&rex.reg_endpos[rp->rs_no]) = (&rp->rs_un.sesave)->se_u.pos; else *(&rex.reg_endp[rp->rs_no]) = (&rp->rs_un.sesave)->se_u.ptr; };

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:5355:24: note: remove extraneous parentheses around the comparison to silence this warning

{ if ((rex.reg_match == ((void*)0))) *(&rex.reg_endpos[rp->rs_no]) = (&rp->rs_un.sesave)->se_u.pos; else *(&rex.reg_endp[rp->rs_no]) = (&rp->rs_un.sesave)->se_u.ptr; };

~ ^ ~

regexp.c:5355:24: note: use '=' to turn this equality comparison into an assignment

{ if ((rex.reg_match == ((void*)0))) *(&rex.reg_endpos[rp->rs_no]) = (&rp->rs_un.sesave)->se_u.pos; else *(&rex.reg_endp[rp->rs_no]) = (&rp->rs_un.sesave)->se_u.ptr; };

^~

=

regexp.c:5516:22: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:5516:22: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:5516:22: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:6213:21: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:6213:21: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:6213:21: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:6266:25: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:6266:25: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:6266:25: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:6294:25: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:6294:25: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:6294:25: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:6325:24: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:6325:24: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:6325:24: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:6341:24: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:6341:24: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:6341:24: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:6363:24: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:6363:24: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:6363:24: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:7711:25: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:7711:25: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:7711:25: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:7740:23: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:7740:23: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:7740:23: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

In file included from regexp.c:8043:

./regexp_nfa.c:3995:24: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:3995:24: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:3995:24: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:4014:21: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:4014:21: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:4014:21: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:4036:21: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:4036:21: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:4036:21: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:4055:21: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:4055:21: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:4055:21: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:4086:24: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:4086:24: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:4086:24: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:4227:24: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:4227:24: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:4227:24: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:4609:25: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:4609:25: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:4609:25: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:4670:22: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:4670:22: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:4670:22: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:4733:25: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:4733:25: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:4733:25: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:4767:25: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:4767:25: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:4767:25: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:4954:24: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:4954:24: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:4954:24: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:5106:21: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:5106:21: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:5106:21: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:5120:21: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:5120:21: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:5120:21: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:5144:25: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:5144:25: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:5144:25: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:5231:24: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:5231:24: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:5231:24: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:5486:25: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:5486:25: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:5486:25: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:5608:21: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:5608:21: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:5608:21: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:5897:23: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:5897:23: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:5897:23: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:5987:26: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:5987:26: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:5987:26: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:6873:26: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:6873:26: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:6873:26: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:6997:24: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:6997:24: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:6997:24: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:7095:24: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:7095:24: note: remove extraneous parentheses around the comparison to silence this warning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:7095:24: note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

2016-09-20

http://anond.hatelabo.jp/20160919121645

内容によりけりだけれど、よくやるリファクタリングの例を紹介しておきます

// したいことは英語でいい名前をつける
void したいこと(){
  // したいこと
}

if( param==0 && 判定(param2) ){
  したいこと();
}else if( !param3 ){
  したいこと();
}

ただし、こういう複雑で奇妙な条件分岐がここに入ってくる時点で設計面の問題があるのではないかと感じます

paramが0の時には何か例外的動作なのではないかとか、「したいこと」の中でさらに何度もparamたちを判定して汚いコードになっているのではないか、などです。

他にも指摘している人がいますが、リーダブルコードを読むのがいいと思います

2016-09-19

http://anond.hatelabo.jp/20160919121645

最近の若者ワンライナーなのか、3項演算子使わないと馬鹿にされるのか知らないけれど、

賢そうな構文は使わなくていい。

boolean check(int param, int param2, int param3)
{
    if ( param == 0 && 判定(param2) )
    {
        return true;
    }
    else if ( param3 == false )
    {
        return true;
    }
    else
    {
        returnn false;
    }
}


void main()
{
    if ( check(param, param2, param3) )
    {
        //したいこと
    }
}

2016-07-30

http://anond.hatelabo.jp/20160730155428

悪い、昼間っからビール飲みだしたから、もうよくわからん

それをそのままってのが意味がよくわからんけど、

newしてから渡せば良いと思うよ。

いちいちクラスに分ける理由は、こういう感じで、クラス内の変数アクセスすれば、画面事の表示とかが簡単に出来る的な?

EventHogeクラスクリックした時のイベント定義するクラス

      // Javaの書き方しらん、インターフェース実装することを定義したい

      public class EventHoge : View.OnClickListener {

        

        //画面事の名称

        public string ViewName = "";

        // Javaの書き方しらん、インターフェースメソッド実装することを定義したい

        public void View.OnClickListener.onClick(View v) {

            // 元増田サンプルそのまま ーー>

            AlertDialog.Builder dlg;

            dlg = new AlertDialog.Builder(MainActivity.this);

            dlg.setTitle("画面の名前:" + ViewName); // 画面名称が表示されるイメージ

            dlg.setMessage("Hello, サンプル!");

            dlg.show();

            //<ーー

       }

     }

MainHogeクラス(画面の初期化を行い、どのボタンにどのイベントを仕込むかを決めるクラス

    // Androidなにも知らんけど、元増田ボタンイベントを書く処理が書いてあるクラスのことが言いたい

    public class MainHoge {

        // そのメソッド

        public void Main() {

            //ボタン実装サンプル

            final Button button = new Button(this);

            button.setText("ダイアログの表示");

            View.OnClickListener ocl = new EventHoge();

            ocl.ViewName = "画面その一";

            button.setOnClickListener(ocl);

        }

    }


こんな感じにすれば、画面が二つあって、

その画面の名称を表示するようなボタンを、二つメソッドコピペして作らなくていい的な?

もうぶっちゃけ元増田が何を悩んでるのか、ようわからんわ。

サンプルは、出来るだけとっちらかさないよう、匿名クラスとか使って、サンプルで紹介したいところ「だけ」を書くんだよね。

から、そのサンプルがどういう意味かをちゃんと読み取って、自分ならこう書くとか、こう書けるか? とかを考えてこそ勉強だと思うよ?

今回のレイだと「View.OnClickListener」っていうインターフェイス実装したクラスを、setOnClickListenerすればいいってことさえわかれば、

匿名クラス?(っていうのかな? ちょっと用語はよくしらん、クラス定義を使い回さず、その場だけのクラス定義を書く書き方)とかを使わずに、

どういうふうに応用ができるか? とか頑張れ!

頑張れ!

頑張れ!

はああああああ。

おれはビールを飲む!

http://anond.hatelabo.jp/20160730125112

うーん?

いや、なんか、通じてないな。

もうちょいサンプル詳しく書くからサンプルのどこがわからいか言ってくれ。

EventHogeクラスクリックした時のイベント定義するクラス

      // Javaの書き方しらん、インターフェース実装することを定義したい

      public class EventHoge : View.OnClickListener {

        // Javaの書き方しらん、インターフェースメソッド実装することを定義したい

        public void View.OnClickListener.onClick(View v) {

            // 元増田サンプルそのまま ーー>

            AlertDialog.Builder dlg;

            dlg = new AlertDialog.Builder(MainActivity.this);

            dlg.setTitle("サンプル");

            dlg.setMessage("Hello, サンプル!");

            dlg.show();

            //<ーー

       }

     }

MainHogeクラス(画面の初期化を行い、どのボタンにどのイベントを仕込むかを決めるクラス

    // Androidなにも知らんけど、元増田ボタンイベントを書く処理が書いてあるクラスのことが言いたい

    public class MainHoge {

        // そのメソッド

        public void Main() {

            //ボタン実装サンプル

            final Button button = new Button(this);

            button.setText("ダイアログの表示");

            button.setOnClickListener(new EventHoge());

        }

    }


こうやって、クラス分けて書けば、外とか中とか、全く関係なくなるじゃん。

元増田サンプルだと、メインの中でインターフェース実装したクラス実装を書いてるから、中とか外とかがあるんじゃないのか?

自分クラスとして定義して、そっちで実装すれば、メインは紐づけるだけでよくなって、仮引数?の中で実装しなくてもすむじゃん。

http://anond.hatelabo.jp/20160730090832

よくわからん

中が嫌なら外でかきゃいいじゃん。

javaAndroidもしらんから適当だけど。

      // Javaの書き方しらん、インターフェース実装することを定義したい

      public class Hoge : View.OnClickListener {

        // Javaの書き方しらん、インターフェースメソッド実装することを定義したい

        public void View.OnClickListener.onClick(View v) {

            // 元増田サンプルそのまま ーー>

            AlertDialog.Builder dlg;

            dlg = new AlertDialog.Builder(MainActivity.this);

            dlg.setTitle("サンプル");

            dlg.setMessage("Hello, サンプル!");

            dlg.show();

            //<ーー

       }

     }

// メインスレッド的なところ

//ボタン実装サンプル

final Button button = new Button(this);

    button.setText("ダイアログの表示");

    button.setOnClickListener(new Hoge());

こう書けば、中で書かなくて良い気がするけど、駄目なの?

なんか、インターフェースから引数の中ってのが意味わからん

どう関係してるの?

2016-07-08

http://anond.hatelabo.jp/20160707235347

お疲れさまです。

設計書の指摘事項および質問事項です。

まず全体的に、インデントおかしいのと「}」が不足しています

プログラム仕様書はいえ「}」や「;」は書く必要がないため、もう少し日本語として通じる文章にしてください。

人間 俺の友達

使われていない変数ですが、問題ありませんか?

下記の

関係 彼女と俺の友達

初期化必要なのでしょうか?

俺 = 彼女いない歴 = 年齢;

俺は、人間型の変数なので、真理値を代入できないのでは?

真理値を人間型にキャストする共通関数があるのでしょうか?

もし(彼女フリー; 彼女彼氏出来るまで; 俺頑張る++){

「もし」ではなく、繰り返しを意味する「諦めない」でしょうか?

また「彼女フリー;」setupメソッドで「なんかモテそう」を代入していますが、フリーで上書きして問題ありませんか? その場合「なんかモテそう」の代入処理は必要なのでしょうか?

変数彼女フォーカス不明のため、このクラス内だけでは考慮できません。

次に「俺頑張る++」は、人間型の変数俺の頑張るプロパティインクリメントするという意味でしょうか?

もしもだ(彼女と俺の友達恋人){

上記のループが回っているときに、このメソッドではない別のメソッドで、変数彼女と俺の友達の値が変更されるため、上記のループの中に条件式があるのでしょうか?

もし、そのためであれば、非同期処理を本当に使う必要があるのか、もう一度設計見直してください。

そのためでないのなら、ループが始まるまえに、条件式を記載してください。


return 今夜も童貞;

voidなので、値を返すことはできません。

updateメソッドの型を指定するべきだと思われます

また、条件式の結果によっては、値を返さないケースがあります

その場合は初期値を返すのか、エラーを投げるのか明記してください。

以上、指摘事項を受けて、修正箇所があれば修正を行い、レビュー結果ドキュメント修正箇所を明記してください。

また、質問箇所については、レビュー結果ドキュメントに回答もセットで記載してください。

文章でわかりにくいところがありましたら、遠慮なく私のところまで聞きにきてください。

明日は午前中は自席にいます、午後から電話会議が散発的にあるため定時後でしたら対応可能です。

確認よろしくお願いします。

2016-07-07

人間 俺;

人間 彼女

人間 俺の友達

関係 彼女と俺の友達

void setup(){

 俺 = 彼女いない歴 = 年齢;

 彼女 = なんかモテそう;

}

void update(){

 もし(彼女フリー; 彼女彼氏出来るまで; 俺頑張る++){

もしもだ(彼女と俺の友達恋人){

 俺 = 諦める;

 return 今夜も童貞;

}

}

2016-06-28

詭弁の特徴のガイドラインに追加して欲しい項目。「的外れ比較や例

http://d.hatena.ne.jp/keyword/%EB%CC%CA%DB%A4%CE%A5%AC%A5%A4%A5%C9%A5%E9%A5%A4%A5%F3

------------------------------------------------------------------------------------------------

詭弁の特徴15条

例:「犬ははたして哺乳類か」という議論をしている場合

あなたが「犬は哺乳類としての条件を満たしている」と言ったのに対して否定論者が…

1.事実に対して仮定を持ち出す

「犬は子供を産むが、もし卵を生む犬がいたらどうだろうか?」

2.ごくまれな反例をとりあげる

「だが、尻尾が2本ある犬が生まれることもある」

3.自分に有利な将来像を予想する

「何年か後、犬に羽が生えないという保証は誰にもできない」

4.主観で決め付ける

「犬自身哺乳類であることを望むわけがない」

5.資料を示さず持論が支持されていると思わせる

世界では、犬は哺乳類ではないという見方一般的だ」

6.一見関係がありそうで関係のない話を始める

「ところで、カモノハシは卵を産むのを知っているか?」

7.陰謀であると力説する

「それは、犬を哺乳類と認めると都合の良いアメリカが画策した陰謀だ」

8.知能障害を起こす

「何、犬ごときにマジになってやんの、バーカバーカ」

9.自分見解を述べずに人格批判をする

「犬が哺乳類なんて言う奴は、社会に出てない証拠現実をみてみろよ」

10.ありえない解決策を図る

「犬が卵を産めるようになれば良いって事でしょ」

11.レッテル貼りをする

「犬が哺乳類だなんて過去概念にしがみつく右翼イタイね」

12.決着した話を経緯を無視して蒸し返す

「ところで、犬がどうやったら哺乳類の条件をみたすんだ?」

13.勝利宣言をする

「犬が哺乳類だという論はすでに何年も前に論破されてる事なのだが」

14.細かい部分のミスを指摘し相手無知認識させる

「犬って言っても大型犬から小型犬までいる。もっと勉強しろよ」

15.新しい概念が全て正しいのだとミスリードする

「犬が哺乳類ではないと認めない限り生物学進歩はない」

参考:18条パターンの追加項目

16.全てか無かで途中を認めないか、あえて無視する。

「全ての犬が哺乳類としての条件を満たしているか検査するのは不可能だ(だから哺乳類ではない)」

17.勝手に極論化して、結論正当性に疑問を呈する。

「確かに犬は哺乳類と言えるかもしれない、しかしだからといって、哺乳類としての条件を全て持っているというのは早計に過ぎないか。」

18.自分で話をずらしておいて、「話をずらすな」と相手を批難する。

現在問題なのは犬の広義の非哺乳類性であり、哺乳類であるかどうかは問題ではない。話をそらすな」

これに付記するものとしてKusakabe(void)論法がある。

追加項目

19.権威主義におちいって話を聞かなくなる。

生物学権威じゃないおまえには犬について議論する資格が無い。生物学者に意見を聞きたい」

------------------------------------------------------------------------------------------------

他に的外れ比較や例えを詭弁として追加して欲しいです。

20.的外れ比較や例えをする

例1「犬が哺乳類だと言うのは、恐竜哺乳類だと言うようなものだ。」

例2「では恐竜哺乳類扱いされているだろうか?されていないだろう。犬の件もそれと同じ事である。」

実際にこういう的外れ比較や例えは見かけます

また、昔2ちゃんねるで見かけたスレでも、比較対象を誤っている論者がいるなどと注意喚起されていました。

ありえない解決策を図るについては、「犬が卵を産めるようになれば良いって事でしょ」は大げさにしても、

「では、他の生き物が哺乳類に含まれるかどうかあなたが全確認してはどう?」というような論は見かけます

2016-05-25

http://anond.hatelabo.jp/20160525194007

void GetLoadDataByResetLoad(...)

{

    // ロード処理が取り消されたのでさっきまでロードされていたデータを再度読み直す

}

2016-04-22

Vim 7.4.1775 のコンパイルしてたらこんなん表示されたけど誰か直して〜

make installしてVim起動できたから直らなくても支障ないけど〜

term.c: In function ‘termtrue_mch_get_color’:
term.c:1387:6: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
      (void)fgets(line, LINE_LEN, fd);
      ^

2016-04-01

月刊Vim 3月号 - ゼロ除算編

:echo 1 / 0
:echo 0 / 0
2147483647
-2147483648

きっしょwwwwwwwwwwwwwwwwwwwwwwwwwwwwww

他の言語もチェックしてみるか

golang

package main

import "fmt"

func main() {
	fmt.Println(1 / 0)
	fmt.Println(0 / 0)
}

division by zero

php

echo 1 / 0;
echo 0 / 0;

PHP Warning: Division by zero

python 2

print 1 / 0
print 0 / 0

ZeroDivisionError: integer division or modulo by zero

python 3

print(1 / 0)
print(0 / 0)

ZeroDivisionError: division by zero

nodejs

nodejsだと1/0と0/0で異なるメッセージが表示された。

console.log(1 / 0);

Infinity

console.log(0 / 0);

NaN

luajit

luajitだとnodejsで表示されたメッセージの短縮形で表示された

print(1 / 0)

inf

print(0 / 0)

nan

haskell

修正しました thx @anekos

main = do
    print(1 / 0)

Infinity

main = do
    print(0 / 0)

NaN

java

public class Test {
    public static void main(String[] args) {
        System.out.println(1 / 0);
    }
}
public class Test {
    public static void main(String[] args) {
        System.out.println(0 / 0);
    }
}
Exception in thread "main" java.lang.ArithmeticException: / by zero
        at Test.main(Test.java:3)

bash

#!/bin/bash

echo $((1 / 0))
echo $((0 / 0))
test.bash: 行 4: 1 / 0: 0 による除算です (エラーのあるトークンは "0")
test.bash: 行 5: 0 / 0: 0 による除算です (エラーのあるトークンは "0")



haskellnodejsとluajitはエラーにならないけどまあいい。

Vimはやべえよ。


結論言語わずゼロ除算はするな









しまった、4月だった。

2016-03-08

はてブ2階を表示するブックマークレット

最近2階が覗きたくなることが増えたので書いた。2階があればブクマ数の周りに2階のリンクを追加する。

javascript:void[].map.call(document.querySelectorAll("a.entry-info,.entry>a.entry-link,.users a"),function(e,n){n=new XMLHttpRequest,n.open("GET","/entry/jsonlite/"+e.href),n.responseType="json",n.onload=function(t,o){(t=n.response)&&e.insertAdjacentHTML("beforebegin",((o=t.count)+" upper"+(o>1?"s":"")).link(t.entry_url))},n.send()});

http://b.hatena.ne.jp/以下のページで使えるはず。

minify前
void [].map.call(document.querySelectorAll('a.entry-info,.entry>a.entry-link,.users a'),function(u,x){
  x=new XMLHttpRequest();
  x.open('GET','/entry/jsonlite/'+u.href);
  x.responseType='json';
  x.onload=function(j,c){
    if(!(j=x.response))return;
    u.insertAdjacentHTML('beforebegin',((c=j.count)+' upper'+(c>1?'s':'')).link(j.entry_url))
  };
  x.send();
});

2016-01-20

Safari拡張機能で document.write を書き換える

こいつをブロックしたい→http://partsa.nikkei.com/parts/js/ab/rtcontrol_rcmd002_02.js

Safari拡張Chromeのものとほぼ同等なので、Chrome拡張での方法検索

Chrome拡張でページのグローバル変数アクセスしたい https://note.mu/kkotaro0111/n/nd527d31957a7

ビンゴ

location.href = 'javascript: document._write = document.write;' +
	'document.write = function() {};' +
	'void 0;';

2016-01-12

厨ニFizzBuzzを書いた

2021/04/25用

%:include <stdio.h>
%:include <stdlib.h>
%:define 三つ子と五つ子の協奏曲 main
%:define ☯ ;
%:define 環 while
%:define 異名 typedef
%:define 終焉 101
%:define 伝承(詩) printf(_Generic((詩), int: "%d\n", char *: "%s\n"), 詩)
%:define 純白を漆黒漆黒を純白に(色) (色 = 終焉 - 色)
%:define 終わりは、斯く示された。 return 0

異名 int 無限整数幻想を維持せぬ整数異名 char 世界言葉を扱うには不十分な箱 ☯
異名 void 虚無 ☯

無限整数幻想を維持せぬ整数 破滅の刻 = 終焉 ☯

虚無
三つ子と五つ子の協奏曲(栞, 慈悲深き終身独裁者の注文)
	無限整数幻想を維持せぬ整数   栞 ☯
	世界言葉を扱うには不十分な箱 **慈悲深き終身独裁者の注文 ☯
{
	環 (0 <-- 破滅の刻
		&& 純白を漆黒漆黒を純白に(破滅の刻)
		&& ((破滅の刻 % 3) * (破滅の刻 % 5)
			? 伝承(破滅の刻)
			: 伝承(破滅の刻 % 15 ? 破滅の刻 % 5 ? "Fizz" : "Buzz" :"FizzBuzz"))
		&& 純白を漆黒漆黒を純白に(破滅の刻)) ☯
	終わりは、斯く示された。 ☯
}

2015-09-18

MethodInvoker を使って、Invoke メソッドを1ラインで書く

ワーカースレッド(この場合Task)からUIスレッドコンポーネント(コントロールなど)へアクセスする。

class AppliForm {

void SomeCall(){

var itemName = "hoge";

System.Threading.Tasks.Task.Run(()=>

{

this.Invoke(new MethodInvoker(() => listViewMe.Items.Add(itemName)));

}

}

}

例によって、Goes To (=>) は、半角化してくらはい

2015-06-15

はてな匿名トラバブックマークレット自分用に調整しました…が

http://d.hatena.ne.jp/Francis/20070210/1171124970


この方のブックマークレット自分用に調整したくて、

不要コードを削ったんだが、まだ不要コードが混じっている気がするんだ。

でも俺、JavaScriptが全くわからんからどこを削ればいいのかもわかっていない状況。誰か助けてけろ~(涙)

今のところ、削っても動作したのは次のコード


javascript:YourID='YourID';w=window;function bq(s){return '';}function enc(s){return encodeURIComponent?encodeURIComponent(s):encodeURI(s);}if(w.getSelection){q=w.getSelection();}void(w.open('http://anond.hatelabo.jp/'+YourID+'/edit?title='+enc(location.href)+'&amp;amp;body='+enc(bq(q)),'_self',''));


javascript:YourID='YourID'の'YourID'を自分はてなIDに変更してブックマークレット登録することで動作


このコードは次のような感じに動作するっぽい。


現在開いているページのURLを取得

現在ウィンドウで、はてな匿名新規作成画面に遷移

新規作成画面のタイトル部分に取得したURLを出力、本文は空白


皆さんにお聞きしたいことは次のとおり


新規ウィンドウを出さずに画面遷移したい

 ↑現在コード新規ウィンドウが出ないから期待動作ではあるんだが、

  これはfunction bq(s){return '';}と'&amp;body='+enc(bq(q)),によってこうなってるって感じ。

  でも、コードとしては不適切な気がして、できればこの部分を削って他のそれらしいコードにしたい。

  けど、これを削除するとなんか新規ウィンドウで開いちゃう。なんかい方法ないかしら…


・選択範囲指定せずにクリックしてもはてな匿名に移動すること

 ↑元のコードは選択範囲を選択して引用するみたいなことができるんだが、

  俺はそれを使わないのでそれ関連のコードは削除した。

  主にd=documentやd.selectionらへん。

  で、これについて、ちゃんと選択関連のコードが全部消せてるのか自信ない。

  なんか不要コードまだあったりしますかね?


・これは欲張りだけど、トラバリンク押下後の遷移先のURLに#tbとつくのを防ぎたい

 ↑トラバしたい記事で、トラックバックリンククリックすると、URLに/YYYYMMDDHHMMSS#tbってつくじゃないですか?

 こういった時にブックマークレットを使うと、日記タイトル部分がhttp://anond.hatelabo.jp/YYYYMMDDHHMMSS#tbになるんだ。

 これを出来ればhttp://anond.hatelabo.jp/YYYYMMDDHHMMSSにしたい。

 これはほんと欲張りだから別にできなくてもいいけども。


以上。一応このままでも動くから別にこれでいいっちゃいいけど、なんか本当にこれでいいのだろうかってちょっぴり不安

2015-04-10

http://anond.hatelabo.jp/20150409221948

他の増田にも突っ込まれているが、君の言う「強者」は我々の所属するコミュニティで通常使用するそれと意味が異なるように思う。

君は、

人間社会常識と異なる用法をしてるのは俺じゃなくてゴキブリ

と書いているが、君のその「人間社会常識」なるもの増田では誰とも共有できていないのが現状である(そうでなければ「これはこういう意味なんだよー」と説明してくれる暇人が出てきそうなものだ)。これでは、まさかとは思いますがあなたの言う「人間社会常識」とは、あなた想像上の存在にすぎないのではないでしょうか煽りたくなった者がいても責めることはできまい。

こういう状態で

書いてないことを読み取るという低能丸出しの行為を2度繰り返すとはw

http://anond.hatelabo.jp/20150409223903)と言われても、君の主張が意味不明からこっちが解釈してやろうってのにそれはないよ、という感想しか持ちえない、少なくともおれは。

そしてついでに書いておくと、君のその「説明を要求されてもはぐらかす」「こういう意味かと聞かれたらそんなことは言ってないと否定する」というスタイルは、それに対する反論コストが非常に高くなるために、かなり有効闘争手法ではある。一時期、たぶん20年くらい前、インターネットコミュニティの一部で非常に流行したvoidの「ということにしたいのですね」もこの一例だと言っていいだろう。ただ、徹頭徹尾アンフェアなので、ふつうの人は最近これを使わない。それに、これは一種の焼畑農法である。この闘争方法に敗れた(というより愛想をつかしたと言うべきかもしれないが)人間コミュニティを利用しなくなると、最終的には、「ということにしたいのですね」「ということにしたいのですね」と言い合う発言者しか残らないが、そんなのbotでもできることであり、意味のあるコミュニケーションとは言えない。

…とここまで書いてもうかなり飽きてきたけど、低能連呼君はvoid風オトボケにそこそこキャッチー罵倒を混ぜてるからあのころfj.sci.mathで認知心理学者を煽ってた大学院生にむしろ近いよね。彼今どうしてるのかなあ、と思って検索したが曽根清治みたいなことになってなかったので安心した。いや、まあネット活動してないだけかもしれないけどw

2015-03-12

http://anond.hatelabo.jp/20150312122358

マジレスすると、U+00a5なら使える。俺なら設計修正させるけど。

Path.GetInvalidFileNameChars メソッド (System.IO)

using System;
using System.IO;

namespace TestInvalidFileName
{
    class Program
    {
        static void Main(string[] args)
        {
            // Get a list of invalid file characters.
            char[] invalidFileChars = Path.GetInvalidFileNameChars();

            Console.WriteLine("The following characters are invalid in a filename:");
            ShowChars(invalidFileChars);
            Console.WriteLine();

            string fileName = '\u00a5' + "108";
            using (var fs = File.Create(fileName))
            {
                if (fs != null)
                {
                    Console.WriteLine("File was created:" + fileName);
                    fs.Close();
                }
                else {
                    Console.WriteLine("File was not created:" + fileName);
                }
            }
        }

        public static void ShowChars(char[] charArray)
        {
            Console.WriteLine("Char\tHex Value");
            // Display each invalid character to the console.
            Array.Sort(charArray);
            foreach (char someChar in charArray)
            {
                if (Char.IsWhiteSpace(someChar))
                {
                    Console.WriteLine(",\t{0:X4}", (int)someChar);
                }
                else
                {
                    Console.WriteLine("{0:c},\t{1:X4}", someChar, (int)someChar);
                }
            }

        }
    }
}
The following characters are invalid in a filename:
Char    Hex Value
(中略)
",      0022
**,      002A
/,      002F
:,      003A
&gt;,      003C
&gt;,      003E
?,      003F
\,      005C
|,      007C

File was created:\108

2015-03-07

externの説明でmain関数で完結した実例見てもわからんだろう

どこの講座のexternの実例見てもだいたいexternいらないのばかりなんだよね

先に定義しておけばいいので、main関数でexternの説明する限り必要性を説明するのは難しいと思う

ファイルを分割した例でも完全に定義があとに来るケースじゃないと。

しいて言えばこんな感じにするべきだろう

別にネタではないので釣りなのか悩まないように

#include &lt;stdio.h&gt;

int main(void)
{
	extern int x;
	printf("%d\n",x);
	return 0;
}

int x=777;

2015-01-24

http://anond.hatelabo.jp/20150124001655

メンバ関数

public void set(String k,double d){

v.put(k,d);

}

を入れた方が美しかったな

反省


あ、それにdistanceDoubleを返すようにして軸を一切共有しない場合はnullにした方がよかったな

奥が深い


おおうJavaInfを扱えるのか

勉強が足りないな

ログイン ユーザー登録
ようこそ ゲスト さん