木曜日, 11月 29, 2012

Microsoft Seminar: "The New Era of Work" (Windows 8)

Chicago
At the Microsoft hosted seminar "The New Era of Work", it claimed the year 2012 is an important era for the operating systems, which will incorporate touch screen capabilities, mostly due to the widespread use of mobile phones and tablets. 

Windows 8 does come with the brand new Metro style interface with boxes occupying the screen rather than icons, together with gesture recognition.  Swiping down will close the applications.  SNS updates will be tied with your directory information.  Picture password.  Start typing in and the app comes up, the Microsoft IT evangelist Brian Lewis told the audience.  It took him half a year just to come across the feature, he said. 
IT Pro Evangelist: Brian Lewis

Microsoft has a Metro style app store online.  The apps are searchable there as well, including those being sold online.  On app search box, a question came from the audience.  Can you set parental permissions? There the speaker offered a very modern answer to all possible questions.  Go online, visit his site, ask him the question there. 

http://mythoughtsonit.com/ITcamp/

There should be a lot of questions indeed.  Microsoft claims to have authority over all Metro apps distribution.  Developers need to get its approval to put their apps online for use for other machines than theirs.  Can Microsoft then take the sole responsibility of the apps? How long will be the wait time?  Would the developers' rights be severely restricted?  There are reports that the pre-installed Windows 7 apps seem to run, but the installers may not work.  It costs $49 (personal) or $99 (corporate) to submit your apps for sale at the Windows Store.

Windows 8 is going to be installed in EVERY machine available in the market.  FSF, the Free Software Foundation is asking for signing the petition: "Windows 8 doesn't offer me the privacy and freedom I deserve. I won't be upgrading to Windows 8; instead, I'm standing with the free software movement."

We had a little discussion on this topic back here.  Would it is not practical for Microsoft to have oversight over all Metro apps?  The Apple store does that, they told me.  It is for security and to make money. 

Other topics that got many asking questions is on Windows to go or USB/SSD to go feature that can put your system in the removable storage and boot the system from there.  There are such bootable image available online but not from Microsoft official site.  Now it is all possible to carry your system along wherever you go.  The questions from the audience: Security?  Partitions?  Data protections?  Will it erase the data?  There was no question, however, on how to prevent pirated such bootable systems from being sold.  Will it be protected from piracy?

Microsoft Seminar: "The New Era of Work" (Surface)

Chicago

Microsoft hosted a seminar in Chicago on Wednesday titled "The New Era of Work".

Microsoft claims this is the new era of for Operating Systems.  The Internet, iPhone/iPad, and cloud has changed the nature of computer systems. 

Microsoft has long been pushing for tablet machine for some time.  And the competition is a nice thing.  The latest iPad 4 offers hardly hardware improvements other than resolution.

At the conference room, the Surface RT's were on display along with Lenovo and Toshiba machines.  All those tablet machines have no home buttons.  Swiping out to the edge does the trick.  And they come with keyboards. 

At the Surface booth, they explained to me that Surface RT has somewhat unique capability that Apple's iPad does not.  It works as a remote terminal and runs apps on the host machine just like a workstation.  That, is a wonderful idea, I thought.  There could be many application for it.  "Can you show me how it works?" I asked.  The machines are not connected, they told me.  They were not able to show me how it works as a terminal. 

The only reason why iPad or iPhone can not be loaded as a removable drive is because of security concerns.  The MP3's and eBooks are copyright protected.  If only those directories that contain the copyrighted files then they will be more accessible by the possibly criminals.  What the remote terminal does is that the files in tablets would be accessible freely.  The remote terminal apps might have security concerns. 

Instead of that wonderful feature, they showed me the Surface apps fully loaded with shop icons.  The sight of the ads of all those stores on the screen overwhelmed me.  It looked much bigger than the simple and elegant Apple Store.  "This may change the business style, and consumer life style", keynote speaker said. 

