jQueryで要素に代入すると領域が確定できなくなるらしい。画面全体に領域が設定されているようだ。さらに、内部要素を追加するとその部分はイベントにフックできないらしい。
ブロック要素にロード時に要素を定義。
さらに、クリックイベントに関数をフック。
するとウインドウ領域全体でクリックイベントで関数が起動。
ブロック要素にロード時に要素を定義。
その要素にクリックイベントをフック。
するとフックされない。
他の要素が絡んでいないかどうか、もう少し追ってみる必要があるわけですが、もう疲れた。ので今日はここまで。
木曜日, 6月 20, 2013
金曜日, 4月 19, 2013
PHPでJava風のprintStackTrace()を実現する方法
PHP では try-catch が使えます。
catchで捕まえた例外をどのように処理するかはまた人それぞれだとは思いますが、Java には printStackTrace() という便利な関数があります。
コールした関数を順に出力してくれる関数です。
ここではPHPで関数コールを出力する関数を実装してみました。
例外処理で呼び出すと、関数呼び出しのトレース文字列を出力します。
関数のコールを順に出力するための関数です。
catchで捕まえた例外をどのように処理するかはまた人それぞれだとは思いますが、Java には printStackTrace() という便利な関数があります。
コールした関数を順に出力してくれる関数です。
ここではPHPで関数コールを出力する関数を実装してみました。
例外処理で呼び出すと、関数呼び出しのトレース文字列を出力します。
try
{
// 関数本体
}
catch(Exception $e)
{
echo trace(debug_backtrace());
}
関数のコールを順に出力するための関数です。
function trace($traceList)
{
$html="";
foreach($traceList as $debugInfo)
{
$pathInfo=pathinfo($debugInfo['file']);
$baseName=$pathInfo['basename'];
$funcName=$debugInfo['function'];
$lineNum=$debugInfo['line'];
$html.="@$funcName ($baseName: $lineNum)";
}
return $html;
}
水曜日, 4月 17, 2013
PHPでJava風のstartsWith()とendsWith()がない件について
読みやすさ、美しさというのもプログラムの質に影響してくるとおもいます。
startsWith(), endsWith()という関数がJavaにはあります。
文字列を比較して、指定した文字列で始まっていれば startsWith()は true を返します。
指定した文字列で終わっていれば endsWith()で true を返します。
Javaのネーミングセンスは最高だと常々思うわけですが、これらの関数はPHPにはありません。
substr_compare()という関数を使って startsWith()とendsWith()を実現してみました。
#文字長を制限し比較するよう変更しました(2013-06-05)。
startsWith(), endsWith()という関数がJavaにはあります。
文字列を比較して、指定した文字列で始まっていれば startsWith()は true を返します。
指定した文字列で終わっていれば endsWith()で true を返します。
Javaのネーミングセンスは最高だと常々思うわけですが、これらの関数はPHPにはありません。
substr_compare()という関数を使って startsWith()とendsWith()を実現してみました。
#文字長を制限し比較するよう変更しました(2013-06-05)。
function endsWith($haystack,$needle,$case=FALSE)
{
$len=mb_strlen($needle);
if(0<mb_strlen($haystack) && mb_strlen($needle)<=mb_strlen($haystack))
$res= (substr_compare($haystack,$needle,-$len,$len,$case)==0);
return $res;
}
function startsWith($haystack,$needle,$case=FALSE)
{
$res=false;
if(mb_strlen($needle)<=mb_strlen($haystack))
$res=(substr_compare($haystack,$needle,0,mb_strlen($needle),$case)==0);
return $res;
}
火曜日, 3月 26, 2013
Firefox で「パスワードを保存しますか」が危険な件について
Firefoxのデフォルト設定では、ログイン時に
「ID/パスワードを保存しますか?」
と聞いてきます。
ここでID/パスワードを保存すると、次にログインするときには自動で値が設定されます。
確かに便利な機能ではあるんですが、これなんとテキストでそのまま見えてしまうんですね。
パスワードはパスワードであって、テキスト表示されるのはセキュリティ上問題がある、と考えられる方は以下のサイトでパスワードを削除できます。
「ID/パスワードを保存しますか?」
と聞いてきます。
ここでID/パスワードを保存すると、次にログインするときには自動で値が設定されます。
確かに便利な機能ではあるんですが、これなんとテキストでそのまま見えてしまうんですね。
パスワードはパスワードであって、テキスト表示されるのはセキュリティ上問題がある、と考えられる方は以下のサイトでパスワードを削除できます。
「オートコンプリート」機能で保存されたパスワードの削除方法
木曜日, 1月 10, 2013
jQueryでページ内移動するには
ページ内移動には、ページ内アンカータグなどを指定して移動します。
index.html#position といった形で指定してやると、その箇所にページがスクロールします。
ページ内アンカータグについては、アンカータグでname属性を、divタグでid属性で指定します。
では、jQueryではどう処理するか、というのが表題の「jQueryによるページ内移動」です。
以下はアニメーションでページをスクロールするスクリプトです。
index.html#position といった形で指定してやると、その箇所にページがスクロールします。
ページ内アンカータグについては、アンカータグでname属性を、divタグでid属性で指定します。
では、jQueryではどう処理するか、というのが表題の「jQueryによるページ内移動」です。
以下はアニメーションでページをスクロールするスクリプトです。
var y=getY(document.getElementById("top"));
$('body,html').animate({
scrollTop: y
}, 800);
木曜日, 11月 29, 2012
Microsoft Seminar: "The New Era of Work" (Windows 8)
| Chicago |
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 を指定するとレイアウトが壊れます。
見事に人柱となった気分です。
#厳格とかいう問題じゃないですよね。これ。
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 のデータを取り出す方法。
フィルターをつける場合について、書いておきます。
ダメ上司の典型。「これネットで見付けんたんだけどどお」
どおって... システム全部書き直せって?
え、あのタグってこちらがつけたものじゃないし、むこうが取り外すだけで話は解決じゃないでしょうか。
こちらがフィルターつけて取り外すのって、それって仕事の一部ですか?!
で、仕事が遅くなったとかいって嫌がらせ。最低。最悪。ほんと性格と頭が悪い。
愚痴はさておいて。本題。
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 タグのすべての要素を取り出し、画像読み込みが終らないものをすべて非表示とすればよいようです。
ところが親切設計の 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*として扱うことができます。
GNUmakefile ファイルにおいて、以下のようにコンパイルの条件を指定すると、make 一発でコンパイルできます。
文字列へのポインタとして扱うことができます。
メンバ関数 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 でいうところのインターフェースの概念と同じもので、メンバ関数を持たないクラスとして実装されます。プロトコルで指定されるメソッドは宣言のみで、抽象クラスとして実装されます。
まさしく、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にあたります。
当然ながら、メンバ変数を持つことはありません。
メソッドの宣言に+(プラス記号)をつけます。
他にも@propertyや@synthesizeなどいうキーワードがありますが、GNUstepはサポートしていません。
参照先がreleaseされたときの挙動を変えるものです。
@property(nonatomic, assign)
@property(nonatomic, retain)
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.
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のクラス宣言と実装、呼び出しの方法を下記に示します。
コンパイラオプションはこちらを使いました。
Objective-Cは引数の指定の仕方が独特です。
型をいちいち指定して呼び出します。
Javaのように引数とメンバ変数を同名にすると警告が出ます。
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販売に影響したというタブレット市場がどのように変化していくのか、新製品を横目にプログラムにいそしむ週末になりそうです。
キーボードに凝りまくったという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の鉄則に従って、書いた分だけここに置いておきます。
文字列変換というごくごくシンプルなものですが、変換後にバッファでのポイントの位置がずれることに注意。
オープンソースの始祖であるところの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に、このように指定します。
このボックス仕様を使うと、横並びのボックスがエレガントに書けます。
外側の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/
すると画像を一発でシームレスにできます。
こんな感じです。
http://easai.web.fc2.com/odonata/photoindex/
木曜日, 9月 06, 2012
Excel のマクロを消すマクロ
Excel のマクロを消すマクロを書こうと思ったら、警告が出ました。
マクロはこんな感じです。
こちらのページ「VBAでマクロのソース削除と標準モジュール削除」を参照させていただきました。
これをデフォルトの設定で走らせると警告が出ます。
これは、マクロセンターの Trust access to the VBA project object model オプションをオンにすると動くようになります。
マクロはこんな感じです。
こちらのページ「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 オプションをオンにすると動くようになります。
登録:
投稿 (Atom)
Flask の Blueprint のテンプレート問題
Flask の Blueprint は、ルート、静的ファイル、テンプレートをまとめて管理できます。しかし、テンプレートが指定できません。 ここでは、Blueprint の template_folder の問題点と回避策を説明します。 Blueprint のテンプレート問題...
-
Qt はまってます。Mac でも書いたアプリがコンパイルできて、しっかり動くのを確認しました。このあいだ Chitubox が Qt 使ってるのを知ってうれしかったです。 Mac でもそのまま動くんですが、アプリのアイコンの設定はプラットフォーム依存です。 公式マニュアルでも設定...
-
コンデンサマイク 極性があります コンデンサマイクがようやく届きました。モジュールではないのでそのままでは信号が弱いので使えません。信号を増幅する必要があります。 ちょっとした手間ですが、首尾よく動いてくれました。この回路の応用で、使えるマイクが出来ます。 ...
-
今日ホール素子が届きました。 ホール素子ってのは ホール効果 を利用して磁場を感知するセンサーです。 iPad のケースとか、閉じると電源が切れてくれますよね。ケースのカバーの磁石の磁場をホール素子が感知してるわけです。 さっそくホール素子を使ってみよう!電圧...


