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
cask 'dash2' do | |
version '2.2.6' | |
sha256 'a7de5e00528611f86d1024164b1b5d536ce039344b6ca3c211918c7458f7e412' | |
url "https://kapeli.com/downloads/v#{version.major}/Dash.zip" | |
name 'Dash' | |
homepage 'https://kapeli.com/dash' | |
auto_updates true |
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
class Klass < ActiveRecord::Base | |
# | |
# Attributes | |
# | |
# | |
# Constants & Enums | |
# |
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
# fixed: Elasticsearch::Transport::Transport::Errors::ServiceUnavailable: [503] | |
# https://hugotunius.se/2015/06/22/elasticsearch-falkiness-in-tests.html | |
# https://medium.com/@thetron/dealing-with-503-errors-when-testing-elasticsearch-integration-in-rails-ec7a5f828274#.ex6quza03 | |
# https://github.com/elastic/elasticsearch-ruby/issues/181#issuecomment-112781924 | |
# spec/support/elasticsearch_cleaner.rb | |
RSpec.configure do |config| | |
config.before(:each, :es => true) do | |
ElasticsearchModel.create_index!(:force => true) | |
ElasticsearchModel.client.cluster.health(wait_for_status: 'yellow') |
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
# This is a skeleton for testing models including examples of validations, callbacks, | |
# scopes, instance & class methods, associations, and more. | |
# Pick and choose what you want, as all models don't NEED to be tested at this depth. | |
# | |
# I'm always eager to hear new tips & suggestions as I'm still new to testing, | |
# so if you have any, please share! | |
# | |
# @kyletcarlson | |
# | |
# This skeleton also assumes you're using the following gems: |
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
[General] | |
loglevel = notify | |
[Proxy] | |
Proxy = custom, 1.2.3.4, 443, rc4-md5, password, http://surge.run/SSEncrypt.module | |
[Rule] | |
DOMAIN-KEYWORD,google,Proxy,force-remote-dns | |
DOMAIN-KEYWORD,facebook,Proxy,force-remote-dns | |
DOMAIN-KEYWORD,youtube,Proxy,force-remote-dns |
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 Foo | |
def bar | |
puts 'foobar' | |
end | |
end | |
class IncludeModule | |
include Foo | |
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
// JavaScript Version | |
uuid = function(e) { | |
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { | |
var r = Math.random() * 16 | 0, v = (c == 'x' ? r : (r & 0x3 | 0x8)); | |
return v.toString(16); | |
}); | |
} |
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
# => 2007-11-19T08:37:48-06:00 Safari下只能Parse这种格式的时间 | |
Time.now.strftime("%FT%T%:z") |
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
$sure = false | |
t = Thread.new { | |
begin | |
# nada | |
ensure | |
sleep | |
$sure = true | |
# cleanup all the things | |
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
# source: http://hashrocket.com/blog/posts/bridging-activerecord-and-mongoid | |
module Extensions::ActiveRecord::HasManyDocuments | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def has_many_documents(association_name, options = {}) | |
class_eval %< | |
def #{association_name} | |
#{association_name.to_s.singularize.classify}.where(#{name.underscore}_id: id) | |
end |
NewerOlder