So how about Surface Pro?  The new version of Surface runs on Intel chip.  It means, it runs Windows 8.  And that means, every desktop apps should work on Surface Pro.  Would it be a killer machine?  Does that mean my desktop apps works on my tablet machine?  "You must recompile all apps for that machine," one of the participants told me.  "Surface Pro will be coming in January," the Microsoft people told me.  "The pricing is not yet announced.  It will be as big as the RT machine," they said in answering my questions. 

to be cont.

火曜日, 11月 27, 2012

ボックスレイアウトが absolute で破綻

表題の通りです。

Firefox, IE でボックスレイアウトを使用する場合。

位置指定に absolute を指定するとレイアウトが壊れます。

<div style="display:box;display:-moz-box;display:-webkit-box;position:absolute;top:100px">
<div style="width:100px;height:100px;border:1px solid blue"></div>
<div style="width:100px;height:100px;border:1px solid blue"></div>
</div>

見事に人柱となった気分です。

#厳格とかいう問題じゃないですよね。これ。

月曜日, 11月 19, 2012

Google Analytics API: フィルターをつける

本日の出来事。

ダメ上司の典型。「これネットで見付けんたんだけどどお」
どおって... システム全部書き直せって?

え、あのタグってこちらがつけたものじゃないし、むこうが取り外すだけで話は解決じゃないでしょうか。
こちらがフィルターつけて取り外すのって、それって仕事の一部ですか?!

で、仕事が遅くなったとかいって嫌がらせ。最低。最悪。ほんと性格と頭が悪い。

愚痴はさておいて。本題。

Google Analytics のデータを取り出す方法。

フィルターをつける場合について、書いておきます。

$filter="ga:hostname!=ホスト名";
$ga->requestReportData(homepageId,null,array('pageviews','visits','bounces','entrances','timeOnSite','exits','newVisits'),null,$filter,$startDate,$endDate);

火曜日, 11月 13, 2012

IEでリンク切れ画像を表示しない

リンク切れ画像は、Firefox では表示されません。

ところが親切設計の IE や Chrome では、画像が見当たらないとそれ専用のアイコンを表示してしまいます。

これで困ったのが、画像リンクを利用してスクリプトを走らせるハックを使うアクセス統計サービスの場合。

きちんと表示されれば問題なく img タグだろうとなんだろうと構わないわけですが、ところがサーバーの都合でスクリプトが動かないという状況が発生。

動かないだけ「画像ありません」というアイコンかしっかり表示されてしまいました。

アクセス統計などアナリティクスに任せとけばいいのに、マイナーブランドなど使うからサーバーの都合で対応をせざるを得ないはめに。

そこで、画像切れリンクは問答無用で「表示しない」という方針といたしました。これで振り回されずにすみます。

本題へ。リンク切れ画像の IE と Chrome 対応策です。

img タグのすべての要素を取り出し、画像読み込みが終らないものをすべて非表示とすればよいようです。

$(function(){

$('img').each(function(){

if(!this.complete){
$(this).hide();
return;
}

});

});

月曜日, 10月 29, 2012

Object-C 文字列;Makefile

Object-Cでは文字列はNSStringなどを使うことができます。

文字列へのポインタとして扱うことができます。

メンバ関数 UTF8String を使うと、char*として扱うことができます。


#import <stdio.h>
#import <foundation/foundation.h> 
#import <Foundation/NSObject.h>

@interface Verb:NSObject
-(void)print: (NSString*)stem;
@end

@implementation Verb
-(void)print: (NSString*)stem
{
  char* str=[stem UTF8String];
  printf("%sim\n",str);
  printf("%sis\n",str);
  printf("%si\n",str);
  printf("%sime\n",str);
  printf("%site\n",str);
  printf("%si\n",str);
}
@end

int main()
{
  NSString *stem=@"rozumim";
  id obj=[Verb alloc];
  [obj print:stem];
  return 0;
}

GNUmakefile ファイルにおいて、以下のようにコンパイルの条件を指定すると、make 一発でコンパイルできます。

