Skip to content

Instantly share code, notes, and snippets.

@winks
Last active January 27, 2017 23:11
Show Gist options
  • Save winks/da8442739be048825482a9042495538e to your computer and use it in GitHub Desktop.
Save winks/da8442739be048825482a9042495538e to your computer and use it in GitHub Desktop.
# A _init.rb file contains Ruby code that will be executed when
# your application boots up. Use it to extend and modify other nodes!
#
# In this simple example, we're simply adding some convenience methods to
# all available blog posts for easier access to specific pieces of data.
extend_siblings do
def date
data.date
end
end
Flutterby::Filters.add("c") do |input, view:|
require 'open3'
require 'base64'
input = input.strip
input = Base64.encode64(input).strip
cmd = "/bin/echo '#{input}' | /usr/bin/base64 -d | " \
"/usr/bin/gcc -o NONONO -xc - && ./NONONO && rm ./NONONO"
stdin, stdout, stderr = Open3.popen3(cmd)
z = stdout.read.strip!
y = stderr.read.strip!
z
end
---
title: Welcome to C
date: 2017-01-25
---
#include<stdio.h>
int main() {
printf("Hello, I am a C program!\n");
}
<!DOCTYPE html><html><head><meta charset="utf-8" /><title>My Flutterby Site</title><meta content="width=device-width, initial-scale=1.0" name="viewport" /><link href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/default.min.css" rel="stylesheet" /><script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/highlight.min.js"></script><link href="/css/styles.css" rel="stylesheet" /><script src="/js/app.js"></script></head><body><div class="container"><article class="post"><div class="post-meta">January 25, 2017</div>
<h1>Welcome to C</h1>Hello, I am a C program!
</article><footer role="main"></footer></div></body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment