Skip to content

Instantly share code, notes, and snippets.

View ArturT's full-sized avatar

Artur Trzop ArturT

View GitHub Profile
@ArturT
ArturT / git_remove_tags.rb
Last active December 17, 2015 19:39
Ruby script to remove local and remote unnecessary tags.
# pull all remote tags
Kernel.system "git", "pull", "--tags"
tags = `git tag | xargs`
tags_list = tags.split(' ')
# don't remove below tags
good_tags = %w(1.0.0 1.1.0 1.1.0.1 1.1.0.2 v1.1.0.3 v1.1.0.4 v1.1.0.5 v1.1.0.6)
# those tags will be deleted
@ArturT
ArturT / .travis.yml
Last active July 12, 2017 01:40
Speed up Travis CI builds by caching the bundle to ftp. Based on s3 example: https://gist.github.com/matiaskorhonen/5203327 See README.md
---
language: ruby
rvm:
- 2.0.0
bundler_args: --without development --path=~/.bundle
env:
global:
- BUNDLE_ARCHIVE="app-bundle-archive"
- RAILS_ENV=test
- secure: "A_VERY_LONG_SERIES_OF_CHARACTERS_HERE"
@ArturT
ArturT / spec_helper.rb
Last active December 23, 2015 00:58 — forked from terut/spec_helper.rb
Use different directory for carrierwave in test environment and clean up after all
RSpec.configure do |config|
# ...
config.after(:all) do
FileUtils.rm_rf(Dir["#{Rails.root}/tmp/test/carrierwave"])
end
end
CarrierWave.configure do |config|
config.root = "#{Rails.root}/tmp/test/carrierwave"
@ArturT
ArturT / gist:8804428
Last active August 29, 2015 13:56 — forked from jackdesert/gist:7090731
don't change non DateTime
require 'rails_admin/config/fields/base'
module RailsAdmin
module Config
module Fields
module Types
class Datetime < RailsAdmin::Config::Fields::Base
def value
value_in_default_time_zone = bindings[:object].send(name)
#!/bin/bash
i=0
files=()
# sort spec files by number of examples for better balancing
for file in $(find ./spec -name "*_spec.rb" -print0 | xargs -0 grep -e "^ *(it|specify)" -c | sort -t: -k2,2rn | awk -F":" '{ print $1 }')
do
if [ $(($i % $CIRCLE_NODE_TOTAL)) -eq $CIRCLE_NODE_INDEX ]
then
files+=" $file"
@ArturT
ArturT / gist:f650813c7035cce7dce9
Created January 14, 2015 14:37
Script to stop all docker containers
#!/bin/sh
CONTAINERS=`docker ps -q`
echo $CONTAINERS
if [ "$CONTAINERS" == "" ];
then
echo no running containers
else
echo containers exist, stopping them
@ArturT
ArturT / gist:e4a3ade36c00afa4e6ec
Created April 11, 2015 08:52
Execute rspec until fail to detect random failing spec
while rspec spec/models/user_spec.rb; do :; done
class GildedRose
def initialize(items)
@items = items
end
def update_quality()
@items.each do |item|
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert"
if item.quality > 0
if item.name != "Sulfuras, Hand of Ragnaros"
it 'increases to 50 when sell_in above 10 and quality is 49' do
item = Item.new('Backstage passes to a TAFKAL80ETC concert', sell_in=15, quality=49)
items = [item]
gilded_rose = described_class.new(items)
gilded_rose.update_quality
expect(item.quality).to eq 50
end
it 'increases to 50 instead of 51 when sell_in at least 5 and quality is 49' do
@ArturT
ArturT / .bash_profile
Last active June 26, 2021 05:55
Watch file changes and run rspec for the test file or specified line number test. Use spring with rspec optionally.
# It requries installed nodemon
# $ npm install -g nodemon
#
# Add this in your ~/.bash_profile
#
# How to use it?
#
# Run spec for user_spec.rb when file changed.
# $ wr spec/models/user_spec.rb
#