Skip to content

Instantly share code, notes, and snippets.

# 私が考える安全なプログラムを書くために必要なこと
今も昔も「入力によって挙動が大幅に変わるAPI」が世の中には多数存在していて、プログラマが本来意図した挙動と異なる動作を引き起こしている。
- ファイルを開こうとしたらコマンドを実行できてしまったり
- CSSセレクタを書いてるつもりがHTMLタグを生成してしまったり
- SELECT文を発行するつもりがDELETE文を発行できてしまったり
こういったときに
- 入力値検証をしないと危険になる
@sonots
sonots / start_server.sh
Last active April 3, 2016 06:56
Gracefully restart unicorn using Server::Starter
start_server --status-file=/path/to/app/log/start_server.stat \
--port=10080 --signal-on-hup=CONT --dir=/path/to/app -- \
bundle exec --keep-file-descriptors unicorn -c config/unicorn.conf.rb config.ru
@satococoa
satococoa / setup.sh
Last active June 5, 2016 03:02
Mac OS X 上での Homebrew + rbenv + ruby-build + ruby + rails の環境構築(Xcode, Comamnd Line Tools のインストールを済ませてから。)
# Homebrew のインストール
# 公式 (http://brew.sh/) に載っているコマンドです
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Ruby のビルドに必要なものをインストール
brew install openssl readline rbenv ruby-build # 時間がかかります
# rbenv 用の設定を .bash_profile に書き込む
echo 'export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl) --with-readline-dir=$(brew --prefix readline) $RUBY_CONFIGURE_OPTS"' >> ~/.bash_profile
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
@shuhei
shuhei / epic.js
Last active August 5, 2016 02:59
An idea of side-effect-free epic like redux-saga for redux-observable
// Explicit in-out of side-effect actions.
function epic(action$, store) {
const fooReq$ = action$.ofType('FOO')
.map(action => call('FOO_REQ', webapi.getFoo, action.payload.id));
const foo$ = action$.ofType('FOO_REQ')
.map(foo => ({ type: 'FOO_FETCHED', payload: { foo } }));
return Observable.merge(
fooReq$,
foo$
@ryo33
ryo33 / saga-relay.js
Last active October 18, 2016 12:35
function* relay(request, relayChannel, nextChannel) {
const result = yield call(request)
yield put(relayChannel, [result, nextChannel])
}
function* runSequencially(requestChannel, resultChannel) {
let head = channel()
let tail = head
while (true) {
const { request, relayResult } = yield race({
'use strict'
import pluralize from 'pluralize'
import ApiRequest from 'lib/ApiRequest'
import { SubmissionError } from 'redux-form'
const ADD_API_RESOURCE = '@api/ADD_RESOURCE'
const REMOVE_API_RESOURCE = '@api/REMOVE_RESOURCE'
@ryo33
ryo33 / 1.md
Last active January 4, 2017 00:14
redux-thunk and redux-middlewares

gaearon/redux-thunk

These examples are not completely compatible about whether to call next(action).

incrementAsync

redux-thunk

function incrementAsync() {
@rchaser53
rchaser53 / uniontype.js
Created February 25, 2017 13:23
continueとreturnでのunion typeの挙動
// for文内のcontinueはNG
const abc = (arg: (string | number)[]) => {
for (let i=0;i<arg.length;i++) {
if (typeof arg[i] === 'string') continue;
const abc: number = arg[i];
}
}
// if文のearly returnはOK
const abc2 = (arg: (string | number)[]) => {
@azu
azu / Reactコンポーネントの作成ステップ.md
Last active June 10, 2017 05:59
Reactコンポーネント作成のステップ

https://gist.github.com/azu/d5e92de127f76545ffc2 の続き

ディレクトリ構造

  • コンポーネント名のディレクトリを作成
  • index.js をおき、そこにコンポーネントを定義する

コンポーネントの分類(TODO: 気に入ってない)

@chroth7
chroth7 / reactD3rescources.md
Last active December 6, 2017 05:37
React/D3 Resources

React <-> D3 Resources

Thanks for all the stars.

Due to unexpected demand, I move this to a proper github repo, see here: https://github.com/chroth7/reactD3resources

I would very much like to get your PRs there, thank you!