h4c

ただのメモ

2014-01-01から1年間の記事一覧

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.EventLis…

convert python datetime to javascript

ff, chrome, IE それぞれ Date.parse の実装がまちまち。なので YYYY-mm-dd なんて渡すとバグの温床になる。面倒臭いが timestamp にしてから渡す。 python: import datetime, time d = datetime.datetime.utcnow() for_js = int(time.mktime(d.timetuple())…

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が無いとも限らないから付けと…

$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': …