Skip to content

Instantly share code, notes, and snippets.

View martinx's full-sized avatar

Martin Xu martinx

View GitHub Profile
@martinx
martinx / SearchSuggestion.rb
Created March 15, 2013 23:23
基于redis的SearchSuggestion
class SearchSuggestion
def self.terms_for(prefix)
return if prefix.blank?
puts "prefix:#{prefix}"
prefix_array = prefix.split
puts prefix_array
unless prefix_array.empty?
$redis.zinterstore "$tmp",prefix_array
terms = $redis.zrevrange "$tmp", 0, 4
@martinx
martinx / Cache Logs
Created March 14, 2013 20:53
nginx purge cache logs
GET /data/attachment/audioimg/8/143410hpzqo0oo5o2oimxm.jpg HTTP/1.1 - 15/Mar/2013:04:48:03 +0800 200 0.000 21863 21863 58.33.250.146 - - - - - iListen/1.5.01290 CFNetwork/609.1.4 Darwin/13.0.0sendfileon
GET /data/attachment/audioimg/0/141236mm3tlwv1wxrwhswr.jpg HTTP/1.1 - 15/Mar/2013:04:48:03 +0800 200 0.000 16130 16130 58.33.250.146 - - - - - iListen/1.5.01290 CFNetwork/609.1.4 Darwin/13.0.0sendfileon
GET /data/attachment/audioimg/0/142535uk7ee7uuuv6f7mh7.jpg HTTP/1.1 - 15/Mar/2013:04:48:03 +0800 200 0.000 26645 26645 58.33.250.146 - - - - - iListen/1.5.01290 CFNetwork/609.1.4 Darwin/13.0.0sendfileon
GET /data/attachment/audioimg/7/1705281f9seimc95gz544d.jpg HTTP/1.1 - 15/Mar/2013:04:48:04 +0800 200 1.440 24675 24675 112.78.65.211 - - - - - Dalvik/1.6.0 (Linux; U; Android 4.1.1; MI 2 MIUI/JLB12.0)sendfileon
GET /data/attachment/audio/0/143734o88bfyydy9aka5d8.audio HTTP/1.1 - 15/Mar/2013:04:48:04 +0800 206 44.649 1240599 1240599 87.0.131.142 - - - - - \xE6\x95\x85\xE4\xBA\x8B\xE5\x8F\xA3\xE8\xA2\x8B\xE5\x90\x
class AdminUser < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :login, :password, :password_confirmation, :remember_me
attr_accessor :login
require 'rubygems'
require 'coderay'
tokens = CodeRay.scan <<-'CODE', :ruby
puts %[Hello, world!]
puts "Here\'s some #@@weird #{ { :code => "for you" } }"
CODE
print tokens.div(:line_numbers => :table, :css => :class)