Tested in Mac OS X: super == command
Open/Goto
- super+t: go to file
- super+ctrl+p: go to project
- super+r: go to methods
| require 'net/http' | |
| require 'uri' | |
| def get_html_content(requested_url) | |
| url = URI.parse(requested_url) | |
| full_path = (url.query.blank?) ? url.path : "#{url.path}?#{url.query}" | |
| the_request = Net::HTTP::Get.new(full_path) | |
| the_response = Net::HTTP.start(url.host, url.port) { |http| | |
| http.request(the_request) |
| # Extend hashes by adding one method that allows you to split a hash into an array of equal-sized hashes. | |
| # Filter items to be included in the result by adding a selecting block that returns true | |
| # if the key/value is to be kept. | |
| # Per the usage example, return values are not ordered unless you're using Ruby 1.9 | |
| # usage: | |
| # a = {1 => 'a', 2 => 'b', 3 => 'c', 4 => 'd', 5 => 'e'} | |
| # a.split_into(3) {|k,v| k.instance_of?(Integer)} |
| install PostgreSQL 9 in Mac OSX via Homebrew | |
| Mac OS X Snow Leopard | |
| System Version: Mac OS X 10.6.5 | |
| Kernel Version: Darwin 10.5.0 | |
| Install notes for PostgreSQL 9.0.1 install using Homebrew: | |
| sh-3.2# brew install postgresql |
| RVM home page: http://rvm.beginrescueend.com | |
| Install RVM | |
| ------------ | |
| See http://rvm.beginrescueend.com/rvm/install/ | |
| bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) | |
| Install rvm for all users |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
| <title>javaScript正则表达式提取字符串中字母、数字、中文</title> | |
| </head> | |
| <body> | |
| <input type="text" id="oText" value="李秉骏的常用代号是96347,英文名字是CashLee噢" size=100><br/> | |
| <input type="button" value="number" onclick="get_character_you_want(this);"> |
| ActiveAdmin::Dashboards.build do | |
| # Add this section in your dashboard... | |
| section "Background Jobs" do | |
| now = Time.now.getgm | |
| ul do | |
| li do | |
| jobs = Delayed::Job.where('failed_at is not null').count(:id) | |
| link_to "#{jobs} failing jobs", admin_jobs_path(q: {failed_at_is_not_null: true}), style: 'color: red' | |
| end |
| class Alert < ActiveRecord::Base | |
| belongs_to :alertable, :polymorphic => true | |
| end | |
| class Region < ActiveRecord::Base | |
| has_many :alerts, :as => :alertable | |
| end | |
| # Call scopes directly from your URL params: | |
| # | |
| # @products = Product.filter(params.slice(:status, :location, :starts_with)) | |
| module Filterable | |
| extend ActiveSupport::Concern | |
| module ClassMethods | |
| # Call the class methods with names based on the keys in <tt>filtering_params</tt> | |
| # with their associated values. For example, "{ status: 'delayed' }" would call |
| class Email < ActiveRecord::Base | |
| # Nope, it's not RFC compliant. F*** that regex. | |
| # http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html | |
| EmailRegex = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i.freeze | |
| before_validation :strip_spaces | |
| # Public: The email address. | |
| # column :address |