Home

Ten Eyck

H1-B ビザに関する 2, 3 のこと

日本語を母語とする方で、僕のようにアメリカで働く人がどれほどいるか知りませんが、外国人 (この場合、正確にはアメリカ人あるいはカナダ人でない人ですね) がアメリカで合法的に働くには、Visa (査証) が必要です。先日、東京赤坂のアメリカ大使館で、NIV (Non-Immigrant Visa: 非移民査証) 面接を受けてきました。

査証にも種類がたくさんあり、一概に云えないでしょうけれど、自分の経験ももしかしたら誰かの役に立つかもしれません。というよりむしろ、自分への備忘録として、査証のスタンプをパスポートに押してもらうまで、どんなことをしたかメモしておきます。

大使館面接に臨むまで

僕は米国の企業に雇用されています。そこに至るまでの何か、というのはこの項で扱いません。多くの米国企業は外国人を雇っているでしょうし、顧問弁護士などもいますから、その辺は“良きに”やってくれるはずです。ここで僕がお勧めしたいのは、個人的に話しができる弁護士を自分の味方として持っておくことです。

幸か不幸か、僕は何度か職場を変えてきました。米国で僕は “alien (異邦人)” ですから間違いなく不利な部分はあるわけです。そこで書類や条件のうえで自分には何が必要なのか、それらはいつまでに必要なのか、そういったことを理解しておくことはとても大事なことです。全て web 上で調べられることですけれど、最新情報にアップデートしてあることとか、電話したらすぐに聞けることとか、そういったことを鑑みると僕は、誰か一人知り合いの attorney (法律家) を持っておくべきだと思います。僕にとっては、米国で雇用されることが目的なのではなく、自分自身のしたいことをすることが目的なのですから、一番大事なこと以外は他の人に頼んでもいんではないかな。高い、という疑問もあるでしょうけれど、英語がしゃべれるなら、安く頼める人は沢山います。それこそ web で調べましょう。

そして合衆国政府の DHS USCIS (Department of Homeland Security, U.S. Citizenship and immigration Services) から、”I-797A, Notice of Action” という書類が来たら、査証面接への準備開始です (もちろん、Notice Type が Approval でないとダメですけど…)。

準備する書類

米国大使館非移民ビザの項目は良く読んでおきましょう。非移民ビザ: 予約ステップには必要な書類がすべて列挙されています。これらを指定された順番 (PDF) でクリアファイルに入れて、持っていきます。僕と同じく H1-B の申請の場合は…

  • パスポート
  • DS-156「オンライン入力式ビザ申請書」
    • カラー写真
    • 申請料金の支払い
  • DS-157「非移民ビザ補足申請書」
  • オリジナルの I-797許可通知
  • I-129請願書のコピー
  • 雇用証明
  • エクスパック 500
  • 面接予約確認書

が必要です。

I-129請願書のコピーというのは、H1-B を申請した時の書類です。普通は会社の法律家が用意しますから、しかるべき人にお願いすれば、すぐにコピーを作ってくれるはずです。

雇用証明に関しては法律家と相談しましょう。新規雇用の場合は Offer Letter (内定通知) 、そこの会社から給料を既にもらっている場合は Pay stub (給与明細) などがよく使われるみたいですね。僕は出来るだけ会社の偉い人の署名の入った何かを持っていくようにしています。

DS-156 について

非移民ビザ: 予約ステップにある通り、DS-156 はオンライン入力式ビザ申請書のページから記入します。プレビューもない Web フォームなので僕はちょっとビビりました。form を submit すると PDF ファイルのダウンロードがあって、開いてみると、自分の情報が入力された DS-156 が出来上がり、というわけです。でも多分、登録番号を作っているだけで、入力内容はどうなんだろう…僕は None と書くべき部分を空白にしてしまって、印刷したあとで、None と書き入れた部分はいくつかあります。あと Signature (署名) は必ず必要です。

また、大使館に入館する際に、書類の不備などをチェックしてくれる受付の方がいるんですが、彼女に 25. Name and telephone numbers of person in U.S. Who you will be staying with or visiting for tourism or business. に上司の名前を書けと云われました。H1-B の形態を考えると少々混乱する記入事項だと思うのですが、まぁそういうことです。

あとこれはいうまでもないことかもしれませんが、DS-156 と DS-157 のコピーを是非取っておくべきです。滞在したことのある国のリストとか、学校に行っていた日付とか、なかなか調べられない情報を沢山書きますので…将来のまた記入する時にコピーがあれば一貫性を保てます。

