Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
defined_indexes = Model.index_specifications.map { |s| s.fields.map(&:to_s) }; | |
existing_indexes = Model.collection.indexes.map { |i| i['key'].keys }; | |
missing_indexes = defined_indexes - existing_indexes | |
# => [] | |
extra_indexes = existing_indexes - defined_indexes - [['_id']] | |
# => [] | |
################################################################################# |
# gem install benchmark-ips | |
require 'benchmark/ips' | |
Benchmark.ips do |x| | |
x.warmup = 0 | |
x.report("threads") do | |
thread = Thread.new { puts 'thread' } | |
thread.join | |
end |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
source 'https://rubygems.org' | |
gem 'puma' | |
gem 'sinatra' | |
gem 'faraday' | |
gem 'typhoeus' | |
group :development do |
class MemoryMiddleware | |
ENV_REQUEST_PATH = 'REQUEST_PATH'.freeze | |
ENV_PUMA_AFTER_REPLY = 'rack.after_reply'.freeze | |
LOGGER = Logger.new('/tmp/memory.log'.freeze) | |
def initialize(app) | |
@app = app | |
end | |
def call(env) |
(export LC_ALL="ru" ; awk '{split($0,l,";") ; print l[2],l[3],l[4]}' ~/.zsh_history | sort | uniq -c | sort -nr | head -n 20) |
require "net/http" | |
require "socket" | |
socket = "/tmp/portal2.sock" | |
sock = Net::BufferedIO.new(UNIXSocket.new(socket)) | |
request = Net::HTTP::Get.new("/") | |
request.exec(sock, "1.1", "/") | |
begin |
# HACK to enable using protected methods from Rails 4.2 and initial states as default attributes for ActiveRecord | |
module StateMachine | |
module Integrations | |
module ActiveModel | |
public :around_validation | |
end | |
module ActiveRecord | |
public :around_save |
This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.
###Array ####Definition:
# http://stackoverflow.com/questions/14972253/simpleform-default-input-class | |
# https://github.com/plataformatec/simple_form/issues/316 | |
# Use this setup block to configure all options available in SimpleForm. | |
SimpleForm.setup do |config| | |
config.boolean_style = :nested | |
config.wrappers :bootstrap3, tag: 'div', class: 'form-group', error_class: 'has-error', | |
defaults: { input_html: { class: 'default_class' } } do |b| | |