fushihara
fushihara
Reputation Top 1%
フシハラ @ Snip2Code
どーやって勝手にコピーされるの防ぐんだよこれ。うわああ死んでくれ~ 2015/10/21
12 Snippets
Published
1 Channel
Created
3 Channels
Following
276 points
Reputation
Top 10% Publisher
Junior Code Generator
Serious Code Generator
Junior Popular Coder
Junior Autobiographer
Senior Autobiographer
Serious Famous Coder
Junior Wise Coder

Recent Snippets See all snippets by fushihara

public by fushihara  2097  0  3  0

Javaに特化した起動スクリプト http://fushi.x0.com/blog/archives/1677

Javaに特化した起動スクリプト http://fushi.x0.com/blog/archives/1677: javaTest
#!/bin/sh
#
# chkconfig: 345 70 30
# description: Fushihara java run test

java=/usr/java/default
prog=javaTest
currentDirectory=/home/fushihara/javaTest/
classPath=bin:src
runClass=org.fushihara.javastdinouttest.Test
javaoptions=
outStd=/var/log/stdOutText.txt
outErr=/var/log/stdErrText.txt

if [ -z ${outStd} ]; then
    outStd=/dev/null
fi
if [ -z ${outErr} ]; then
    outErr=/dev/null
fi

cmdline="${java}/bin/java -Dfile.encoding=UTF-8 -Xbootclasspath/a:${classPath} ${runClass} ${javaoptions}"
RETVAL=0
#echo -e "\e[42;97m[OK]\e[0m"
#echo -e "\e[41;97m[NG]\e[0m"


start() {
     PROC=`getpid`
     if [ ${PROC} -eq 0 ]; then
         cd ${currentDirectory}
         echo -n $"${prog}を起動中…"
         `${cmdline}  >> ${outStd} 2>> ${outErr} ` < /dev/null &
         PROC2=`getpid`
         if [ ${PROC2} -ne 0 ]; then
             echo -e "\e[42;97m[成功:${PROC2}]\e[0m"
         else
             echo -e "\e[41;97m[失敗]\e[0m"
         fi
     else
         echo -e $"${prog}(PID=${PROC})は\e[41;97m起動中\e[0mです"
     fi
}

stop() {
     PROC=`getpid`
     if [ ${PROC} -ne 0 ]; then
         kill ${PROC}
         echo -e "${prog}を\e[42;97m終了\e[0mしました"
     else
         echo -e "${prog}は実行されて\e[41;97mいません\e[0mでした"
     fi
}

status(){
     PROC=`getpid`
     if [ ${PROC} -ne 0 ]; then
         echo -e "${prog}(PID=${PROC})は\e[42;97m実行中\e[0mです"
     else
         echo $"${prog}は\e[41;97m停止\e[0mしています"
     fi
}

getpid(){
     RES=`ps ax | grep ${runClass} | grep -v ' grep ' | awk '{print$1}'` 
     if [ -z ${RES} ]; then
        RES=0
     fi
     echo ${RES}
}

case "$1" in
     start)
          start
          ;;
     stop)
          stop
          ;;
     status)
          status
          ;;
     restart)
          stop
          start
          ;;
     *)
     echo $"Usage: ${prog} {start|stop|status|restart}: "
     RETVAL=2
esac

exit $RETVAL

;

public by fushihara  158572  0  3  0

簡単作業ディレクトリ

簡単作業ディレクトリ: createTempDir.bat
@echo off
set dateStr=%date%
set timeStr=%time%
set dateStr=%dateStr:/=-%
set dateStr=%dateStr: =0%
set timeStr=%timeStr::=-%
set timeStr=%timeStr: =0%
set new_temp_path=%TMP%\temp_%dateStr%_%timeStr%\
mkdir "%new_temp_path%"
explorer "%new_temp_path%"


;

public by fushihara  119511  0  3  0

確認くんスーパーライト

確認くんスーパーライト: index.php
<?php
$time=time();
$ipAddress = $_SERVER["REMOTE_ADDR"];
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);

