- Rails 7.0.2
- stimulus js
- importmaps
- dropzone.js
- direct upload ActiveStorage
This is simple implementation of technologies in hobby project of mine built in Rails7 where I need direct upload to S3.
This is simple implementation of technologies in hobby project of mine built in Rails7 where I need direct upload to S3.
// Implementation in ES6 | |
function pagination(c, m) { | |
var current = c, | |
last = m, | |
delta = 2, | |
left = current - delta, | |
right = current + delta + 1, | |
range = [], | |
rangeWithDots = [], | |
l; |
For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.
Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon
with HyperThreading enabled, but it can work without problem on slower machines.
You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.
Most of the time simple output statements using warn
, raise
, or a logger will help you find your issue. But sometimes you need the big guns, and that means ruby-debug
.
The ruby-debug
package has had some rocky times during the transition from Ruby 1.8.7 to 1.9.2 and beyond. But now, finally, the debugger is reliable and usable.
function KnowledgeMapInitGlobals() { | |
window.KnowledgeMapGlobals = { | |
colors: { | |
blue: "#0080C9", | |
green: "#8EBE4F", | |
red: "#E35D04", | |
gray: "#FFFFFF" | |
}, |
require 'amqp' | |
module HiringThingEM | |
def self.start | |
if defined?(PhusionPassenger) | |
PhusionPassenger.on_event(:starting_worker_process) do |forked| | |
# for passenger, we need to avoid orphaned threads | |
if forked && EM.reactor_running? | |
EM.stop | |
end | |
Thread.new { |
#!/usr/bin/env ruby | |
require 'logger' | |
require 'rest_client' | |
$stdout.sync = true | |
$stdin.sync = true | |
path = "/usr/local/var/log/ejabberd/auth.log" | |
file = File.open(path, File::WRONLY | File::APPEND | File::CREAT) |
# Run me with: | |
# | |
# $ nginx -p /path/to/this/file/ -c nginx.conf | |
# | |
# All requests are then routed to authenticated user's index, so | |
# | |
# GET http://user:password@localhost:8080/_search?q=* | |
# | |
# is rewritten to: | |
# |
# Add this to the end of your development.rb and add | |
# | |
# gem 'pry' | |
# | |
# to your Gemfile and run bundle to install. | |
silence_warnings do | |
begin | |
require 'pry' | |
IRB = Pry |