WordPress A8の広告バナーをランダムに表示させたいんだけどうまくいかぬ…

WordPress A8の広告バナーをランダムに表示させたいんだけどうまくいかぬ… 時

前にA8の広告をサイドバーに表示させる記事を書きましたが、
今度は複数のバナーをランダムで表示させたいという欲望があふれました。

そのときにどうすればいいんじゃ、となったのでメモしときます。

 <script type="text/javascript">
 <!--
 tag=new Array();
 tag[0]='ここにA8の広告バナーのHTMLをコピペ。';
 tag[1]='コピペ';
 tag[2]='コピペ';
 
 i=Math.floor(Math.random()*tag.length);
 document.write(tag[i]);
 
 // -->
 </script>

これでばっちりうまくいきました。
どこに貼ればいいかはここに書いてあります。
http://onlineconsultant.jp/pukiwiki/?cmd=read&page=WordPress%20A8%E3%81%A7%E3%82%B2%E3%83%83%E3%83%88%E3%81%97%E3%81%9F%E5%BA%83%E5%91%8A%E3%83%90%E3%83%8A%E3%83%BC%E3%82%92WordPress%E3%81%AB%E8%B2%BC%E3%82%8A%E3%81%9F%E3%81%84%E3%82%93%E3%81%A0%E3%81%91%E3%81%A9%E3%81%A9%E3%81%86%E3%81%99%E3%82%8C%E3%81%B0%E3%81%84%E3%81%84%E3%82%93%E3%81%98%E3%82%83…

注意点ですが、
A8の広告バナーのHTMLをコピペするときは、
必ず改行は削除してください。

はまりポイントです。

by 芦野輝明
twitter→https://twitter.com/teriyakiegg

WordPress

UITextViewに閉じるボタンをつける

iPhone

// ツールバーの作成
viewdidloadに、

UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
toolBar.barStyle = UIBarStyleBlackOpaque; // スタイルを設定
[toolBar sizeToFit];

// フレキシブルスペースの作成(Doneボタンを右端に配置したいため)
UIBarButtonItem *spacer = [[UIBarButtonItem alloc] UIBarButtonItemSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];

// Doneボタンの作成
UIBarButtonItem *done = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(closeKeyboard:)];

// ボタンをToolbarに設定
NSArray *items = [NSArray arrayWithObjects:spacer, done, nil];
[toolBar setItems:items animated:YES];

// ToolbarをUITextFieldのinputAccessoryViewに設定
テキストビュー.inputAccessoryView = toolBar;
}

  • (void)closeKeyboard:(id)sender{

[テキストビュー resignFirstResponder];
}

Ubuntu 16.10 Network Interfaceを追加する

Linuxサーバー

さくらインターネットVPSにUbuntu 16.10をインストールし、コントロールパネルからスイッチを追加しました。

Ubuntuサーバー側では下記のように新しいネットワークインターフェイス設定を追加してネットワークを再起動します。

 # sudo vim /etc/network/interfaces.d/private
 auto ens4
 iface ens4 inet static
         address 192.168.1.11
         netmask 255.255.255.0
         network 192.168.1.0
         broadcast 192.168.1.255
 # sudo systemctl networking restart

Ubuntu ログイン時に自動でターミナルを立ちあげてスクリプトを実行する

Linuxサーバー

下記パスにGnome Terminalの自動起動設定を記述します。

 ~/.config/autostart/gnome-terminal.desktop

設定内容例

 [Desktop Entry]
 Version=1.0
 Name=Test        
 Comment=Test the terminal running a command inside it
 Exec=gnome-terminal -e "bash -c 'echo hello;$SHELL'"
 Icon=utilities-terminal
 Terminal=false
 Type=Application
 Categories=Application;

実行するスクリプトの最後に$SHELLを記述しないと、スクリプトの実行終了時に自動的にターミナルが閉じられてしまいます。

参考

http://askubuntu.com/questions/436891/create-a-desktop-file-that-opens-and-execute-a-command-in-a-terminal
http://askubuntu.com/questions/20330/how-to-run-a-script-without-closing-the-terminal

Unable to add window

Android

Android エラー Unable to add window

サービス内で、AlertDialogを出そうとしたところ次のようなエラーが出てしまいました。

 android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

どうやら、サービス内で、AlertDialogは出せないようです。
Activityを起動して、そこでAlertDialogを出すのがよさそうです。