This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
log = require('sys').log | |
dgram = require('./lib/dgram') | |
var Buffer = require('buffer').Buffer; | |
var endat = 10; | |
var count = 0; | |
socket = dgram.createSocket(); | |
socket.addListener('message', function (msg, rinfo) { | |
log('got message from '+ rinfo.address +' port: '+ rinfo.port); | |
log('data len: '+ rinfo.size + " data: "+ msg.toString('ascii', 0, rinfo.size)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# an example of using the diff-lcs gem | |
# a mirror of the gem is hosted at http://github.com/defunkt/diff-lcs | |
# or `gem install diff-lcs` | |
require 'diff/lcs' | |
first, second = "hello, world!", "Hello, world!" | |
diff = Diff::LCS.diff(first, second) | |
patched = Diff::LCS.patch!(first, diff) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'java' | |
java_import 'javax.ws.rs.Path' | |
java_import 'javax.ws.rs.GET' | |
java_import 'javax.ws.rs.Produces' | |
java_package 'com.headius.demo.jersey' | |
java_annotation 'Path("/helloworld")' | |
class HelloWorld | |
java_annotation 'GET' | |
java_annotation 'Produces("text/plain")' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
STDOUT.sync = true | |
require 'queue' | |
start_time = Time.now.to_i | |
msg = 0 | |
queue = Queue.new("testing") | |
queue.subscribe do |obj| | |
msg += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'open-uri' | |
require 'net/http' | |
require 'uri' | |
require 'pp' | |
require 'json' | |
# This is my modified version of defunkt's gist.rb | |
# http://github.com/defunkt/gist/blob/master/gist.rb | |
# more scripts that harness the Github Gist API can be found at |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: Pieter Noordhuis | |
# Description: Simple demo to showcase Redis PubSub with EventMachine | |
# http://gist.github.com/348262 | |
# Incomplete evented Redis implementation specifically made for | |
# the new PubSub features in Redis. | |
# Modifications by Roger Jungemann | |
require 'stringio' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Comment | |
include DataMapper::Resource | |
belongs_to :user | |
belongs_to :video | |
property :id, Serial | |
property :uuid, String | |
property :content, Text | |
property :created_on, DateTime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "build daemontools from source" | |
task :install do | |
sh "curl -O curl -O http://cr.yp.to/daemontools/daemontools-0.76.tar.gz" | |
sh "tar zxf daemontools-*.tar.gz && rm daemontools-*.tar.gz" | |
sh "mv admin/daemontools-* ../daemontools && rm -rf admin" | |
sh "cd daemontools && package/compile" | |
puts "You can now run commands that exist in the daemontools/command dir." | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# recursively observes a folder and periodically checks new or updated files | |
# into a git repository. | |
# | |
# usage: | |
# ruby bakerie.rb path repo_path | |
# | |
# if repo_path doesn't exist or isn't a git repository, bakerie will create | |
# the folder and make it into a repository. It is unwise to have path and | |
# repo_path be the same. | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://snippets.aktagon.com/snippets/445-How-to-create-a-JSONP-cross-domain-webservice-with-Sinatra-and-Ruby | |
require 'sinatra/base' | |
require 'json/pure' | |
module JSONPatra | |
class App < Sinatra::Base | |
get "/" do | |
callback = params['callback'] | |
json = { :hello => "world!" }.to_json |