GNUSTEP_MAKEFILES=c:/GNUstep/GNUstep/System/Library/Makefiles
include $(GNUSTEP_MAKEFILES)/common.make

TOOL_NAME = verb
verb_OBJC_FILES = verb.m

include $(GNUSTEP_MAKEFILES)/tool.make


土曜日, 10月 27, 2012

Objective-Cのプロトコルとは

Objective-C では、クラス継承の際に必須のメソッドを規定するプロトコルという概念があります。

まさしく、Java でいうところのインターフェースの概念と同じもので、メンバ関数を持たないクラスとして実装されます。プロトコルで指定されるメソッドは宣言のみで、抽象クラスとして実装されます。

#import >stdio .h=".h">
#import >foundation bject.h="bject.h">

@protocol ToString
-(void)toString;
@end

@interface Test:NSObject>tostring>
@end

@implementation Test
-(void)toString
{ 
  printf("This is class Test.\n");
}
@end

int main()
{
  id obj=[Test alloc];
  [obj toString];
  return 0;
}



火曜日, 10月 23, 2012

Objective-C のクラスメソッド

Objective-Cにも静的なメソッドというものがあります。

Objective-Cの用語ではクラスメソッドというものです。

Javaでいうところのstaticにあたります。

当然ながら、メンバ変数を持つことはありません。

メソッドの宣言に+(プラス記号)をつけます。

#import <stdio.h>
#import <Foundation/NSObject.h>

@interface Test:NSObject
{
  int index;
}
- (void) hello;
- (void) setIndex:(int) i;
+ (void) dump;
@end

@implementation Test
- (void) setIndex:(int) i
{
  self->index=i;
}
-(void)hello
{
  printf("Hello NSObject %d\n",self->index);
}
+(void)dump
{
  printf("Class method = static");
}
@end

int main()
{
  [Test dump];
  return 0;
} 

他にも@propertyや@synthesizeなどいうキーワードがありますが、GNUstepはサポートしていません。

参照先がreleaseされたときの挙動を変えるものです。
@property(nonatomic, assign)
@property(nonatomic, retain)

月曜日, 10月 22, 2012

OOP, any problems?

Do not compare apples and oranges.

OOP is implemented as an extension of C.  But it is a completely different concept. 

What is good about OOP is the change of the design framework of programming.  Say, Lisp can be converted to C and that indeed is what the compiler does.  But they are different languages with more focuses on its abstraction.  Likewise, OOP is a way of abstraction, a way to express it.

Writing in Lisp is different from writing in C.  They are not interchangeable.  It may be the same to the machine but not to programmers.

Not even knowing the importance of its concepts and talking about issues of implementation, is somewhat like looking at trees and not seeing the woods.

It is just a way to devalue OOP. 

The reason why they are to denigrate the importance of the revolution, is totally of theirs, not ours.

In the year 2012, why should we need to emphasize the importance of OOP for Pete's sake?

Please.  Let us have the freedom of thoughts and religions.

日曜日, 10月 21, 2012

Object-Cのクラスについて

それでは試行錯誤でどうやら動くようになったGNUstepの話の続きを。

Object-CはC++に似て、クラスの定義にヘッダーを必要とします。

変数・関数の宣言に順番を気にしなければならなかったCの名残りといえるでしょう。

定義と実装は別々に行います。

Javaの場合には、そんなものは必要がなく、publicクラスにそれぞれ独自のファイルを用意してクラスの実装のみを記述します。

#importでクラスを指定さえすれば、順番も関係なく使用することができます。

Object-Cのクラス宣言と実装、呼び出しの方法を下記に示します。

#import <stdio.h>
#import <Foundation/NSObject.h>

@interface Test:NSObject
-(void) hello;
@end

@implementation Test
-(void)hello
{
  printf("Hello NSObject\n");
}
@end

int main()
{
  id obj=[Test alloc];
  [obj hello];
  return 0;
}

