h4c

ただのメモ

Compiling Plim on the fly with Sublime Text

Put this on your packages directory of st. ex) $HOME/Library/Application\ Support/Sublime\ Text\ 2/Packages/PlimCompiler/plim_compiler.py

import sublime, sublime_plugin
import os
import subprocess

class PlimCompiler(sublime_plugin.EventListener):
    def on_post_save(self, view):
        setting = view.settings().get('plim_compiler')
        syntax = setting.get('syntax')
        command = setting.get('command')
        current_syntax = os.path.splitext(os.path.basename(view.settings().get('syntax')))[0]
        if current_syntax == syntax:
            src_name = view.file_name()
            name, ext = os.path.splitext(src_name)
            if ext == '.plim':
                dst_name = '%s.html' % name
                subprocess.Popen([command, '-o', dst_name, src_name])

In setting (Preferences.sublime-settings):

...
    "plim_compiler":
    {
        "command": "plimc",
        "syntax": "Ruby Slim"
    },
...

CORSメモ

XHR2

送信側

JS:

var xhr2 = new XMLHttpRequest();
xhr2.open("GET", "https://api.example.jp/xhr/");
xhr2.setRequestHeader("X-CSRF-Token", "r4nd0MStr1ng");
xhr2.withCredentials = "true";
xhr2.send

同一OriginでもXSSが無いとも限らないから付けとけば安心かな。

HTTP Request Header:

GET http://api.example.jp/xhr HTTP/1.1
X-CSRF-Token: r4nd0MStr1ng
Origin: http://example.jp
Cookie: session=hutsunosessionid

受信側

HTTP Response Header:

HTTP/1.1 200 OK
Access-Control-Allow-Origin: http://example.jp
Access-Control-Allow-Credentials: true

WebSocket

var ws = new WebSocket("wss://api.example.jp");
ws.send("msg");
GET https://api.example.jp/ HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Host: api.example.jp
Origin: https://example.jp
Sec-WebSocket-Key: c2Vjd2Vic29ja2V0a2V5ZGF5bw==

必ずサーバ側でOriginヘッダを検証する。 ※ホスト名は完全一致で検証する。さもないとサブドメインとか@とかで抜けられる。

  • 備考:AngularJSの$httpでカスタムヘッダを付けて送る方法
 myModule.config(function($httpProvider) {
   $httpProvider.defaults.headers.common['X-CSRF-Token'] = 'r4nd0MStr1ng';
 });
  • SockJS socket management service

https://gist.github.com/snj/9500488

$resource on Angular

I recommend that you use $resource.

It may support (url override) in next version of Angularjs. Then you will be able to code like this:

// need to register as a serviceName
$resource('/user/:userId', {userId:'@id'}, {
    'customActionName':    {
        url:'/user/someURI'
        method:'GET',
        params: {
            param1: '....',
            param2: '....',
        }
    },
     ....
});
And return callbacks can be handled in ctrl scope like this.

// ctrl scope
serviceName.customActionName ({
    paramName:'param',
    ...
}, 
function (resp) {
    //handle return callback
}, 
function (error) {
    //handler error callback
});
Probably you can handle code on higher abstraction level.

http://stackoverflow.com/questions/11850025/recommended-way-of-getting-data-from-the-server/11850027#11850027

都道府県コード一覧

01 北海道
02 青森県
03 岩手県
04 宮城県
05 秋田県
06 山形県
07 福島県
08 茨城県
09 栃木県
10 群馬県
11 埼玉県
12 千葉県
13 東京都
14 神奈川県
15 新潟県
16 富山県
17 石川県
18 福井県
19 山梨県
20 長野県
21 岐阜県
22 静岡県
23 愛知県
24 三重県
25 滋賀県
26 京都府
27 大阪府
28 兵庫県
29 奈良県
30 和歌山県
31 鳥取県
32 島根県
33 岡山県
34 広島県
35 山口県
36 徳島県
37 香川県
38 愛媛県
39 高知県
40 福岡県
41 佐賀県
42 長崎県
43 熊本県
44 大分県
45 宮崎県
46 鹿児島県
47 沖縄県

Our Deepest Fear


Our Deepest Fear . . . - YouTube

Our deepest fear is not that we are inadequate.

Our deepest fear is that we are powerful beyond measure.

It is our light, not our darkness

That most frightens us.

We ask ourselves

Who am I to be brilliant, gorgeous, talented, fabulous?

Actually, who are you not to be?

You are a child of God.

Your playing small

Does not serve the world.

There's nothing enlightened about shrinking

So that other people won't feel insecure around you.

We are all meant to shine,

As children do.

We were born to make manifest

The glory of God that is within us.

It's not just in some of us;

It's in everyone.

And as we let our own light shine,

We unconsciously give other people permission to do the same.

As we're liberated from our own fear,

Our presence automatically liberates others.

私たちがもっとも恐れているのは、 自分が不十分な存在である、 ということではありません。 私たちがもっとも恐れているのは、 自分が計り知れないほどに力に満ちた存在である、 ということです。 私たちがもっともおびえているのは、 自分の光であって、闇ではありません。

人は自分に問いかけます。 「この自分が、すぐれた、 魅力的な、才能豊かな、 すばらしい存在になれるのだろうか?」 なれないはずはありません。

私たちは神の子なのです。

取るに足らないもののふりをしても、 世の中のためにはなりません。 周囲の人々が不安を感じないように、 自分を小さく見せても 何の美徳もありません。

私たちは、自分の中にある 神の栄光を実現するために生まれてきました。 それは、限られた人たちの中だけに 存在するのではありません。 誰の中にもあるのです。

私たちが自らの光を輝かせるとき、 無意識のうちに、他の人が輝くことも ゆるせるようになります。

私たちが自分の恐れていることから 解放されたとき、 私たちがただそこにいるだけで 他の人を解放するでしょう。