Skip to content

Instantly share code, notes, and snippets.

@tomekw
tomekw / test_channel_spec.rb
Last active January 10, 2022 20:51
Unit testing ActionCable channels with RSpec
# app/channels/hello_channel.rb
class HelloChannel < ActionCable::Channel::Base
def say_hello(data)
times_to_say_hello = data.fetch("times_to_say_hello")
hello = "Hello, #{current_profile.name}!"
times_to_say_hello.times do
ActionCable.server.broadcast(current_profile.id, hello)
end
end
@LeCoupa
LeCoupa / redis_cheatsheet.bash
Last active March 18, 2024 09:08
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
@el-sai
el-sai / sidekiq.config
Last active October 15, 2018 02:05
Sidekiq configuration(script) for running the Sidekiq Server on the Amazon Elastic Beanstalk instance alongside the application server(Puma). Both Application Server and Sidekiq Server run on the same instance using the same resources.
# I'm using this script for a 64-bit Linux Environment running Puma with Ruby 2.3 version.
# I have tested that the Sidekiq server stops and restarts by handling the USR1 and TERM signals while deploying an app, rebooting an instance and while restarting the app server.
# Below are the steps to include this script in the EB instance and start sidekiq server on deployment.
## Include this file inside the .ebextensions folder in the application directory.
## Set up the sidekiq.yml(sidekiq concurrency, queues and other settings) file inside the config folder in the application directory.
## Make sure sidekiq pid file path and sidekiq log file path SHOULD NOT be specified in the above sidekiq.yml file.(only when using this script on EB instance)
## Set the RAILS_ENV variable in the EB configuration.
## Deploy the application to the EB instance.
## ssh into the instance and search if sidekiq is running. ( ps aux | grep sidekiq )
## Once this script is added to the EB instance, add the .ebextensions/sideki
@ngsmrk
ngsmrk / sidekiq_monitoring
Created August 11, 2014 11:51
Sidekiq queue checking via rails console
stats = Sidekiq::Stats.new
stats.queues
stats.enqueued
stats.processed
stats.failed
@agarciadelrio
agarciadelrio / active_admin.js
Created April 17, 2012 20:30
Getting active_admin panels become collapsable with non-intrusive javascript with jquery
//....add this in app/assets/javascript/active_admin.js
$(function(){
// CONFIGURE PANELS COLLAPSER
$(".panel[data-panel]").each(function(){
var $this = $(this);
var $a = $("<a href='javascript:void(null)'>").on("click",function(event){
$(this).closest(".panel").find(".panel_contents").each(function(){
$(this).slideToggle();
});
$(this).closest("h3").each(function(){