Skip to content

Instantly share code, notes, and snippets.

@mgng
mgng / hardrock.txt
Created September 5, 2012 05:27
ハードロック
アイアン・メイデン
アリス・クーパー
イングヴェイ・マルムスティーン
ヴァニラ・ファッジ
ヴァン・ヘイレン
ヴェルヴェット・リヴォルヴァー
エイプリル・ワイン
オジー・オズボーン
ガンマ・レイ
グラハム・ボネット
@mgng
mgng / array_stdclass.php
Created August 23, 2012 07:52
array と stdClass
<?php
$data = array(
"id" => "mgng",
"name" => "ムグ"
);
echo $data['name'];
$data = new stdClass();
$data->id = "mgng";
$data->name = "ムグ";
@mgng
mgng / gero.html
Created August 22, 2012 06:32
javascriptでテキストエリアの文字列をダウンロードさせる
<p>
<textarea id="id_textarea">あいうえおインータネット</textarea><br />
<button onclick="kuso()">ダウンロード</button>
<div id="id_download"></div>
</p>
<script type="text/javascript">
function kuso(){ if(window.File){
var b = new Blob(
[ document.getElementById('id_textarea').value ],
<?php
function obj( $json_str = null ) {
$obj = new stdClass();
$json = json_decode( $json_str );
if ( $json !== null ) {
foreach( $json as $k => $v ) {
$obj->{"{$k}"} = $v;
}
}
return $obj;
@mgng
mgng / unko1.php
Created July 11, 2012 00:51
空文字またはうんこに一致する正規表現
<?php
if ( $str === "" || $str === "うんこ" ) {
// match
}
<?php
$s = '{"":123, "a":456}';
var_dump( json_decode($s) );
//object(stdClass)#1 (2) {
// ["_empty_"]=>
// int(123)
// ["a"]=>
// int(456)
//}
<?php
$o = json_decode( '{ "a" : 1, "//" : 2 }' );
echo $o->a; // 1
echo $o->//; // Parse error: syntax error, unexpected $end, expecting T_STRING or T_VARIABLE or '{' or '$'
echo $o->{'//'}; // 2
@mgng
mgng / is_mb.php
Created May 25, 2012 09:02
is_mb
<?php
// utf-8環境で全角文字かチェック
function is_mb ( $str ) {
//return preg_match( '/[\x20-\x7E\xA1-\xDF]+/u', $str ) !== 1;
return preg_match( '/[ -~。-゚]+/u', $str ) !== 1;
}
@mgng
mgng / index.html
Created May 10, 2012 01:09
Twig sample
私の名前は{{name}}です。
@mgng
mgng / gist:2504710
Created April 27, 2012 00:59
atpages IPアドレス
www1.atpages.jp 27.96.58.178
www2.atpages.jp 183.177.144.194
www3.atpages.jp 183.177.144.195
www4.atpages.jp 27.96.58.183
www5.atpages.jp 183.177.144.197
www6.atpages.jp 183.177.144.198
www7.atpages.jp 183.177.144.199
www8.atpages.jp 183.177.144.196
www9.atpages.jp 183.177.144.200
www10.atpages.jp 183.177.144.201