Skip to content

Instantly share code, notes, and snippets.

View tmtk75's full-sized avatar

Tomotaka Sakuma tmtk75

View GitHub Profile
@tmtk75
tmtk75 / showcase.yaml
Created February 3, 2011 06:58
YAML showcase
###
### YAML Showcase
### Thanks for http://jp.rubyist.net/magazine/?0009-YAML
### To run:
### cat $0 | ruby -r pp -r yaml -e 'pp YAML.load STDIN.read'
###
collection:
mapping(block-style):
name: Taro
age: 32
@tmtk75
tmtk75 / hpricot.rb
Created November 27, 2011 01:55
Hpricot, Ruby scraping library, getting started
require 'hpricot'
require 'open-uri'
doc = Hpricot( open("https://commons.wikimedia.org/wiki/Crystal_Clear").read )
(doc/:a).each do |link|
puts link[:href]
end
@tmtk75
tmtk75 / color-wheel.rb
Created November 27, 2011 03:30
Color Wheel CSS Generate
#!/usr/bin/ruby
=begin
Script to generate scss for color-wheel.
=end
$saturation = ARGV[0] || 100
$luminousness = ARGV[1] || 50
$split = ARGV[2].to_i || 24
def mk_suffix(deg)
"#{deg}_#{$saturation}_#{$luminousness}"
#!/bin/sh
##
## Publish onto Github Pages, providing an easy way to publish.
##
## Prepare: creating gh-pages branch at local and remote.
## $ jekyll
## $ git co -b gh-pages
## $ git ls-files | xargs git rm
## $ mv _site/* .
## $ git add .
@tmtk75
tmtk75 / markdown-tag.rb
Created November 30, 2011 08:10
Jekyll Markdown Tag
=begin
Jekyll tag to include Markdown text from _includes directory preprocessing with Liquid.
Usage:
{% markdown <filename> %}
Dependency:
- kramdown
=end
module Jekyll
class MarkdownTag < Liquid::Tag
def initialize(tag_name, text, tokens)
<link href="http://tmtk75.github.com/jumly-core/jumly-0.1.0-rc1.min.css" type="text/css" rel="stylesheet"/>
<script src='http://code.jquery.com/jquery-1.7.1.min.js' type="text/javascript"></script>
<script src='http://jashkenas.github.com/coffee-script/extras/coffee-script.js' type="text/javascript"></script>
<script src="http://tmtk75.github.com/jumly-core/jumly-0.1.0-rc1.min.js" type="text/javascript"></script>
{% jumly_includes %}
{% jumly sequence %}
@found "You", ->
@message "Hello!", "JUMLY"
{% endjumly %}
## Plugin for Jekyll to use JUMLY.
module JUMLY
class Script < Liquid::Block
def initialize(tag_name, markup, tokens)
super
@markup = markup.strip
end
def render(context)
<<SCRIPT.strip
<script type="text/jumly+#{@markup}">#{@nodelist.join ""}</script>
---
layout: default
---
<head>
{% jumly_includes %}
</head>
<body>
{% jumly sequence %}
@found "You", -> @message "Hello!", "JUMLY"
{% endjumly %}