DS-156 を作成するのに、正直に言えば、I-797A は必要ありません。そして DS-156 を作成しないと、NIV 面接の予約を入れることができません。また NIV 面接は常に混雑しています。なので、もし時間に余裕がなくて、日程を早く決めておきたいのならば、DS-156 を早い段階で作成して、前もって予約を入れておく、というのは手かもしれません。

面接当日

東京赤坂の大使館では、まず正門脇の警備室を通過します。そこはもうほとんど空港のゲート並みに(にこやかですが)調べられます。予約確認証を見せることから始まるので、すぐ取り出せるようにしておくべきでしょう。また全ての電子機器は預けさせられます。ノートパソコンを持っていくのはあまり良い考えとは思いません。デジタルカメラ、携帯電話もそこで預けます。

そして入館前に先ほども云いましたが、書類のチェックが行われます。係員の方はてきぱきとしていますが、やってくる人には日本語を母語としない方も結構います。ので、寛容になりましょう。あと僕のように冬に来る人は寒い中でしばらく待たされますので、その辺は準備をしっかりと。

面接、というと、静かな部屋で厳かに、一人一人行われるようなものを、僕はイメージしていましたが、大分違います。実際は…透明な板で仕切られたカウンター越しに、書類を提出して、待って、呼ばれて、また待って、呼ばれて…銀行や運転免許センターのような感じでしょうか。焦らず、気張らず、リラックスしているのがいいと思います。

まずは用意した書類を最初の窓口に提出します。そして指紋採取、その後面接となります。僕は2回目の申請ですが指紋はまた採取されました…

注意深く人の流れを見ていると、質問の量や質に違いがあるのがわかると思います。その流れは属人的なように思えますが… つまり面接で聞かれる内容が多い人は、それを聞く専門の人の窓口に流れているように、僕は観察しましたが、もしかしたら違うかもしれません。しかし間違いないのは、ごく数分の会話で (笑顔で) 窓口を去る人もいるし、時間をかけて書類を持って帰らされる人もいる、ということです。僕はいつもその多く質問する人の窓から呼ばれないことを祈りつつ、待ちます。

待ち時間は単調かつ思っているより絶対長いです。僕は小説を持っていきましたが、呼び声が気になってしまってなかなか読み進められませんでした。気が散ってもいいアナログな何か、新聞とか雑誌とかを持っていくといいかもしれません。あとトイレも最初に書類を出したらすぐに行くべきですね。

幸い、僕の面接はほんの数分で終わりました。ゲートをくぐって出るまで、大使館の滞在時間はざっと2〜3時間程度だったでしょうか。 (その多くは待ち時間ですよ!)

今回は驚いたことに、提出から 25 時間程 (つまり翌日) で、手元にパスポートが帰ってきました!前回はやっぱり(営業日換算で)4日程かかったけどなぁ…ちなみに提出した DS-156 と DS-157 を除く、全ての書類は返却されます。

False となる値 - JavaScript: The Good Parts

JavaScript: The Good Parts ―「良いパーツ」によるベストプラクティス“の Appendix A に収録されている(であろう)表を引用しています。

False となる値

以下にあげる値は、if や switch の条件式の中で、false となります。

Type Value
number 0
number NaN
string ""(要素が空(から)の文字列)
boolean false
Object null
undefined undefined

意識/無意識のうちにでも理解しているとは思いますが、こうやって整理されているとまたわかりやすいですね。

さてここからは余談です。多くの言語では、文字列と配列は非常によく似た存在です。つまりどちらであっても、長さというプロパティがあって、添字によって中のデータに一つ一つアクセスできる、というものです。もし要素が空(から)の文字列が false であるなら、要素が空の配列はどうでしょう?実際には要素が空(から)の配列は false とは評価されません。おそらく JavaScript の Array は Object に帰するもので、空配列は null でない Object と云う意味で、例外になってしまうからでしょうか。

Falsy values - “JavaScript: The Good Parts”

This entry is a note from “JavaScript: The Good Parts” on page 106, Appendix A: Awful Parts.

Falsy Values

In JavaScript, following values are considered as “false” when they come to conditional expression.

Type Value
number 0
number NaN
string ""(empty string)
boolean false
Object null
undefined undefined

You must have understood them already, but it’s good to have it organized.

In most of languages, String and Array is very similar. I mean, both instances have a length property for nature and you can access stored values by their own indexes. So I was wondering, if an empty string is falsy, why not an empty array is? No, an empty array is not falsy. I guess its because an array is acutally an object. Try typeof operator with one.