header("Content-Disposition: inline");	
header("content-type: text/plain; charset=utf8");
print("time:".date("Y/m/d H:i:s T",$time)."\n");
print("ip:{$ipAddress}\n");
print("host:{$hostname}\n");
print("time_unix:{$time}\n");
print("\n");
foreach (getallheaders() as $name => $value) {
	print("{$name}:{$value}\n");
}
print("end");


;

public by fushihara  1742  0  3  0

animetick.netに各局の放送日時を表示するボタンを追加するTampermonkey用userScript.js

animetick.netに各局の放送日時を表示するボタンを追加するTampermonkey用userScript.js: gistfile1.js
// ==UserScript==
// @name       animetick(トップ画面)
// @namespace  http://use.i.E.your.homepage/
// @version    0.1
// @description  enter something useful
// @match      http://animetick.net/*
// @copyright  2012+, You
// ==/UserScript==
disableChIds=[
  8,//tvk
  14,//テレ玉
  28,//テレビ大阪
  35,//ラジオ大阪(1314)
  36,//KBS京都(1143)
  37,//RCC中国放送(1350)
  38,//ABCラジオ(1008)
  48,//MBS毎日放送
  49,//NHKラジオ第一
  54,//読売テレビ
  58,//サンテレビジョン
  59,//テレビ愛知
  60,//テレビ新広島
  66,//KBS京都
  67,//ABCテレビ
  70,//関西テレビ
  72,//群馬テレビ
  74,//奈良テレビ
  77,//東海テレビ
  79,//CBCテレビ
  80,//中京テレビ
  81,//メ~テレ
  82,//三重テレビ
  83,//ぎふチャン
  86,//テレビ和歌山
  87,//BBCびわ湖放送
  88,//北海道テレビ放送
  89,//北海道放送
  90,//テレビ北海道
  91,//北海道文化放送
  92,//札幌テレビ放送
  93,//TVQ九州放送
  94,//RKB毎日放送
  95,//テレビせとうち
  96,//福岡放送
  98,//東北放送
  99,//広島ホームテレビ
  100,//とちぎテレビ
  102,//中国放送
  103,//広島テレビ
  104,//岡山放送
  105,//山陽放送
  111,//テレビ信州
  113,//SBSテレビ
  114,//南海放送
  115,//テレビ愛媛
  116,//あいテレビ
  117,//愛媛朝日テレビ
  118,//i-revo
  120,//@nifty
  123,//瀬戸内海放送
  124,//西日本放送
  125,//テレビ山口
  126,//山口放送
  127,//山口朝日放送
  129,//TwellV
  130,//角川アニメチャンネル
  133,//ラジオ関西(558)
  134,//MBSラジオ(1179)
  138,//九州朝日放送
  139,//東海ラジオ(1332)
  140,//南海放送(1116)
  141,//テレビ静岡
  142,//熊本放送
  143,//アニメワン
  144,//テレビ西日本
  145,//サガテレビ
  146,//北陸朝日放送
  147,//北陸放送
  148,//福井放送
  149,//福井テレビ
  154,//だいいちテレビ
  155,//静岡朝日テレビ
  156,//超!A&G+
  157,//アニメNewtypeチャンネル
  162,//TOKYO FM(80.0)
  164,//Music Japan TV
  166,//bayfm(78.0)
  167,//TAKARAZUKA SKY STAGE
  168,//長崎放送
  169,//長崎文化放送
  170,//テレビ長崎
  171,//長崎国際テレビ
  172,//テレビ金沢
  176,//旅チャンネル
  177,//テレビドガッチ
  180,//InterFM(76.1)
  181,//福井さかいケーブルテレビ
  182,//USTREAM
  183,//中部日本放送(1053)
  184,//ZIP-FM(77.8)
  185,//レディオキューブFM三重(78.9)
  186,//FM AICHI(80.7)
  188,//NACK5(79.5)
  189,//bayfm78(78.0)
  190,//FMヨコハマ(84.7)
  191,//ラジオ日本(1422)
  195,//NHKラジオ第二
  198,//青森放送
  199,//青森朝日放送
  200,//青森テレビ
  201,//琉球放送
  202,//琉球朝日放送
  203,//沖縄テレビ
  206,//BSN
  207,//TeNY
  208,//新潟テレビ21
  209,//NST
  210,//DMM.com
  -1
];
//top画面において、各アニメのタイトルをクリックした時のイベントを仕込む
$(".ticket_title").click(function(e){
    var id=e.currentTarget.id;
    var match=id.match(/anime_(\d+)_(\d+)/);
    if(match==null){
        return;
    }
    if($(e.currentTarget).data("checked")!=null){
        return;
    }
    $(e.currentTarget).data("checked",true);
    var titleId=match[1];
    var count=match[2];
    setTimeout((function(titleId){
        return function(){
            onAnimeTitleClick(titleId);
        };
    })(titleId),1000);
});
//作品個別ページ http://animetick.net/anime/3319 で各サブタイの要素にしょぼかるボタンを追加する
(function(){
    //tid取得
    var m=window.document.URL.match(/\/anime\/(\d+)/);
    if(m==null){return;}
    var tid=m[1];
    var divArea=$("div.episode");
    jQuery.each(divArea, function(i, v) {
        var linkUrl=$(v).find(".sub_title>a").attr("href");
        var m,episodeNo;
        m=linkUrl.match(/\/ticket\/\d+\/(\d+)/);
        if(m==null){return;}
        episodeNo=m[1];
        var button=$("<button>").attr("class","episode_watch button").attr("style","width:2em;").data("tid",tid).data("episode",episodeNo).text("s");
        $(v).append(button);
        button.click(function(e){
                    $.ajax({
                       type: "get",
                        url: "http://cal.syoboi.jp/json.php",
                       data: "Req=ProgramByCount,TitleMedium,ChFilter,SubTitles,UPS&UserInfo=1&TID="+$(e.currentTarget).data("tid")+"&Count="+$(e.currentTarget).data("episode"),
                        dataType :"jsonp",
                       success: function(msg){
                           insertBroadcastDiv(button,msg);
                           button.attr('disabled', true);
                       }
                     });
        });
    });
})();

