Skip to content

Instantly share code, notes, and snippets.

View komiyak's full-sized avatar

Kosuke Komiya komiyak

View GitHub Profile
@nukos
nukos / category_archive.html
Last active February 10, 2016 00:37
Jekyll for category archive.
---
layout: default
---
<h2 class="post_title">{{page.title}}</h2>
<ul>
{% for post in site.posts %}
{% for category in post.category %}
{% if category == page.category %}
<li class="archive_list">
<time datetime='{{post.date | date: "%Y-%m-%d"}}'>{{post.date | date: "%m/%d/%y"}}</time> <a class="archive_list_article_link" href='{{post.url}}'>{{post.title}}</a>
@emersonf
emersonf / s3etag.sh
Last active August 14, 2024 13:56
A Bash script to compute ETag values for S3 multipart uploads on OS X.
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: $0 file partSizeInMb";
exit 0;
fi
file=$1
if [ ! -f "$file" ]; then
@be9
be9 / paginate.rb
Created September 5, 2013 04:18
kaminari + JSON API pagination helper
def paginate(scope, default_per_page = 20)
collection = scope.page(params[:page]).per((params[:per_page] || default_per_page).to_i)
current, total, per_page = collection.current_page, collection.num_pages, collection.limit_value
return [{
pagination: {
current: current,
previous: (current > 1 ? (current - 1) : nil),
next: (current == total ? nil : (current + 1)),