Skip to content

Instantly share code, notes, and snippets.

@vexus2
vexus2 / prepare.php
Created October 11, 2012 01:37
[PHP]ZendFramework用prepare設定 Zend日付バグの対応含む
<?php
if (defined('E_DEPRECATED')) {
error_reporting(E_ALL & ~E_DEPRECATED & ~E_WARNING);
} else {
error_reporting(E_ALL);
}
defined('APPLICATION_CONFIG')
|| define('APPLICATION_CONFIG', 'application.ini');
@vexus2
vexus2 / common_formatter.php
Created October 11, 2012 01:34
[PHP]ISO8601形式日付などのフォーマットを行う汎用クラス
<?php
/**
* フォーマット変換ユーティリティクラス
*/
class CommonFormatter
{
/**
* 日付のフォーマット配列
*/
private static $DATE_FORMAT_ARRAY = array(
@vexus2
vexus2 / common_validator.php
Created October 11, 2012 01:30
[PHP]汎用バリデーションクラス
<?php
/**
* 汎用バリデータ用クラス
* 文字列・数字・文字数などのチェックを行う
*/
class CommonValidator
{
/**
* 日付のフォーマット配列
*/
@vexus2
vexus2 / build.xml
Created October 11, 2012 01:27
[xml]Jenkins用のbuild.xml phpcpd/phpmd/phpunit/phpdoc使用
<?xml version="1.0" encoding="utf-8" ?>
<project name="auoneLibrary" basedir="." default="all">
<property name="outputDir" value="."/>
<target name="phpcpd">
<phpcpd minTokens="10">
<fileset dir="./application/">
<include name="**/*.php"/>
<exclude name="library/lwopenid/**/*.php"/>
</fileset>
@vexus2
vexus2 / nico_video_fetcher.rb
Created October 10, 2012 02:28
[Ruby]ニコニコ動画検索APIを実行し動画情報を取り出す
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
if RUBY_VERSION < '1.9'
require 'rubygems'
end
require File.expand_path('../../config/boot', __FILE__)
require 'json'
require 'mechanize'
require 'cgi'
@vexus2
vexus2 / nico_video_fetcher.rb
Created October 8, 2012 14:04
[Ruby]ニコニコ動画APIを叩くとき用。事前にログインさせCookie値を取得する。
# ログインしてクッキー抽出
def login(mail, pass)
host = 'secure.nicovideo.jp'
path = '/secure/login?site=niconico'
body = "mail=#{mail}&password=#{pass}"
https = Net::HTTP.new(host, 443)
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
response = https.start { |https|
@vexus2
vexus2 / login_step.php
Created October 5, 2012 02:43
[PHP]UserAgent切り替え for Behat
<?php
/**
* @var $world FeatureContext
*/
$steps->Given( '/^"([^"]*)" でアクセスしている$/', function ( $world, $table ) {
switch ( $table ) {
case "フィーチャフォン":
$user_agent = "KDDI-CA39 UP.Browser/6.2.0.13.1.5 (GUI) MMP/2.0";
break;
case "スマートフォン":