This file contains 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
# -*- coding: utf-8 -*- | |
require 'nokogiri' | |
require 'open-uri' | |
require 'pry' | |
doc = Nokogiri::HTML(open('http://resys.51qiangzuo.com/')) | |
a = doc.xpath('//table[@class="attendee_list"]/tr/td').grep(/公司/).map{|a| a.text.gsub(/公司:\s*/,"")} | |
num = {} | |
list = { | |
"土豆" => "土豆网", |
This file contains 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 'optparse' | |
options = {} | |
OptionParser.new do |opts| | |
opts.banner = "Usage: #{$0} -r JID -m content" | |
opts.on('-m', '--message MESSAGE','Message to be sent') do |m| | |
options[:message] = m | |
end |
This file contains 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
plugins: | |
sitemap_generator: # all optional | |
file_name: sitemap.xml | |
exclude_id: | |
- search.html | |
- pages.html | |
change_frequency_custom_name: changefreq | |
priority_custom_variable_name: priority |
This file contains 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
# -*- encoding : utf-8 -*- | |
## | |
# Apple 类, 只有一个属性, 叫做重量 (@weight) | |
# Apple 还有一个类属性, 叫做苹果数量 (@@count) | |
class Apple | |
@@count = 0 | |
## | |
# 我是类方法, 直接在 Apple 上面调用我就行了 | |
def self.count |
This file contains 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 python | |
# coding: UTF-8 | |
import re | |
import time | |
DHCPD_LEASES_FILE="/var/lib/dhcpd/dhcpd.leases" | |
# read dhcpd_leases file and match all ip,mac pair, and convert to dict type to store | |
dhcp_leases = open(DHCPD_LEASES_FILE,"r").read() |
This file contains 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
namespace :deploy do | |
## set max_hosts 20 or via env | |
set :max_hosts, ENV['MAXHOSTS'] || 20 | |
## set max_hosts on update_code | |
task :update_code, :except => { :no_release => true }, :max_hosts => "#{max_hosts}" do | |
logger.info "\e[0;31;1mNOTICE:\e[0m Pulling repo from #{repository}: max_hosts => '#{max_hosts}'" | |
on_rollback { run "rm -rf #{release_path}; true" } | |
strategy.deploy! | |
finalize_update |
This file contains 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
PREFIX="/usr/local" | |
RBENV_PREFIX="$PREFIX/rbenv" | |
BIN_PATH="$PREFIX/bin" | |
RBENV_GROUP="rbenv" | |
umask 002 | |
## Install rbenv, ruby-build and rbenv-gem-rehash | |
git clone git://github.com/sstephenson/rbenv.git $RBENV_PREFIX |
This file contains 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
default["ops-oob"]["rbenv_tar"] = "rbenv_6u2.tar.gz" |
This file contains 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
# config/deploy.rb | |
namespace :deploy do | |
desc "check local vendor/cache" | |
task :bundled_package do | |
run_locally do | |
unless test "[[ -d #{File.expand_path("../../vendor/cache", __FILE__)} ]]" | |
error "please `bundle package --all` first!" | |
raise StandardError | |
end |
This file contains 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 Gem | |
class << self | |
## | |
# Returns full path of previous but one directory of dir in path | |
# E.g. for '/usr/share/ruby', 'ruby', it returns '/usr' | |
def previous_but_one_dir_to(path, dir) | |
split_path = path.split(File::SEPARATOR) | |
File.join(split_path.take_while { |one_dir| one_dir !~ /^#{dir}$/ }[0..-2]) |
OlderNewer