Skip to content

Instantly share code, notes, and snippets.

@rike422
rike422 / gist:5801928
Last active December 18, 2015 15:08
重複検出
function dupulicate(array) {
var storage = {};
var duplicateArray = [];
var i,value;
for ( i=0; i < array.length; i++) {
value = array[i];
if (value in storage) {
duplicateArray.push(value);
} else {
storage[value] = true;
@rike422
rike422 / gist:5805050
Last active December 18, 2015 15:29
jsでrailsの日付拡張っぽく日付取得するやつ(未テスト)タイムゾーン回り怪しい
Number.prototype.ago = function() {
var result, addSec, gap;
result = new Date();
addSec = this.valueOf() * 86400000;
gap = dt.setTime(Date.now() - addSec);
result.setTime(gap);
return dt;
}
Number.prototype.since = function() {
@rike422
rike422 / gist:7096675
Created October 22, 2013 07:48
casper.js使い方

casper.jsとは

CasperJS is an open source navigation scripting & testing utility written in Javascript for the PhantomJS WebKit headless browser and SlimerJS (Gecko). It eases the process of defining a full navigation scenario and provides useful high-level functions, methods & syntactic sugar for doing common tasks such as:

参考資料

コマンド

ユースケース
* 概要を把握する
** 全体的にそのリストからどのような印象を受けるか考える
* 項目を一見ずつブラウズする必要があるか
* 特定の項目を検索する必要があるか
* ソートやフィルタリングを行う必要があるか?
@rike422
rike422 / gist:8008335
Created December 17, 2013 16:59
titanium用のgruntfail src配下をapp配下に移す想定
module.exports = function(grunt) {
'use strict';
// Grunt Initialize
grunt.initConfig({
pkg : grunt.file.readJSON('package.json'),
watch : {
all : {
files : [ 'Resources/**/*.js' ],
tasks : [ 'tishadow:spec' ]
},
@rike422
rike422 / shell
Created September 30, 2014 14:11
skypeから引っこ抜くやつ
echo ' SELECT chat.friendlyname, ms.timestamp, ms.author, ms.body_xml, ms.from_dispname FROM Messages as ms LEFT JOIN Chats as chat ON ms.chatname = chat.name;' | sqlite3 -csv main.db
@rike422
rike422 / coffee
Created October 29, 2014 11:02
hubot のなんだってスクリプト
nandatte = [
"http://suiseinanpa.com/wp-content/uploads/434536.jpg"
"https://shuyaout.files.wordpress.com/2014/10/1.gif"
"http://shimoinaba.cocolog-nifty.com/photos/uncategorized/2010/12/21/photo.jpg"
"http://livedoor.blogimg.jp/nandemoj22/imgs/3/9/3998d2a1.jpg"
]
module.exports = (robot) ->
robot.hear /(だったんだよ)/i, (msg) ->
@rike422
rike422 / file0.css
Created November 20, 2014 09:41
rubygems.orgを目に優しくするユーザcss
.body--index, .header--interior {
background-image: none;
}
body {
background-color: #846059;
}
Array.prototype.sample = function(loop) {
var result = [], loop = loop || 1;
for(var i = 0; i < loop; i++) {
result.push(this[Math.floor(Math.random() * this.length)]);
}
return result;
}
@rike422
rike422 / .tmux.conf
Last active August 29, 2015 14:13
tmux.conf
# prefixキーをC-aに変更する
set -g prefix C-a
# C-bのキーバインドを解除する
unbind C-b
# キーストロークのディレイを減らす
set -sg escape-time 1
# ウィンドウのインデックスを1から始める