投稿

ラベル(プログラミング)が付いた投稿を表示しています

[HTML] JavaScriptで押されたボタンの値を取り出す

イメージ
 以下にサンプルコード。 <!DOCTYPE html> <html> <head> <script type="text/javascript"> function buttonPush(obj) { document.getElementById('value').innerHTML = obj.value; } </script> </head> <body> <input type="button" value="1" onclick="buttonPush(this);"> <input type="button" value="2" onclick="buttonPush(this);"> <input type="button" value="3" onclick="buttonPush(this);"> <input type="button" value="4" onclick="buttonPush(this);"> <input type="button" value="5" onclick="buttonPush(this);"> <input type="button" value="6" onclick="buttonPush(this);"> <input type="button" value="7" onclick="buttonPush(this);"> <input type=...

[HTML] CSSを使って文字を上下左右中央に表示する方法

イメージ
以下で可能。 適当なhtmlファイル(例:CSS_Test_001.html等)に以下コードを張り付けて保存し、ブラウザから開いくとHello World!の文字がブラウザ上下左右中央に表示される。 なお、古いブラウザだと動作しないらしい。 ---ここから--- <!DOCTYPE html> <html> <head> <title>CSS Test 001</title> <style> .middle{ position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); } </style> </head> <body> <div class='middle'> <p>Hello World!</p> </div> </body> </html> ---ここまで---

【プログラミング】いろんな”hello world"

イメージ
いろんなプログラミング言語とインターフェースで"hello world"を試してみる。順次追加予定。 テキストインターフェース系 C言語 C++ rust pascal java FORTRAN UNIX系シェル python perl ruby2.5 Windowsバッチファイル Web系 HTML Android Android テキストインターフェース系 C言語 ソースコード #include <stdio.h> void main(void) { printf("hello world\n"); } ソースコードファイル名 ./helloworld.c コンパイル例 $ cc -o helloworld helloworld.c $ 実行例 $ ./helloworld hello world $

【プログラミング】UbuntuにPascalを導入する

UbuntuにPascalを導入してみた。Free Pascalというものを使ってみた。 環境 Ubuntu 18.04 手順 インストール $ sudo apt install fp-compiler-3.0.4 $ 動作確認 $ fpc -iW 3.0.4+dfsg-18ubuntu2 $ vi helloworld.p program helloworld being writeln ('hello world'); end. $ fpc helloworld.p $ ./helloworld hello world $ 参考 https://wiki.lazarus.freepascal.org/Hello,_World 以上

【プログラミング】UbuntuにRuby 2.5系を導入する

Ubuntuにプログラミング言語のRuby(2.5系)をインストールしてみた。 環境 Ubuntu 18.04 手順 インストール $ sudo apt install ruby $ 動作確認 $ ruby --version ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu] $ vi helloworld.rb #!/usr/bin/ruby puts "hello world" $ chmod u+x ./helloworld.rb $ ./helloworld.rb hello world $ 参考 https://www.ruby-lang.org/ja/ 以上

【プログラミング】Ubuntuにrustを導入する

Ubuntuにプログラミング言語の rust を導入してみた。 環境 Ubuntu 18.04 手順 インストール $ sudo apt install rustc $ 動作確認 $ vi helloworld.rs fn main() { println!("hello world"); } $ rustc helloworld.rs $ ./helloworld hello world $ 参考 https://www.rust-lang.org/ 以上

【プログラミング】python3でhello world

Ubuntu 18.04で標準で入っているpython3( wikipedia )でhello worldしてみた。 $ vi helloworld.py print("hello world") $ python3 helloworld.py hello world $ 以上

【プログラミング】UbuntuにGo(Go言語,golang)を導入してみる

