Skip to content

Instantly share code, notes, and snippets.

@shimabox
shimabox / gem_mailcatcher.rb
Last active August 29, 2015 14:14
mailcatcherのレシピ(gem eventmachineをダウングレードして動かす)
# Cookbook Name:: app
# Recipe:: mailcatcher
#
# Copyright 2015, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
# rubyとgem は既に入っている想定
# ruby -v => 2.0.0p598
@shimabox
shimabox / gem_mailcatcher
Created March 5, 2015 21:20
mailcatcherのレシピ
#
# Cookbook Name:: app
# Recipe:: mailcatcher
#
# Copyright 2014, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
# rubyとgem は既に入っている想定
@shimabox
shimabox / alog.js
Last active December 19, 2015 02:39
/*@cc_on!@*/false だけでIEかどうかの判定ができると聞いて / alertとconsole.logのラッパー的な / 名前も簡易(alert + console.log)
;(function(ns){
if(typeof ns.alog === 'function') return;
ns.alog = function(){
var args = [].slice.call(arguments).concat();
if (/*@cc_on!@*/false) {
return alert(args);
}
@shimabox
shimabox / test_for_use_the_header_function.php
Created December 12, 2016 23:08
header関数を使うメソッドのテストコード
<?php
/**
* メッセージ(json)を返すAPIと仮定
*
* あくまでもサンプルなので例外処理は入れていません
*/
class Sample
{
/**
* @var array
@shimabox
shimabox / d3_sample.html
Last active December 31, 2016 11:20
Visualize the benchmark by d3.js
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Visualize the benchmark by d3.js</title>
<style>
body {
font: 12px sans-serif;
}
.axis path,
@shimabox
shimabox / phpunit_ajax_sample.php
Last active June 22, 2017 05:44
jsonを返すAPIのテストコード
<?php
/**
* メッセージ(json)を返すAPIと仮定
*
* あくまでもサンプルなので例外処理は入れていません
*/
class Sample
{
/**
* @var array
@shimabox
shimabox / getUrlStatus.php
Last active August 7, 2017 22:30
URLを渡すとヘッダー情報を見てステータスを返す
<?php
/**
* URLのステータスを返す
*
* <code>
* $ret = getUrlStatus($url);
*
* $ret->url; // string URL<br>
* $ret->reachedUrl; // string 最後に到達したURL<br>
* $ret->isValid; // bool 有効なURLか<br>
@shimabox
shimabox / PHPUnitとPHPのバージョン対応表.md
Last active August 17, 2017 22:41
PHPUnitとPHPのバージョン対応表
@shimabox
shimabox / blink_game.py
Created August 28, 2018 21:56
目をつぶったら画面キャプチャを終了するやつ(Python+OpenCV)
<?php
namespace Sample1;
/**
* 当クラスでは更新命令数を監視し(実際には教えてもらうが)
*
* - 最初の命令から閾値となる秒数が過ぎていない
* - かつ、監視していた実行数が許可された実行数を超えていたら
* 閾値 - 最初の計測から今回の処理までの実行間隔 の値で usleep