Skip to content

Instantly share code, notes, and snippets.

@kerotaa
kerotaa / slug2name.rb
Created June 16, 2013 12:44
A filter that converts category slug to display name.
module Jekyll
module Slug2Name
def slug2name(input)
slug = @context.registers[:site].config['category_slugs'][input]
slug ? slug : input
end
end
end
Liquid::Template.register_filter(Jekyll::Slug2Name)
@kerotaa
kerotaa / remove-empty-lines-html.rb
Last active May 26, 2020 03:48
A plugin that remove empty lines from HTML files on jekyll.
module Jekyll
module Convertible
def write(dest)
path = destination(dest)
FileUtils.mkdir_p(File.dirname(path))
if File.extname(path).downcase == '.html' then
self.output.strip!
reg = /<\/?pre[^>]*>/i
pres = self.output.scan(reg)
tary = self.output.split(reg)
@kerotaa
kerotaa / _establish-break.scss
Last active December 23, 2015 23:49
いい感じな改行を実現するSCSS mixin。
@mixin establish-break($body: true, $pre: true, $inline: true, $table: true) {
@if $body {
body {
word-wrap: break-word;
}
}
@if $pre {
pre {
overflow: auto;
@mixin linear-gradient($start, $color-stops...) {
$start: unquote($start);
$vendors-direction: null;
$directions: top left bottom right;
@if str-index($start, "top") > 0 or str-index($start, "left") > 0 or str-index($start, "bottom") > 0 or str-index($start, "right") > 0 {
$proc: ();
@for $i from 1 to 4 {
@if str-index($start, nth($directions, $i)) > 0 {
$proc: append($proc, nth($directions, if($i < 3, $i + 2, $i - 2)));
path = require 'path'
grunt.registerMultiTask 'template_concat', ->
indent = (text, indentStr, width)->
lines = text.split "\n"
t = ''
for i in [0...width]
t += indentStr
lines.forEach (line, index)->
lines[index] = t + line
<?xml version="1.0"?>
<root>
<item>
<name>Change Shift_Underscore(_) to Singlequote(')</name>
<identifier>private.swap_singlequote_and_backquote</identifier>
<autogen>
--KeyToKey--
KeyCode::JIS_UNDERSCORE, VK_SHIFT,
KeyCode::KEY_7, VK_SHIFT
</autogen>
# CSSO on stylesheet saved
on_stylesheet_saved do |filename|
if File.exists?(filename)
system("csso #{filename} #{filename}")
end
end
@mixin close-button($size: 32px, $border-width: 1px, $color: #000) {
@include inline-block;
position: relative;
width: $size;
height: $size;
&:hover {
cursor: pointer;
}
@kerotaa
kerotaa / ga-count.js
Created September 16, 2013 23:04
クリックカウントをdata属性で管理したいときに使う。
$('[data-ga-count]').on('click.ga', function() {
var $this = $(this),
data = $this.data('ga-count'),
splitter = ':';
if (data.indexOf(splitter) == -1 || $this.data('ga-counted')) return true;
$this.data('ga-counted', true);
data = data.split(splitter);
_gaq.push(['_trackEvent', data[0], 'click', data[1]]);
});
strong {
position: relative;
}
strong::after {
display: inline-block;
content: '';
position: absolute;
z-index: -1;
bottom: 0;