Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: kschiess/cod
base: 9c0d57eca1
...
head fork: kschiess/cod
compare: 513e1620e1
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 15 files changed
  • 0 commit comments
  • 1 contributor
View
39 website/build/index.html
@@ -5,14 +5,9 @@
</head>
<body onload="sh_highlightDocument();">
<a href="/cod/tutorial/pipes.html">IO.pipes</a>
- <script type="text/javascript">(function() {
- $('h1').each(function(el) {
- return document.writeln(el);
- });
-
- }).call(this);
-
- </script><p>This is a work in progress&#8230;</p>
+ <div id="toc">
+ <h1>Table of Contents</h1>
+ </div><p>This is a work in progress&#8230;</p>
<p>Want to watch this happen? Here&#8217;s a list of things I&#8217;ve worked on recently
and what I changed:</p>
<h2>2012-03-30</h2>
@@ -22,5 +17,31 @@
<li><a href="tutorial/pipes.html">tutorial/pipe</a> A few examples and the example runner.
Examples for a lot of the pattern you&#8217;d need in reality.</li>
</ul>
- <p>Come back later &#8211; this is undergoing frequent changes.</p></body>
+ <p>Come back later &#8211; this is undergoing frequent changes.</p><script type="text/javascript">(function() {
+ var toc, ul;
+ toc = $('#toc');
+
+ document.anchor_id = 0;
+
+ ul = document.createElement('ul');
+
+ toc.append(ul);
+
+ $('body > h1,h2,h3').each(function() {
+ var a, anchor_name, li;
+ anchor_name = "a" + document.anchor_id;
+ document.anchor_id += 1;
+ $(this).attr('id', anchor_name);
+ li = document.createElement('li');
+ $(li).addClass(this.tagName);
+ a = document.createElement('a');
+ $(a).attr('href', "#" + anchor_name).text($(this).text());
+ $(li).append(a);
+ return $(ul).append(li);
+ });
+
+ }).call(this);
+
+ </script>
+ </body>
</html>
View
9 website/build/stylesheets/site.css
@@ -25,5 +25,14 @@ body {
background-color: #f8f8f8;
padding-bottom: 1.4em; }
+#toc li {
+ list-style: none; }
+ #toc li.H2 {
+ padding-left: 1em; }
+ #toc li.H3 {
+ padding-left: 2em; }
+#toc ul {
+ padding-left: 0; }
+
.links {
text-align: center; }
View
35 website/build/tutorial/conventions.html
@@ -5,15 +5,36 @@
</head>
<body onload="sh_highlightDocument();">
<a href="/cod/tutorial/pipes.html">IO.pipes</a>
- <script type="text/javascript">(function() {
- $('h1').each(function(el) {
- return document.writeln(el);
+ <div id="toc">
+ <h1>Table of Contents</h1>
+ </div><p>channel often means a cod channel
+ cod is <em>cod</em>
+ examples don&#8217;t wait for children, but you should
+ very often, examples don&#8217;t close their channels, but you should</p><script type="text/javascript">(function() {
+ var toc, ul;
+ toc = $('#toc');
+
+ document.anchor_id = 0;
+
+ ul = document.createElement('ul');
+
+ toc.append(ul);
+
+ $('body > h1,h2,h3').each(function() {
+ var a, anchor_name, li;
+ anchor_name = "a" + document.anchor_id;
+ document.anchor_id += 1;
+ $(this).attr('id', anchor_name);
+ li = document.createElement('li');
+ $(li).addClass(this.tagName);
+ a = document.createElement('a');
+ $(a).attr('href', "#" + anchor_name).text($(this).text());
+ $(li).append(a);
+ return $(ul).append(li);
});
}).call(this);
- </script><p>channel often means a cod channel
- cod is <em>cod</em>
- examples don&#8217;t wait for children, but you should
- very often, examples don&#8217;t close their channels, but you should</p></body>
+ </script>
+ </body>
</html>
View
39 website/build/tutorial/pipes.html
@@ -5,14 +5,9 @@
</head>
<body onload="sh_highlightDocument();">
<a href="/cod/tutorial/pipes.html">IO.pipes</a>
- <script type="text/javascript">(function() {
- $('h1').each(function(el) {
- return document.writeln(el);
- });
-
- }).call(this);
-
- </script><h1>Pipes</h1>
+ <div id="toc">
+ <h1>Table of Contents</h1>
+ </div><h1>Pipes</h1>
<p>A pipe is a descriptor pair for interprocess communication.<sup class="footnote" id="fnr1"><a href="#fn1">1</a></sup> It allows data
to flow in one direction, from its read end to the write end. In a way, a
pipe is the prototypical <em>cod</em> channel; they have been standing model for how
@@ -199,5 +194,31 @@
<a href="https://github.com/kschiess/procrastinate">procrastinate</a> by doing your work
in child processes.</p>
<p class="footnote" id="fn4"><a href="#fnr4"><sup>4</sup></a> This has pitfalls. Have a look at the section titled &#8220;Signal handling
-might mess up library X&#8221; in the <a href="unix.html">chapter on unix tricks</a>.</p></body>
+might mess up library X&#8221; in the <a href="unix.html">chapter on unix tricks</a>.</p><script type="text/javascript">(function() {
+ var toc, ul;
+ toc = $('#toc');
+
+ document.anchor_id = 0;
+
+ ul = document.createElement('ul');
+
+ toc.append(ul);
+
+ $('body > h1,h2,h3').each(function() {
+ var a, anchor_name, li;
+ anchor_name = "a" + document.anchor_id;
+ document.anchor_id += 1;
+ $(this).attr('id', anchor_name);
+ li = document.createElement('li');
+ $(li).addClass(this.tagName);
+ a = document.createElement('a');
+ $(a).attr('href', "#" + anchor_name).text($(this).text());
+ $(li).append(a);
+ return $(ul).append(li);
+ });
+
+ }).call(this);
+
+ </script>
+ </body>
</html>
View
29 website/build/tutorial/select.html
@@ -5,12 +5,33 @@
</head>
<body onload="sh_highlightDocument();">
<a href="/cod/tutorial/pipes.html">IO.pipes</a>
- <script type="text/javascript">(function() {
- $('h1').each(function(el) {
- return document.writeln(el);
+ <div id="toc">
+ <h1>Table of Contents</h1>
+ </div><h1>Selecting channels</h1><script type="text/javascript">(function() {
+ var toc, ul;
+ toc = $('#toc');
+
+ document.anchor_id = 0;
+
+ ul = document.createElement('ul');
+
+ toc.append(ul);
+
+ $('body > h1,h2,h3').each(function() {
+ var a, anchor_name, li;
+ anchor_name = "a" + document.anchor_id;
+ document.anchor_id += 1;
+ $(this).attr('id', anchor_name);
+ li = document.createElement('li');
+ $(li).addClass(this.tagName);
+ a = document.createElement('a');
+ $(a).attr('href', "#" + anchor_name).text($(this).text());
+ $(li).append(a);
+ return $(ul).append(li);
});
}).call(this);
- </script><h1>Selecting channels</h1></body>
+ </script>
+ </body>
</html>
View
29 website/build/tutorial/serialisation.html
@@ -5,12 +5,33 @@
</head>
<body onload="sh_highlightDocument();">
<a href="/cod/tutorial/pipes.html">IO.pipes</a>
- <script type="text/javascript">(function() {
- $('h1').each(function(el) {
- return document.writeln(el);
+ <div id="toc">
+ <h1>Table of Contents</h1>
+ </div><h1>Serialisation</h1><script type="text/javascript">(function() {
+ var toc, ul;
+ toc = $('#toc');
+
+ document.anchor_id = 0;
+
+ ul = document.createElement('ul');
+
+ toc.append(ul);
+
+ $('body > h1,h2,h3').each(function() {
+ var a, anchor_name, li;
+ anchor_name = "a" + document.anchor_id;
+ document.anchor_id += 1;
+ $(this).attr('id', anchor_name);
+ li = document.createElement('li');
+ $(li).addClass(this.tagName);
+ a = document.createElement('a');
+ $(a).attr('href', "#" + anchor_name).text($(this).text());
+ $(li).append(a);
+ return $(ul).append(li);
});
}).call(this);
- </script><h1>Serialisation</h1></body>
+ </script>
+ </body>
</html>
View
29 website/build/tutorial/tcp.html
@@ -5,12 +5,33 @@
</head>
<body onload="sh_highlightDocument();">
<a href="/cod/tutorial/pipes.html">IO.pipes</a>
- <script type="text/javascript">(function() {
- $('h1').each(function(el) {
- return document.writeln(el);
+ <div id="toc">
+ <h1>Table of Contents</h1>
+ </div><h1><span class="caps">TCP</span> channels</h1><script type="text/javascript">(function() {
+ var toc, ul;
+ toc = $('#toc');
+
+ document.anchor_id = 0;
+
+ ul = document.createElement('ul');
+
+ toc.append(ul);
+
+ $('body > h1,h2,h3').each(function() {
+ var a, anchor_name, li;
+ anchor_name = "a" + document.anchor_id;
+ document.anchor_id += 1;
+ $(this).attr('id', anchor_name);
+ li = document.createElement('li');
+ $(li).addClass(this.tagName);
+ a = document.createElement('a');
+ $(a).attr('href', "#" + anchor_name).text($(this).text());
+ $(li).append(a);
+ return $(ul).append(li);
});
}).call(this);
- </script><h1><span class="caps">TCP</span> channels</h1></body>
+ </script>
+ </body>
</html>
View
39 website/build/tutorial/unix.html
@@ -5,14 +5,9 @@
</head>
<body onload="sh_highlightDocument();">
<a href="/cod/tutorial/pipes.html">IO.pipes</a>
- <script type="text/javascript">(function() {
- $('h1').each(function(el) {
- return document.writeln(el);
- });
-
- }).call(this);
-
- </script><h1>Tricks and Gotchas</h1>
+ <div id="toc">
+ <h1>Table of Contents</h1>
+ </div><h1>Tricks and Gotchas</h1>
<p>When you start using <em>cod</em> for your own projects, I assume you want to cross
over to the unixy, using-forks-instead-of-threads side of things. This is fine
with me, and one of the reasons I created cod.</p>
@@ -26,5 +21,31 @@
<ul>
<li>Enterprise Ruby</li>
<li>Ruby 2.0</li>
- </ul></body>
+ </ul><script type="text/javascript">(function() {
+ var toc, ul;
+ toc = $('#toc');
+
+ document.anchor_id = 0;
+
+ ul = document.createElement('ul');
+
+ toc.append(ul);
+
+ $('body > h1,h2,h3').each(function() {
+ var a, anchor_name, li;
+ anchor_name = "a" + document.anchor_id;
+ document.anchor_id += 1;
+ $(this).attr('id', anchor_name);
+ li = document.createElement('li');
+ $(li).addClass(this.tagName);
+ a = document.createElement('a');
+ $(a).attr('href', "#" + anchor_name).text($(this).text());
+ $(li).append(a);
+ return $(ul).append(li);
+ });
+
+ }).call(this);
+
+ </script>
+ </body>
</html>
View
BIN  website/source/images/fish.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
10 website/source/index.html.textile
@@ -1,13 +1,19 @@
+---
+title: cod - ipc, not beards
+---
+
This is a work in progress...
Want to watch this happen? Here's a list of things I've worked on recently
and what I changed:
+h2. 2012-04-02
+
+* Style changes, added a fish image courtesy of "Norwegian Institute of Marine Research":http://www.fisheries.no/ecosystems-and-stocks/marine_stocks/fish_stocks/cod/. (Thanks!)
+
h2. 2012-03-30
* "tutorial/unix":tutorial/unix.html Headlines only; stuff that you need to
be aware of in this mode of programming.
* "tutorial/pipe":tutorial/pipes.html A few examples and the example runner.
Examples for a lot of the pattern you'd need in reality.
-
-Come back later - this is undergoing frequent changes.
View
36 website/source/layout.slim
@@ -17,18 +17,40 @@ html
body onload="sh_highlightDocument();"
a href="#{{asset_url 'tutorial/pipes.html'}}" IO.pipes
+ | -
+ a href="#{{asset_url 'tutorial/pipes.html'}}" TCP streams
+ | -
+ a href="#{{asset_url 'tutorial/pipes.html'}}" Beanstalkd tubes
- #toc
+ - if data.page.toc
+ #toc
+ img src="#{{asset_url 'images/fish.png'}}"
+ h1 Table of Contents
== yield
coffee:
toc = $('#toc')
+
+ if toc
+ # a small hack: anchors are generated by enumerating the headers.
+ document.anchor_id = 0
- create_list= (level, where, scope) ->
- ul = where.append('<ol></ol>')
- $("h#{level}", scope).each (el, idx) ->
- li = ul.append("<li>#{$(this).text()}</li>")
- create_list(level+1, li, el)
+ ul = document.createElement('ul')
+ toc.append(ul)
- create_list(1, toc)
+ $('body > h1,h2,h3').
+ each ->
+ anchor_name = "a#{document.anchor_id}"
+ document.anchor_id += 1
+
+ $(this).attr('id', anchor_name)
+
+ li = document.createElement('li')
+ $(li).addClass this.tagName
+
+ a = document.createElement('a')
+ $(a).attr('href', "##{anchor_name}").text $(this).text()
+
+ $(li).append(a)
+ $(ul).append(li)
View
87 website/source/stylesheets/site.css.sass
@@ -12,31 +12,74 @@ body
color: #333
line-height: 1.4em
+
+img
+ margin-left: auto
+ margin-right: auto
+ display: block
+ margin-top: 3em
+
+a
+ text-decoration: none
+
+/* Headers
+h1,h2,h3,h4
+ color: #454545
+h2
+ font-size: 1.5em
+ margin:
+ top: 1em
+ bottom: 0em
+
+/* Source code style
+code
+ color: #696969
+pre
+ line-height: 1.4em
+
+ &.sh_sourceCode
+ border-radius: 0.5em
+ background-color: #f8f8f8
+ padding-bottom: 1.4em
+
+/* Table of Contents
+#toc
+ margin-left: auto
+ margin-right: auto
+ width: 18em
+ font-size: 1.1em
+ background-color: #f8f8f8
+ border-radius: 0.5em
+ padding:
+ left: 0.5em
+ right: 0.5em
+ top: 1px
+ bottom: 1px
+ margin-top: 2em
+
+ /* Content style
+ h1
+ font-size: 1.1em
+ color: #aaa5a5
a
- text-decoration: none
+ color: #aaa5a5
+
+ /* List style
+ li
+ list-style: none
- h1,h2,h3,h4
- color: #454545
- h2
- margin:
- top: 1.5em
- bottom: 0em
+ &.H2
+ padding-left: 1em
+ &.H3
+ padding-left: 2em
- code
- color: #696969
+ ul
+ padding-left: 0
- pre
- line-height: 1.4em
-
- &.sh_sourceCode
- border-radius: 0.5em
- background-color: #f8f8f8
- padding-bottom: 1.4em
-
-#toc
- li
- border: 1px solid red
+ img
+ margin-top: -1.5em
-.links
- text-align: center
+.footnote
+ padding: 0
+ margin: 0
View
5 website/source/tutorial/Gemfile
@@ -1,5 +0,0 @@
-source 'https://rubygems.org'
-
-gem 'case'
-gem 'cod'
-gem 'text-highlight'
View
14 website/source/tutorial/Gemfile.lock
@@ -1,14 +0,0 @@
-GEM
- remote: https://rubygems.org/
- specs:
- case (0.5.2.1)
- cod (0.4.4)
- text-highlight (1.0.2)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- case
- cod
- text-highlight
View
17 website/source/tutorial/pipes.html.textile
@@ -1,5 +1,6 @@
---
title: "Pipes"
+toc: true
---
h1. Pipes
@@ -47,7 +48,7 @@ either end and render them useless:
<pre class="sh_ruby"><code title="Access before fork">
chan = Cod.pipe
- chan.put :smthng # raises <Errno::EPIPE: Broken pipe>
+ chan.put :smthng # raises <Errno::EPIPE: Broken pipe>
fork do
chan.get
end
@@ -111,7 +112,7 @@ Have a look at this nifty trick:
end
end
- channel.get # => #<RuntimeError: Meanwhile, back at th...
+ channel.get # => #<RuntimeError: Meanwhile, back at th...
</code></pre>
One could even raise the error returned in the parent process, simulating a
@@ -149,8 +150,8 @@ And here 's an example of one producer, M consumers:
Worker.new(n)
end
- work = Cod.pipe # for sending work to workers
- result = Cod.pipe # for receiving results from workers
+ work = Cod.pipe # for issuing work
+ result = Cod.pipe # for receiving results
# Set up ten worker processes
pids = 10.times.map do |i|
@@ -214,8 +215,9 @@ Using _cod_, it boils down to this:
# Do something without worrying about signals
- # Here's the advantage of self-pipe: You can decide when
- # to listen for signals. Otherwise trap is very preemptive.
+ # Here's the advantage of self-pipe: You can
+ # decide when to listen for signals. Otherwise
+ # trap is very preemptive.
self_pipe.read.get # => :USR1
</code></pre>
@@ -223,10 +225,11 @@ Did you notice that a split pipe returns an array that also answers to
<code>#read</code> and <code>#write</code>? This is useful for when you cannot
come up with a name for both ends, as in the above example.
+!/images/fish.png!
fn1. man 2 pipe
-fn2. @code_link(Cod::ConnectionLost)
+fn2. @code_link(Cod::ConnectionLost)
fn3. Something that another library of mine could help you with:
"procrastinate":https://github.com/kschiess/procrastinate by doing your work

No commit comments for this range

Something went wrong with that request. Please try again.