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
<VirtualHost *:80> | |
ServerName www.esdb.cn | |
ServerAlias esdb.cn | |
DocumentRoot /home/ubuntu/apps/xxx.com/current/public | |
<Directory /home/ubuntu/apps/xxx.com/current/public> | |
Options FollowSymLinks | |
AllowOverride None | |
Require all granted | |
</Directory> |
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
# graphite/statsd/grafana setup on new Amazon Linux instance | |
# add http://graphite/ to grafana as a data source | |
sudo su | |
yum update --assumeyes | |
yum install --assumeyes docker | |
service docker start | |
docker \ | |
run \ |
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
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work. | |
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0." | |
Database files have to be updated before starting the server, here are the steps that had to be followed: | |
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default | |
brew unlink postgresql | |
brew install [email protected] | |
brew unlink [email protected] | |
brew link postgresql |
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
# Currently (2017/2018) it's not possible to change the Ruby 'minor' version (eg. 2.3 => 2.4) using the web console | |
# However, it's possible using the 'awscli' tool. | |
brew install awscli # pip install awscli | |
aws elasticbeanstalk update-environment \ | |
--solution-stack-name "64bit Amazon Linux 2017.09 v2.6.1 running Ruby 2.4 (Puma)" \ | |
--environment-name "myappenv1" --region "us-east-2" \ | |
--version-label "app-1234-210000_120123" | |
# For Amazon Linux 2 |
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
# Gemfile | |
# gem "ruby-prof" | |
# gem "ruby-prof-flamegraph" | |
# gem "stackprof" | |
require "ruby-prof" | |
require "stackprof" | |
module ProfilerWrapper | |
def self.stackprof(name) |
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
result = ActiveRecord::Base.connection.execute("select * from my_shapes_table limit 1;") | |
shape = parser.parse result.values.first.last # .first row , .last column | |
RGeo::GeoJSON.encode(shape).to_json | |
# => "{\"type\":\"MultiPolygon\",\"coordinates\":[[[[...]]]]}" |
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
[database] | |
log_queries = 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
# Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations? | |
describe 'Modal' do | |
should 'display login errors' do | |
visit root_path | |
click_link 'My HomeMarks' | |
within '#login_area' do | |
fill_in 'email', with: '[email protected]' | |
fill_in 'password', with: 'test' |
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
# alternatively use benchmark/ips | |
n = 100_000 | |
data = "..." | |
Benchmark.ips do |benchmark| | |
benchmark.report("include?") do | |
n.times { data.to_s.downcase.include?('windows') } | |
end | |
benchmark.report("match?") do |
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
import traceback; [line for line in traceback.format_stack() if not 'site-packages' in line] |
OlderNewer