UbuntuにGo(Go言語,golang)を導入してみた。 環境 Ubuntu 18.04 go 1.12.7 手順 インストール $ wget https://dl.google.com/go/go1.12.7.linux-amd64.tar.gz $ sudo tar -C /usr/local -xzf go1.12.7.linux-amd64.tar.gz $ export PATH=$PATH:/usr/local/go/bin 動作確認 $ cd $ mkdir -p go/src/helloworld $ cd go/src/helloworld $ vi helloworld.go package main import "fmt" func main() { fmt.Printf("hello, world\n") } $ go build $ ./helloworld hello world $ 参考 Getting Started https://golang.org/doc/install 以上

【プログラミング】Ubuntuにgfortranを導入してみる

イメージ
Ubuntuにgfortranを導入してみる。 環境 Ubuntu 18.04 手順 インストール $ sudo apt-get update $ sudo apt-get install gfortran 動作確認 ファイルを作成(拡張子はf90固定) $ vi helloworld.f90 program helloworld print *,"hello world" end program helloworld コンパイルと実行 $ gfortran -o helloworld helloworld.f90 $ ./helloworld hello world 参考 GNU Fortran https://gcc.gnu.org/fortran/ 以上

[PHP] pharファイルの固め方と解凍の仕方

pharファイルの固め方と解凍の仕方を調べてみた。取りあえず動いたのでご報告。 固め方 例) カレントディレクトリ(./)にあるファイルおよびディレクトリ全部を1階層上のTest.Pharに固める > php /usr/bin/phar.phar pack -f ../Test.Phar ./ 解凍の仕方 例)Test.Pharの内容をディレクトリ./Testに解凍する > php /usr/bin/phar.phar extract -f Test.Phar ./Test 他 openSUSEで確認。その際下記を追加インストール&設定 php7, php7-phar, php7-zlib php.iniを書き換え → php.iniの探し方は ここ 参照 phar.readonly = 0 phar.require_hash = 0 参考 phar, phar.phar - PHAR (PHP archive) command line tool

NetBeansでウインドウアプリを実行してみる

イメージ
ウインドウアプリ(以下)を実行するまでの最短手順を確認してみた。 Ubuntu上で表示された空のウインドウ NetBeansのインストールはGoogle先生に聞いてみよう。 Ubuntu 14.04 LTS環境へのインストールなら こちらの記事 がおすすめ。

[VBScript]ファイル名に日付を付加してコピー(バックアップ)する

概要 ファイル名に日付文字列を付加してコピー(バックアップ)するVBScriptサンプルを記す。 例) aaa.txt → aaa_20150921.txt サンプル 以下を任意のVBSファイル(例. backup.vbs)として保存。ダブルクリック等で実行。 Dim oFS, ddd Set oFS = WScript.CreateObject("Scripting.FileSystemObject") ' ddd = "_" ddd = ddd & Year(Now()) ddd = ddd & Right("0" & Month(Now()), 2) ddd = ddd & Right("0" & Day(Now()), 2) ' oFS.CopyFile "aaa.txt", "aaa" & ddd & ".txt" 以上

古い楽天APIの廃止と新しい楽天APIへのバージョンアップ作業

イメージ
古い楽天APIが廃止されるとのメールを受信したので、最新の楽天APIに移行してみた。以下、要点のみ記載する。 楽天ウェブサービス2014年7月21日キャプチャ画面 条件 対象AP 楽天トラベル 施設詳細検索 移行元 2009-09-09 移行先 2013-10-24 移行方法 (1) リクエストURLの変更 旧: http://api.rakuten.co.jp/rws/3.0/rest?developerId=<your id>&hotelID=<hotel ID> 新: https://app.rakuten.co.jp/services/api/Travel/HotelDetailSearch/20131024?applicationId=<your id>&format=xml&hotelID=<hotel id> ※ applicationIdは新規取得 (2) xmlの抜き出し方を変更 旧: $ns = "http://api.rakuten.co.jp/rws/rest/HotelDetailSearch/3.0"; $body = $xml->Body->children($ns)->children(); $hb = $body->hotel->hotelBasicInfo; 新: $body = $xml->hotels; $hb = $body->hotel->hotelBasicInfo; ※複数件検索の場合は違うかも 以上

ソースコード検索サイト

