Skip to content

Instantly share code, notes, and snippets.

View ang3lkar's full-sized avatar

Angelos Karagkiozidis ang3lkar

View GitHub Profile
@ang3lkar
ang3lkar / gist:9971571
Last active August 29, 2015 13:58
Various snippets
# RUN MULTIPLE SERVERS LOCALLY
rails s
rails s -p 3001 -P tmp/pids/server2.pid
# RUN A SPECIFIC METHOD IN A MINITEST CLASS
ruby -Ilib:test test/models/widget_test.rb -n test_refresh
# PRETTY LOOP PRINT
Encoding.list.each{|enc|
begin
@ang3lkar
ang3lkar / hash_to_checksum
Created July 17, 2014 09:11
Hash to checksum
# Thanks to tenderlove on Peepcode play by play
require 'digest/md5'
def fetch username
records = JSON.parse get username
records.each do |hash|
checksum = Digest::MD5.hexdigest Marshal.dump(hash)
hash['checksum'] = checksum
end
#RUN A SPECIFIC MINITEST TEST
ruby -Ilib:test test/../file_test.rb -name test_something
@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
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 / 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.

@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 / 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 / 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 / .atom
Last active February 12, 2016 09:31
Editor configuration files
"*":
editor:
preferredLineLength: 120
showIndentGuide: true
tabLength: 2
whitespace:
ensureSingleTrailingNewline: true
removeTrailingWhitespace: true