Skip to content

Instantly share code, notes, and snippets.

View moroya's full-sized avatar

moroya moroya

View GitHub Profile
var img = $('<img/>').on('load', function(){
// 読み込めた時の処理
$(this).remove(); // GC
img = null;
}).on('error', function(){
// 読み込めなかった時の処理
$(this).remove(); // GC
img = null;
(function(){
var loadCount = 0;
var scriptURL = [
'//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js',
'//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js'
];
function getScript(src, callback) {
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
@moroya
moroya / AikatsuBot.js
Last active December 14, 2015 05:49
穏やかじゃないBot
// Node.jsで走らせるとよいよ三ε(๑^ᴗ^๑)з スイー
//
// node-twitterを利用してるから
// $ npm install twitter
//
// あと次回のアイカツ時間は手動で打ってるから、
// 実務で利用する場合はAPIで取得するようにしたほうが便利だと思う。
var twitter = require('twitter');
var BOT_ID = 'BOT_ID';
@moroya
moroya / jquery.mobile.events.js
Created April 24, 2013 08:48
jQuery mobile 1.3.1からモバイルイベント部分のみを取り出したもの
/**
* jquery.mobile.vmouse.js
*
* https://github.com/jquery/jquery-mobile/blob/1.3.1/js/jquery.mobile.vmouse.js
*
* Copyright 2010, 2013 jQuery Foundation, Inc. and other contributors
* Released under the MIT license.
* http://jquery.org/license
*/
// first
$(window).queue('myqueue', function() {
console.log('first');
setTimeout(function(){
$(window).dequeue('myqueue');
}, 1000);
});
// second
$(window).queue('myqueue', function() {
// first
function first() {
var df = $.Deferred();
setTimeout(function(){
console.log('first');
df.resolve();
}, 1000);
return df.promise();
@moroya
moroya / screenshot.js
Created May 8, 2013 15:43
phantomjs screenshot test
var page = require('webpage').create();
var system = require('system');
// 引数を引っ張る
var address = system.args[1];
var output = system.args[2];
var delay = Number(system.args[3]);
// ビューポートのサイズ
page.viewportSize = {
@moroya
moroya / gist:5585431
Last active December 17, 2015 09:09
image download
var imgs = document.querySelectorAll('a[href*="jpg"], a[href*="gif"], a[href*="png"]');
for(var i=0;i<imgs.length;i++) {
dispatchMouseEvents({ type:'click', altKey:true, target:imgs[i], button:0 });
}
function dispatchMouseEvents(opt) {
var evt = document.createEvent('MouseEvents');
evt.initMouseEvent(opt.type, opt.canBubble||true, opt.cancelable||true, opt.view||window,
opt.detail||0, opt.screenX||0, opt.screenY||0, opt.clientX||0, opt.clientY||0,
@moroya
moroya / httpd.conf
Created May 17, 2013 15:18
httpd.conf
### Section 1: Global Environment
### Apache全体に影響を及ぼすセクション
# Apacheのパス
ServerRoot "/etc/httpd"
# ポート番号の指定
Listen 80
# 同時接続数
<VirtualHost *:80>
ServerName example.net
DocumentRoot "/var/html/www/"
<Directory "/var/html/www/">
Order Allow,Deny
Allow from All
AllowOverride All
Options FollowSymLinks
</Directory>