Skip to content

Instantly share code, notes, and snippets.

View fushihara's full-sized avatar

Fushihara fushihara

View GitHub Profile
@fushihara
fushihara / json_jap.php
Created April 6, 2012 12:23
日本語が読めるjsonエンコード
<?php
function json_jap($str){
//"\u3042\u3044\u3046\u3048\u304a" → "あいうえお"
$str=preg_replace_callback('{\\\\u([0-9a-f]{4})}',function($m){return mb_convert_encoding(hex2bin($m[1]),'UTF-8','UTF-16');},$str);
$str=str_replace(['\/','&gt;','&lt;','&apos;','&amp;'],['/','>','<','\'','&'],$str);
return $str;
}
?>
@fushihara
fushihara / internetTVGuide.php
Created April 7, 2012 01:44
internetTVGuideを解析
<?php
class internetTVGuide{
//エリアコード
const AREA_HOKKAIDO=1;
const AREA_AOMORI=2;
const AREA_IWATE=3;
const AREA_MIYAGI=4;
const AREA_AKITA=5;
const AREA_YAMAGATA=6;
const AREA_FUKUSHIMA=7;
@fushihara
fushihara / json_jap.php
Created April 26, 2012 05:42
マルチバイト文字がそのままのjson_encode ref: http://qiita.com/items/71e1ec7e52b76f467d29
<?php
function json_jap($obj){
$str=json_encode($obj);
$str=preg_replace_callback('{\\\\u([0-9a-f]{4})}',function($m){return mb_convert_encoding(hex2bin($m[1]),'UTF-8','UTF-16');},$str);
$str=str_replace(['\/','&gt;','&lt;','&apos;','&amp;'],['/','>','<','\'','&'],$str);
return $str;
}
?>
@fushihara
fushihara / file0.txt
Created May 4, 2012 19:12
join用の配列を作らずに文字列をjoinする ref: http://qiita.com/items/e04937a6f53df0f2058e
data=["あ","い","う"];
res="";join=" ";
for(i=0;i<data.length;i++){
res+=(res!="")?join:"";
res+=data[i];
}
res;
@fushihara
fushihara / fix.user.js
Created May 7, 2012 15:46
ニコニコ動画Zero 外見修正
// ==UserScript==
// @name ZeroFix
// @include http://www.nicovideo.jp/watch/*
// ==/UserScript==
(function(){
var $,$$,e,t="",f1,f2,f3;
$=function(e){return document. querySelector(e);};
$$=function(n,i){var e;e=document.createElement(n);e.innerHTML=i;return e;}
f1=function(){
@fushihara
fushihara / nicoAddController.user.js
Created May 8, 2012 20:12
ニコニコ追加コントローラー
// ==UserScript==
// @name ニコニコ追加コントローラー
// @include http://www.nicovideo.jp/watch/*
// @description ニコニコ動画Zeroのプレイヤーの下にコントローラーを追加します
// ==/UserScript==
add=function(){
var $,$$,e,f,t="",f0,f1,f2,upR=true,contentsHtml="",contentsCSS="",g1,g2,g3;
contentsHtml='\
<span class="left">\
<div class="playPause">||</div>\
@fushihara
fushihara / gist:3306110
Created August 9, 2012 17:20
youtubeの動画ID
$index=1;
$results=[];
do{
$xml = simplexml_load_file('http://gdata.youtube.com/feeds/api/videos?vq=minecraft&max-results=50&start-index='.$index.'&orderby=relevance');
if(!$xml){break;}
foreach($xml->entry as $v){
preg_match('{.+/(.+?)$}',$v->id,$match);
$id=$match[1];
print $index." ".$id."\n";
$results[$id]=true;
@fushihara
fushihara / main.php
Created September 30, 2012 08:39
CURLOPT_POSTFIELDS fix
$postArr=array()l
$postArr["message"]="@user";
$postArr["image"]="_PRE_"."/file.png";
$post2=post2($postArr,"_PRE_");
$curl = curl_init();
$header=array();
$header[]=$post2["header"];
$post=$post2["post"];
@fushihara
fushihara / gist:3971917
Created October 29, 2012 06:22
nico bug
<font size="7"><font color="#9933FF"><i><u><s>
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
http://www.ugtop.com/spill.shtml