Skip to content

Instantly share code, notes, and snippets.

View kivanio's full-sized avatar
🏠
Working from home

Kivanio Barbosa kivanio

🏠
Working from home
View GitHub Profile
//....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(){
@import "select2";
@kivanio
kivanio / _readme.md
Last active August 29, 2015 14:16 — forked from tinynumbers/_readme.md

Saving ActiveAdmin filters between requests

This shows one technique for preserving filters on index pages for ActiveAdmin resources, without having to patch the ActiveAdmin core.

It restores any previously-used filters whenever the index page is rendered for a resource, unless the current request is an actual application of new filters. It also properly handles the clear-filters button (via a synchronous Ajax request that happens immediately before the normal filter form processing).

Yes, it's a bit of a hack, but it has worked well for me so far.

Usage

# http://helabs.com.br/blog/2014/05/28/quick-add-and-quick-edit-on-active-admin/
# room.rb
action_item only: :index do
link_to 'Quick add', admin_room_quick_add_path, class: 'fancybox', data: { 'fancybox-type' => 'ajax' }
end
controller do
def quick_add
@room = Room.new
simple-form
-----------
= f.input :country_id, :as => :select, :collection => Country.priority, include_blank: false, :label => "Country :", :priority => [ "United States", "Canada" ]
= f.input :state_id, :label => "State :" do
= f.grouped_collection_select :state_id, Country.order(:name), :states, :name, :id, :name, include_blank: false
@formStateSelect = (form_name) ->
$("form:regex(id, .*#{form_name}.*)").each (index, element) =>
#!/bin/sh
set -e
set -x
if ! mount -t cd9660 /dev/cd0 /mnt; then
echo 'Must run Virtual Machines > Install VMware Tools first' >&2
exit 1
fi
VMWARE_TOOLS=/tmp/vmware-tools-distrib
require "net/http"
def start_server
# Remove the X to enable the parameters for tuning.
# These are the default values as of Ruby 2.2.0.
@child = spawn(<<-EOC.split.join(" "))
XRUBY_GC_HEAP_FREE_SLOTS=4096
XRUBY_GC_HEAP_INIT_SLOTS=10000
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0
  1. General Background and Overview
class HealthCheck
class Middleware
def initialize(application)
@application = application
end
def call(environment)
if environment['PATH_INFO'] == '/health-check'
if HealthCheck.healthy?
ip_address_whitelist:
- 127.0.0.1
- 1.2.3.4
- 5.6.7.8
whitelisted_pages:
- /assets/.*
- /
- /login