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 'rbconfig' | |
| module Celluloid | |
| module CPUCounter | |
| case RbConfig::CONFIG['host_os'][/^[A-Za-z]+/] | |
| when 'darwin' | |
| @cores = Integer(`sysctl hw.ncpu`[/\d+/]) | |
| when 'linux' | |
| @cores = if File.exists?("/sys/devices/system/cpu/present") | |
| File.read("/sys/devices/system/cpu/present").split('-').last.to_i+1 |
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 | |
| require "active_support/dependencies" | |
| require "irb" | |
| root = File.expand_path('../../', __FILE__) | |
| %w(lib).each do |path| | |
| ActiveSupport::Dependencies.autoload_paths << "#{root}/#{path}" | |
| 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
| # encoding: utf-8 | |
| git :init | |
| remove_file ".gitignore" | |
| file '.gitignore', <<-IGNORE | |
| *.rbc | |
| *.sassc | |
| .sass-cache | |
| capybara-*.html |
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
| syntax on | |
| set nocompatible " be iMproved | |
| filetype off " required! | |
| set number | |
| set rtp+=~/.vim/bundle/vundle/ | |
| call vundle#rc() | |
| " let Vundle manage Vundle | |
| " required! |
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 "prawn" | |
| Prawn::Docuemtn.generate("zh.pdf") do |pdf| | |
| pdf.image "./001.jpg", at: [0, 792], width: 612 | |
| pdf.start_new_page | |
| pdf.image "./002.jpg". at: [0, 792], width: 612 | |
| 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
| Function SendDeleteRequest($url) { | |
| try { | |
| $request = [Sytem.Net.WebRequest]::Create("$url") | |
| $request.Method = "DELETE" | |
| $request.GetResponse() | |
| } | |
| catch | |
| { | |
| Write-Host "Fail to send DELETE request to $url" | |
| } |
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
| server { | |
| listen 7977; | |
| server_name example.com; | |
| set_real_ip_from 127.0.0.1; | |
| real_ip_header X-Real-IP; | |
| location /ip { | |
| default_type text/plain; | |
| echo "$remote_addr"; |
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 | |
| require "mechanize" | |
| require 'logger' | |
| logger = Logger.new(STDOUT) | |
| TEST_URL = "http://baidu.com" | |
| Entry = Struct.new(:host, :port) do | |
| attr_accessor :alive |
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
| # encoding: utf-8 | |
| require "watir" | |
| email, password = ARGV[0], ARGV[1] | |
| puts "email: #{email}" | |
| puts "password: #{password}" | |
| browser = Watir::Browser.new | |
| browser.goto("http://zhe800.com") |
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 Wechat | |
| class SignatureValidator | |
| attr_accessor :token, :params | |
| def initialize(token, params) | |
| @token = token | |
| @params = params | |
| end | |
| def calculate |