Skip to content

Instantly share code, notes, and snippets.

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

dongyuwei dongyuwei

💭
天天听儿歌
View GitHub Profile
@dongyuwei
dongyuwei / weibo_to_google_contact.py
Created March 18, 2011 10:21
添加部门通讯录到google contacts,继而可以通过google sync同步到手机通讯录。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#sync contacts of SINA WeiBo to Google contacts,then U can sync all contacts to your Mobile using *Google Sync* client.
#see: http://code.google.com/apis/contacts/docs/3.0/developers_guide_python.html && http://www.google.com/mobile/sync/
#by [email protected] | yuwei@staff
import atom
import gdata.contacts
import gdata.contacts.service
import csv
@dongyuwei
dongyuwei / [email protected]
Created August 1, 2011 08:49
打印出新浪微博xmpp好友分组及各组内好友
require 'rubygems'
require 'xmpp4r'
require 'xmpp4r/roster/helper/roster'
#Jabber::debug = true
jid = Jabber::JID.new('[email protected]')#my weibo uid
cl = Jabber::Client.new(jid)
@dongyuwei
dongyuwei / station.rb
Created August 27, 2011 13:20
使用微博api查询站点经纬度等信息
%w(rubygems sinatra oauth weibo).each { |lib| require lib }
enable :sessions
Weibo::Config.api_key = "3926176445"
Weibo::Config.api_secret = "651156f9b786fdc0781376f3b121f359"
get '/' do
"<a href='/connect'>授权,搜索公交站点信息</a>"
end
@dongyuwei
dongyuwei / search_sina_contacts.rb
Created November 16, 2011 08:24
自动登陆erp,搜索公司同事通讯录信息
#! /usr/bin/ruby
#author [email protected]
%w(rubygems mechanize iconv).each{|lib| require lib}
def auto_search(name,password,keyword)
m = Mechanize.new
m.get('http://cas.erp.sina.com.cn/cas/login?ext=&service=http://searchemp.erp.sina.com.cn/login02.asp') do |page|
my_page = page.form_with(:name => 'login_form') do |f|
f.username = name
@dongyuwei
dongyuwei / test-em-channel-pubsub.rb
Created November 29, 2011 14:16
em-channel for pub-sub
require 'rubygems'
require 'eventmachine'
EM.run{
channel = EM::Channel.new
sid = channel.subscribe{ |topic,msg| p [topic, msg] }
channel.push(['topic',{'key1'=>'value1'}])
channel.push({'topic'=>'test','msg'=>{'a'=>'b'}})
channel.unsubscribe(sid)
EM.stop
}
@dongyuwei
dongyuwei / query-gmail-dns.rb
Created December 5, 2011 13:26
query-gmail-dns
require 'rubygems'
require "em-udns"
EM.run do
EM::Udns.nameservers = "8.8.8.8"
resolver = EM::Udns::Resolver.new
EM::Udns.run resolver
query = resolver.submit_A "gmail.com"
@dongyuwei
dongyuwei / phonegap-jquerymobile.js
Created December 16, 2011 09:41
解决jquerymobile用phonegap打包后后退导航失效问题
document.addEventListener("deviceready", function(){
var initUrl = location.href;
if (Device.platform === 'Android') {
//阻止按后退按钮就退出程序
navigator.app.overrideBackbutton(true);
}
/*解决jquerymobile用phonegap打包后后退导航失效问题*/
document.addEventListener("backbutton", function(){
@dongyuwei
dongyuwei / jsdom-test.js
Created January 17, 2012 08:42
jsdom-test , find github coder's link
var jsdom = require('jsdom'), console = require('console');
jsdom.env({
html: 'https://github.com/popular/forked',
scripts: [
'http://code.jquery.com/jquery-1.5.min.js'
],
done: function(errors, window) {
var $ = window.$;
console.log($('td.title > a').length);
@dongyuwei
dongyuwei / gitcoder.rb
Created January 17, 2012 08:50
find the website/blog of github top coder
require 'rubygems'
require 'nokogiri'
require 'net/http'
require 'openssl'
require 'open-uri'
class Net::HTTP
alias_method :origConnect, :connect
def connect
@dongyuwei
dongyuwei / nextTick.js
Created January 30, 2012 03:48 — forked from mmalecki/nextTick.js
process.nextTick vs setTimeout(fn, 0)
for (var i = 0; i < 1024 * 1024; i++) {
process.nextTick(function () { Math.sqrt(i) } )
}