コンパイラオプションはこちらを使いました。
gcc nsclass.m -I c:/GNUstep/GNUstep/System/Library/Headers -L c:/GNUstep/GNUstep/System/Library/Libraries -lobjc -lgnustep-base 


Objective-Cは引数の指定の仕方が独特です。

型をいちいち指定して呼び出します。

Javaのように引数とメンバ変数を同名にすると警告が出ます。

#import <stdio.h>
#import <Foundation/NSObject.h>

@interface Test:NSObject
{
  int index;
}
- (void) hello;
- (void) setIndex:(int) i;
@end

@implementation Test
- (void) setIndex:(int) i
{
  self->index=i;
}
-(void)hello
{
  printf("Hello NSObject %d\n",self->index);
}
@end

int main()
{
  id obj=[Test alloc];
  [obj setIndex:10];
  [obj hello];
  return 0;
}

土曜日, 10月 20, 2012

Windows で GNUstep を使った Object-C プログラミング

iPad が隆盛を極めてはや数年、マイクロソフトもついに(高額)タブレットPCを発売。

キーボードに凝りまくったというCMがネットで流れています。26日にはARMベースのマシンが発売されます。

最安モデルで499ドル。まさにアップル並みの値段。

競合モデルとしては、もっさりと遅いでも安いAndroidマシンか、アップルの小型iPadマシンか。

1月には Windows 8 ベースのマシンが発売されます。

Windowsベースのアプリが動くとなれば、これは革命です。


開発者として、傲慢なアップルの「開発しにくくしてカネをとろうとする」態度は正直なところ好きになれません。

頭(か性格か)の悪すぎるやりかただと思います。

と正直な感想から、Object-Cのはなし。

WindowsでもGNUstepというプロジェクトがあって、Object-Cでプログラムが書けます。

こちらを参照しました。

OOP言語であるObject-Cですが、C#よりJavaに遠い。

PC販売に影響したというタブレット市場がどのように変化していくのか、新製品を横目にプログラムにいそしむ週末になりそうです。

金曜日, 10月 05, 2012

Elispで文字列置換

久しぶりに elisp でプログラム。

オープンソースの始祖であるところのGNUの鉄則に従って、書いた分だけここに置いておきます。

文字列変換というごくごくシンプルなものですが、変換後にバッファでのポイントの位置がずれることに注意。

(defun replace-tags-region (from-string to-string begin end)
"Replaces from-string to to-string in the region from begin to end."
  (let ((len (- (length to-string)(length from-string))))
    (goto-char begin)
    (while (search-forward from-string end t)
      (replace-match to-string t)
      (setq end (+ end len)))))

(defun replace-tags-list (tag-list)
"Takes a list of (from-string to-string) and replaces all from-string to to-string in the buffer."
  (replace-tags-region (car tag-list) (cadr tag-list)(point-min)(point-max))) 

  