//アニメのサブタイ一覧が表示された前提で、しょぼかるボタンを仕込む
function onAnimeTitleClick(titleId){
    var targetElements=$("#anime_p_"+titleId+" .episode");
    jQuery.each(targetElements, function(i, v) {
        var count=v.id.match(/.+_(\d+)$/)[1];
        var button=$("<button>").attr("class","episode_watch button").attr("style","width:2em;").data("tid",titleId).data("episode",count).text("s");
        $(v).append(button);
        $(v).find(".episode_watch_here").remove();
        button.click(function(e){
                    $.ajax({
                       type: "get",
                        url: "http://cal.syoboi.jp/json.php",
                       data: "Req=ProgramByCount,TitleMedium,ChFilter,SubTitles,UPS&UserInfo=1&TID="+$(e.currentTarget).data("tid")+"&Count="+$(e.currentTarget).data("episode"),
                        dataType :"jsonp",
                       success: function(msg){
                           insertBroadcastDiv(button,msg);
                           button.attr('disabled', true);
                       }
                     });
        });
    });
}
function insertBroadcastDiv(baseDom,syoboData){
    //データを並び替える
    var programDatas=[];
    for(var pid in syoboData.Programs){
        programDatas.push(syoboData.Programs[pid])
    }
    programDatas.sort(function(a,b){return a.StTime-b.StTime;});
    
    //htmlを作る
    var html="";
    for(var i=0;i<programDatas.length;i++){
        var programData=programDatas[i];
        var isActiveChannel=true;
        if(disableChIds.indexOf(programData.ChID-0)!=-1){
            isActiveChannel=false;
        }
        html+=isActiveChannel?"<span style=\"color:red;\">":"";
        html+=new Date(programData.StTime*1000).toLocaleString();
        html+=" ";
        html+=programData.ChName;
        html+=isActiveChannel?"</span>":"";
        html+="<br>";
    }
  $("<div>"+html+"</div>").insertAfter(baseDom);
}


;

public by fushihara  1830  0  3  0

nico bug

nico bug: gistfile1.txt
<font size="7"><font color="#9933FF"><i><u><s>
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...........</s></u></i></font></font>

;