Skip to content

Instantly share code, notes, and snippets.

View voloko's full-sized avatar

Vladimir Kolesnikov voloko

View GitHub Profile
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<head>
<title> Drag and Drop</title>
</head>
<body>
<style>body, html { margin: 0; padding: 0; };</style>
<div id="draggable" draggable="true" unselectable="unselectable"
style="position:absolute;left:600px;top:50px;width:100px;height:100px;
line-height:100px;font-size:18px;background:#CCF;font-family:sans-serif;
uki.view.NativeSelect = uki.newClass(uki.view.Base, new function() {
var Base = uki.view.Base.prototype,
proto = this, emptySelectSize = {};
proto.typeName = function() { return 'uki.view.NativeSelect'; };
proto._createDom = function() {
this._dom = uki.createElement('select', Base.defaultCss);
};
get '/delay/:n' do |n|
EM.add_timer(n) do
async_write ["{a:'delayed for #{n} seconds'}"]
async_finish
end
response.headers['Content-Type'] = 'application/x-javascript'
async_start
end
@voloko
voloko / reader.rb
Created October 9, 2009 08:46
Twitter realtime API client
# Moved JSONStream to a separate project.
# See: http://github.com/voloko/twitter-stream
# or simply sudo gem install twitter-stream -s http://gemcutter.org
require 'rubygems'
require 'twitter/json_stream'
EventMachine::run {
stream = Twitter::JSONStream.connect(
:path => '/1/statuses/filter.json',
require 'rubygems'
require 'eventmachine'
require 'em/buftok'
require 'base64'
class TwitterRealtimeJSON < EventMachine::Connection
MAX_LINE_LENGTH = 16*1024
attr_accessor :code
attr_accessor :headers
./configure --with-ruby --with-amqp --with-ruby-headersdir=/opt/local/include/ruby1.9-1.9.1/ruby --prefix=/opt/local/
def generate_file_files
debug_msg "Generating file documentation in #@outputdir"
templatefile = @template_dir + 'file.rhtml'
@files.each do |file|
outfile = @outputdir + file.path
debug_msg " working on %s (%s)" % [ file.full_name, outfile ]
rel_prefix = @outputdir.relative_path_from( outfile.dirname )
debug_msg " rendering #{outfile}"
ruby -e "require 'webrick';s=WEBrick::HTTPServer.new :Port=>3001,:DocumentRoot=>Dir.pwd;trap('INT'){s.shutdown};s.start"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Aspect test</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script src="../lib/prototype.js" type="text/javascript"></script>
<script src="../lib/aspect.js" type="text/javascript"></script>
<style type="text/css" media="screen">
.x
/**
* Aspects for js (Function call interception)
* Released under the MIT License
* @copyright 2009 Vladimir Kolesnikov
* @author Vladimir Kolesnikov <voloko@gmail.com>
*/
var Aspect = new function() {
this.add = function(obj, aspectName, aspect) {