Skip to content

Instantly share code, notes, and snippets.

@wgkoro
wgkoro / isTargetPage.js
Created January 18, 2017 11:10
Railsで特定のページでだけ動かしたい場合のjs判定
// 外部に露出させるオブジェクトを生成
(function(window) {
var app = function() {};
// 動作対象ページか判定する。controller名、action名で判定する
// どちらか片方指定, 両方指定どちらでも可。
app.prototype.isTargetPage = function(targetHash) {
if (!this.hasValidArgument(targetHash)) {
return false;
}
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);
@wgkoro
wgkoro / 0_reuse_code.js
Created February 18, 2016 03:53
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@wgkoro
wgkoro / othello.html
Created October 16, 2015 08:33
おせろゲーム ベースHTML (とサンプルスクリプト)
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>おせろ</title>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<style>
@wgkoro
wgkoro / file_write_in_try-catch.php
Last active August 29, 2015 14:25
try{ }catch の中でファイル書き込みを実行し、例外なげたらどうなるんだっけ?
<?php
// 結果:例外なげてもファイルに書き込まれる
try {
$fp = fopen('./fugafuga.log', 'a');
fwrite($fp, '123');
fclose($fp);
throw new Exception('e');
}
catch(Exception $e) {
@wgkoro
wgkoro / 0017.py
Last active August 29, 2015 14:17
AOJ-0017 Caesar Cipher
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys, string
alphabet = 'abcdefghijklmnopqrstuvwxyza'
table = string.maketrans(alphabet[:-1], alphabet[1:])
for s in sys.stdin:
while not('the' in s or 'this' in s or 'that' in s):
s = s.translate(table)
@wgkoro
wgkoro / keycode_check.html
Created October 6, 2014 07:41
キーコードを確認するためのHTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script>
$(function(){
$('#target').on({
keyup : function(e){
(NeoBundleUpdate時にエラー)
[neobundle/install] ( 2/39): |vimproc| git pull --rebase && git submodule update --init --recursive
function neobundle#commands#install..<SNR>27_install..neobundle#installer#sync..neobundle#installer#get_revision_number..neobundle#util#system..vimpro
c#system..<SNR>113_system..vimproc#pgroup_open..<SNR>113_pgroup_open..vimproc#plineopen3..<SNR>113_plineopen..<SNR>113_convert_args..vimproc#get_comma
nd_name の処理中にエラーが検出されました:
行 5:
E119: Not enough arguments for function: vimproc#filepath#which
E116: 関数の無効な引数です: vimproc#util#substitute_path_separator( vimproc#filepath#which(a:command, path)), '//', '/', 'g'), '\n')
E116: 関数の無効な引数です: substitute(vimproc#util#substitute_path_separator( vimproc#filepath#which(a:command, path)), '//', '/', 'g'), '\n')
@wgkoro
wgkoro / filickr_credit_mobile.js
Last active August 29, 2015 14:00
Flickr credit for mobile
javascript:(function(){
var title,a,
divs = document.getElementsByTagName('div'),
len = divs.length;
for(var i=0;i<len;i++){
if(divs[i].className.match(/photo_meta/)){
title = divs[i].getElementsByTagName('h2')[0].childNodes[0].nodeValue.replace(/ /g, '').replace(/\t/g, '').replace(/\n/g, '');
break;
}
}
@wgkoro
wgkoro / flickr_credit_pc.js
Last active August 29, 2015 14:00
Flickr Credit bookmarklet
javascript:(function(){
var a,title,
divs = document.getElementsByTagName('div'),
len = divs.length;
for(var i=0;i<len;i++){
if(divs[i].className == 'attribution-info'){
a = divs[i].getElementsByTagName('a')[0];
break;
}
}