A very simple example of using a map of channels for pub/sub in go.
To run it go here http://play.golang.org/p/eXwppMgHR3
#!/bin/bash | |
# | |
# Copy data from a Time Machine volume mounted on a Linux box. | |
# | |
# Usage: copy-from-time-machine.sh <source> <target> | |
# | |
# source: the source directory inside a time machine backup | |
# target: the target directory in which to copy the reconstructed | |
# directory trees. Created if it does not exists. | |
# |
A very simple example of using a map of channels for pub/sub in go.
To run it go here http://play.golang.org/p/eXwppMgHR3
# I've been thinking about Null Objects and Optional Types in Ruby lately. | |
# Optional Types are often defined using both a Null type and some kind of | |
# Proxy for non-nulls, but proxies have all sorts of subtle problems in Ruby. | |
# Let's say we do optional types without a proxy. E.g.: | |
x = Maybe("foo") # => "foo" | |
y = Maybe(nil) # => NullObject.instance | |
# In order to keep NullObjects from "leaking" into places they aren't wanted, | |
# we need an inverse conversion function to "collapse" values back to either |
# Signal catching | |
def shut_down | |
puts "\nShutting down gracefully..." | |
sleep 1 | |
end | |
puts "I have PID #{Process.pid}" | |
# Trap ^C | |
Signal.trap("INT") { |
require 'socket' | |
require 'sinatra/base' | |
require 'pry' | |
puts "Ruby runtime parsing SinatraServer in main thread: #{Thread.current}" | |
sinatra_thread = Thread.new do | |
class SinatraServer < Sinatra::Application | |
puts "Sinatra running in thread: #{Thread.current}" |
<MESSAGE> = *<SPACE> *1(<':'> PREFIX <1*SPACE>) COMMAND *<SPACE> *1PARAMS | |
PREFIX = NICKNAME | |
NICKNAME = (LETTER / SPECIAL) *(LETTER / DIGIT / SPECIAL / '-') | |
COMMAND = 1*LETTER / 3DIGIT | |
PARAMS = *14(1*<SPACE> MIDDLE *<SPACE>) *1(1*<SPACE> <':'> TRAILING) / | |
15(1*<SPACE> MIDDLE) *<SPACE> | |
MIDDLE = NOSPCRLFCL *(':' / NOSPCRLFCL) | |
TRAILING = *(':' / SPACE / NOSPCRLFCL) | |
<NOSPCRLFCL> = %x01-09 / %x0B-0C / %x0E-1F / %x21-39 / %x3B-FF |
# http://ruby-doc.org/stdlib-2.0.0/libdoc/open-uri/rdoc/OpenURI.html | |
require 'open-uri' | |
# Go fetch the contents of a URL & store them as a String | |
response = open('http://www.example.com').read | |
# "Pretty prints" the result to look like a web page instead of one long string of HTML | |
URI.parse(response).class | |
# Print the contents of the website to the console |
/ Generate an HTML5 video tag with embedded Flash fallback | |
/ @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video HTML5 video tag spec | |
/ | |
/ @local [Hash] video Attribute hash for the `video` tag | |
/ @option video [Integer] :width (320) Width of the video tag in pixels | |
/ @option video [Integer] :height (240) Height of the video tag in pixels | |
/ | |
/ @local [Hash] src Mapping of source file types to URLs for source files | |
/ @option src [String] :mp4 URL of an MP4 source file for the video | |
/ @option src [String] :webm URL of a WebM source file for the video |
package sergius.fun; | |
/** | |
* Based on demo http://download.oracle.com/otndocs/products/javafx/2/samples/Ensemble/index.html#SAMPLES/Scenegraph/Events/Mouse Events | |
* with next license: | |
* Copyright (c) 2008, 2012 Oracle and/or its affiliates. All rights reserved. | |
* Use is subject to license terms. | |
*/ | |
import javafx.application.Application; | |
import javafx.scene.Scene; |
I want to write plugins for Atom's editor in Ruby. Opal makes this possible. Atom is one of several projects in recent times to combine Chromium with Node.js for a desktop app. While it utilizes chromium for it's gui, and boasts "[e]very Atom window is essentially a locally-rendered web page", writing Atom plugins is more like writing a server-side node.js app than a typical single-page client-side app (albeit with really awesome integration with Chrome Devtools). Opal development, on the other hand, has to-date been focused primarily on the browser use-case.
Because of this, I had to make a choice between using the opal-node package from npm, using Opal via Ruby w/ a compile step, or packaging up opal-parser.js, including it with the app, and writing in compilation on the fly. Each choice came with compromises. Using opal-node would have been easiest, just create a top level index.coffee that required opal-node, and then require in your ruby