Skip to content

Instantly share code, notes, and snippets.

@wgkoro
wgkoro / isTargetPage.js
Created Jan 18, 2017
Railsで特定のページでだけ動かしたい場合のjs判定
View isTargetPage.js
// 外部に露出させるオブジェクトを生成
(function(window) {
var app = function() {};
// 動作対象ページか判定する。controller名、action名で判定する
// どちらか片方指定, 両方指定どちらでも可。
app.prototype.isTargetPage = function(targetHash) {
if (!this.hasValidArgument(targetHash)) {
return false;
}
View compare_version.js
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 Feb 18, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// 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 Oct 16, 2015
おせろゲーム ベースHTML (とサンプルスクリプト)
View othello.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 Aug 29, 2015
try{ }catch の中でファイル書き込みを実行し、例外なげたらどうなるんだっけ?
View file_write_in_try-catch.php
<?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 Aug 29, 2015
AOJ-0017 Caesar Cipher
View 0017.py
#!/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 Oct 6, 2014
キーコードを確認するためのHTML
View keycode_check.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){
View gist:fd08bb4fac4161fa4902
(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 Aug 29, 2015
Flickr credit for mobile
View filickr_credit_mobile.js
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 Aug 29, 2015
Flickr Credit bookmarklet
View flickr_credit_pc.js
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;
}
}
You can’t perform that action at this time.