Skip to content

Instantly share code, notes, and snippets.

View kolosek's full-sized avatar

Nebojsa Zoric kolosek

View GitHub Profile
@kolosek
kolosek / application.css
Created January 25, 2015 08:04
Application layout for rails girls
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require_tree .
*/
body {
background-color: #4B7399;
@kolosek
kolosek / rspec-examples
Created February 13, 2015 16:12
Rspec relation tests
Subscription
factories
should have :subscription factory
should assign the product price from the product record
should have :active_subscription factory
should have :cancelled_subscription factory
:active_subscription
status
should == "active"
:cancelled_subscription
@kolosek
kolosek / finance.rb
Last active August 29, 2015 14:15 — forked from mattetti/gist:1015948
Excel calculator
module Excel
module Formulas
def pmt(rate, nper, pv, fv=0, type=0)
((-pv * pvif(rate, nper) - fv ) / ((1.0 + rate * type) * fvifa(rate, nper)))
end
def ipmt(rate, per, nper, pv, fv=0, type=0)
p = pmt(rate, nper, pv, fv, 0);
ip = -(pv * pow1p(rate, per - 1) * rate + p * pow1pm1(rate, per - 1))
(type == 0) ? ip : ip / (1 + rate)
@kolosek
kolosek / capybara cheat sheet
Last active September 9, 2015 11:43 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@kolosek
kolosek / install_librets
Last active September 14, 2015 10:19 — forked from martron/install_librets
Installing libRETS on Ubuntu 14.04
# Installing librets in Ubuntu 14.04 can actually be fairly painless. Took me half an hour.
# I followed the instructions found at https://gist.github.com/sarkis/4472012 and made some modifications to keep it current.
cd ~/; mkdir src; cd src # or go to whatever folder you want to build source from
sudo apt-get update && sudo apt-get install build-essential
sudo apt-get install ruby-dev libexpat1-dev libcurl3-dev libboost-dev libboost-filesystem-dev antlr antlr3 libantlr-dev swig libboost-program-options-dev python-dev
# Swig preskociti
Download swig latest, unpack, read install file inside, and install
https://github.com/swig/swig/releases
# See http://m.onkey.org/running-rails-performance-tests-on-real-data
# START : HAX HAX HAX
# Load Rails environment in 'test' mode
RAILS_ENV = "test"
require File.expand_path('../../config/environment', __FILE__)
# Re-establish db connection for 'performance' mode
silence_warnings { RAILS_ENV = "performance" }
ActiveRecord::Base.establish_connection
@kolosek
kolosek / spec_helper.rb
Last active September 18, 2015 12:59 — forked from ahamid/spec_helper.rb
benchmark + profile RSpec test
require 'ruby-prof'
require 'benchmark'
module BenchmarkHelpers
PROFILE_OUTPUT_DIR = "profiling"
def self.safe_filename(name)
name.gsub(" ", "_")
end
def self.example_output_target_file!(example)
@kolosek
kolosek / elastic-search.sh
Created January 28, 2014 11:11
Install the elastic search the easy way
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
# NEW WAY / EASY WAY
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.9.deb
sudo dpkg -i elasticsearch-0.90.9.deb
@kolosek
kolosek / hacker-processes-check.sh
Last active June 10, 2016 11:10 — forked from shaiguitar/gist:1032229
check processes with kill -0
usage()
{
echo "./$0 [--verbose]"
}
VERBOSE=0
if [ "$1" == "--verbose" ]; then
VERBOSE=1
fi
@kolosek
kolosek / db.rake
Last active August 23, 2016 02:11 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd