Skip to content

Instantly share code, notes, and snippets.

View ang3lkar's full-sized avatar

Angelos Karagkiozidis ang3lkar

View GitHub Profile
@ang3lkar
ang3lkar / backend_test.rb
Created June 27, 2016 14:59
Rails performance test setup
require 'test_helper'
require 'rails/performance_test_help'
require_relative 'support/backend_test_helper'
class BackendTest < ActionDispatch::PerformanceTest
include BackendTestHelper
attr_reader :eddard, :jaime
setup do
@ang3lkar
ang3lkar / README.md
Created March 4, 2016 14:25 — 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.

@ang3lkar
ang3lkar / .atom
Last active February 12, 2016 09:31
Editor configuration files
"*":
editor:
preferredLineLength: 120
showIndentGuide: true
tabLength: 2
whitespace:
ensureSingleTrailingNewline: true
removeTrailingWhitespace: true
@ang3lkar
ang3lkar / vim_cheatsheet.md
Created January 26, 2016 11:00 — forked from awidegreen/vim_cheatsheet.md
Vim shortcuts

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
@ang3lkar
ang3lkar / pre-push.sh
Last active December 4, 2020 16:04
Git hook scripts
#!/bin/bash
remote="$1"
url="$2"
[[ $url =~ git[@|\.]heroku.com[:|\/](.+)\.git ]]
app=${BASH_REMATCH[1]}
z40=0000000000000000000000000000000000000000
@ang3lkar
ang3lkar / boot.rb
Last active September 8, 2015 16:04 — forked from chuckbergeron/boot.rb
One Database Per Branch, Per Environment
CURRENT_BRANCH = `git status | head -1`.to_s.gsub('On branch ','').chomp
@ang3lkar
ang3lkar / rails_integration_testing.md
Last active November 15, 2020 05:41
My notes on Rails integration testing

Due to a considerable lack of rails integration testing tutorials/guides, here are my notes.

Integration environment

Much better to have a separate environment for integration tests. Follow the Rails guide to create one. Be careful to edit the session domain in the integration.rb file if necessary:

config.session_store :cookie_store, key: '_workable_session', domain: 'test.host'

If the domain is different from what your app expects, you will be losing your session across your requests.

Plugboard = Hash[*('A'..'Z').to_a.shuffle.first(20)]
Plugboard.merge!(Plugboard.invert)
Plugboard.default_proc = proc { |hash, key| key }
def build_a_rotor
Hash[('A'..'Z').zip(('A'..'Z').to_a.shuffle)]
end
Rotor_1, Rotor_2, Rotor_3 = build_a_rotor, build_a_rotor, build_a_rotor
@ang3lkar
ang3lkar / .vimrc
Last active August 29, 2015 14:15
My Vim config
syntax on
filetype indent plugin on
autocmd Filetype gitcommit setlocal spell textwidth=72
#RUN A SPECIFIC MINITEST TEST
ruby -Ilib:test test/../file_test.rb -name test_something