Skip to content

Instantly share code, notes, and snippets.

@djo
djo / deploy.rb
Last active December 21, 2023 07:08
Rails, Nginx, XSendfile, and X-Accel-Mapping
# Symlink the shared protected folder
run "ln -nfs #{shared_path}/protected #{latest_release}/protected"
@djo
djo / boot.rb
Created May 15, 2014 08:41
Setup Syck YAML engine in Ruby 2, Rails, DelayedJob
require 'rubygems'
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
# YAML Syck engine support was dropped in Ruby 2.0 and it's available only by a gem 'syck'.
# Some gems (delayed_job[1] for instance) have YAML extensions depending on the engine.
# Switching to the Syck engine should be done in boot.rb before loading all gems in application.rb:
@djo
djo / trace_func.rb
Created November 14, 2014 13:37
Handle ruby trace
proc_object = proc do |event, file, line, id, binding, klass|
puts "#{event} in #{file}/#{line} #{id} #{klass}"
end
set_trace_func(proc_object)
@djo
djo / build.sbt.md
Last active August 29, 2015 14:14
Resolve conflicts in Apache Spark with Parquet format

Conflicts in the sbt dependencies when adding parquet-format:

java.lang.RuntimeException: deduplicate: different file contents found in the following:
path-to-cache/org.slf4j/slf4j-api/jars/slf4j-api-1.7.9.jar:META-INF/maven/org.slf4j/slf4j-api/pom.properties
path-to-cache/com.twitter/parquet-format/jars/parquet-format-2.2.0-rc1.jar:META-INF/maven/org.slf4j/slf4j-api/pom.properties

To resolve it exclude slf4j-api/pom.properties from parquet-format package:

@djo
djo / run.sh
Last active January 27, 2020 04:35
Handling of UNIX-signals in Erlang/Elixir is not supported, this script provides start-stop management with handling TERM signal for Docker installation.
#!/usr/bin/env bash
set -x
term_handler() {
echo "Stopping the server process with PID $PID"
erl -noshell -name "term@127.0.0.1" -eval "rpc:call('app@127.0.0.1', init, stop, [])" -s init stop
echo "Stopped"
}
trap 'term_handler' TERM INT