Skip to content

Instantly share code, notes, and snippets.

@ahomu
ahomu / style_live_compile.html
Created January 5, 2013 05:17
JS BinのHTMLにこれを貼り付ければ、CSSのLive Editorになるよくん。Stylus/LESSのいずれか。簡易デモ用。 ※Stylusのクライアントサイド実行は、Try Stylusを含め@extend(s?)に対応していないので注意
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<script src="http://aho.mu/demo/jsbin_live/highlight.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
var style = document.querySelector('style'),
output = document.getElementById('output'),
@ahomu
ahomu / input.coffee
Created December 1, 2012 19:41
LiveScriptでCallback Hellに挑む
# 本当はLiveScript(.ls)だが、シンタックスハイライトの都合で.coffee
# ファイルを読み込む
err, files <-! fs.readdir source
if err then return console.log 'Error finding files: ' + err
# ファイルリストを回す
filename, fileIndex <-! files.forEach
console.log filename
@ahomu
ahomu / grunt-yslow.js
Created November 22, 2012 08:13
WIP: HARを取得して、Yslowで評価するぞくん
module.exports = function(grunt) {
'use strict';
var TEMP_HAR_RESOURCE = '.har.tmp';
var exec = require('child_process').exec,
YSLOW = require('yslow').YSLOW,
doc = require('jsdom').jsdom(),
util = grunt.utils || grunt.util,
@ahomu
ahomu / ajax_page.html
Created November 21, 2012 23:40
PhantomJSでStatic HTML生成するぞ君
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Ajax Page</title>
</head>
<body style="background-color: #fff;">
<h1>Ajax的にナニかするよー</h1>
<div id="content">
<p>loading...</p>
</div>
@ahomu
ahomu / Gruntfile.js
Created November 19, 2012 13:31
console族をgrunt-contrib-copy時にアレするソレ。minify前推奨。
/*global module:false*/
module.exports = function (grunt) {
grunt.initConfig({
copy: {
js: {
files: {
'../public/js' : 'js/app-all.min.js'
},
options: {
@ahomu
ahomu / snapshot.js
Created November 6, 2012 11:15
% phantomjs snapshot.js > stdoutfilename
var page = require('webpage').create();
var url = 'http://localhost:1234/';
page.viewportSize = {
width: 1024,
height: 768
};
page.settings.userAgent = 'I am Phantom';
page.open(url, function (a, b, c) {
setTimeout(function() {
console.log(page.content);
@ahomu
ahomu / gist:4023029
Created November 6, 2012 06:35
Geolocation test
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>hmmm...?</title>
<meta name="viewport" content="width=device-width">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<style type="text/css">
#js-geoloc {
font-size: 150%;
@ahomu
ahomu / reveal.data-image.js
Created October 2, 2012 23:38
Reveal.js set background-image when slides changed
/**
* set background-image when slides changed
<section data-image="path/to/background">
<!-- slide content -->
</section>
*/
var stateBg = document.querySelector('.state-background');
Reveal.addEventListener( 'slidechanged', function( event ) {
@ahomu
ahomu / shot.js
Created September 30, 2012 23:28
Create slides(Reveal.js) PNG images using phantomjs
console.log('Loading a web page');
var page = require('webpage').create();
var url = 'http://localhost:1947/';
page.viewportSize = {
width: 1024,
height: 768
};
page.open(url, function (status) {
//Page is loaded!
var iz, i = 0, queue = {};
@ahomu
ahomu / ?
Created September 15, 2012 08:53
Android created Gist
Around 2012/09/11 20:12:07, Detected M4.3 earthquake centered in Off the coast of Fukushima, 10km deep.Maximum scale will be Level 2. http://twiple.jp/e/5IeSgSud #NamazuAlert