This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$json = json_decode( file_get_contents( "http://instagram.com/parishilton/media" ) ); | |
if ( ! isset( $json->status ) || $json->status !== 'ok' ) { | |
exit('error'); | |
} | |
foreach( $json->items as $item ) { | |
$data = array( | |
'username' => $item->user->username, | |
'full_name'=> $item->user->full_name, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="javascript:;"> | |
<input type="text" id="status" value="" /> | |
<input type="file" id="file" /> | |
<input type="submit" id="update" value="送信" /> | |
</form> | |
<script> | |
$(function(){ | |
$("#update").bind("click", function(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// これつけないと動かないケースもある | |
// stream_set_blocking( STDIN, 1 ); | |
while ( false !== ($line=trim( fgets(STDIN) ) ) ) { | |
// 何かしら処理 | |
error_log( "{$line}\n", 3, "./log.txt" ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// PDOオブジェクト | |
$pdo = null; | |
// DBファイルパス | |
$db_path = './db.sqlite'; | |
// 接続 $db_path ファイルがなければ作成される | |
try{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$startDate ="2013-11-12 00:00:00"; | |
$endDate = "2013-11-13 00:00:00"; | |
// mongodb内部でISODate Objectで保存されている場合は MongoDate 使って変換する必要がある | |
$query = array("insert_date" => array( | |
'$lt' => new MongoDate(strtotime($endDate)), | |
'$gte' => new MongoDate(strtotime($startDate)) | |
)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
var_dump( | |
preg_match( '/\A[\d]+\z/u', '1' ), // int(1) | |
preg_match( '/\A[\d]+\z/u', '1' ), // int(1) | |
preg_match( '/\A[\d]+\z/', '1' ), // int(1) | |
preg_match( '/\A[\d]+\z/', '1' ), // int(0) | |
preg_match( '/\A[0-9]+\z/u', '1' ), // int(1) | |
preg_match( '/\A[0-9]+\z/u', '1'), // int(0) | |
preg_match( '/\A[0-9]+\z/', '1' ), // int(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html lang="ja-JP"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>テスト</title> | |
</head> | |
<body> | |
<select name="" id=""> | |
<option value="値です" label="ラベルです">表示項目です</option> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="id_input"></div> | |
<script> | |
(function(){ | |
var input = document.createElement( 'input' ); | |
input.setAttribute( 'type', 'text' ); | |
input.setAttribute( 'name', 'userid' ); | |
input.setAttribute( 'maxlength', 5 ); // IE7の場合は 'maxLength' にしないとだめ | |
input.setAttribute( 'value', '' ); | |
document.getElementById( 'id_input' ).appendChild( input ); | |
})() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isDuplicate( list ) { | |
var _list = list.concat(); | |
while( _list.length ) { | |
var cur = _list.pop(); | |
for( var i=0,l=_list.length; i<l; i++ ) { | |
if ( | |
( _list[i][0] <= cur[0] && cur[0] <= _list[i][1] ) | |
|| | |
( _list[i][0] <= cur[1] && cur[1] <= _list[i][1] ) | |
) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$path = '/path/to/漢字.txt'; | |
var_dump( | |
basename( $path ), | |
end( explode( '/', $path ) ) | |
); | |
/* |