Skip to content

Instantly share code, notes, and snippets.

View Epigene's full-sized avatar

Augusts Bautra Epigene

View GitHub Profile
@Epigene
Epigene / rails_admin_authorization.md
Last active September 23, 2015 10:23
Workflow for setting up authorization levels for rails_admin

Authorization for RailsAdmin

Setup

gem "cancancan", '~> 1.12.0'
rails g cancan:ability

Configuration

@Epigene
Epigene / paymode_statistics_hash.rb
Created September 22, 2015 07:34
@pipeline.build_paymode_statistics_hash("2015-01-01", "2015-12-12")
{
#<PipelinePaymentSystem:0x007f885982bed0> { :id => 111, :status => "active", :system_type => "base", :amount => 2, :pipeline_id => 6, :payment_system_id => 6, :currency_id => 1, :created_at => Mon, 21 Sep 2015 12:33:41 EEST +03:00, :updated_at => Mon, 21 Sep 2015 12:33:42 EEST +03:00, :app_offer_id => nil, :direct_sell_type => "levels2_only", :design_file => nil } => {
:started => 4,
:paid => 0,
:cr => 0.0,
:retry_seen => 0,
:retry_seen_percent => 0.0,
:retried => 0,
:retried_percent => 0,
:paid_in_retry => 0,
@Epigene
Epigene / poro_extension.rb
Last active September 15, 2015 13:37
Rails initializer for quick monkeypatches and additions to basic ruby classes
class Numeric
# 200.01.safe_percent(50) #=> 25.%
def safe_percent(part)
if self > 0
if part >= 0
return 100*part.to_f/self.to_f
else
raise "Sorry, no negative numbers please"
end
elsif self == 0
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@Epigene
Epigene / database.yml
Created August 17, 2015 09:22
database.yml example
base: &base
adapter: postgresql
encoding: utf-8
pool: 5
username: augusts
database: sha
password:
development:
<<: *base
@Epigene
Epigene / UbuntuRedis.md
Last active August 15, 2018 10:17
Install Redis on your Production Ubuntu

Install deps

sudo apt-get update
sudo apt-get install -y build-essential tcl8.5

Get code

cd /tmp
@Epigene
Epigene / RailsAppDeployment.md
Last active October 27, 2015 15:02
Rails App deployment setup

Make Rails App deployable to ubuntu droplet with mina

Mina

Add gems

group :development do
  gem 'mina' # New deploy candidate
@Epigene
Epigene / new_rails_app_init.md
Last active October 15, 2015 09:04
How to init a new Rails 4.2 app in mid-2015

Replace <project> with myapp and you are good to go.

# Make new gemset of latest ruby found at https://www.ruby-lang.org/en/downloads/
$ rvm install 2.2.2
$ rvm use 2.2.2@<project> --create
$ gem install bundler
$ gem install rails

# Init rails app
@Epigene
Epigene / DevEnvironmentSetup.md
Last active February 11, 2016 07:15
RubyOnRails Dev Environment setup on Mac

The Stack

  1. Atom Editor
  2. iTerm2 + Fish2
  3. Spark
  4. Karabiner + Seil + LatvianHash
  5. Postgres app
  6. Dashlane
  7. Flint
  8. Xee
@Epigene
Epigene / gist:47c059a825acd4445e61
Created June 27, 2015 12:54
First Data FDL response (error) codes
RESPONSE_CODES = {
"000" => "Approved",
"001" => "Approved, honour with identification",
"002" => "Approved for partial amount",
"003" => "Approved for VIP",
"004" => "Approved, update track 3",
"005" => "Approved, account type specified by card issuer",
"006" => "Approved for partial amount, account type specified by card issuer",
"007" => "Approved, update ICC",
"100" => "Decline (general, no comments)",