Skip to content

Instantly share code, notes, and snippets.

package main
import (
"io"
"log"
"net"
)
func handleConnection(conn net.Conn) {
io.WriteString(conn, "HTTP/1.1 2000000000000000000000000000000000000000000000000000000000000000 OK\r\nConnection: close\r\nContent-Length: 5\r\n\r\nSuccess\r\n")
(Spin Version 6.2.5 -- 3 May 2013)
+ Partial Order Reduction
Full statespace search for:
never claim - (none specified)
assertion violations +
acceptance cycles - (not selected)
invalid end states +
State-vector 244 byte, depth reached 169, errors: 0
mtype = { Ready, NotReady, Commit, Abort }
chan from_arbiter[4] = [1] of { mtype };
chan from_worker[4] = [1] of { mtype };
active proctype Arbiter() {
assert (_pid == 0);
mtype v1, v2, v3;
from_arbiter[1]!Ready;
from_arbiter[2]!Ready;
from_arbiter[3]!Ready;
@draftcode
draftcode / Rakefile
Last active December 20, 2015 22:58
require 'rake/clean'
CC = "clang"
CLEAN.include(FileList["pan{,.*}"])
CLEAN.include(FileList["*.pml.trail"])
CLOBBER.include(FileList["*.pml"].map { |fn| fn.gsub(/.pml$/, '') })
rule /^[^.]+$/ => '.pml' do |t|
sh "spin -a #{t.prerequisites.join(' ')}"
noHandle = false
focusHandler = (e)->
if e.target.isContentEditable
noHandle = true
else
nohandle = false
keypressHandler = (e)->
return if noHandle
<h1>Editing {{.Title}}</h1>
<form action="/save/{{.Title}}" method="POST">
<div><textarea name="body" rows="20" cols="80">{{printf "%s" .Body}}</textarea></div>
<div><input type="submit" value="Save"></div>
</form>
package main
import (
"fmt"
"os/exec"
"regexp"
"strconv"
"strings"
"time"
)
require 'net/ssh'
require 'tmpdir'
require 'socket'
path = Dir::Tmpname::create('forwarded_socket') { |path| path }
UNIXServer.open(path) do |server|
at_exit do
File.unlink(path)
end
# -*- coding: utf-8 -*-
require 'net/ssh'
Net::SSH.start(HOSTNAME, USERNAME) do |ssh|
ssh.open_channel do |channel|
channel.exec('ruby') do |ch, success|
abort 'cannot execute ruby' unless success
ch.on_data do |c, data|
$stdout.puts("received #{data}")
# -*- coding: utf-8 -*-
from __future__ import division, absolute_import, print_function, unicode_literals
import sys
def tracer(frame, event, arg):
print("source: {}\tlineno: {}".format(frame.f_code.co_filename, frame.f_lineno))
with open(frame.f_code.co_filename, 'r') as f:
print(f.readlines()[frame.f_lineno-1][0:-1])
return tracer