;; Usage:
;; (setq tag-list '(("TABLE" "table")("TD" "td")("TR" "tr")))
;; (replace-tags tag-list)

(defun replace-tags (tag-list)
"Takes a list of lists of (from-string to-string) and replaces all from-string to to-string in the buffer."
  (mapcar 'replace-tags-list tag-list))

(defun create-end-tag (tag-name)
  "Creates closing tag from the given tag-name."
  (concat "</" tag-name ">"))

(defun create-half-begin-tag (tag-name)
  "Creates opening tag from the given tag-name."
  (concat "<" tag-name " "))

(defun create-attribute-tag (tag-name)
  "Creates attribute string from the given tag-name."
  (concat " " tag-name "=\""))

(defun create-begin-tag (tag-name)
  "Creates opening tag from the given tag-name."
  (concat "<" tag-name ">"))

 

;; Usage:
;;(setq tag-list '("TABLE" "TD" "B" "BR" "A" "HTML" "NOSCRIPT" "SCRIPT" "HEAD" "BODY" "TR" "TITLE" "I"))
;;(mapcar (lambda (x)(create-replacement-list 'create-end-tag x)) tag-list)
(defun create-replacement-list (create-list tag-name)
"Creates a list of tag name and lowercase tag name lists."
  (cons (funcall create-list tag-name) (list (funcall create-list (downcase tag-name)))))

(defun lowercase-html-tags()
"Converts uppercase HTML tag names to lowercase."
  (interactive)
  (let* ((tag-list '("TABLE" "TD" "B" "BR" "A" "HTML" "NOSCRIPT" "SCRIPT" "HEAD" "BODY" "TR" "TITLE" "I"))
  (attribute-list '("VALIGN" "ALIGN" "WIDTH" "HEIGHT" "BOTTOM" "CLASS" "BGCOLOR" "BORDER" "LEFT" "RIGHT" "TOP" "CELLPADDING" "CELLSPACING" "BORDERCOLOR" "CENTER" "MIDDLE" "HREF" "COLSPAN" "ROWSPAN" "SRC" "onMouseOver" "onMouseOut" "ALT" "NAME" "ID" "VSPACE" "LINK" "META" "LEFTMARGIN" "TOPMARGIN" "MARGINWIDTH" "MARGINHEIGHT" "onLoad" "BACKGROUND" "TYPE" "HTTP-EQUIV" "CONTENT" "REL" "LANGUAGE"))
  (half-tag-list '("TABLE" "TD" "A" "IMG" "LINK" "META" "SCRIPT" "BODY" "TR" "DIV"))
  (replacement-end-tags (mapcar (lambda (x)(create-replacement-list 'create-end-tag x)) tag-list))
  (replacement-begin-tags (mapcar (lambda (x)(create-replacement-list 'create-begin-tag x)) tag-list))
  (replacement-half-begin-tags (mapcar (lambda (x)(create-replacement-list 'create-half-begin-tag x)) half-tag-list))
  (replacement-attribute-tags (mapcar (lambda (x)(create-replacement-list 'create-attribute-tag x)) attribute-list)))
    (replace-tags replacement-attribute-tags)
    (replace-tags replacement-end-tags)
    (replace-tags replacement-half-begin-tags)
    (replace-tags replacement-begin-tags)))

水曜日, 9月 19, 2012

IE でCSS3の display:box を使うには、flexie.js を使えばいい

そうです。IEはまだCSS3の display:box 仕様に対応していません。

このボックス仕様を使うと、横並びのボックスがエレガントに書けます。


外側のDIVに、このように指定します。

    display: -webkit-box;
    display: -moz-box;    
    display: box; 
 
内部のDIV要素がきれいに並んでくれます。
 
ただし、上記のようにIEには対応していません。

そこで、この flexie.js を導入すると、見事に横並びボックスが実現できます。

ダウンロード:http://flexiejs.com/
 
これでページのHTMLタグが整理できそうです。
 
 

土曜日, 9月 08, 2012

シームレスの背景画像をGIMPで作るには

シームレスの背景画像をGIMPで作るには、メニューからFilters|Map|Make Seamlessを選択します。

すると画像を一発でシームレスにできます。

こんな感じです。

http://easai.web.fc2.com/odonata/photoindex/


木曜日, 9月 06, 2012

Excel のマクロを消すマクロ

Excel のマクロを消すマクロを書こうと思ったら、警告が出ました。

マクロはこんな感じです。

こちらのページ「VBAでマクロのソース削除と標準モジュール削除」を参照させていただきました。

Dim objVBCOMPO     As Object
        For Each objVBCOMPO In ActiveWorkbook.VBProject.VBComponents
            With objVBCOMPO.CodeModule
                If .CountOfLines <> 0 Then .DeleteLines 1, .CountOfLines
            End With
            If (objVBCOMPO.Type = vbext_ct_StdModule Or objVBCOMPO.Type = vbext_ct_MSForm) Then
                ActiveWorkbook.VBProject.VBComponents.Remove objVBCOMPO
            End If
        Next objVBCOMPO
        Set objVBCOMPO = Nothing
End Sub


これをデフォルトの設定で走らせると警告が出ます。



これは、マクロセンターの Trust access to the VBA project object model オプションをオンにすると動くようになります。

金曜日, 8月 31, 2012

クリックで表示を切り替える(単位変換など)

米国での長さの単位はきわめていまいましいことにすべてインチ・フィートです。

 ここで、インチ・フィートに要素を変換する jQuery スクリプトを示します。

 $(document).ready(function(){
  $(".millimeters").hide();
  $("#convertIN").click(function(){
   $(".millimeters").hide();
   $(".inches").show();
      });
  $("#convertMM").click(function(){
   $(".millimeters").show();
   $(".inches").hide();
      });
     });

JQuery であると容易に要素の表示を切り替えることができます。

 ... there was a question in the Reddit session to Obama whether the US would ever move to metric system.

リンクをかけたブロックの中に、別のリンク先に飛ぶエレメントを置く

リンクをかけたブロックの中に、別のリンク先に飛ぶエレメントを置きたいとします。

ブロックにはリンクがかかっているので、内部の要素をクリックしてもリンク先に飛んでしまいます。

どのようにリンクを無効にするか。

jQuery には event.preventDefault() というメソッドがあります。

これを呼ぶと、ブロックにかかっているリンクを無効にできます。

     $(document).ready(function(){
         $(".クラス名").click(function (event){
             event.preventDefault();
             document.location="飛ばしたい先のアドレス";
         });
     });


これで、内部要素をクリックすると、ブロックにかかっているリンクを無効にして指定されたアドレスに飛ぶよう指定できます。

(はいはい。ブロックにリンクをかけるというのは推奨されない方法です。)

水曜日, 8月 29, 2012

好みのエディタでオンラインの文章を編集する

ブログ編集画面などで、テキストエリアの文章を好きなエディタで編集可能な Firefox のアドオンがあります。

→ It's All Text!

このアドオンを使うと、テキストエリアにボタンがついて、押すと指定されたエディタが起動します。

ホットキーやエディタの設定は、Firefox のメニューから、Add-ons の Extensions で設定します。

 It's All Text の Options ボタンを押すと、設定画面が表示されます。


このアドオンがあると、オンラインでのテキスト編集の精神的負担が軽くなります。

ブログなどでオススメです。

火曜日, 8月 28, 2012

xampp 1.8 にアップグレードしました。

xamppをアップグレードしました。Ver. 1.8が最新のようです。

MySQLもアップグレードとなるので、データベースも移動することになります。

このあたりは、data以下をすべてまるごとコピーでOK。

phpMyAdminでID/Passwordの設定を行ってデータベースがきちんと移動できたかどうかを確認して一安心。

ファイル: config.inc.php
$cfg['Servers'][$i]['user'] = 'ユーザー名';
$cfg['Servers'][$i]['password'] = 'パスワード';

PHPのデフォルトがすべての警告を表示するとなっているので、まずそいつに黙ってもらって無事にアップグレードを完了。

ファイル: /php/php.ini
;error_reporting = E_ALL | E_STRICT
error_reporting = E_ERROR

を使えるようにして、curlを有効にする。

short_open_tag = On

extension=php_curl.dll
 
コントロールパネルもアップグレードされておりました。

月曜日, 8月 06, 2012

Excelのキャッシュをクリアする

Excelマクロの問題です。

サブルーチンの文字を書き換えるとExcel自体が壊れる。

といういかにもプログラミング環境の不備という問題に直面しました。

プレコンパイルしているとすればキャッシュファイルを消すという手順が必要となるわけですが、ネットに情報がない。

ActiveXのキャッシュがあるとされる場所には.exdファイルは見当たらず。
C:\Users\ユーザー名\AppData\Local\Temp\VBE

...

結局サブルーチン名を書き換えるということで問題を解決。

PHP: 定数を扱う

プロジェクトごとの定数を扱うクラス Config\Constants の紹介です。 <?php namespace Config; class Constants {     public const DB_USER = "linguist...