Here, I tried to evaluate an array with JavaScript’s nature, duck typing, but well, it doesn’t work as I imagined.

var a = [];
console.log( a ? 'true' : 'false'); //of course, true;

console.log( (String.prototype.constructor.apply(a)) ? 'true' : 'false'); //Oh? false... so..?

var b = ['b'];
console.log( (String.prototype.constructor.apply(b)) ? 'true' : 'false'); //still false...

Any value, even if it’s a string type of a String wrapper object, passed to string constructor makes an empty string.

String.prototype.constructor(['a']);

will do more as what you can imagine. String.prototype.constructor will run .valueOf() on the argument.

文字列比較 - JavaScript: The Good Parts

いつだったか、この blog にも何度か登場している Mauvis に勧められて購入した “JavaScript: The Good Parts ―「良いパーツ」によるベストプラクティス” は原書で何度か読みました。なんだか翻訳が最近出たそうなのですが(訳の問題はわかりませんが)、これはお勧めです。すごく薄いけど、気付かされることがすくなくとも、僕には沢山ありました。しばらくこの本から学んだことをいくつか紹介していきたいと思います。

最初は String の比較です。

以下の expression は共に true と評価されます。

('cat' == 'c' + 'a' + 't') // true
('cat' === 'c' + 'a' + 't') // true

この本を読むまでは、JavaScript はなんとなくインスタンスベースの比較をしてるのかなぁと思ってました。それはつまり、等号( == あるいは === )の左右両辺にが全く同じメモリアドレスを指し示している時だけ、true と評価される、ということです。しかし実際には、String の比較時はその文字列の内容を評価していました。

var s1 = s2 = 'foo';
var s3 = 'foo';
s1 == s2; // true
s1 == s3; // still true, of course.

従って、もし万が一、インスタンスで文字列を比較したい場合は、以下のようにするといいでしょう。

var s4 = new String('foo');
var s5 = new String('foo');
s4 == s5 //false

しかし本の中になんども登場する通り(そして僕も強く同意しますが)、Wrapper Object (String, Number そして Boolean) は混乱の元です。必要となるシチュエーションもあまり想像できません。

ところでインスタンスベースの文字列比較、というのはもうあまりポピュラーではないんでしょうか?僕が多分最初に Java を学んだときはインスタンスベースの比較だったような気がしたのですが、今試してみたら (1.5.0_16 on Intel Mac) 内容で比較していますね。PHP も同じようです。

String comparison - “JavaScript: The Good Parts”

I’ve read “JavaScript: The Good Parts” a few times already, since it’s a thin but dense book. This book is somehow basic, but full of discerning. I should have do an Advent Calendar-ish thing if I could start this earlier.. But anyway, I will keep writing a bit about what I learned from this book for a while.

So the first thing, is a string comparison, on Chap. 2, page 10.

Following expressions both return true!

('cat' == 'c' + 'a' + 't') // true
('cat' === 'c' + 'a' + 't') // true

Before I read this, I originally thought JavaScript might compare the instance-base equality. I mean if the string instances on both side on the equal sign were pointing to the exactly same memory address, it would return true, but it is actually comparing its value.

var s1 = s2 = 'foo';
var s3 = 'foo';
s1 == s2; // true
s1 == s3; // still true, of course.

So, if you wanna do instance base equality, do as follows:

var s4 = new String('foo');
var s5 = new String('foo');
s4 == s5 //false

But as it’s mentioned in the book (and I strongly agreed!), wrapper objects (String, Number and Boolean) are just seeds of confusion. I don’t also see the neccessity of using them.

By the way, I thought that instance-base comaprison is more popular rather than value-base comparison. But as far as I just tested, Java (1.5.0_16 on Intel Mac) compares value, PHP compares value.. that’s intereting.

configure your Sandbox with Scheme

Mac OS X - from the server room to your desktop

[EN] / JA
BSD’s Jordan talks about inside Mac OS X. People just talk about the (future) release date of Snow Leopard, but I think more interesting thing is that… On page 29, as Sandbox Profiling language, they use Scheme!

EN / [JA]
FreeBSD の著名な開発者 Jordan Hubbard が Mac OS X の内部についてプレゼンテーションをし、その中で次期リリースについてふれらているのが話題になっていますが、僕はそれよりも、29ページ目にある、Sandbox Profiling 言語として使用されている Scheme に注目したいですね。

