Skip to content

Instantly share code, notes, and snippets.

View rskull's full-sized avatar

Ryota Mogi rskull

View GitHub Profile
@rskull
rskull / gist:1705139
Created January 30, 2012 16:02
閲覧中のページをツイートする
//http://rskull.hateblo.jp/entry/2012/03/27/223151
(function (d) {
var title = d.title;
var ref = d.referrer;
var url = location.href;
window.open('http://twitter.com/intent/tweet?text=[ '+encodeURI(title)+' ]?url='+url+'&original_referer='+ref, 'win','height=350,width=350');
})(document);
@rskull
rskull / gist:1647555
Created January 20, 2012 14:18
32文字のランダムな文字列作成
<?php
$token = md5(uniqid(mt_rand(), true));
@rskull
rskull / gist:1455659
Created December 10, 2011 17:22
RSSを取得して時間指定でキャッシュする。
<?php
//RSSを取得してキャッシュする。
function getxml ($url, $path, $timer) {
$file_load = true;
//チャージしたRSSファイルの鮮度チェック
if (file_exists($path)) {
$mt = filemtime($path);
@rskull
rskull / gist:1443018
Created December 7, 2011 14:33
フォームのパスワードを表示させる。
//ブックマークレット
javascript:(function () {
var form = document.forms;
for (i=0;i<form.length;i++) {
var elem = form[i].elements;
for (j=0;j<elem.length;j++) {
if (elem[j].type == 'password') {
elem[j].type = 'type';
}
}
@rskull
rskull / gist:1403561
Created November 29, 2011 05:26
ランダムな文字列の生成
<?php
function randstr ($len) {
$list = 'abcdifghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_';
$ls = str_split($list);
for ($i=0;$i<$len;$i++) {
$token .= $ls[mt_rand(0, 62)];
}
return $token;
}
@rskull
rskull / gist:1327391
Created October 31, 2011 12:31
天気が悪いときだけメールくれる。
<?php
//cronでまわす
mb_language('Japanese');
mb_internal_encoding('UTF-8');
//RSS取得 東京
$xml_file = 'http://rss.weather.yahoo.co.jp/rss/days/13.xml';
$xml = simplexml_load_file($xml_file);
$res = $xml -> channel -> item[0] -> title;
@rskull
rskull / gist:1326182
Created October 30, 2011 17:49
今月の最終日を取得する
//今月の最終日取得
function lastday () {
var now = new Date();
var y = now.getFullYear();
var m = now.getMonth();
for (i=27;i<=32;i++) {
var check = new Date(y, m, i);
if (check.getMonth() != m) {
return i - 1;
}
@rskull
rskull / gist:1324776
Created October 29, 2011 17:02
画像で時計を表示
//日付取得
var now = new Date();
var y = now.getFullYear(); // 年
var mo = now.getMonth() + 1; // 月
var d = now.getDate(); // 日
var h = now.getHours(); // 時
var m = now.getMinutes(); // 分
var s = now.getSeconds(); // 秒
//imgオブジェクト作成
@rskull
rskull / gist:1294734
Created October 18, 2011 06:14
ロリロリ変換機 ver.2.0
//ブックマークレット
javascript:(function(){
var s=document.createElement("script");
s.src="http://rskull.com/src/rori.js";
document.body.appendChild(s)})();
//ロリロリ変換本体
var i = 0;
var box = document.createElement("div");
box.style.fontSize = '40px';
@rskull
rskull / gist:1212131
Created September 12, 2011 19:26
9500秒を時:分:秒に変換 [コードゴルフ]
<?$s=9500;$m=$s%3600;echo($s-$m)/3600,':'.floor($m/60).':'.$m%60;