Skip to content

Instantly share code, notes, and snippets.

View redrick's full-sized avatar
🏡
Working from home

Andrej Antas redrick

🏡
Working from home
View GitHub Profile
@redrick
redrick / rspec_rails_cheetsheet.rb
Last active October 23, 2022 21:00 — forked from nerdinand/rspec_rails_cheetsheet.rb
New expect syntax + new hash syntax and couple corrections
#Model
expect(@user).to have(1).error_on(:username) # Checks whether there is an error in username
expect(@user.errors[:username]).to include("can't be blank") # check for the error message
#Rendering
expect(response).to render_template(:index)
#Redirecting
expect(response).to redirect_to(movies_path)
@redrick
redrick / .screenrc-main-example
Last active September 3, 2017 13:06 — forked from ChrisWills/.screenrc-main-example
A nice default screenrc
# GNU Screen - main configuration file
# All other .screenrc files will source this file to inherit settings.
# Author: Christian Wills - cwills.sys@gmail.com
shell -$SHELL
# Allow bold colors - necessary for some reason
attrcolor b ".I"
# Tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
@redrick
redrick / links.rb
Last active May 9, 2017 21:24
OTRS REST API Ticket Creation setup file
@redrick
redrick / README.md
Last active February 24, 2017 09:17
RabbitMQ + PostgreSQL

install rabbitMQ:

brew install rabbitmq
brew services start rabbitmq

web interface

http://localhost:15672/
@redrick
redrick / rc
Created August 9, 2016 11:19
.ssh/rc config file macOS for screen
# Fix SSH auth socket location so agent forwarding works with screen.
if test "$SSH_AUTH_SOCK" ; then
ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock
fi
# Taken from the sshd(8) manpage.
if read proto cookie && [ -n "$DISPLAY" ]; then
if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then
# X11UseLocalhost=yes
echo add unix:`echo $DISPLAY |
@redrick
redrick / .zshrc
Created August 9, 2016 11:15
Screen SSH keys forwarding
# Predictable SSH authentication socket location.
SOCK="/tmp/ssh-agent-$USER-screen"
if test $SSH_AUTH_SOCK && [ $SSH_AUTH_SOCK != $SOCK ]
then
rm -f /tmp/ssh-agent-$USER-screen
ln -sf $SSH_AUTH_SOCK $SOCK
export SSH_AUTH_SOCK=$SOCK
fi  zsh  [unix]  100%  95/95☰ : 1
@redrick
redrick / README.md
Created March 4, 2016 20:19 — forked from derwiki/README.md
Ruby module that you can use in a `before_action` on sensitive controllers for which you'd like a usage audit trail

Adding an audit log to your Rails app

If you have any sort of administrative interface on your web site, you can easily imagine an intruder gaining access and mucking about. How do you know the extent of the damage? Adding an audit log to your app is one quick solution. An audit log should record a few things:

  • controller entry points with parameter values
  • permanent information about the user, like user_id
  • transient information about the user, like IP and user_agent

Using the Rails framework, this is as simple as adding a before_action to your admin controllers. Here’s a basic version that I’m using in production.

@redrick
redrick / README.md
Last active December 27, 2015 13:39

Commands examples

If the namespace is not used then the commands will perform on top of the default database. bundle exec rake db:create bundle exec rake db:migrate

By using the namespace we are going to use all the configuration for our alternate DB. bundle exec rake store:db:create bundle exec rake store:db:migrate

@redrick
redrick / elasticsearch_centos.sh
Last active December 26, 2015 10:19 — forked from rajraj/es.sh
cd ~
sudo yum update
sudo yum install java-1.7.0-openjdk -y
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.5.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
# require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
require 'mina/rvm' # for rvm support. (http://rvm.io)
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# repository - Git repo to clone from. (needed by mina/git)