Skip to content

Instantly share code, notes, and snippets.

@azu
azu / Incremental DOM.md
Last active July 13, 2022 16:07
Incremental DOM ざっと見たやつ。追記: 初期バージョンのコードなので最新では異なる場合があります。

Incremental DOM

Introducing Incremental DOM — Google Developers — Medium

Reactやvirtual-dom、Glimmer(Ember)などVirtual DOMの実装は色々あるが、これらのVirtual DOM実装には2つの問題がある

  • 既存のテンプレート言語を利用していない(しにくい)
  • モバイルでのパフォーマンス、特にメモリに関しては大きすぎる

これらを解決するためにIncremental DOMと言うものを作っている(WIP)

SQLインジェクション対策について

教育的な観点ではなく実務的な観点から、僕の考えをまとめてみる。UTF-8 を利用し、SET NAMES を利用していなくて mysql で、クライアントプリペアドステートメントなケースを想定している。

SQL インジェクションとは

$foo=$_POST[‘id’];
query(“SELECT * FROM foo WHERE id=$foo”);

のように外部からの文字列をそのまま使用してクエリを組みたてたときに、意図せぬ SQL を発行されてしまう脆弱性のことである。

@cjohansen
cjohansen / gist:4135065
Created November 23, 2012 10:43
Naming this in nested functions

tl;dr

If you must nest functions in a way that requires access to multiple this', alias outer this to something meaningful - describe the value it's holding. Treat this as the invisible first argument.

In general though, avoiding the situation (nested functions and frivolous use of this) will frequently produce clearer results.

Naming this in nested functions

I was accidentally included in a discussion on how to best name this in nested functions in JavaScript. +1's were given to this suggestion of using _this.

Giving style advice on naming nested this without a meaningful context isn't too helpful in my opinion. Examples below have been altered to have at least some context, although a completely contrived and stupid one.

fizz = function f() {
fizz = function () {
fizz = function () {
fizz = f
return "Fizz"
}
}
}
buzz = function f() {
@hagino3000
hagino3000 / method_missing.js
Last active January 16, 2020 13:11
__noSuchMethod__ for Chrome
/**
* Enable route to __noSuchMethod__ when unknown method calling.
*
* @param {Object} obj Target object.
* @return {Object}
*/
function enableMethodMissing(obj) {
var functionHandler = createBaseHandler({});
functionHandler.get = function(receiver, name) {
@teramako
teramako / sortedJSON.js
Created February 27, 2012 07:55
キーをソートしてJSON化のサンプル
var o = {
b: "B",
c: "C",
a: "A",
};
print(JSON.stringify(o));
// {"b":"B","c":"C","a":"A"}
@think49
think49 / outerHTML.js
Created January 16, 2011 08:27
outerHTML.js : HTML5 規定の element.outerHTML を定義する。
/**
* outerHTML.js
*
* @version 1.4
* @author think49
*/
if (!('outerHTML' in document.createElement('p')) && 'innerHTML' in document.createElement('p') && (typeof HTMLElement === 'function' || typeof HTMLElement === 'object')) {
(function () {
var _Node = (typeof Node === 'function' || typeof Node === 'object') ? Node : {
@azu
azu / Greasemonkey.js
Created November 27, 2010 17:54
WebStormにGreasemonkeyの補完候補を追加する
/**
* Created by azu.
* Date: 10/11/28
* License: MIT License
*/
var unsafeWindow = window;
/**
* コンソールにログを吐く