Skip to content

Instantly share code, notes, and snippets.

View fetus-hina's full-sized avatar
💭
I may be slow to respond.

AIZAWA Hina fetus-hina

💭
I may be slow to respond.
View GitHub Profile
@fetus-hina
fetus-hina / gist:1182904
Created August 31, 2011 05:53
Ameba blog X-WSSE
<?php
date_default_timezone_set('Asia/Tokyo');
require_once('Zend/Http/Client.php');
define('AMEBA_URL', 'http://atomblog.ameba.jp/servlet/_atom/blog');
request('USERNAME', 'PASSWORD');
function request($user_name, $password) {
$client = new Zend_Http_Client();
@fetus-hina
fetus-hina / gist:1182976
Created August 31, 2011 07:08
Ameba blog post
<?php
date_default_timezone_set('Asia/Tokyo');
require_once('Zend/Uri.php');
require_once('Zend/Http/Client.php');
$wsse = new AmebaWsse('USER', 'PASS');
// API の URI を取得
$uris = getAmebaApiUris($wsse);
@fetus-hina
fetus-hina / gist:1188777
Created September 2, 2011 14:41
UUID version 1 generate
#include <iostream>
#include <uuid/uuid.h>
int main(int, char *[]) {
uuid_t uuid;
uuid_generate_time(uuid);
char buffer[128 / 4 + 4 + 1] = {};
uuid_unparse(uuid, buffer);
std::cout << buffer << std::endl;
@fetus-hina
fetus-hina / gist:1195111
Created September 5, 2011 14:26
Zend_Service_Twitter を PHP 5.1 で動かすための無理矢理な動作変更継承
<?php
class Xend_Service_Twitter extends Zend_Service_Twitter {
protected function _prepare($path) {
try {
parent::_prepare($path);
} catch(Zend_Uri_Exception $e) {
$this->_localHttpClient->resetParameters()->setUri($this->_uri->__toString());
}
}
}
@fetus-hina
fetus-hina / gist:1199879
Created September 7, 2011 05:54
FC2 他 metaWeblog API 対応ブログ用 API 投稿サンプル
<?php
date_default_timezone_set('Asia/Tokyo');
require_once('Zend/XmlRpc/Client.php');
require_once('Zend/Date.php');
define('BLOG_ID', '0'); // 何でもOK?
define('USERNAME', '********');
define('PASSWORD', '********');
$client = new Zend_XmlRpc_Client('http://blog.fc2.com/xmlrpc.php');
<?php
class Text_Ngram implements Countable, SeekableIterator, ArrayAccess {
private
$text = '',
$chunk_size = 0,
$max_count = 0,
$charset = 'UTF-8',
$current = 0; // for iterator
public function __construct($text, $n, $charset = 'AUTO') {
@fetus-hina
fetus-hina / gist:1404444
Created November 29, 2011 11:12
mb_str_replace() 説明ページ用プロトタイプ
<?php
/**
* マルチバイト対応 str_replace
*
* @param mixed $search 検索文字列
* @param mixed $replace 置換文字列
* @param mixed $subject 対象文字列
* @param string $encoding 文字列のエンコーディング(省略: 内部エンコーディング)
*
* @return mixed subject 内の search を replace で置き換えた文字列
@fetus-hina
fetus-hina / gist:1404449
Created November 29, 2011 11:14
mb_str_replace() 説明ページ用使い方例
<?php
require_once(dirname(__FILE__) . '/mb_str_replace.function.php');
$subject = '赤パジャマ青パジャマ黄パジャマ';
$search = 'パジャマ';
$replace = '信号';
$result = mb_str_replace($search, $replace, $subject);
var_dump($result);
@fetus-hina
fetus-hina / mb_str_replace.function.php
Created November 29, 2011 11:18
mb_str_replace() 説明ページ表示用ソース(リリースソース)
<?php
/*
* マルチバイト対応 str_replace()
*
* Release 3 update 1
*
* Copyright (C) 2006,2007,2011,2012 by HiNa <hina@bouhime.com>. All rights reserved.
*
* LICENSE
*
@fetus-hina
fetus-hina / output.txt
Created November 29, 2011 11:22
mb_str_replace() 説明ページ用互換性注意事項
<?php
$subject = 'hogefuga';
$table = array('hoge' => 'foo',
'fuga' => 'bar',
'piyo' => 'baz',
'foo' => '***',
'bar' => '+++',
'baz' => '---');
$functions = array('str_replace', 'mb_str_replace');
foreach($functions as $f) {