Coway’s Game of Life

Conway's Game of Life

ライフゲームは思い入れがあるというか、僕が NYU で一番最初に自分で書き上げたプログラムです。セル・オートマトンというアイデアもとても面白いし、何より動いていくその様が大好きでした。ITP の最初の期末、発表の数時間前に書き上げて、動いていたのはとても感動的…なんて話はどこかに書いた気がします。どうってことないプログラムだけれど、やっぱり動くのをみるのは気持ちいいですよね。その発表したバージョンは、Macromedia Director Lingo で書かれていて、どうやったか覚えてないけど、マルチプレイヤーでした…3人まで参加できて、matrix のアニメーションを排他ロックしていたはず…

マルチプレイヤーの部分はまだ実装してませんが、一人遊びをする分にはこれで十分かと思います。お楽しみください。100分の1程度の割合で、セルが突然変異をするので色がだんだんかわっていきますよ。

インタラクションの制御に MochiKit を使っていますが、もうちょっと改良の余地はありそうです。

モチキット入門

諸般の事情により、今更ですが MochiKit をはじめてみました。Prototype.js と jQuery にどっぷりだった人が全然違う vocabulary にすごい悪戦苦闘してる感じ。ただしばらく使ってみると、それなりに使いやすいのは解ってきたので、ごく初歩でつまずいたところを簡単に羅列しておきます。

  • Mochikit ではなく MochiKit
    このへんは、キャピタルレター好きのドイツ人感性だろうか…
  • MochiKit.js はローダー。
    意味論的にメソッドがファイル (object) に分類されていて、MochiKit.js を読み込むと凡てのファイルを読み込む。選択的に使いたい場合は、<script>文を複数行書く。ただし、依存関係もあるので、MochiKit.MochiKit.SUBMODULES に書かれた順序で読み込むのが正しい感じ。
  • global 汚染しない方法もある
    jQuery な人が最初に気持ち悪いと思うのは、デフォルトでかなりの数の関数が global 名前空間に登録されていること。official のドキュメントの一番最初にあるが、<script type="text/javascript">MochiKit = {__export__: false};</script>を MochiKit 関連を読み込む前に発行しておけば、FQMN (Fully-Qualified-Method-Name: なんて言い方があるかどうか知らないが) のみのアクセスに制限できる。
  • ドキュメントは expand all してページ内検索
    語彙がだいぶ違うとはいえ、宇宙語ではないので多分全ての語彙からキーワードを検索すれば多分何かは解るはず。ドキュメントは Overview が時代遅れな感じがしますが、細かい部分の完成度は高いです。

前に作った、Conway’s Game of Life を MochiKit を使って書き直してみました。というか、EventRunner を使わなくなっただけとも言えます…

Duck Typing on JavaScript, and getter/setter

My friend Mauvis brought me (ahem) an interesting problem again.

Write a one-line piece of JavaScript code that concatenates all strings passed into a function: 

function concatenate (/*any number of strings*/) {
  var string = /*your one line here*/
  return string;
}

So, the first thing I’ve tried was as follows:

