Skip to content

Instantly share code, notes, and snippets.

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

dongyuwei dongyuwei

💭
天天听儿歌
View GitHub Profile
require 'rubygems'
require 'redis'
def main(opts={})
r = Redis.new(opts)
um = 0
while true do
newum = r.info[:used_memory]
if newum != um && um != 0
diff = newum.to_i-um.to_i
@dongyuwei
dongyuwei / gmail-feed-ruby
Created July 9, 2010 09:52
get gmail's new email feeds,write in ruby
#! /usr/bin/ruby
#author newdongyuwei@gmail.com
require 'uri'
require 'net/http'
require 'net/https'
require 'rexml/document'
#https://user:password@mail.google.com/mail/feed/atom
gmail_feed_url = "https://mail.google.com/mail/feed/atom"
@dawsontoth
dawsontoth / contextMenusInTiDesktop.html
Created March 4, 2011 17:28
Context menus in Titanium Desktop, a quick sample.
<html>
<body>
<style type="text/css">
body {
-webkit-user-select: auto !important;
}
</style>
Here is some text.
<br />
<textarea rows="10" cols="70">
@saga
saga / gist:1098601
Created July 22, 2011 00:54
lua method_missing
t = {}
meta = {__index =
function(_, idx)
return function(...)
-- ... will be table type "arg"
print(idx, arg[1])
end
end}
setmetatable(t, meta)
@gauteh
gauteh / .gitignore
Created November 5, 2011 23:19
python script for starring and liking google reader items from exported json (used to migrate starred and liked items), check http://gaute.vetsj.com/greader for web app version.
*.json
*.xml
token*
oauth*
@mishoo
mishoo / drop-debug.js
Created November 11, 2011 07:45
Drop debug(...) calls using PatternJS
var U = require("uglify-js");
var fs = require("fs");
var sys = require("sys");
var code = fs.readFileSync("/tmp/test.js", "utf8");
// 1. parse
var ast = U.parser.parse(code);
// 2. UglifyJS compress
@jwo
jwo / deploy.rb
Created January 2, 2012 19:58
Capistrano with Unicorn Reloading
set :application, "yyyyyyyyyyy"
set :repository, "here-be-your-githubs"
set :scm, :git
set :branch, "master"
set :user, "xxxxxxxx"
set :scm_verbose, true
default_run_options[:pty] = true
set :deploy_via, :remote_cache
ssh_options[:forward_agent] = true
@kwilczynski
kwilczynski / em-test.rb
Created January 31, 2012 12:17
EM.epoll, EM#fork_reactor and signals oddities ...
require 'rubygems'
require 'eventmachine'
children = []
Signal.trap('SIGINT') do
EventMachine.next_tick { EventMachine.stop_event_loop }
end
Signal.trap('EXIT') do
# Configs
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
config secondsBetweenRepeat 0.1
config checkDefaultsOnLoad true
config focusCheckWidthMax 3000
config keyboardLayout qwerty
config windowHintsShowIcons true
config windowHintsIgnoreHiddenWindows false
@trevordixon
trevordixon / Routes.js
Last active May 9, 2016 16:59
Very simple Express-like routing for PhantomJS
var Routes = (function() {
var _ = {}, ctor = function(){};
_.bind = function bind(func, context) {
var bound, args, slice = Array.prototype.slice;
args = slice.call(arguments, 2);
return bound = function() {
if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments)));
ctor.prototype = func.prototype;
var self = new ctor;
var result = func.apply(self, args.concat(slice.call(arguments)));