イメージ
有効な使い所が実は良く分かっていないが、覚えておきたいので記しておく。 以下、全世界のFOSSのコード検索をしてくれるサイト。 Koders.com 試しに、Fortran言語でhello worldを検索。 あぁ。確かにFortranってこんな感じのコード書くんだったよな。 コード記載のど忘れに役に立つかな? 以上

[HTML/CSS]意図しない回り込みの回避

暫く悩んでいたが昨日解決したので忘れないうちに記しておく。 確認環境 IE 9.0.2 Google Chrome 14.0.835.163 FireFox 6.0.2 (1)回りこんでしまう例 表示例 test test test test test test コード例 <div style="float: left; background-color: blue;"> <p>test</p> </div> <div style="background-color: yellow;"> <p>test</p> <p>test</p> <p>test</p> <p>test</p> <p>test</p> </div> (2)回り込みを回避した例 表示例 test test test test test test コード例 <div style="background-color: blue; float: left;"> test</div> <div style="background-color: yellow; float: left;"> test<br /> test<br /> test<br /> test<br /> test</div> <div style="clear: both;"></div> 以上

[WordPress]コメント入力フォームからE-Mail入力項目を無くす

WordPressコメントフォームからE-Mail欄を無くす方法を記す。 環境条件 WordPress 3.0.0以降 方法 [外観]-[テーマ編集]-[テーマのための関数(functions.php)]とクリック 下記コードを追加 /* E-Mailの入力項目を無くす */ function my_comment_fields($fields) { $fields['email'] = ''; return $fields; } add_filter('comment_form_default_fields','my_comment_fields'); /* 余計な表記を無くす(ついでに) */ function my_comment_form_defaults($args){ $args['comment_notes_before']= ''; $args['comment_notes_after']= ''; return $args; } add_filter('comment_form_defaults','my_comment_form_defaults'); 参考 http://codex.wordpress.org/Function_Reference/comment_form http://tenman.info/labo/snip/?p=371 http://www.csfactory.jp/blog/2010/08/25/wordpress-3-0-%E4%BB%A5%E9%99%8D%E3%81%AE%E3%82%B3%E3%83%A1%E3%83%B3%E3%83%88%E3%83%95%E3%82%A3%E3%83%BC%E3%83%AB%E3%83%89/ 以上

[WordPress]ログインしている時にアクセスカウンターなどを表示したくない。

WordPressにi2iのアクセスカンターを仕掛けているが、投稿記事のプレビュー回数やはてな等のブックマーク時のアクセスまでカウントされてしまう。 管理者除外などしてしまえば良いのだろうが、必ずしもうまく機能するわけでない。 このBloggerも同じ状態なのだが、とりあえず、解決したWordPressについて記しておく。 方法 [テーマの編集]で、テンプレートに直接アクセスカンターを仕掛ける。 その際、以下のコードにする。青文字部分にi2iからのタグを貼り付ける。 <?php if ( !is_user_logged_in() ) { echo ' <span id="noscripttags"><noscript>...(中略)...</script> '; } ?> 以上

Borland C++ コンパイラ

イメージ
久しぶりにBorland C++を使ってみた。 http://www.codegear.com/jp/downloads/free/cppbuilder へアクセスし、"C++コンパイラのダウンロード"の項で、"こちらのページ"をクリック。

[JavaScript]JavaScriptを使ったリダイレクト

去年の10月に書いたコード。無くさないようにここにアップしておく。 以下のコードをリダイレクト元にWebページに記述。 <script type="text/javascript"> <!-- window.open("<your redirect url>","_top","") --> </script> 以上

[HTML]Webページのスクリーンショット

イメージ
Webページのスクリーンショットをブログ記事に埋め込む方法を記す。 やり方 イメージ画像のソース指定先として、以下を設定。 http://wimg.ca/size_2/ + <スクリーンショットを取りたいURL> 以下例。 HTMLコードの例 <img src="http://wimg.ca/size_2/http://www.yahoo.co.jp/" /> 実行例 参考 http://wimg.ca/ 以上