Skip to content

Instantly share code, notes, and snippets.

View elvanja's full-sized avatar

Vanja Radovanović elvanja

View GitHub Profile
@elvanja
elvanja / multiple_curies_for_hal_links.md
Last active August 29, 2015 14:06
Proposal to support multiple curies for links
@elvanja
elvanja / dynamicSlider.js
Created November 4, 2014 21:48
A take on jQuery UI Slider with slide handle adapting to dynamically generated content. See it in action @ http://codepen.io/elvanja/pen/pqrFG
var DynamicSlider = function() {
var config = {
wrapperSelector: '#slider-bar-wrap',
barSelector: '#slider-bar',
paneSelector: '#slider-pane',
contentSelector: '#slider-content',
paddingRight: 0,
focus: true
};
@elvanja
elvanja / jQuery-UI-slider-for-dynamic-content.markdown
Last active August 29, 2015 14:08
A Pen by Vanja Radovanović.
@elvanja
elvanja / bare_repository.rb
Created February 19, 2015 20:43
Repository template
# https://github.com/mikeebert/repository_template/blob/master/lib/base_repository.rb
module InMemory
class BaseRepository
class RecordNotFound < StandardError
def initialize(id)
@id = id
end
def to_s
@elvanja
elvanja / 1_rcat_tests.rb
Created October 20, 2011 18:49 — forked from practicingruby/1_rcat_tests.rb
Implementing a clone of UNIX cat in Ruby
# Task: Implement the rcat utility and get these tests to pass on a system
# which has the UNIX cat command present
# To see Gregory Brown's solution, see http://github.com/elm-city-craftworks/rcat
# Feel free to publicly share your own solutions
# If you want to see detailed commentary on how to solve this problem
# please subscribe to the Practicing Ruby Journal ( practicingruby.com )
# An article on this topic will be released on Tuesday 10/18.
@elvanja
elvanja / spec_helper_without_rails.rb
Created November 19, 2012 07:11
Spec helper without Rails
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }
# Requires all extra / autoload paths, @see /config/initializers/auto_require.rb
# Recommendation: do not rely on autoload for domain objects, use this just for specs
unless defined?(Rails)
%W(
app/persistence
app/representers
@elvanja
elvanja / rspec_without_rails.sh
Created November 19, 2012 07:13
Run RSpec without Rails
#!/bin/sh
grep spec_helper_without_rails -Rl spec/* | xargs rspec
@elvanja
elvanja / bulk_add_permission_ldap_groups_without_username.rake
Last active October 13, 2015 15:08
Gitlab bulk add permissions respecting ldap groups (without username, for Gitlab version <= 3.1.0)
require "net/ldap"
# if a project belongs to a ldap group
# add users from ldap group to the project
# remove all other users from the project
# else
# add all users as usual
desc "Add or removes users from projects (admin users are added as masters) respecting LDAP and project groups"
task :add_or_remove_users_from_project_teams_using_ldap_groups => :environment do |t, args|
gl = Gitlab.config
@elvanja
elvanja / .rspec
Created December 28, 2012 07:42 — forked from coreyhaines/.rspec
--colour
-I app
@elvanja
elvanja / deploy_to_heroku.sh
Created January 5, 2013 22:45
Deploy to heroku from current branch Precompiles assets but doesn't pollute the workspace
#!/bin/sh
# http://stackoverflow.com/questions/3878624/how-do-i-programmatically-determine-if-there-are-uncommited-changes
require_clean_work_tree () {
# Update the index
git update-index -q --ignore-submodules --refresh
err=0
# Disallow unstaged changes in the working tree
if ! git diff-files --quiet --ignore-submodules --; then