@a = 'A', @b = 'B'
Warming up --------------------------------------
s = s + @a; s = s + @b
49.000 i/100ms
s += @a; s+= @b 51.000 i/100ms
s = "#{s}#{@a}"; s = "#{s}#{@b}"
50.000 i/100ms
s.concat(@a).concat(@b)
db/schema.rb merge=railsschema |
# config/initializers/redis.rb | |
require 'redis' | |
# Disables the `flushdb` and `flushall` commands. | |
class Redis | |
module DangerousCommands | |
def flushdb | |
raise 'This is EXTREMELY DANGEROUS! If you really want to EMPTY THE ENTIRE DATABASE, do it from `redis-cli`.' | |
# You could call `super` here if you want to allow access in some circumstances. | |
end |
if ENV['REDIS_ACCESS_MODE'] == 'readonly' | |
class Redis | |
class Client | |
WRITE_COMMANDS = ::Rails.cache.data.command.map { |a| a[0] if a[2].include?('write') }.compact.to_set.freeze | |
def process(commands) | |
if commands.flatten.any? { |c| WRITE_COMMANDS.include?(c.to_s) } | |
raise NotImplementedError, "REDIS_ACCESS_MODE is set to 'readonly', disallowing writes" | |
end |
#!/bin/bash | |
USER=${1:-sebble} | |
STARS=$(curl -sI https://api.github.com/users/$USER/starred?per_page=1|egrep '^Link'|egrep -o 'page=[0-9]+'|tail -1|cut -c6-) | |
PAGES=$((658/100+1)) | |
echo You have $STARS starred repositories. | |
echo |
First, add pry-rails to your Gemfile:
https://github.com/rweng/pry-rails
gem 'pry-rails', group: :development
Then you'll want to rebuild your Docker container to install the gems
#!/usr/bin/env ruby | |
# | |
# Merge multiple git repositories into a new one. | |
# Users `git filter-branch` to rewrite paths, so that `git log` works seamlessly | |
# Built from the script at http://dominik.honnef.co/posts/2016/04/merging-git-repositories/ | |
#------------------------------------------------------------------------------ | |
new_repo = '/tmp/new_repo' | |
base = '[email protected]:customer' | |
dest_branch = 'master' |
CRYSTAL = crystal | |
UNAME = "$(shell uname -ms)" | |
LIBRARY_PATH = $(shell brew --prefix crystal-lang)/embedded/lib | |
LIBS = -levent -lpcl -lpcre -lgc -lpthread | |
LDFLAGS = -Wl,-undefined,dynamic_lookup | |
TARGET = crystal_example_ext.bundle | |
$(TARGET): crystal_example_ext.o | |
$(CC) -bundle -L$(LIBRARY_PATH) -o $@ $^ $(LIBS) $(LDFLAGS) |
class NotificationsController < ApplicationController | |
def notify_me | |
# Rails reserve a db connection from connection pool for each request, lets put it back into connection pool. | |
ActiveRecord::Base.clear_active_connections! | |
# required header | |
response.headers['Content-Type'] = 'text/event-stream' | |
sse = ActionController::Live::SSE.new(response.stream) |
Custom recipe to get OS X 10.10 Yosemite running from scratch, setup applications and developer environment. I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.
This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.
You are encouraged to fork this and modify it to your heart's content to match your own needs.