Skip to content

Instantly share code, notes, and snippets.

View dongyuwei's full-sized avatar
💭
天天听儿歌

dongyuwei dongyuwei

💭
天天听儿歌
View GitHub Profile
@dongyuwei
dongyuwei / sub.rb
Created November 15, 2010 02:30
redis pub sub test
require "rubygems"
require "redis"
puts <<-EOS
To play with this example use redis-cli from another terminal, like this:
$ redis-cli publish test msg
EOS
redis = Redis.connect
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@dongyuwei
dongyuwei / test-nautilus-pyextension.py
Created November 23, 2010 07:34
test-nautilus-pyextension
import gtk
import nautilus
import os
#http://seemanta.net/myblog/?p=509
#sudo apt-get install python-nautilus
#killall nautilus
#see https://bugs.launchpad.net/ubuntu/+source/nautilus-python/+bug/125990
#http://code.google.com/p/giuspen-nautilus-pyextensions
def alert(message):
"""A function to debug"""
#!/usr/bin/env ruby
# This script performs an OAuth authorized POST with multipart encoding to
# http://twitter.com/account/update_profile_image.json
#
# This code is primarily taken from my Grackle library's implementation at
# http://github.com/hayesdavis/grackle
#
# RUNNING THIS WILL CHANGE AN ACCOUNT'S PROFILE IMAGE. BE CAREFUL.
#
@dongyuwei
dongyuwei / weibo.rb
Created December 4, 2010 04:33
新浪微博客户端 using sinatra
#! /usr/bin/ruby
#author [email protected]
require 'rubygems'
require "sinatra"
require 'oauth'
require 'oauth/consumer'
require 'yaml'
require 'logger'
require 'rubygems'
require 'eventmachine'
require 'net/ssh'
require 'net/scp'
require 'ruby-growl'
#http://codeforpeople.rubyforge.org/directory_watcher/classes/DirectoryWatcher.html
module Handler
def file_modified
puts "#{path} modified"
@dongyuwei
dongyuwei / sync.rb
Created January 28, 2011 06:18
auto sync local workcopy to remote server
#author [email protected]
require 'rubygems'
require 'fsevents'
require 'net/ssh'
require 'net/scp'
require 'ruby-growl'
host = "10.210.74.63"
username = "my name"
password = "my password"
@dongyuwei
dongyuwei / ssh.py
Created February 9, 2011 08:58
ssh python with password
import paramiko
client = paramiko.SSHClient()
client.load_system_host_keys()
client.connect('10.210.74.63','username'='my name', 'password'='my passwd')
stdin, stdout, stderr = client.exec_command('ls -l')
@dongyuwei
dongyuwei / README.md
Created February 16, 2011 15:12 — forked from mloughran/README.md

Getting started

First add your twitter username and password. Then server.rb and once it's started open websocket.html in your browser. You should see some tweets appear. If not take a look at the javascript console.

@dongyuwei
dongyuwei / tryruby-websocket.rb
Created February 23, 2011 06:20
tryruby-websocket.rb
%w(rubygems sinatra sinatra/base erubis eventmachine em-websocket open3).each{|lib|require lib}
class WebServer < Sinatra::Base
#enable :sessions
use Rack::Static, :urls => ["/images","/css","/js" ], :root => "views"
set :run, true
use Rack::Auth::Basic do |name, password|