function concatenate () {
  var string = (function (a) {var r = [];for (var i = 0, len = a.length; i < len; ++i}{ r[i] = a[i]}return r.join('');)(arguments);
  return string;
}

I know that doesn’t look good. And it’s just in one line, but it’s actually a few lines.

Then Mauvis replied me back..

function concatenate () {
  var string = function(a){return Array.prototype.slice.call(a).join('');}(arguments);
  return string;
}

and eventually it bacame like this.

function concatenate () {
  var string = Array.prototype.join.call(arguments, '');
  return string;
}

This is a pretty interesting topic in JavaScript. The first one I did is pretty straight forward, right? Arguments object is an array-like object, that each local (function) space has automatically. You can iterate like an array. So I loop through each value, put it all together in a different array, then construct a new string.

The second one and third one are a bit unusual for the first look. What it does is apply Arguments object as an array in order to call slice or join method, which both of them are originally Array’s prototype methods.

If you are fuzzy about it, Let’s take a look the specification of JavaScript.

It’s a little too long, but I quote an entire section of slice (Page 105 - 106) here.

15.4.4.10 Array.prototype.slice(start, end)

The slice method takes two arguments, start and end, and returns an array containing the elements of the array from element start up to, but not including, element end (or through the end of the array if end is undefined). If start is negative, it is treated as (length + start) where length is the length of the array. If end is negative, it is treated as (lengt+ end) where length is the length of the array. The following steps are taken:

  1. Let A be a new array created as if by the expression new Array().
  2. Call the [[Get]] method of this object with argument "length".
  3. Call ToUint32(Result(2)).
  4. Call ToInteger(start).
  5. If Result(4) is negative, use max( (Result(3) + Result(4)), 0 ); else use min( Result(4), Result(3) ).
  6. Let k be Result(5).
  7. If end is undefined, useResult(3); else use ToInteger(end).
  8. If Result(7) is negative, use max( (Result(3) + Result(7)),0 ); else use min( Result(7), Result(3) ).
  9. Let n be 0.
  10. If k is greater than or equal to Result(8), go to step 19.
  11. Call ToString(k).
  12. If this object has a property named by Result(11), go to step 13; but if this object has no property named by Result(11), then go to step 16.
  13. Call ToString(n).
  14. Call the [[Get]] method of this object with argument Result(11).
  15. Call the [[Put]] method of A with arguments Result(13) and Result(14).
  16. Increase k by 1.
  17. Increase n by 1.
  18. Go to step 10.
  19. Call the [[Put]] method of A with arguments "length" and n.
  20. Return A.

The length property of the slice method is 2.

NOTE

The slice function is intentionally generic; it does not require that its this value be an Array object. Therefore it can be transferred to other kinds of objects for use as a method. Whether the slice function can be applied successfully to a host object is implementation-dependent.

And here’s join section (page 103). This one is snippet.

15.4.4.5 Array.prototype.join (separator)

The elements of the array are converted to strings, and theses trings are then concatenated, separated
by occurrences of the separator. If no separator is provided, a single comma is used as the separator. The join method takes one argument, separator, and performs the following steps..

…(snip)…

NOTE

The join function is intentionally generic; it does not require that its this value bean Array object. Therefore, it can be transferred to other kinds of objects for use as a method. Whether the join function can be applied successfully to a host object is implementation-dependent.

Both sections consist of definition, procedures, and note. And interesting thing is on the Note: intentionally generic and implementation-dependent. So it depends on Browser dev, to implement it generic or not..

I made a page to try out those things: Duck Typing test.

And acutally, as it’s written on SPEC, you can use slice/join for your own object. What it’s written on 2 and 14 on Array.prototype.slice procedure, it needs to access [[Get]], which is an internal method for each object (page 26 - 28). According to John Resig’s JavaScript Getters and Setters, it can be used in Firefox, Safari and Opera. But as far as I tried, it doesn’t work in Opera. If IE has the other way to do it, I will be more interested in…

Process String

My good friend Mauvis was writing on his blog about to convert a string to comma separated ascii numbers. I commented there about his code. Here’s how I wrote, and also see his original: String.toCharCode().

String.prototype.toCharCode = function()
{
  var str = this.split('');
  var len = str.length;
  var work = new Array(len);
  for (var i = 0; i < len; ++i)
  {
    work[i] = String.charCodeAt(str[i]);
  }
  return work.join(',');
}

It was his quick hack for the day, I suppose, but it turns out to be very interesting thing to me. There are a few points to write faster code.

  1. explicit length of for loop — dot access considered harmful at least for speed.
    for JavaScript, .(dot) access is always very slow. Some people do like… for (var i = 0; i < arr.length; i++). That’s not good. On this case, i need to use array length twice so I made a local variable. The local variables are always the fastest access.
  2. NO for…in for Array
    for…in is basically built for Object enumeration. By using for…in, JavaScript will pass all properties with the internal DontEnum attribute false, to i (or accessor whatever you name). MDC:Object.propertyIsEnumerable() is very interesting to read about this topic.
  3. Do not concatenate a string
    In most of languages, string is immutable. In my early life of programming, I always wondered.. what’s the hell? Immutable? As its meaning, string is not changeable. but let’s see like…
    var s = "foo";
    s = "bar";
    alert(s); // returns "bar"!

    right? You can change it. But as a lower process level point of view, the code above is same exact meaning as follows.

    var s = new String("foo");
    s = new String("bar");
    alert(s); // returns "bar"!

    Two instantiation process. Now you believe me, right? This article: HotRubyがC Rubyより速い本当の理由は? (written in Japanese) explains very comprehensively how JavaScript engine would implement it. At least you should take a look at this picture. But overall, String concatenation considered harmful. In most cases, you can use Array.join() to connect multiple strings.

These looks very minor and small changes. But it does make a difference.

Home

Search
Feeds
Meta
Links

Return to page top