Skip to content

Instantly share code, notes, and snippets.

View zorab47's full-sized avatar
⌨️

Charles Maresh zorab47

⌨️
View GitHub Profile
# Add the following lines to .git/hooks/prepare-commit-msg and
# ensure it is executable.
# Prefix the message with the branch's name e.g. "#STORY-23: "
# The reason the branch line is commented is to prevent accidental
# commits.
BRANCH=`git branch | grep '^*' | sed -e 's/^\* //'`
MESSAGE=`cat "$1"`
echo "#$BRANCH: $MESSAGE" > "$1"
#!/bin/sh
COMMAND="magick"
for FILE in *.png
do
echo "Processing $FILE"
echo $COMMAND $FILE
done
@zorab47
zorab47 / rubygem installer
Created August 2, 2010 19:05
Install Rubygems
!/bin/bash
cd /tmp
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
tar xzf rubygems-1.3.7.tgz
cd rubygems-1.3.7
sudo ruby ./setup.rb
@zorab47
zorab47 / rails.watchr
Created November 16, 2010 14:00
Rails Watchr
def run_all_tests
# see Rakefile for the definition of the test:all task
system( "rake -s test" )
end
def run(cmd)
puts(cmd)
system(cmd)
end
@zorab47
zorab47 / offline_template.rb
Created November 22, 2011 16:18
Offline Template for Rails 2.3.x
# Public: Template to render views outside the context of a controller.
#
# Useful for rendering Rails 2.3.x views in rake tasks or background jobs when a
# controller is unavailable.
#
# Examples
#
# template = OfflineTemplate.new(:users)
# template.render("users/index", :layout => false, :locals => { :users => users })
#
@zorab47
zorab47 / deploy.rb
Created October 10, 2012 18:24
Capistrano task to precomile assets locally, if necessary
namespace :deploy do
namespace :assets do
task :precompile, :roles => :web, :except => { :no_release => true } do
assets_path = File.join(release_path, "public/assets")
assets_empty = capture("ls -x #{assets_path}").length == 0
has_current_release = capture("if [ -d #{current_path} ]; then echo -n \"yes\"; fi") == "yes"
compile_assets = false
@zorab47
zorab47 / resource_collection_spec.rb
Created August 29, 2013 15:40
Failing spec for ActiveAdmin::ResourceCollection
require 'spec_helper'
describe ActiveAdmin::ResourceCollection do
let(:application) { ActiveAdmin::Application.new }
let(:namespace) { ActiveAdmin::Namespace.new(application, :admin) }
context ".add" do
let(:resource) { ActiveAdmin::Resource.new(namespace, AdminUser) }
let(:resource_renamed) { ActiveAdmin::Resource.new(namespace, AdminUser, as: "SuperAdminUser") }
# RSpec CanCan matcher.
#
# When testing your user must have an id otherwise a nil foreign key will
# match on new records.
#
# Examples
#
# describe User do
# subject { User.create! }
#
# Adaptation of the VMware adapters fix script by Oisin Grehan:
# http://www.nivot.org/post/2008/09/05/VMWareVMNETAdaptersTriggeringPublicProfileForWindowsFirewall.aspx
# see http://msdn2.microsoft.com/en-us/library/bb201634.aspx
#
# *NdisDeviceType
#
# The type of the device. The default value is zero, which indicates a standard
# networking device that connects to a network.
#
@zorab47
zorab47 / active_admin_actions.rake
Last active October 12, 2022 15:34
Rake task to list ActiveAdmin resource and page actions
task :active_admin_actions => :environment do
skip_resources = [ 'Dashboard' ]
namespace = ActiveAdmin.application.namespace(:admin)
pages = namespace.resources.select { |r| r.is_a? ActiveAdmin::Page }
resources = namespace.resources.select { |r| r.respond_to? :resource_class }
resource_actions =
resources.each_with_object({}) do |resource, actions|