Skip to content

Instantly share code, notes, and snippets.

View mclaughj's full-sized avatar

Joseph McLaughlin mclaughj

View GitHub Profile
<article>
<h2>archive</h2>
<% years = [] %>
<% @articles.select.each {|a| years.push(a[:date].year)} %>
<% years.uniq!.each do |year| %>
<div class="archive-section">
<h3><%= year %></h3>
<ul>
<% @articles.select {|a| a[:date].year == year && a[:date] <= Date.today}.each do |article| %>
<li>
@mclaughj
mclaughj / gist:580133
Last active September 23, 2015 15:58
<script type="text/javascript">
$(document).ready(function(){
$('.gistinclude').each(function(){
var gistLocation = $(this);
$.getJSON('http://gist.github.com/'+$(this).attr('data-gistid')+'.json?callback=?', function(data){
gistLocation.replaceWith(data.div);
});
});
});
</script>
<p class="gistinclude" data-gistid="580160"></p>
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
cat 'work in progress'
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Border Image Test</title>
<style type="text/css">
#slider {
/*This shows how to use border-image to mimic the behavior
of stretchableImageWithLeftCapWidth:topCapHeight: in CSS.
This example has a border-left and border-right width of 15px.
def cocktailsort(array)
arr = Array.new(array)
swapped = true
while swapped do
swapped = false
for i in 0.upto(arr.length-2) do
if arr[i] > arr[i+1] then
arr[i], arr[i+1] = arr[i+1], arr[i]
swapped = true
end
def archives filter = "", tag = nil
entries = ! self.articles.empty??
self.articles.select do |a|
filter !~ /^\d{4}/ || File.basename(a) =~ /^#{filter}/
end.reverse.map do |article|
Article.new article, @config
end : []
if tag.nil?
{ :archives => Archives.new(entries, @config) }
def go route, env = {}, type = :html
# ...
elsif route.first == 'tag' && route.size == 2
if (data = archives('', route[1])).nil?
http 404
else
context[data, :tag]
end
def tags()
self[:tags] || ""
end