This file contains 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 | |
/** | |
* X秒前、X分前、X時間前、X日前などといった表示に変換する。 | |
* 一分未満は秒、一時間未満は分、一日未満は時間、 | |
* 31日以内はX日前、それ以上はX月X日と返す。 | |
* X月X日表記の時、年が異なる場合はyyyy年m月d日と、年も表示する | |
* | |
* @param <String> $time_db strtotime()で変換できる時間文字列 (例:yyyy/mm/dd H:i:s) | |
* @return <String> X日前,などといった文字列 | |
**/ |
This file contains 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
javascript:(function(){ var heads = document.getElementsByTagName('head'); if(! heads.length){alert('QRエラー\nheadタグが見つかりません。');return} var s = document.createElement('script'); s.type = 'text/javascript'; s.charset = 'utf-8'; s.src = 'https://zafiel.wingall.com/js/qrgenerator.js'; heads[0].appendChild(s); })(); |
This file contains 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
/* =========================== | |
Author : wg.koro | |
Version : 1.1 | |
URL : https://gist.github.com/wgkoro/7973374 | |
Blog : https://zafiel.wingall.com/archives/8396 | |
QRコード生成ブックマークレット。 | |
見ているページのURL、あるいは選択した文字列のQRコードを生成する。 | |
ブックマークレットにして実行するとハッピー。 | |
============================== */ |
This file contains 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(window) { | |
var app = function() {}; | |
// 動作対象ページか判定する。controller名、action名で判定する | |
// どちらか片方指定, 両方指定どちらでも可。 | |
app.prototype.isTargetPage = function(targetHash) { | |
if (!this.hasValidArgument(targetHash)) { | |
return false; | |
} |
This file contains 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
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
""" | |
スレッドの使い方練習 | |
""" | |
import threading, time | |
import collections | |
import traceback | |
class Data: |
This file contains 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
#!/usr/bin/env python | |
#-*- coding:utf-8 -*- | |
u""" | |
Author : wg.koro | |
Update : 2013/10/29 | |
ページスクレイピング補助クラス。 | |
def scrape(soup_obj) をオーバーライドして使うと幸せになれる。 | |
Args: |
This file contains 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
#!/usr/bin/env python | |
#-*- coding:utf-8 -*- | |
import time | |
import os | |
from selenium import webdriver | |
class AndroidTest: | |
def __init__(self): | |
self._browser = webdriver.Remote(command_executor='http://localhost:8080/wd/hub', desired_capabilities=webdriver.DesiredCapabilities.ANDROID) | |
self._current = os.path.realpath(os.path.dirname(__file__)) |
This file contains 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
/** | |
* 指定サイズ以内の画像幅、高さを算出、 | |
* img要素にそのサイズを適用する | |
* | |
* 使い方: | |
* | |
* 例) 幅150px, 高さ200px以内で画像を表示する | |
* var img = document.createElement('img'); | |
* img.src = 'http://hoge.com/img/fuga.jpg'; | |
* imgResize.resize(img, 150, 200); |
This file contains 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
var availableVersion = 4.2; // 4.2以上を対象とする | |
var userVersion = '4.4.0.10'; | |
var numList = userVersion.split('.'); | |
var version = numList.slice(0, 2).join('.'); | |
console.log(version); // => "4.4" | |
console.info(typeof version); // => string | |
version = parseFloat(version, 10); |
This file contains 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
*** nginx-proxy-cache-purge_org.php 2012-04-09 06:22:30.000000000 +0900 | |
--- nginx-proxy-cache-purge_new.php 2013-02-04 00:35:13.000000000 +0900 | |
*************** | |
*** 13,18 **** | |
--- 13,20 ---- | |
$link = get_permalink($post_id); | |
$parse = parse_url($link); | |
$post_url = $parse[scheme].'://'.$parse[host].'/purge'.$parse[path]; | |
+ $post_url_sp = $parse[scheme].'://'.$parse[host].'/pg_s'.$parse[path]; | |
+ $post_url_ft = $parse[scheme].'://'.$parse[host].'/pg_f'.$parse[path]; |
NewerOlder