The knitr package provides an easy way to embed R code in a Jekyll-Bootstrap blog post. The only required input is an R Markdown source file.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var usage = 'Usage: node sum.js val1 val2 [other_vals]'; | |
var nums = process.argv.slice(2); | |
var sum = 0; | |
// as a simple program | |
console.log(nums); | |
if (nums.length < 2) { | |
console.log(usage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
def get_pages | |
# get an array of pages whose source filename contains .html | |
@pages = sitemap.resources.find_all { |page| page.source_file.match(/\.html/) } | |
# sort them by an arbitrary YAML frontmatter property called 'order' | |
@pages.sort! { |a,b| a.data['order'].to_i <=> b.data['order'].to_i } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// returns an array of localStorage items in key/value pairs based on a query parameter | |
// returns all localStorage items if query isn't specified | |
// query can be a string or a RegExp object | |
function findLocalItems (query) { | |
var i, results = []; | |
for (i in localStorage) { | |
if (localStorage.hasOwnProperty(i)) { | |
if (i.match(query) || (!query && typeof i === 'string')) { | |
value = JSON.parse(localStorage.getItem(i)); |
Links from @bcomnes's talk on the anatomy of an indieweb site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Terraformer = require('terraformer') | |
var point = new Terraformer.Point({ | |
type: 'Point', | |
coordinates: [-122.677425, 45.521637] | |
}) | |
var res = point.toMercator() | |
document.documentElement.innerHTML = res.coordinates |