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
用ssh代理来翻墙也很容易,为了避免和自己的管理账户冲突,可以新建一个ssh用户,并且禁用该用户的shell。以下是相关命令: | |
1. groupadd sshfq(增加组sshfq) | |
2. useradd -d /home/sshfq -m -g sshfq -s /bin/false sshfq (增加用户sshfq创建同名目录并属于组sshfq并禁止shell) | |
3. passwd sshfq (修改sshfq密码) | |
4.ssh -qTfnN -D 7070 [email protected] |
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 "rubygems" | |
require "oauth" | |
TQQ_CONSUMER_KEY = "9b43a5afaca04afd8eb573e673fce3f9" | |
TQQ_CONSUMER_SECRET = "dd6b3cef9a6896e373085a83cd8b74f9" | |
# 1. 获取Request Token | |
consumer = OAuth::Consumer.new(TQQ_CONSUMER_KEY, TQQ_CONSUMER_SECRET, { | |
:site => "https://open.t.qq.com", | |
:request_token_path => "/cgi-bin/request_token", |
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 'rubygems' | |
require "builder" | |
module Builder | |
class XmlBase | |
def _escape(text) | |
text | |
end | |
end | |
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
module ActiveSupport | |
module JSON | |
module Encoding | |
def self.escape(string) | |
if string.respond_to?(:force_encoding) | |
string = string.encode(::Encoding::UTF_8, :undef => :replace).force_encoding(::Encoding::BINARY) | |
end | |
json = string.gsub(escape_regex) { |s| ESCAPED_CHARS[s] } | |
json = %("#{json}") | |
json.force_encoding(::Encoding::UTF_8) if json.respond_to?(:force_encoding) |
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
- (void)reachabilityChanged:(NSNotification *)note | |
{ | |
Reachability* curReach = [note object]; | |
NSParameterAssert([curReach isKindOfClass: [Reachability class]]); | |
NetworkStatus status = [curReach currentReachabilityStatus]; | |
if (status == NotReachable) { | |
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil | |
message:@"当前没有可用网络" | |
delegate:nil |
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
*.pbxproj -crlf -diff -merge |
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 -wKU | |
require "net/http" | |
require "uri" | |
####################### Standard HTTP Request ####################### | |
def standard_http_request | |
uri = URI.parse("http://wwwgoogle.com.hk") | |
# Shortcut |
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 "rubygems" | |
require "/Library/Ruby/Gems/1.8/gems/apns-0.9.0/lib/apns" | |
################### | |
# Hosts Config | |
################### | |
# Push Notification Service: | |
# | |
# (default: gateway.sandbox.push.apple.com is) |
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 | |
# object_model/alphanumeric.rb | |
require "test/unit" | |
class String | |
def to_alphanumeric | |
gsub(/[^\w\s]/,'') | |
end | |
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
#!/usr/bin/env ruby | |
class C | |
end | |
p C.ancestors # => [C, Object, Kernel, BasicObject] | |
# => [C, Object, Kernel] in Ruby 1.8 | |
p Class.ancestors # => [Class, Module, Object, Kernel, BasicObject] | |
# => [Class, Module, Object, Kernel] in Ruby 1.8 |