Skip to content

Instantly share code, notes, and snippets.

@mgng
mgng / gist:34283
Created December 10, 2008 08:52
template
<?php
/* Template.php
【前準備】
・Template.php と同階層に template, cache, compile ディレクトリを作成(適切に権限与えとく必要あり)
・以下の内容で template/test.tpl を作成
--------------------
aaaの内容は{aaa}
bbbの内容は{bbb}
--------------------
@mgng
mgng / gist:34339
Created December 10, 2008 14:50
GD + Imagick = morphing
<?php
/**
* GD+Imagick = morphing
*
* @param string $fromPath
* @param string $toPath
* @param string $outPath
* @param integer $frame OPTIONAL
* @param integer $delay OPTIONAL
*/
@mgng
mgng / gist:34340
Created December 10, 2008 14:51
create gif animation
<?php
// create animation gif
function animate($fileList, $delay, $out){
$img = new Imagick();
$img->setFormat('gif');
foreach($fileList as $file) {
$tmp = new Imagick($file);
$tmp->setFormat('gif');
$tmp->setImageDelay($delay);
$img->addImage($tmp);
@mgng
mgng / gist:34342
Created December 10, 2008 15:04
gif transparent check
<?php
// gif transparent check
function getGifTp($imgPath) {
$sz = getimagesize($imgPath);
$x = $sz[0];
$y = $sz[1];
$im = imagecreatefromgif($imgPath);
for($sx=0; $sx<$x; $sx++) {
for($sy=0; $sy<$y; $sy++) {
$rgb = imagecolorat($im, $sx, $sy);
@mgng
mgng / gist:34594
Created December 11, 2008 03:26
JPEG 2 ASCII
<?php
// JPEG 2 ASCII
$in = 'test.jpg';
$out = 'test.html';
$buf = '';
$gd = imagecreatefromjpeg($in);
$w = imagesx($gd);
$h = imagesy($gd);
for($y=0; $y<$h; $y++){
@mgng
mgng / gist:35892
Created December 15, 2008 05:10
myspace mp3 / flv loader
<?php
/**
* Misc_Lib_Myspace class
*
* myspace url/id ⇒ get mp3/flv video
*
* [usage_1 set id]
* $ms = new Misc_Lib_Myspace();
* $ms->setId('britneyspears');
* $ms->load();
@mgng
mgng / gist:36917
Created December 17, 2008 02:10
get mobile gw-ip addr
<?php
/* MobileIp.php
*
* usage:
* require_once 'MobileIp.php';
* print_r( MobileIp::get('all') );
* print_r( MobileIp::get() );
* print_r( MobileIp::get('docomo') );
* print_r( MobileIp::get('au') );
* print_r( MobileIp::get('softbank') );
@mgng
mgng / gist:36936
Created December 17, 2008 04:22
class -> array
<?php
// クラスを配列にキャストするとどうなるか
class Test {
private $a = 'private';
public $b = 'public';
}
$obj = new Test();
$arr = (array)$obj;
echo $arr["\0Test\0a"]; // private
@mgng
mgng / gist:45973
Created January 12, 2009 11:59
??
<?php
// テスト
set_time_limit(600);
$tNum = 92;
$base = 'http://pic2ch.giox.org/';
$src = file_get_contents("{$base}thread/{$tNum}");
if ($src === false) {
@mgng
mgng / gist:49899
Created January 21, 2009 09:11
簡易HTTP
<?php
// Http class
// 日本語UTF-8
class Http
{
public static function get($url, $header = null) {
$param = array(
'http'=>array('method'=>'GET')
);
if ($header !== null) {